-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
ImportError for implicit namespace (pyproject, setuptools) #7875
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
Comments
I expect that the issue is somewhere in |
Hi all (special to @jacobtylerwalls)! I know these are busy times, but I feel that this is quite a fundamental issue. I may be making a mistake -- I hope so and please do help me to sort it out! If not, however, you may want to triage this and get a discussion going. I appreciate your efforts :) |
Which version of setuptools are you using? |
I've tested this setup (and repreduced the issue) with versions |
Could you try with |
I got the same results with versions |
I really want to look into this, but haven't found the time. Sorry! Trying to do so in the coming weeks. |
@DanielNoord thank you for the heads up -- I appreciate the notification. I've tried some minor things that did not help (but might we worth noting).
So.. no luck thus far. I look forward to your analysis. Until that time though, let's enjoy the last bit of 2022 and we'll be in touch next year! |
Thanks for your patience. I just found some time to have a look.
EDIT: removed irrelevant proposed diffs
For now, as a workaround, you could lint |
Actually, looking closer, all the diff really does is revert pylint-dev/astroid#1756. I'm not yet sure of the correct behavior. |
@jacobtylerwalls thank you for joining the discussion and providing suggestions! I'm somewhat surprised by the comment
that was introduced in pylint-dev/astroid#1756. In both my local development environment (using |
You have a nice test case here. Something should be done to improve the situation. Unfortunately this has been missing from pylint for forever (doesn't look to be recently caused in astroid*). Some of the variations on the failure were also referenced in #1361 before we closed it. 1. 2. 3. (* in astroid 2.12.0, 2. briefly behaved like 3., but we got several bug reports and reverted it in pylint-dev/astroid#1756 in 2.12.5) Workaround is to use |
@jacobtylerwalls could you point me to some of these issues to better understand the issue with resolving to site-packages? I don't quite understand what happens in #7365 -- that case seems weird also just because the pylint output states the module prepended with I only specified my use case partially. Ultimately, I want to be able to install several namespace packages, all of them part of the same namespace, and then run pylint on the package as a whole (so not just |
Sure thing.
In addition to #7365 we also got a bug report after the fact in pylint-dev/pylint-plugin-utils#27 (comment). I agree that the handling of namespace packages needs improving. The code paths through this part of astroid and pylint are terribly tangled. We would just like to find incremental improvements that don't create breaking changes (unless we do really need to advertise breaking changes in a 3.0 version.) Any analysis or draft patches are much appreciated. |
I'd expect a solution to this issue to likely give a way of handling this one as well. I did make a pr for it in past and mostly stalled out on writing tests for it/whether that option was worth it. Maybe now I should revive that pr as still feels like any solution that involves guessing sys.path/reverse engineering import system is likely to be tricky. The original pr was this one. Most of complexity/bugs with namespace packages comes from pylint trying to be smart and guessing what to add to sys.path if packages are uninstalled. This smartness is convenient for simple projects and allowing users to not need to install there own code, but becomes tricky for more complex packages (mostly namespace weirdness). If pylint expected (with an opt-in flag) that all packages must be installed already and doesn't alter sys.path at all, the complexity disappears. |
This is to accomodate pylint not working with implicit namespace packages. See pylint-dev/pylint#7875 or one of its many duplicates. isort’s auto-detection seems to need some extra config to recognize the package.
Bug description
Hi all,
I try to run
pylint
on an implicit namespace that is build from apyproject.toml
withsetuptools
as backend. However,pylint
is not able to deduce the namespace and throws anImportError
.Project lay-out:
pyproject.toml
fun.py
Configuration
No response
Command used
pip install . pylint foo.bar
Pylint output
Expected behavior
pylint
analysis of the module, similar to the following output (obtained by puttingfun.py
infoo
and updating the package name):Pylint version
OS / Environment
Ubuntu 20.04.5 LTS (in WSL 2 on Windows 10)
Additional dependencies
No response
The text was updated successfully, but these errors were encountered: