diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2022-07-08 12:08:54 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2022-07-08 12:08:54 -0400 |
commit | f75d60a63f9b5e99481231ea9b2b956616278327 (patch) | |
tree | cf6762c8b801fbb25dea8177f9b8774f735e1546 | |
parent | 8447c995e822ca63836037290d045f0fd6d53fb5 (diff) | |
download | python-coveragepy-git-f75d60a63f9b5e99481231ea9b2b956616278327.tar.gz |
style: use new regex match object group access
-rw-r--r-- | coverage/files.py | 4 | ||||
-rw-r--r-- | coverage/misc.py | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/coverage/files.py b/coverage/files.py index 09f09da7..507496ff 100644 --- a/coverage/files.py +++ b/coverage/files.py @@ -270,7 +270,7 @@ def sep(s): """Find the path separator used in this string, or os.sep if none.""" sep_match = re.search(r"[\\/]", s) if sep_match: - the_sep = sep_match.group(0) + the_sep = sep_match[0] else: the_sep = os.sep return the_sep @@ -387,7 +387,7 @@ class PathAliases: for regex, result in self.aliases: m = regex.match(path) if m: - new = path.replace(m.group(0), result) + new = path.replace(m[0], result) new = new.replace(sep(path), sep(result)) if not self.relative: new = canonical_filename(new) diff --git a/coverage/misc.py b/coverage/misc.py index 777cdc43..e9b1b8eb 100644 --- a/coverage/misc.py +++ b/coverage/misc.py @@ -324,17 +324,17 @@ def substitute_variables(text, variables): def dollar_replace(match): """Called for each $replacement.""" - # Only one of the groups will have matched, just get its text. + # Only one of the dollar_groups will have matched, just get its text. word = next(g for g in match.group(*dollar_groups) if g) # pragma: always breaks if word == "$": return "$" elif word in variables: return variables[word] - elif match.group('strict'): + elif match['strict']: msg = f"Variable {word} is undefined: {text!r}" raise CoverageException(msg) else: - return match.group('defval') + return match['defval'] text = re.sub(dollar_pattern, dollar_replace, text) return text |