[eradicate] Fix false positive for lines with leading whitespace (ERA001) - #25122
Merged
Merged
Conversation
…ERA001`) Summary -- This PR fixes #25116 by reusing our `is_python_whitespace` helper for trimming lines that may contain code. This avoids false positives in cases where comments are preceded by tabs (or form-feeds). These would previously fail to trim the whitespace and end up parsing a module like: ```py \t# comment here ``` which is valid Python. Test plan -- New tests based on the report
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| ERA001 | 7 | 7 | 0 | 0 | 0 |
Linter (preview)
ℹ️ ecosystem check detected linter changes. (+7 -0 violations, +0 -0 fixes in 2 projects; 54 projects unchanged)
langchain-ai/langchain (+3 -0 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --no-fix --output-format concise --preview
+ libs/langchain/langchain_classic/chains/natbot/crawler.py:173:9: ERA001 Found commented-out code + libs/langchain/langchain_classic/chains/natbot/crawler.py:174:9: ERA001 Found commented-out code + libs/langchain/langchain_classic/chains/natbot/crawler.py:175:9: ERA001 Found commented-out code
milvus-io/pymilvus (+4 -0 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --no-fix --output-format concise --preview
+ examples/bulk_import/example_bulkinsert_json.py:94:1: ERA001 Found commented-out code + examples/bulk_import/example_bulkinsert_json.py:95:1: ERA001 Found commented-out code + examples/orm_deprecated/bulk_import/example_bulkinsert_json.py:126:1: ERA001 Found commented-out code + examples/orm_deprecated/bulk_import/example_bulkinsert_json.py:127:1: ERA001 Found commented-out code
Changes by rule (1 rules affected)
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| ERA001 | 7 | 7 | 0 | 0 | 0 |
Contributor
Author
|
Hmm, I didn't think about this also trimming tabs after the # {"rows": [
# {"str_field": "row-based_0", "float_vector_field": [0.190, 0.046, 0.143, 0.972, 0.592, 0.238, 0.266, 0.995]},
# {"str_field": "row-based_1", "float_vector_field": [0.149, 0.586, 0.012, 0.673, 0.588, 0.917, 0.949, 0.944]},
# ......
# ]
# }but I think that still makes sense and matches the space handling. |
ntBre
marked this pull request as ready for review
May 12, 2026 19:53
MichaReiser
approved these changes
May 13, 2026
thejchap
pushed a commit
to thejchap/ruff
that referenced
this pull request
May 23, 2026
…ERA001`) (astral-sh#25122) Summary -- This PR fixes astral-sh#25116 by reusing our `is_python_whitespace` helper for trimming lines that may contain code. This avoids false positives in cases where comments are preceded by tabs (or form-feeds). These would previously fail to trim the whitespace and end up parsing a module like: ```py \t# comment here ``` which is valid Python. Test plan -- New tests based on the report
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.
Summary
This PR fixes #25116 by reusing our
is_python_whitespacehelper fortrimming lines that may contain code. This avoids false positives in
cases where comments are preceded by tabs (or form-feeds). These would
previously fail to trim the whitespace and end up parsing a module
like:
which is valid Python.
Test plan
New tests based on the report