[Python-projects] PyLint: False positive "<type> has no '<method>' member"
Sylvain Thénault
sylvain.thenault at logilab.fr
Tue Dec 5 08:48:24 CET 2006
On Friday 24 November à 15:20, Maarten ter Huurne wrote:
>
> Hi,
>
> If I run PyLint on the following program:
> ===
> def radixSort(elements, keyFuncs):
> sortList = None
> for keyFunc in reversed(keyFuncs):
> if sortList is None:
> sortList = sorted(elements, key = keyFunc)
> else:
> sortList.sort(key = keyFunc)
> return sortList
> ===
> It issues this warning:
> ===
> E1101: 7:radixSort: Instance of 'None' has no 'sort' member
> ===
>
> I think this is a problem of the type inference. Even if it doesn't understand
> that in the "else" clause of "if sortList is None" it is guaranteed that
> "sortList" is not None, it should still know that "sortList" can be either None
> or a list, since "sorted" always returns a list (see the assignment in line 5).
ticket #3207 on the astng project.
--
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