Dev-iL commented on code in PR #63598:
URL: https://github.com/apache/airflow/pull/63598#discussion_r2935378111
##########
scripts/ci/prek/changelog_duplicates.py:
##########
@@ -38,25 +38,32 @@
pr_number_re = re.compile(r".*\(#([0-9]{1,6})\)`?`?$")
-files = sys.argv[1:]
-
-failed = False
-for filename in files:
- seen = []
- dups = []
- with open(filename) as f:
- for line in f:
- match = pr_number_re.search(line)
- if match:
- pr_number = match.group(1)
- if pr_number not in seen:
- seen.append(pr_number)
- elif pr_number not in known_exceptions:
- dups.append(pr_number)
-
- if dups:
- print(f"Duplicate changelog entries found for {filename}: {dups}")
- failed = True
-
-if failed:
- sys.exit(1)
+
+def find_duplicates(lines: list[str]) -> list[str]:
+ """Find duplicate PR numbers in changelog lines, excluding known
exceptions."""
+ seen: list[str] = []
+ dups: list[str] = []
+ for line in lines:
+ match = pr_number_re.search(line)
+ if match:
+ pr_number = match.group(1)
+ if pr_number not in seen:
+ seen.append(pr_number)
+ elif pr_number not in known_exceptions:
+ dups.append(pr_number)
+ return dups
Review Comment:
```suggestion
def find_duplicates(lines: list[str]) -> list[str]:
"""Find duplicate PR numbers in changelog lines, excluding known
exceptions."""
seen: list[str] = []
dups: list[str] = []
for line in lines:
if (match := pr_number_re.search(line)) and (pr := match.group(1)):
if pr not in seen:
seen.append(pr)
elif pr not in known_exceptions:
dups.append(pr)
return dups
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]