Copilot commented on code in PR #65358:
URL: https://github.com/apache/airflow/pull/65358#discussion_r3234672889
##########
scripts/ci/prek/common_prek_utils.py:
##########
@@ -526,16 +526,101 @@ def get_all_provider_info_dicts() -> dict[str, dict]:
return providers
-def has_nocheck_marker(source_lines: list[str], node: ast.ImportFrom, marker:
str) -> bool:
- """Check if the import statement has the given nocheck marker comment on
any of its lines."""
+_NOQA_RE = re.compile(r"#\s*noqa\s*:\s*([^\n]*)", re.IGNORECASE)
+_NOQA_CODE_RE = re.compile(r"\b([A-Z]+\d+)\b")
+
+
+def _parse_noqa_codes(line: str) -> set[str]:
+ """Extract codes from a ``# noqa: <codes>`` comment in a source line."""
+ match = _NOQA_RE.search(line)
+ if not match:
+ return set()
+ return set(_NOQA_CODE_RE.findall(match.group(1)))
Review Comment:
_parse_noqa_codes() currently extracts any code-like token from everything
after `# noqa:` via `_NOQA_CODE_RE.findall(...)`. This can accidentally treat
codes mentioned in the explanatory text as active ignore codes (e.g. `# noqa:
F401 - see SDK002 docs` would suppress `SDK002`). Consider parsing only the
comma-separated code list (e.g. split on `,` and take the leading `<CODE>`
token from each item) so that trailing explanations don’t introduce unintended
suppressions.
--
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]