-
-
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
Pylint does not follow python import order : Builtin modules are imported before custom modules #6535
Comments
In my case I haven't been able to reproduce the Create (venv39) programming python test.py
Fatal Python error: init_import_site: Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site.py", line 589, in <module>
main()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site.py", line 566, in main
known_paths = removeduppaths()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site.py", line 127, in removeduppaths
dir, dircase = makepath(dir)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site.py", line 92, in makepath
dir = os.path.join(*paths)
AttributeError: module 'os' has no attribute 'path' |
I can reproduce this, I wonder if the order is interpreter dependent. If that's the case we need to handle this dynamically. |
I encountered this issue multiple times over the last month and that is because my main python is 3.11 and pylint is not yet compatible with 3.11. So, I forced us to use oldest supported python and lock it during linting. I hope to see py311 support added soon in astroid. |
I have the same issue.
I hope this issues will be resolved. |
I encountered a similar error that can shed light to what is going on Python version We have a module in our source code
A quick solution was to change from I'm guessing it's a regex that is wrongly matching imports or something like that. |
I understand most projects linking issues here are postponing their 3.11 support due to this. Anyway, if anybody following this have more info, I'd be interested. |
According to the OP this isn't |
…os builtin package (relates to pylint-dev/pylint#6535)
For example: `import copy` now finds `copy` instead of `copy.py`. This worked correctly before in at least some cases if there was a (more?) complete chain of __init__.py files from cwd all the way to the location of the `copy.py` module. Closes pylint-dev/pylint#6535
I would be grateful for anyone's input on pylint-dev/astroid#2223, which should fix the OP. By installing from that branch and retesting your use case, you can give us the confidence to make changes to a delicate part of this tool's system. Thanks! |
For example: `import copy` now finds `copy` instead of `copy.py`. This worked correctly before in at least some cases if there was a (more?) complete chain of __init__.py files from cwd all the way to the location of the `copy.py` module. Closes pylint-dev/pylint#6535
For example: `import copy` now finds `copy` instead of `copy.py`. This worked correctly before in at least some cases if there was a (more?) complete chain of __init__.py files from cwd all the way to the location of the `copy.py` module. Closes pylint-dev/pylint#6535
Ubuntu 22.10 was EOLed on 2023-07-26.¹ The obvious thing would be to _upgrade_ to Ubuntu 23.04. But we run into the new Python policy Ubuntu has instituted (see 0050eac). We could comply with this or move this task to Fedora, but then we find that Pylint does not work with Python 3.11² which is what is in use on both Ubuntu 23.04 and all supported Fedora releases. So downgrading to Ubuntu 22.04 seems like the simplest options for an environment that is still in its support window. ¹ https://wiki.ubuntu.com/Releases ² Discussed in the comments of pylint-dev/pylint#6535. Symptoms are complaints of `os` members not existing.
Bug description
when a project holds a module name that shadows builtin module name, pylist fails on
no-member
, when clearly this is not the case.reproduction
given 2 files:
os.py
an empty filetest.py
with the following contentand now pylint fails on
no-member
as followsbut the code is correct
Configuration
No response
Command used
Pylint output
Expected behavior
pylint should be aware of the
import
tree, and report such issue if that is indeed the case.in the reproduction snippet above,
test.py
imports theos
builtin module (and notos.py
) that has theenviron()
.Pylint version
OS / Environment
macos
Additional dependencies
No response
The text was updated successfully, but these errors were encountered: