Skip to content

[pygrep-hooks]: Detect file-level suppressions comments without rule codes (PGH004) #16699

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2025

Conversation

MichaReiser
Copy link
Member

Summary

This PR stabilizes the preview behavior of PGH004 to also detect blanked file-level noqa comments (and not just line level comments).

This preview behavior was first released with Ruff 0.4.8 (June 2025). There are no open issues or PRs open related to this behavior.

@MichaReiser MichaReiser added the rule Implementing or modifying a lint rule label Mar 13, 2025
@MichaReiser MichaReiser requested review from dylwil3 and ntBre March 13, 2025 08:26
Copy link

codspeed-hq bot commented Mar 13, 2025

CodSpeed Performance Report

Merging #16699 will degrade performances by 4.6%

Comparing micha/blanked-noqa-file-level (c1c0d1b) with micha/ruff-0.10 (d622137)

Summary

❌ 1 regressions
✅ 31 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
red_knot_check_file[incremental] 5.2 ms 5.5 ms -4.6%

Copy link
Contributor

github-actions bot commented Mar 13, 2025

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+5 -0 violations, +0 -0 fixes in 5 projects; 50 projects unchanged)

apache/airflow (+1 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --no-preview --select ALL

+ docs/exts/exampleinclude.py:1:1: PGH004 Use specific rule codes when using `ruff: noqa`

apache/superset (+1 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --no-preview --select ALL

+ tests/integration_tests/superset_test_config_sqllab_backend_persist_off.py:17:1: PGH004 Use specific rule codes when using `ruff: noqa`

pytest-dev/pytest (+1 -0 violations, +0 -0 fixes)

+ testing/code/test_source.py:2:1: PGH004 Use specific rule codes when using `ruff: noqa`

pdm-project/pdm (+1 -0 violations, +0 -0 fixes)

+ src/pdm/installers/__init__.py:1:1: PGH004 Use specific rule codes when using `ruff: noqa`

astropy/astropy (+1 -0 violations, +0 -0 fixes)

+ astropy/io/ascii/__init__.py:3:1: PGH004 Use specific rule codes when using `ruff: noqa`

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
PGH004 5 5 0 0 0

Linter (preview)

✅ ecosystem check detected no linter changes.

@MichaReiser MichaReiser force-pushed the micha/blanked-noqa-file-level branch from 1e89b3d to c1c0d1b Compare March 13, 2025 08:36
@MichaReiser MichaReiser added this to the v0.10 milestone Mar 13, 2025
@MichaReiser
Copy link
Member Author

The ecosystem checks are all true-positives

Copy link
Collaborator

@dylwil3 dylwil3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I do think that we should have a followup issue/PR where we add the feature that this rule has for inline suppressions where it tries to guess if you just forgot a colon

@MichaReiser MichaReiser merged commit 72ffa12 into micha/ruff-0.10 Mar 13, 2025
20 of 21 checks passed
@MichaReiser MichaReiser deleted the micha/blanked-noqa-file-level branch March 13, 2025 12:46
@MichaReiser MichaReiser mentioned this pull request Mar 13, 2025
2 tasks
@MichaReiser MichaReiser restored the micha/blanked-noqa-file-level branch March 14, 2025 07:24
MichaReiser added a commit that referenced this pull request Mar 14, 2025
#16720)

## Summary

I accidentially dropped this commit from the Ruff 0.10 release. See
#16699
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants