[Python-projects] Pylint not identifying types correctly

Emile Anclin emile.anclin at logilab.fr
Wed Apr 15 09:21:06 CEST 2009


On Tuesday 14 April 2009 21:21:33 Marcelo de Sena Lacerda wrote:
> Hi, I'm new to the list and I'm having a problem with pylint. It is not
> identifying types correctly in the following code:
>
> org = Organization.get_by_key_name('LOL')
>
> str = org.key().name()
>
> The get_by_key_name method always returns a Organization instance that
> have a key() method.

> Pylint however says that get_by_key_name returns a list, that does not
> have a key method.
>
> How do I solve this?


I don't understand your problem; here is a test module which is no problem 
with pylint :

$ cat test.py 
"""test module"""

class Org:
    """test"""
    def __init__(self, name):
        self.name = name

    def key(self):
        """get key"""
        return self.name

    def get_by_key_name(self, name):
        """a method"""
        print "search", name
        return self

ORG = Org('Org Inc')

ORG = ORG.get_by_key_name('LOL')

ORG_NAME = ORG.key()

$ pylint test.py 
No config file found, using default configuration

(no warnings or so)

So you should be more precise...

Also, it is usual to add the version of pylint etc you use;
right now we have :

$ pylint --version
No config file found, using default configuration
pylint 0.18.0, 
astng 0.19.0, common 0.39.0
Python 2.5.4 (r254:67916, Feb 18 2009, 03:00:47) 
[GCC 4.3.3]


--

Emile Anclin <emile.anclin at logilab.fr>
http://www.logilab.fr/   http://www.logilab.org/ 
Informatique scientifique & et gestion de connaissances



More information about the Python-Projects mailing list