-
-
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
Support imports of namespaces in python>=3.3 (modules without __init__.py files) #842
Comments
Agree that this would be nice to have, but not sure when this will happen. |
This would be great to have. Is this just a minor enhancement? Out of curiosity, where would the change have to be made? |
For my organization, it's not minor but a real showstopper. We use lots of namespace packages and are moving to the new implicit namespace package layout, so we can't use pylint in the mean time. Is this something a motivated would-be contributor with no prior pylint experience could reasonably fix? |
@kstrauser |
@moylop260 But I use import errors. :-/ I've temporarily switched to flake8 but I'd much prefer pylint on the CI server. |
Flake8 don't have |
A big problem with use |
@kstrauser, this would probably be a bit difficult, since it will require modifications through astroid as well (the inference engine of Pylint). But if you want to tackle it, I can help you with the details. |
@PCManticore Thanks, after looking at it that might be outside my current resource availability. I'm going to keep that in mind as a possibility, though. |
Let's fix this before the next release. I'm assigning to me for now, but if anyone wants to chime in and help, I wouldn't mind. |
For the record, I started implementing this feature. It's pretty much work in progress, but you can check these two branches https://github.com/PyCQA/pylint/commits/namespace_package and https://github.com/PyCQA/astroid/commits/namespace_package. It doesn't support Python 3.3 though, it is a bit cumbersome to support it, but if someone needs it, say it now. |
This should be fixed, you'll need the pylint's and astroid's master branch if you want to test. Please give it a go and let me know if you have problems with it. |
@PCManticore |
This is closed but I don't think it was merged. Any news ? |
This is available in the master branch. It will be released though in a On Aug 2, 2016 8:06 PM, "abstrus" [email protected] wrote:
|
I'm still having this problem? Was the release ever published? |
This was already released @janosh but there might be some bugs lurking around. Please open a new issue with some reproduction examples. |
Never mind, I was specifying the imports from the wrong starting point, i.e. |
FTR this error pops up for me with the latest pylint under Python 3.7 but occasionally: only in Travis CI and GitHub Actions CI/CD. No errors locally. I've been trying to figure out the difference between envs but still no luck... |
Python 3.3 introduced "Implicit Namespace Packages" (based on PEP-420), which states the following:
"Native support for package directories that don’t require
__init__.py
marker files [...]".In other words, if I have the following file structure (without any
__init__.py
files whatsoever):And the content of blah.py is
from foo.bar import baz; print(baz)
, thenpython3.5 ./blah.py
will successfully output:<module 'foo.bar.baz' from '/tmp/foo/bar/baz.py'>
.The problem is, that
pylint ./blah.py
outputs:E: 1, 0: Unable to import 'foo.bar' (import-error)
I tried to manipulate
sys.path
(frominit-hook
of my.pylintrc
) in any which way, and nothing seemed to help except for adding the__init__.py
files everywhere :(.The text was updated successfully, but these errors were encountered: