[Python-projects] Suggestion about E1101 Instance of 'None' has no 'get' member
Michael Foord
fuzzyman at voidspace.org.uk
Wed Dec 13 23:19:23 CET 2006
Barry Scott wrote:
> Sylvain Thénault wrote:
>
>>>>> 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...
>>>>
>>>>
>>>>
>>>>
>>> Indeed. Adding this support will make pylint significantly more useful.
>>>
>>> You already parse the comments to process the pylint: ones. Isn't this
>>> an extension of
>>> that parsing?
>>>
>>>
>> Well yes and no since ideally it should be at the astng level, so other
>> astng based program take advantage of this information as well. Another
>> idea would be to get information from lines such as :
>>
>> assert isinstance(self.attr, aclass)
>>
>> as Adrien suggested to me.
>>
>>
> That is a nice idea, especially if you pick up the info from any method
> of a class
> so that it does not have to be executed at runtime of the code.
> Something like:
>
> class Foo:
> def __init__( self ):
> self.some_object = None
>
> def useSome( self ):
> self.some_object.someMethod()
>
> def __pylint_hint( self ):
> assert isinstance( self.some_object, some_module.SomeClass )
>
>
This is how the Wing IDE does code completion (where it can't divine
the type).
Personally I don't like the idea of adding to production code just to
help PyLint or my IDE, but many people like it.
Fuzzyman
http://www.voidspace.org.uk/index2.shtml
> Barry
>
> _______________________________________________
> Python-Projects mailing list
> Python-Projects at lists.logilab.org
> http://lists.logilab.org/mailman/listinfo/python-projects
>
>
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.409 / Virus Database: 268.15.18/586 - Release Date: 13/12/2006
More information about the Python-Projects
mailing list