Skip to content

Commit f75d60a

Browse files
committed
style: use new regex match object group access
1 parent 8447c99 commit f75d60a

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

coverage/files.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def sep(s):
270270
"""Find the path separator used in this string, or os.sep if none."""
271271
sep_match = re.search(r"[\\/]", s)
272272
if sep_match:
273-
the_sep = sep_match.group(0)
273+
the_sep = sep_match[0]
274274
else:
275275
the_sep = os.sep
276276
return the_sep
@@ -387,7 +387,7 @@ def map(self, path):
387387
for regex, result in self.aliases:
388388
m = regex.match(path)
389389
if m:
390-
new = path.replace(m.group(0), result)
390+
new = path.replace(m[0], result)
391391
new = new.replace(sep(path), sep(result))
392392
if not self.relative:
393393
new = canonical_filename(new)

coverage/misc.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -324,17 +324,17 @@ def substitute_variables(text, variables):
324324

325325
def dollar_replace(match):
326326
"""Called for each $replacement."""
327-
# Only one of the groups will have matched, just get its text.
327+
# Only one of the dollar_groups will have matched, just get its text.
328328
word = next(g for g in match.group(*dollar_groups) if g) # pragma: always breaks
329329
if word == "$":
330330
return "$"
331331
elif word in variables:
332332
return variables[word]
333-
elif match.group('strict'):
333+
elif match['strict']:
334334
msg = f"Variable {word} is undefined: {text!r}"
335335
raise CoverageException(msg)
336336
else:
337-
return match.group('defval')
337+
return match['defval']
338338

339339
text = re.sub(dollar_pattern, dollar_replace, text)
340340
return text

0 commit comments

Comments
 (0)