Repository navigation
[pylint] Fix PLC1802 autofix creating a syntax error and mark autofix as unsafe if there's comments in the len call - #18836
Merged
Conversation
Contributor
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| PLC1802 | 9 | 7 | 0 | 0 | 2 |
Linter (preview)
ℹ️ ecosystem check detected linter changes. (+7 -0 violations, +0 -2 fixes in 3 projects; 52 projects unchanged)
apache/superset (+1 -0 violations, +0 -2 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview --select ALL
- superset/migrations/versions/2018-07-22_11-59_bebcf3fed1fe_convert_dashboard_v1_positions.py:444:61: PLC1802 [*] `len(SEQUENCE)` used as condition without comparison + superset/migrations/versions/2018-07-22_11-59_bebcf3fed1fe_convert_dashboard_v1_positions.py:444:61: PLC1802 `len(SEQUENCE)` used as condition without comparison + superset/migrations/versions/2018-11-12_13-31_4ce8df208545_migrate_time_range_for_default_filters.py:91:20: PLC1802 [*] `len(keys)` used as condition without comparison
pandas-dev/pandas (+4 -0 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview
+ pandas/core/frame.py:7238:14: PLC1802 [*] `len(by)` used as condition without comparison + pandas/core/indexes/base.py:7621:12: PLC1802 [*] `len(index_like)` used as condition without comparison + pandas/io/parsers/base_parser.py:246:12: PLC1802 [*] `len(ic)` used as condition without comparison + pandas/io/parsers/python_parser.py:284:16: PLC1802 [*] `len(content)` used as condition without comparison
astropy/astropy (+2 -0 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview
+ astropy/tests/runner.py:547:16: PLC1802 [*] `len(paths)` used as condition without comparison + astropy/units/core.py:1328:12: PLC1802 [*] `len(results)` used as condition without comparison
Changes by rule (1 rules affected)
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| PLC1802 | 9 | 7 | 0 | 0 | 2 |
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
I've also found another bug while fixing this, where the diagnostic would not trigger if the
lencall argument variable was shadowed. This fixed a few false negatives in the test cases.Example:
Fixes #18811
Fixes #18812
Test Plan
Add regression test