-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[pylint]
Implement len-test
(PLC1802
)
#14309
Conversation
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
PLC1802 | 21 | 21 | 0 | 0 | 0 |
C1802
)C1802
)
C1802
)[pylint]
Implement use-implicit-booleaness-not-len (C1802
)
[pylint]
Implement use-implicit-booleaness-not-len (C1802
)[pylint]
Implement use-implicit-booleaness-not-len
(C1802
)
[pylint]
Implement use-implicit-booleaness-not-len
(C1802
)[pylint]
Implement use-implicit-booleaness-not-len
(PLC1802
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for this contribution! Some minor nits/requests for a few more tests. I also didn't get a chance to review the implementation carefully, but I'll hold off for now in case the new tests inspire any changes.
crates/ruff_linter/resources/test/fixtures/pylint/len_as_condition.py
Outdated
Show resolved
Hide resolved
crates/ruff_linter/resources/test/fixtures/pylint/len_as_condition.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really great, thank you! I think even with the possible misses around control flow, this makes sense to implement. You would have to be pretty pathological to create a custom class C
that implements __len__
and __bool__
where bool(x) != bool(len(x))
for x: C
... so I think it's okay.
[pylint]
Implement use-implicit-booleaness-not-len
(PLC1802
)[pylint]
Implement len-as-condition
(PLC1802
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there! Looking good!
Naming: Maybe |
[pylint]
Implement len-as-condition
(PLC1802
)[pylint]
Implement len-test (
PLC1802`)
[pylint]
Implement len-test (
PLC1802`)[pylint]
Implement len-test
(PLC1802
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you for the great contribution and your patience through all the reviews!
Summary
This PR implements
use-implicit-booleaness-not-len
/C1802
Test Plan
Checked against pylint tests:
Notes
len-as-condition
might be solution)References
PEP 8 on empty sequences and implicit booleaness