This is my code:
class Horse:
def talk(self):
print 'Hihaaa!'
class Farm:
def __init__(self, animal):
self.animal = animal
def animaltalk(self):
self.animal.sing()
def main():
horse = Horse()
farm = Farm(horse)
farm.animaltalk()
main()
This is my pylint
:
$ pylint --version
No config file found, using default configuration
pylint 1.4.3,
astroid 1.3.6, common 0.63.2
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2]
This is the output of pylint:
$ pylint farm.py
************* Module farm
C: 1, 0: Missing module docstring (missing-docstring)
C: 1, 0: Missing class docstring (missing-docstring)
C: 1, 0: Old-style class defined. (old-style-class)
W: 1, 0: Class has no __init__ method (no-init)
C: 3, 4: Missing method docstring (missing-docstring)
R: 3, 4: Method could be a function (no-self-use)
R: 1, 0: Too few public methods (1/2) (too-few-public-methods)
C: 7, 0: Missing class docstring (missing-docstring)
C: 7, 0: Old-style class defined. (old-style-class)
C: 12, 4: Missing method docstring (missing-docstring)
R: 7, 0: Too few public methods (1/2) (too-few-public-methods)
C: 16, 0: Missing function docstring (missing-docstring)
I am not interested in all those warnings/messages, unless they really have to do with my problem, which is: pylint
is unable to tell me that self.animal.sing()
is an error (it should be self.animal.talk()
).
Is there a way of forcing
pylint
to perform a deeper analysis, or is this a fundamental limitation of the Python language?Or is there a better pattern to code this kind of functionality (an object collecting other pre-instantiated objects), so that
pylint
can perform better error-checking?
The reason why I need this is that, in complex code, big refactorings cause errors that are not caught by pylint
, which means that the only way to catch them is with testing; unfortunately, I have no tests for all my code paths. A better pylint
analysis would go a long way towards solving obvious problems in my code.
Please report it to pylint's bug tracker: https://bitbucket.org/logilab/pylint/. That's actually a problem because in pylint, Instances don't know their arguments. This should be easily fixable.