-
Notifications
You must be signed in to change notification settings - Fork 767
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
v2021.1.3 broke pkgutil-style namespace packages - Missing Imports #892
Comments
I'll need to investigate more deeply, but from the screen shot above, it looks like both the local and installed packages are namespace modules. Therefore, "example_pkg.b.bb" should resolve to the local one. In other words, on first inspection, it looks like this is a regression that I introduced with my recent change. |
I can verify the behavior. v2021.1.2 works well, v2021.1.3 provides the same issue for me. |
Thanks for the excellent repro steps. I found and fixed the problem. The fix will be in the next release. Apologies for introducing the regression. |
Fantastic news @erictraut. Thank you for the quick fix. |
This issue has been fixed in version 2021.2.0, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202120-3-february-2021 |
I am running 2021.2.0 and I am still seeing the problem for packages which share This observation is for macos 11.2 on MacBook pro 15in 2018. |
2021.2.0 fixed it for me. |
@jdwestbrook Do you have an example project somewhere we can test? |
Here is an example - https://github.com/rcsb/py-rcsb_utils_config.git pyenv shell 3.9.1 open vscode and then open file rcsb/utils/config/ConfigUtil.py I am seeing that the import from rcsb.utils.io.FileUtil import FileUtil I am using the latest insiders build (daily) and the latest Pylance (daily) release. |
If you don't do the editable installs, does it work as expected? Editable installs are not quite supported at the moment (#78), so it could be the case that your code was working due to a bug. |
You nailed it. When explicitly installed the rcsb.utils.io module from PyPi, vscode finds the module. |
Yeah, sorry about that. Thanks for that repo, though, as it'll be very useful when we try and get editable installs working. |
Environment data
Expected behaviour
I expect VSCode to be able to import from pkgutil-style namespaced packages.
Actual behaviour
It's not able to import from pkgutil-style namespaced packages
Logs
Code Snippet / Additional information
We use pkgutil-style namespace packages, as documented here:
https://packaging.python.org/guides/packaging-namespace-packages/#pkgutil-style-namespace-packages
I've forked their example project to reproduce the issue:
https://github.com/mvanderlee/sample-namespace-packages/tree/pylance_v2021.1.3
Steps:
Clone https://github.com/mvanderlee/sample-namespace-packages/tree/pylance_v2021.1.3 and ensure you're on the
pylance_v2021.1.3
branchOpen
sample-namespace-packages/pkgutil/pkg_b
in VSCodeeCreate virtual environment
Activate the virtualenv
VSCode should've prompted you to use the virtualenv, or you can select it yourself by adding this to your
settings.json
Install pkg_a
pip install ..\pkg_a
Open
![image](https://user-images.githubusercontent.com/918128/106150524-d349b380-6151-11eb-89b2-4452451b6234.png)
example_pkg/b/__init__.py
and observe that line 16 has an import error.Revert Pylance to v2021.1.2 and observer that the import works fine.
Project layout:
![image](https://user-images.githubusercontent.com/918128/106150648-e8bedd80-6151-11eb-98d4-1405e502d7d8.png)
Likely broken by this change: #885 (comment)
The text was updated successfully, but these errors were encountered: