Skip to content
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

PLC1802 has false negatives for ascii and sorted #14690

Closed
dscorbett opened this issue Nov 30, 2024 · 0 comments · Fixed by #14692
Closed

PLC1802 has false negatives for ascii and sorted #14690

dscorbett opened this issue Nov 30, 2024 · 0 comments · Fixed by #14692
Labels
rule Implementing or modifying a lint rule

Comments

@dscorbett
Copy link

len-test (PLC1802) in Ruff 0.8.1 does not recognize the builtins ascii and sorted as returning sequences, leading to false negatives.

$ cat plc1802.py
bool(len(ascii(1)))
bool(len(sorted("")))

$ ruff check --preview --isolated --select PLC1802 plc1802.py --output-format concise
All checks passed!

Compare similar builtins with true positives.

$ cat plc1802.py 
bool(len(repr(1)))
bool(len(list("")))

$ ruff check --preview --isolated --select PLC1802 plc1802.py --output-format concise
plc1802.py:1:6: PLC1802 [*] `len(repr(1))` used as condition without comparison
plc1802.py:2:6: PLC1802 [*] `len(list(""))` used as condition without comparison
Found 2 errors.
[*] 2 fixable with the `--fix` option.
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 a pull request may close this issue.

2 participants