Skip to content
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

E1101: false positive with urlparse.ParseResult #597

Closed
pylint-bot opened this issue Jul 6, 2015 · 4 comments
Closed

E1101: false positive with urlparse.ParseResult #597

pylint-bot opened this issue Jul 6, 2015 · 4 comments
Labels

Comments

@pylint-bot
Copy link

Originally reported by: Martin Geisler (BitBucket: mg, GitHub: @mg?)


I got no-member warnings from code like this:

import urlparse

result = urlparse.urlparse('http://example.net/')
result = result._replace(scheme='https')
result.geturl()

The output is:

% pylint -rn test.py      
No config file found, using default configuration
************* Module test
C:  1, 0: Missing module docstring (missing-docstring)
C:  3, 0: Invalid constant name "result" (invalid-name)
C:  4, 0: Invalid constant name "result" (invalid-name)
E:  5, 0: Instance of 'ParseResult' has no 'geturl' member (no-member)

If I remove the line with the _replace call, the no-member error goes away.

This is with Pylint 1.4.4:

% pylint --version
No config file found, using default configuration
pylint 1.4.4, 
astroid 1.3.6, common 1.0.1
Python 2.7.10 (default, Jun  1 2015, 16:21:46) 
[GCC 4.9.2]

@pylint-bot
Copy link
Author

Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore):


Thanks for the report! It should be fixed in astroid's tip: https://bitbucket.org/logilab/astroid/commits/e2f5b69a60b32fbd853025586c9adb689aabb533
I'll release 1.4 in a couple of weeks though.

@povesma
Copy link

povesma commented Apr 19, 2021

I have the identical issue, also if .geturl() follows ._replace(), but code is the following:

    parsed_url = parse.urlparse(url)
    sorted_query = parse.urlencode(sorted(parse.parse_qsl(parsed_url.query), key=lambda param: param[0]))
    new_parsed_url = parse.ParseResult._replace(parsed_url, query=sorted_query)
    new_url = new_parsed_url.geturl()

if I use an instance of ParseResult (new_parsed_url) instead of class static method, like:
new_parsed_url = parsed_url._replace(query=sorted_query)

the error disappears.

pylint --version
pylint 2.7.4
astroid 2.5.3
Python 3.8.7 (default, Mar  9 2021, 10:52:42)
[Clang 12.0.0 (clang-1200.0.32.29)]

@hippo91
Copy link
Contributor

hippo91 commented May 13, 2021

@povesma thanks for your report. Would you mind opening a new one as this one is very old?

@hippo91
Copy link
Contributor

hippo91 commented May 13, 2021

@povesma sorry, i just saw that you already did it. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants