-
-
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
false import-errors with pip >= 21.3 #7306
Comments
I am having a similar error, but on my side it happens when using setuptools >=64.0.0 which was introduced by https://togithub.com/pypa/setuptools/pull/3488. Have you tried pinning the setuptools version below 64.0.0 for the build backend ? Here is my failing workflow: https://github.com/libretime/libretime/runs/7938963601?check_suite_focus=true |
Here is another minimal reproducible repository https://github.com/jooola/pylint-import-error-bug |
@jooola Can you confirm that for the reproducing repository doing |
@DanielNoord I was was able to fix my issue buy applying the patch I just pushed. Which pin the setuptools version below 64.0.0 https://github.com/jooola/pylint-import-error-bug/blob/main/before_setuptools_v64.0.0.patch Ooh wait, I had to deactivate and reactivate the virtual environment once everything was installed to get this to work again. I'll try the same with setuptools>=64.0.0. |
Ok, I can confirm this again, setuptools<64 fixes the bug, without necessarily reentering the virtual venv. |
The issue is in the following piece of code: On The repository with the pinning of I'm not sure I'll be able to get to this this week so if anybody is interested please go ahead and investigate more or propose a solution. I'm inclined to open an issue against Edit: Replied to pypa/setuptools#3518. There seem to be issues with the new system and other static analysis tools. Let's hope they get back to us! |
I have a fix ready for this in pylint-dev/astroid#1752. However, I'm not sure this is the right way forward. Other linters have been hesitant to add support for import hooks, see: I'm not sure we should start supporting them, but at least this works I guess? 😅 |
pylint is used in our workflows and currently it breaks them with import errors from an editable installation of our projects. Is there something we can change in the usage of pylint to avoid these errors without changing the project's code or file hierarchy? |
It's a bit of a stretch but you could install See https://stackoverflow.com/questions/20101834/pip-install-from-git-repo-branch Fixing stuff in our import system is difficult as much can be broken. So it takes some time for these fixes to make it to release. This branch has been working for me with the new setuptools versions though. Edit: Or any of the suggestions by @jooola |
You can either pin the setuptools version (see the bug reproduction repository) or add the legacy editable option (using the |
Thank you for your recommendations but the issue is reproduced with these versions: Python 3.9.2 So setuptools is less than 64. |
Even then, installing my local branch should fix this as it add support for custom import hooks. Also note that it's quite easy to have |
Can you please elaborate on the |
The only safe and non-intrusive fix for now is |
It seems it might be a bug caused by pypa/setuptools#3499 that affects setuptools |
For me, the only way of making pylint to work agian in editable installs is to also use |
Ok, so I was able to confirm that I changed my |
I see that this bug happens even with the latest Any pinning of setuptools would produce other problems, even if done only for development. |
I don't understand your comment. There is an incompatibility with Anyway, @Pierre-Sassoulas would you mind releasing |
Sure let's release a new version of astroid. |
@DanielNoord Thanks for your work on pylint-dev/astroid#1752! I installed I'm finding that whereas before ************* Module test_everything
tests/test_everything.py:6:14: E1101: Module 'pylint_bug_mre' has no 'goodbye' member; maybe 'Goodbye'? (no-member)
tests/test_everything.py:11:12: E1101: Module 'pylint_bug_mre' has no 'hello' member; maybe 'Hello'? (no-member) It seems like pylint recognizes the module being imported and the two classes that it exports, but it doesn't recognize its submodules. I confirmed that pylint reports no errors if I use a Edit: I dug through When you try importing |
Seems to be resolved in pylint 3.0 |
Let's close then, please open a new issue referencing this one if you still encounter the issue. |
Bug description
summary:
import-error
with recent pip versions (>= 21.3)pip install -e .
, on a project withsetup.py
andpyproject.toml
The following change from pip 21.3.0 may be relevant:
create project & env:
Configuration
No response
Command used
Pylint output
Expected behavior
no import-error, as with earlier pip versions
Pylint version
OS / Environment
No response
Additional dependencies
pip => 21.3
The text was updated successfully, but these errors were encountered: