[Python-projects] pylint/astng feature request: namedtuple support
Maarten ter Huurne
maarten at treewalker.org
Thu Mar 26 00:58:22 CET 2009
Hi,
On the following program pylint issues a false positive:
===
from urlparse import urlparse
print urlparse('http://www.logilab.org/project/pylint').path
===
E1101: 2: Instance of 'ParseResult' has no 'path' member
Here astng correctly infers that urlparse() returns a ParseResult instance,
but doesn't know that ParseResult has a "path" member.
This is the line in urlparse.py that defines ParseResult:
===
class ParseResult(namedtuple('ParseResult', 'scheme netloc path params query
fragment'), ResultMixin):
===
The namedtuple() function is new in Python 2.6 and is documented here:
http://docs.python.org/library/collections.html#collections.namedtuple
The class using namedtuple() explicitly lists the members it acquires; it
would be very useful if pylint would consider these members present.
Bye,
Maarten
More information about the Python-Projects
mailing list