Skip to content

Avoid treating lowercase letters as # noqa codes#14229

Merged
charliermarsh merged 1 commit intomainfrom
charlie/b
Nov 9, 2024
Merged

Avoid treating lowercase letters as # noqa codes#14229
charliermarsh merged 1 commit intomainfrom
charlie/b

Conversation

@charliermarsh
Copy link
Member

Summary

An oversight from the original implementation.

Closes #14228.

@charliermarsh charliermarsh changed the title Avoid treating lowercase letters as noqa codes Avoid treating lowercase letters as # noqa codes Nov 9, 2024
},
Code {
code: "F841",
range: 12..16,
Copy link
Member Author

Choose a reason for hiding this comment

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

This seems "fine", it's not ambiguous.

@charliermarsh charliermarsh merged commit ce3af27 into main Nov 9, 2024
@charliermarsh charliermarsh deleted the charlie/b branch November 9, 2024 17:49
@github-actions
Copy link
Contributor

github-actions bot commented Nov 9, 2024

ruff-ecosystem results

Linter (stable)

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

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

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

- providers/src/airflow/providers/apache/hdfs/sensors/hdfs.py:45:37: RUF100 [*] Unused `noqa` directive (unknown: `Ignore`)
- providers/src/airflow/providers/apache/hdfs/sensors/hdfs.py:50:38: RUF100 [*] Unused `noqa` directive (unknown: `Ignore`)
- providers/src/airflow/providers/google/cloud/hooks/bigquery.py:59:42: RUF100 [*] Unused `noqa` directive (unknown: `Used`)

pandas-dev/pandas (+0 -0 violations, +0 -0 fixes)


Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
RUF100 3 0 3 0 0

Linter (preview)

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

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

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

- providers/src/airflow/providers/apache/hdfs/sensors/hdfs.py:45:37: RUF100 [*] Unused `noqa` directive (unknown: `Ignore`)
- providers/src/airflow/providers/apache/hdfs/sensors/hdfs.py:50:38: RUF100 [*] Unused `noqa` directive (unknown: `Ignore`)
- providers/src/airflow/providers/google/cloud/hooks/bigquery.py:59:42: RUF100 [*] Unused `noqa` directive (unknown: `Used`)

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
RUF100 3 0 3 0 0

let suffix = line[prefix..]
.chars()
.take_while(char::is_ascii_alphanumeric)
.take_while(char::is_ascii_digit)
Copy link
Contributor

@InSyncWithFoo InSyncWithFoo Nov 9, 2024

Choose a reason for hiding this comment

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

What about ParsedFileExemption::lex_code()?

There are multiple reimplementations of the # noqa parsing algorithm, including two by me (RyeCharm, #14111) and another by @koxudaxi (Ruff PyCharm Plugin). I would appreciate it if you could keep it consistent.

@dhruvmanila dhruvmanila added the bug Something isn't working label Nov 15, 2024
dylwil3 added a commit that referenced this pull request Mar 11, 2025
# Summary
The goal of this PR is to address various issues around parsing
suppression comments by

1. Unifying the logic used to parse in-line (`# noqa`) and file-level
(`# ruff: noqa`) noqa comments
2. Recovering from certain errors and surfacing warnings in these cases

Closes #15682 
Supersedes #12811 
Addresses
#14229 (comment)
Related: #14229 , #12809
MichaReiser pushed a commit that referenced this pull request Mar 13, 2025
# Summary
The goal of this PR is to address various issues around parsing
suppression comments by

1. Unifying the logic used to parse in-line (`# noqa`) and file-level
(`# ruff: noqa`) noqa comments
2. Recovering from certain errors and surfacing warnings in these cases

Closes #15682 
Supersedes #12811 
Addresses
#14229 (comment)
Related: #14229 , #12809
MichaReiser pushed a commit that referenced this pull request Mar 13, 2025
# Summary
The goal of this PR is to address various issues around parsing
suppression comments by

1. Unifying the logic used to parse in-line (`# noqa`) and file-level
(`# ruff: noqa`) noqa comments
2. Recovering from certain errors and surfacing warnings in these cases

Closes #15682 
Supersedes #12811 
Addresses
#14229 (comment)
Related: #14229 , #12809
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0.7.3 introduces false positives for invalid # noqa directives with RUF100

3 participants