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

Pyright no longer resolves modules in the directory containing notebooks #3088

Closed
thomasaarholt opened this issue Jul 22, 2022 · 2 comments
Closed
Labels
duplicate This issue or pull request already exists

Comments

@thomasaarholt
Copy link

Describe the bug
In VSCode notebooks, I have been able to keep functions in a process_data.py file placed in the same directory as a notebook I am working with. That way I can move functionality out of the notebook and into the .py module to keep the notebook clean.

As of the latest pre-release version, pylance does not resolve the import, and so does not know anything about the functions I am importing. It does work in a regular other.py file.

fails in notebook

image

works in regular .py files

image

I've awkwardly bypassed this using the following try-except. pylance recognises imports via the .process_data relative import, but this raises an importerror when called on its own in the notebook :(

try:
    from process_data import numeric_categorical_columns
    from .process_data import numeric_categorical_columns
except SyntaxError:
    print("uh oh, check imports")
except ImportError:
    pass

VS Code extension or command-line
Running Python extension pre-release version v2022.11.12021011

@erictraut
Copy link
Contributor

Notebook support is handled by pylance. Transferring the issue to pylance-release.

@erictraut erictraut transferred this issue from microsoft/pyright Jul 22, 2022
@heejaechang
Copy link
Contributor

dupe - #3017

@heejaechang heejaechang added the duplicate This issue or pull request already exists label Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants