We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
len(...) > 0
len(...)
What about a diagnostic to change
if len(...) > 0: ...
into
if len(...): ...
I think they can be considered equivalent, because
object.__len__()
Should return an integer >= 0.
>>> class C: ... def __len__(self): ... return -1 ... >>> len(C()) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: __len__() should return >= 0
pylint --enable-all-extensions a.py does not warn about it.
pylint --enable-all-extensions a.py
I am a new user and do not actually know if this is in-scope for the project, sorry if it isn't the case.
The text was updated successfully, but these errors were encountered:
This is already covered by FURB115:
nums = [] if len(nums) > 0: pass
Running Refurb:
$ refurb x.py x.py:3:4 [FURB115]: Replace `len(x) > 0` with `x`
Since empty containers are falsey, len(x) can be further simplified to just x.
len(x)
x
Sorry, something went wrong.
No branches or pull requests
Overview
What about a diagnostic to change
into
Proposal
I think they can be considered equivalent, because
object.__len__()
which (quote)Should return an integer >= 0.
pylint --enable-all-extensions a.py
does not warn about it.I am a new user and do not actually know if this is in-scope for the project, sorry if it isn't the case.
The text was updated successfully, but these errors were encountered: