[code-quality] pylint suggestion
Jim Reuter
jreuter at ddn.com
Tue Sep 4 16:44:26 EDT 2018
Hopefully this is the right place for Pylint suggestions; I did not see any
other mailing lists that appeared to fit.
I am working on a large project with a lot of existing Python code,
and we use pylint in our processes.
One frequently used module has a class with a lot of property methods
and regular methods, e.g.
class Cl(Parent):
@property
def thing1(self):
return calculate_thing1()
@property
def test2(self):
return get_test2()
def is_fubd(self):
return some_other_test() == 42
So, naturally, I mistakenly used the last item above as if it was
a property instead of a method:
if is_fubd:
do_something()
else:
do_something_else()
The code, of course, needs to be:
if is_fubd():
...
The first form is valid code but mostly useless, because the
is_fubd method exists so an 'if' test is always true. And it is
a real pain to find the mistake by inspection. It would sure
be nice to have pylint flag this usage as suspicious.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/code-quality/attachments/20180904/3c5cd196/attachment.html>
More information about the code-quality
mailing list