[Python-projects] Suggestion about E1101 Instance of 'None' has no 'get' member
Sylvain Thénault
sylvain.thenault at logilab.fr
Wed Dec 13 11:39:08 CET 2006
On Tuesday 12 December à 13:38, Barry Scott wrote:
> I see a lot of E1101 for classes like this:
>
> class Foo:
> def __init__( self ):
> self.some_object = None
>
> def setSome( self, obj ):
> self.some_object = obj
>
> def useSome( self ):
> self.some_object.someMethod()
>
>
> pylint will complain about the call to someMethod.
which pylint/astng version are you using ? I don't get any E1101 With your code
sample (the setSome method introduce an ambiguity in the inference and
in that case pylint don't issue E1011).
> Is there a way to tell pylint that self.some_object is expected to have
> a certain type? If not is such a feature possible to implement?
>
> I'm thinking about annotation like:
> self.some_object = None # pylint: variable_type=Some
>
> meaning that some_object is expected to be class Some.
this is certainly feasible at the astng level, the main difficulty being
that comments are not in the ast and so a preparsing of the module file
will be necessary (i think). Anyway we'll have to support this kind of
thing at some point...
--
Sylvain Thénault LOGILAB, Paris (France)
Formations Python, Zope, Plone, Debian: http://www.logilab.fr/formations
Développement logiciel sur mesure: http://www.logilab.fr/services
Python et calcul scientifique: http://www.logilab.fr/science
More information about the Python-Projects
mailing list