-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed false positive of no-member
for methods of namedtuples instances
#4487
Conversation
no-member
for methods of namedtuples instances
Marking this as ready for review to get some comments -- to see if this is the correct approach to the issue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look good to me :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll have a look, it doesn't seem like it's an issue with subclassing from urllib import parse
parsed_url = parse.urlparse("http://www.this-is-weird.com")
a = parse.ParseResult._replace(parsed_url, query='foo')
b = a.geturl() # false-positive: no-member
# snippet from urllib.parse
_ParseResultBase = namedtuple('ParseResult', 'scheme netloc path params query fragment')
# ...
class ParseResult(_ParseResultBase, _NetlocResultMixinStr):
__slots__ = ()
def geturl(self):
return urlunparse(self) |
Closing because @nelfin convinced me it should be fixed in astroid instead. |
Steps
doc/whatsnew/<current release.rst>
. (not sure if important bugfix)Description
From investigation, it seems like _replace() yields a NamedTuple instance and
.geturl()
is not a valid attribute -- therefore the warning is triggered.Therefore to circumvent this false-positive,
--> Then we don't fire the error
I'm not too sure if this is the correct approach and thus it's marked as a draft PR, but opening this PR to get reviews / thoughts on whether this might be a potential solution / how to approach this issue
Type of Changes
Related Issue
Closes #4377