Visitar URL original
refactor: (?x:...) lets us use re.VERBOSE even when combining later · coveragepy/coveragepy@80fb808 · GitHub
Skip to content

Commit 80fb808

Browse files
committed
refactor: (?x:...) lets us use re.VERBOSE even when combining later
1 parent cc272bd commit 80fb808

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

‎coverage/sqldata.py‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,13 +1191,13 @@ def filename_suffix(suffix: str | bool | None) -> str | None:
11911191

11921192

11931193
# A regex to match parallel file name suffixes, with named groups.
1194-
# We combine this with other regexes, so can't use verbose syntax.
1195-
SUFFIX_PATTERN = (
1196-
r"\.(?P<host>[^.]+)"
1197-
+ r"\.pid(?P<pid>\d+)"
1198-
+ rf"\.X(?P<random>\w{{{NRAND}}})x"
1199-
+ rf"(\.H(?P<hash>\w{{{NHASH}}}h))?"
1200-
)
1194+
# We combine this with other regexes, so be careful with flags.
1195+
SUFFIX_PATTERN = rf"""(?x: # re.VERBOSE, but only for part of the pattern
1196+
\.(?P<host>[^.]+) # .hostname
1197+
\.pid(?P<pid>\d+) # .pid1234
1198+
\.X(?P<random>\w{{{NRAND}}})x # .Xabc123x
1199+
(\.H(?P<hash>\w{{{NHASH}}}h))? # .Habcdef1234h (optional)
1200+
)"""
12011201

12021202

12031203
def filename_match(filename: str) -> re.Match[str] | None:

0 commit comments

Comments
 (0)