MNT delete dead and invalid noqa comments#1663
Open
romanlutz wants to merge 4 commits into
Open
Conversation
Removes # noqa: E501/D1xx/G001/G003/A003 comments throughout the fairlearn/ package; none of those rules are enabled in the ruff config, so the suppressions were no-ops. Also drops F401 noqas on __init__.py re-exports that are covered by __all__, and fixes the "# noqa : G003" typo (extra space breaks the noqa parser). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…-noqas # Conflicts: # docs/user_guide/installation_and_version_guide/v0.15.0.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The project's ruff config in
pyproject.tomlonly enables["E4", "E7", "E9", "F", "NPY201"], so any# noqa: <code>for a rule outside that set is a no-op suppression that just adds visual noise (and in some cases hides genuine bugs, like the malformed# noqa : G003/# noq: F401typos that don't match ruff's noqa parser at all). This PR sweepsfairlearn/and removes them.What's removed:
# noqa: E501(line length is not enforced).# noqa: D1xx(D102/D103/D105) - pydocstyle is not enabled.# noqa : G001/# noqa : G003(flake8-logging-format is not enabled), including the typo variant with a space before the colon - 7 of them in_adversarial_mitigation.py.# noqa: A003inbounded_group_loss.py(flake8-builtins is not enabled).# noqa: F401re-export suppressions in__init__.pyfiles that already declare__all__(postprocessing/,reductions/, and threereductions/subpackages). Ruff treats names listed in__all__as used, so the noqa was redundant. Also fixed the broken# noq: F401typo (missinga) inreductions/_moments/__init__.py.What's kept:
# noqa: F401infairlearn/__init__.pyandexperimental/enable_metric_frame_plotting.py- those modules don't declare__all__, so the suppression is still load-bearing.# noqa: F401inmetrics/__init__.py- that module builds__all__dynamically (_core + _fairness + _base_metrics + list(sorted(_generated_metric_dict.keys()))), which ruff can't statically resolve, so removing the noqas surfaced real F401 violations. I restored those specific lines after the sweep.# noqa: F841in the docstring code samples inside_adversarial_mitigation.py(F841 is enforced).Behavior is unchanged - these are comment-only edits.
Tests
Verified locally:
ruff check fairlearn testpasses;pytest test/unit -qshows 6804 passed (the 2 failures in plotting tests are pre-existing Tk environment issues reproducible onorigin/main, unrelated to this change).Documentation
Added a changelog entry under "Other improvements" in
docs/user_guide/installation_and_version_guide/v0.15.0.rst.Screenshots
N/A