-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 fails to import module if the script is named the same way #7093
Comments
pylint fails to import the `apport` module for `data/apport`, because it has the same name. See bug pylint-dev/pylint#7093 Signed-off-by: Benjamin Drung <bdrung@ubuntu.com>
Thanks for the report. Fixed in pylint-dev/astroid#1536, which will be part of pylint 2.15's upgrade to astroid 2.12. This may even be a duplicate of #2648 but I'm reluctant to declare that until we have distilled a mergeable test case from it. This issue has a clear test case, which I would welcome adding to the suite. Would you like to prepare a PR? It will pass as soon as we merge #7153. Because this issue requires a particular directory structure, and might not reproduce cleanly with the generic system for functional tests in tests/functional, you might follow the models at #7117 or #7113. |
pylint incorrectly complains about import-self on importing `apport` in `data/apport`. See pylint-dev/pylint#7093 Signed-off-by: Benjamin Drung <bdrung@ubuntu.com>
I spent most of my weekend debugging a similar issue. The project root (with requirements.txt) is named Can you confirm this will be fixed in 2.15.0? Also, is there a date announced for 2.15.0 or a workaround until that time? |
The cases reported to this issue board relating to imports can be deceivingly different. It would be a great help if you could install pylint from the
Unfortunately not, the workaround is to install from the main branch as above. |
You can follow the release at https://github.com/PyCQA/pylint/milestone/56. I'm going to remove this from the 2.15.0 milestone as we want to release soon and as if seems like a real release would be convenient be helpful for testing on your side :) |
Still reproduces on pylint at 1baa10e and astroid at 39d9cafb8b39432957f4e640d5ef222b66a7096e, so #7093 (comment) was not correct. |
it seems this issue is still there in version 3.3.3 with astroid 3.3.8 |
Bug description
Apport provides a module name
apport
, but also a script nameddata/apport
. Pylint throws a bunch of failures fordata/apport
. This problem can be reproduces with this Shell script:It will create
name/math.py
withand
data/name
withAfter setting
PYTHONPATH
,data/name
will execute successfully.Configuration
No response
Command used
or
or
pylint --init-hook='import sys; sys.path.append(".")' name data/name
Pylint output
Expected behavior
pylint should produce no output.
Pylint version
OS / Environment
Ubuntu 22.04 (jammy)
Additional dependencies
No response
The text was updated successfully, but these errors were encountered: