Skip to content
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

No completion in namespace packages #4138

Closed
MikhailArkhipov opened this issue Apr 26, 2018 · 5 comments
Closed

No completion in namespace packages #4138

MikhailArkhipov opened this issue Apr 26, 2018 · 5 comments
Assignees

Comments

@MikhailArkhipov
Copy link

.
├── projecta
│   └── foo
│       ├── bar
│       │   └── __init__.py
│       └── __init__.py
└── projectb
    └── foo
        ├── baz
        │   └── __init__.py
        └── __init__.py

test.py:

import projectA.foo
import projectA.foo.bar
import projectB.foo
import projectB.foo.baz

projectA.

image

Jedi:
image

PyCharm:
image

@MikhailArkhipov
Copy link
Author

Works in 3.6 but not in 2.7. 2.7 works if __init__.py is added to ProjectA and ProjectB. See also https://stackoverflow.com/questions/32152373/python-why-can-i-import-modules-without-init-py-at-all

@MikhailArkhipov
Copy link
Author

MikhailArkhipov commented Aug 23, 2018

Apparently is is pretty common case. See
microsoft/vscode-python#2213 and
microsoft/vscode-python#2319

mpl_toolkits does not have __init__.py, just bunch of subfolders. Adding __init__.py makes us import the module.

@zooba
Copy link
Member

zooba commented Aug 23, 2018

2.7 doesn't support namespace packages - they were added in 3.3.

mpl_toolkits should be coming through AstPythonInterpreter.ImportModule, so it should be easy enough to look through all search paths and return a set of multiple modules.

The original issue in this thread is about namespace packages in the user's own project, which is going to be a different fix. You'll probably want to split the "in stdlib" vs "in project" cases into separate bugs.

@MikhailArkhipov
Copy link
Author

Yes, I know. Matplotlib issue is somewhat simpler.

@MikhailArkhipov
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants