Skip to content

MNT delete dead and invalid noqa comments#1663

Open
romanlutz wants to merge 4 commits into
mainfrom
romanlutz/delete-dead-noqas
Open

MNT delete dead and invalid noqa comments#1663
romanlutz wants to merge 4 commits into
mainfrom
romanlutz/delete-dead-noqas

Conversation

@romanlutz

Copy link
Copy Markdown
Member

Description

The project's ruff config in pyproject.toml only 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: F401 typos that don't match ruff's noqa parser at all). This PR sweeps fairlearn/ and removes them.

What's removed:

  • All # noqa: E501 (line length is not enforced).
  • All # noqa: D1xx (D102/D103/D105) - pydocstyle is not enabled.
  • All # 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.
  • Both # noqa: A003 in bounded_group_loss.py (flake8-builtins is not enabled).
  • # noqa: F401 re-export suppressions in __init__.py files that already declare __all__ (postprocessing/, reductions/, and three reductions/ subpackages). Ruff treats names listed in __all__ as used, so the noqa was redundant. Also fixed the broken # noq: F401 typo (missing a) in reductions/_moments/__init__.py.

What's kept:

  • # noqa: F401 in fairlearn/__init__.py and experimental/enable_metric_frame_plotting.py - those modules don't declare __all__, so the suppression is still load-bearing.
  • # noqa: F401 in metrics/__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: F841 in the docstring code samples inside _adversarial_mitigation.py (F841 is enforced).

Behavior is unchanged - these are comment-only edits.

Tests

  • no new tests required
  • new tests added
  • existing tests adjusted

Verified locally: ruff check fairlearn test passes; pytest test/unit -q shows 6804 passed (the 2 failures in plotting tests are pre-existing Tk environment issues reproducible on origin/main, unrelated to this change).

Documentation

  • no documentation changes needed
  • user guide added or updated
  • API docs added or updated
  • example notebook added or updated

Added a changelog entry under "Other improvements" in docs/user_guide/installation_and_version_guide/v0.15.0.rst.

Screenshots

N/A

romanlutz and others added 4 commits June 11, 2026 23:44
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant