Skip to content

ruff: fix `noqa` syntax

Claudia Pellegrino requested to merge auerhuhn/namcap:fix-ruff into master

Namcap is using Ruff’s # noqa directives slightly wrong.

That used to work anyway due to lenient parsing. However, upstream PR 5571 has introduced a change in noqa parsing. The parser now no longer allows slight variations to the noqa syntax. Rather than parsing it on a best-effort basis, it now aborts the parsing step altogether, and emits these warnings when running ruff .:

warning: Invalid `# noqa` directive on Namcap/__init__.py:4: expected a comma-separated list of codes (e.g., `# noqa: F401, F841`).
warning: Invalid `# noqa` directive on Namcap/rules/__init__.py:8: expected a comma-separated list of codes (e.g., `# noqa: F401, F841`).
warning: Invalid `# noqa` directive on Namcap/rules/__init__.py:41: expected a comma-separated list of codes (e.g., `# noqa: F401, F841`).

Those warnings were not visible in Namcap’s CI due to suppression via the the ruff -q switch.
However, the ruff step has been failing due to this since the upstream PR has landed in extra/ruff.

This MR fixes the # noqa directives so the F401 errors are effectively disabled again, fixing CI.

Merge request reports