Skip to content

Commit 3522e2c

Browse files
committed
Group warnings under filename
1 parent 2618b19 commit 3522e2c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Doc/tools/check-warnings.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
"venv",
2525
}
2626

27+
PATTERN = re.compile(r"(?P<file>[^:]+):(?P<line>\d+): WARNING: (?P<msg>.+)")
28+
2729

2830
def check_and_annotate(warnings: list[str], files_to_check: str) -> None:
2931
"""
@@ -39,11 +41,10 @@ def check_and_annotate(warnings: list[str], files_to_check: str) -> None:
3941
see:
4042
https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-a-warning-message
4143
"""
42-
pattern = re.compile(r"(?P<file>[^:]+):(?P<line>\d+): WARNING: (?P<msg>.+)")
4344
files_to_check = next(csv.reader([files_to_check]))
4445
for warning in warnings:
4546
if any(filename in warning for filename in files_to_check):
46-
if match := pattern.fullmatch(warning):
47+
if match := PATTERN.fullmatch(warning):
4748
print("::warning file={file},line={line}::{msg}".format_map(match))
4849

4950

@@ -67,7 +68,8 @@ def fail_if_regression(
6768
print(filename)
6869
for warning in warnings:
6970
if filename in warning:
70-
print(warning)
71+
if match := PATTERN.fullmatch(warning):
72+
print(" {line}: {msg}".format_map(match))
7173
return -1
7274
return 0
7375

0 commit comments

Comments
 (0)