[code-quality] pylint suggestion
Carl Crowder
carl.crowder at gmail.com
Wed Sep 5 05:27:15 EDT 2018
I think that this would be better a pylint specific issue on github
Also I think this would be quite hard - it seems you want a check that says 'if this is a function that is used in a boolean but it it not called' that seems quite specific and you never know, if it's not a syntax error, perhaps it's legitimately used by someone?
However I defer to the pylint gurus as this is just my conjecture :-)
On 05/09/2018 11:05:21, Jim Reuter <jreuter at ddn.com> wrote:
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/20180905/ad8e881b/attachment.html>
More information about the code-quality
mailing list