pylint icon indicating copy to clipboard operation
pylint copied to clipboard

False positive 'requests.packages' has no 'urllib3' member (no-member)

Open ItsIgnacioPortal opened this issue 4 years ago • 6 comments

Steps to reproduce

Given a file a.py:

# pylint: disable=missing-docstring
import requests
from urllib3.exceptions import InsecureRequestWarning

requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)

Current behavior

Result of pylint a.py:

************* Module a
a.py:5:0: E1101: Module 'requests.packages' has no 'urllib3' member (no-member)

---------------------------------------------------------------------
Your code has been rated at -6.67/10 (previous run: -10.00/10, +3.33)

Expected behavior

No warning, as the code runs perfectly despite the pylint error.

pylint --version output

Result of pylint --version output:

pylint 2.6.0
astroid 2.4.2
Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)]

Additional dependencies:

requests==2.25.1
urllib3==1.24.3

ItsIgnacioPortal avatar Jun 16 '21 19:06 ItsIgnacioPortal

Thank you for opening the issue, I can reproduce this on the latest pylint.

Pierre-Sassoulas avatar Jun 16 '21 19:06 Pierre-Sassoulas

Same issue for me:

$ pylint --version
pylint 2.12.2
astroid 2.9.0
Python 3.8.9 (default, Apr 21 2021, 23:14:29)
[GCC 10.2.0]

$ cat pylint_bug_repro.py
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning

requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

$ pylint pylint_bug_repro.py
************* Module pylint_bug_repro
pylint_bug_repro.py:2:0: E0401: Unable to import 'requests.packages.urllib3.exceptions' (import-error)
pylint_bug_repro.py:4:0: E1101: Module 'requests.packages' has no 'urllib3' member (no-member)

Lucas-C avatar Dec 09 '21 08:12 Lucas-C

I found this issue doing a Google search. It's not a false positive as requests.packages.urllib3 is just an alias for urllib3. Change the code to:

import requests
import urllib3

urllib3.disable_warnings(category = urllib3.exceptions.InsecureRequestWarning)

mheath avatar Sep 07 '22 18:09 mheath

I found this issue doing a Google search. It's not a false positive as requests.packages.urllib3 is just an alias for urllib3. Change the code to:

import requests
import urllib3

urllib3.disable_warnings(category = urllib3.exceptions.InsecureRequestWarning)

You've found a way to do the same thing without the false positive. That's nice. This code I posted initially still causes a false positive though.

ItsIgnacioPortal avatar Sep 08 '22 08:09 ItsIgnacioPortal