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.

_______________________________________________
code-quality mailing list
code-quality@python.org
https://mail.python.org/mailman/listinfo/code-quality

Reply via email to