Reputation: 2268
λ python --version
Python 3.10.6
λ flake8 --version
5.0.4 (mccabe: 0.7.0, pycodestyle: 2.9.1, pyflakes: 2.5.0) CPython 3.10.6 on Linux
# and on Windows
## Edit: after update
λ flake8 --version
6.0.0 (mccabe: 0.7.0, pycodestyle: 2.10.0, pyflakes: 3.0.1) CPython 3.10.6 on Linux
type(user) == User
isinstance(user, User)
test = []
if type(test) == list:
print('test is a list')
else:
print('test not a list')
Both flake8 test.py
& pycodestyle test.py
commands, in terminal, do not show any errors. Yet they should.
I have no extra config, from what I'm reading this error should be enabled by default; Per pycodestyle 2.9.1 Docs
# noqa
I've also tried:
{flake8|pycodestyle} --select E721 test.py
to explicitly select the error{flake8|pycodestyle} --ignore E302 test.py
to clear the default ignore list{flake8|pycodestyle} --ignore E302 --select E721 test.py
Am I missing something?- I quite like this error and now I'm worried it's not catching other errors as well.
Upvotes: -2
Views: 558
Reputation: 2268
Hopefully this will help somebody in the future.
This is proper behavior, the Docs do not correctly describe the error
# Allow comparison for types which are not obvious
obvious
types are:SINGLETONS = frozenset(['False', 'None', 'True'])
Their Doc example of if type(user) == User:
is not obvious and therefor wouldn't trigger it
test = []
print(type(test) == list) # Pass
print(type(test) == type(list)) # Pass
print(type(test) == type(float)) # Pass
print(type(test) == type(None)) # Fail
print(type(test) == type(True)) # Fail
I presume some Linters, possible pylint, does not work like this- thus my confusion, as I saw this error while using pylsp-all in Vim
Upvotes: -1