[Python-projects] Suggestion about E1101 Instance of 'None' has no 'get' member

Barry Scott barry.scott at onelan.co.uk
Tue Dec 12 14:38:49 CET 2006


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.

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.

Barry



More information about the Python-Projects mailing list