What's wrong
WPS421 forbids calling some built-in functions, which includes hasattr().
How it should be
The function hasattr() should be allowed. There are certain scenarios where using hasattr() makes sense, and sometimes is even faster (as even outlined in the referenced video @ 13:34-14:15 mark)
For code readability, if hasattr(foo, 'bar'): is cleaner than if getattr(foo, 'bar', None):.
I believe there was an argument against using hasattr() in python2, but I don't believe the same argument is valid for python3.
Flake8 version and plugins
n/a
pip information
n/a
OS information
n/a
What's wrong
WPS421 forbids calling some built-in functions, which includes
hasattr().How it should be
The function
hasattr()should be allowed. There are certain scenarios where usinghasattr()makes sense, and sometimes is even faster (as even outlined in the referenced video @ 13:34-14:15 mark)For code readability,
if hasattr(foo, 'bar'):is cleaner thanif getattr(foo, 'bar', None):.I believe there was an argument against using
hasattr()in python2, but I don't believe the same argument is valid for python3.Flake8 version and plugins
n/a
pip information
n/a
OS information
n/a