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

False alarm of no-name-in-module with setuptools 50.0 in Python 3.5.1 #3807

Closed
gavincyi opened this issue Sep 2, 2020 · 3 comments
Closed
Labels

Comments

@gavincyi
Copy link

gavincyi commented Sep 2, 2020

Background

The issue happens on setuptools 50.0.2 (or greater than 50.0.1) and Python 3.5.1. Since setuptools version 50.0, setuptools overrides the stdlib distutils by default.

Setuptool's issue n°2232 : Once again, Setuptools overrides the stdlib distutils on import. For environments or invocations where this behavior is undesirable, users are provided with a temporary escape hatch. If the environment variable SETUPTOOLS_USE_DISTUTILS is set to stdlib, Setuptools will fall back to the legacy behavior.

https://setuptools.readthedocs.io/en/latest/history.html

Pylint starts to throw out false alarms on no-name-in-module in Python 3.5.1.

Steps to reproduce

  1. Create the environment with the latest setuptools - pip install -U setuptools
  2. Create a simple python file to import stdlib function, e.g.
"""Test."""
from math import sqrt

print(sqrt(2))

Current behavior

Pylint throws out alerts of "no-name-in-module" on the stdlib functions

$ pylint test_pylint.py 
************* Module test_pylint
test_pylint.py:2:0: E0611: No name 'sqrt' in module 'math' (no-name-in-module)

----------------------------------------------------------------------
Your code has been rated at -15.00/10 (previous run: 10.00/10, -25.00)

Expected behavior

For setuptools versions < 50.0, pylint behaves correctly.

Same behavior if setuptools falls back to the legacy behavior, i.e.

$ SETUPTOOLS_USE_DISTUTILS=stdlib pylint test_pylint.py 

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

pylint --version output

pylint 2.6.0
astroid 2.4.2
Python 3.5.1 (default, May 29 2019, 15:41:33) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]

Potential impact

As mentioned in the setuptools ticket, it is likely that other micro Python versions e.g. Python 3.5.X, 3.6.X and 3.7.X are impacted as well, while I haven't tested them.

@Pierre-Sassoulas
Copy link
Member

I had to fix something similar in the build in 2261844, but to be fair I don't understand a lot about the issue and how to fix it permanently without using the hack they gave in their release note.

@gavincyi
Copy link
Author

gavincyi commented Sep 8, 2020

The setuptools behaviour has been reverted in 50.1.0 so now the issue is not urgent until they flip back the distutils hack again. My understanding the hatch is done by inserting the meta path finder.

Meanwhile could you shed me the light how pylint looks up the module and returns the no module alert?

@Pierre-Sassoulas
Copy link
Member

Sorry for not answering sooner. I did not see your question. Now that I see it, I don't understand it 😄

Anyway, I'm closing as it's related to python 3.5 that is no longer supported. Feel free to tell me to reopen if it affect python 3.6 or above.

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

2 participants