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

Native Interactive Window - Pylance errors with variables imported in jupyter startup script #7098

Closed
jaymegordo opened this issue Aug 12, 2021 · 4 comments
Labels
bug Issue identified by VS Code Team member as probable bug notebook-intellisense Intellisense & other language features in notebook cells for any language

Comments

@jaymegordo
Copy link

Environment data

  • Version: 1.60.0-insider
  • Commit: 7c25c174726ab969db3f99058cdf24bcfae1cfbe
  • Date: 2021-08-11T05:13:17.497Z
  • Jupyter Extension version: v2021.8.2025984474
  • Python Extension version: v2021.9.1117361286-dev
  • OS: Darwin x64 20.6.0
  • Python and/or Anaconda version: 3.9.2
  • Type of virtual environment used: poetry
  • Jupyter server running: Local

One main part of my workflow is to have certain variables/modules imported at jupter startup, defined in a startup.py file at:

  • ~/.ipython/profile_default/startup/startup.py

Expalained fully here

Expected behaviour

  • Jupyter/native interactive window/pylance recognizes variables imported through a startup script.

Actual behaviour

For example I'd have

#! startup.py
import pandas as pd

The module is imported, and pd is valid in the globals(), but pylance doesn't seem to recognize it. I'll also import lots of custom objects from the current project I'm working on, so you can imagine it's kinda hard to work when almost every variable is "undefined" (and also doesn't have intellisense).

In screenshots:
Screen Shot 2021-08-12 at 9 48 59 AM

Not sure what's actually going on here, but just expanding the code from the previous image (before executing anything) made pylance/problems go crazy:
Screen Shot 2021-08-12 at 9 50 00 AM

pd is recognized after explicitely importing in the current session:
Screen Shot 2021-08-12 at 9 52 06 AM

@jaymegordo jaymegordo added the bug Issue identified by VS Code Team member as probable bug label Aug 12, 2021
@greazer greazer added notebook-intellisense Intellisense & other language features in notebook cells for any language and removed needs-triage labels Aug 12, 2021
@greazer greazer added this to the August 2021 milestone Aug 12, 2021
@greazer
Copy link
Member

greazer commented Aug 12, 2021

@jaymegordo Thanks for the feedback!

@rchiodo
Copy link
Contributor

rchiodo commented Aug 31, 2021

Sorry but this isn't currently supported. This is basically the same bug as this one:
#6987

@rchiodo rchiodo closed this as completed Aug 31, 2021
@jaymegordo
Copy link
Author

@rchiodo thanks for letting me know. Do you know if there will be any plans to support this in the future? Do you know of any other workarounds to have certain modules importd to the IW automatically which would support intellisense?

@rchiodo
Copy link
Contributor

rchiodo commented Sep 1, 2021

@jaymegordo you can track #6987 to see if we end up supporting dynamic modules in pylance or not. My guess is it won't be supported for a long time as pylance doesn't run any python code. It's all static analysis based. We might be able to fudge it by concating the code for a run startup commands onto the top of the notebook, but we haven't tried yet.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug notebook-intellisense Intellisense & other language features in notebook cells for any language
Projects
None yet
Development

No branches or pull requests

4 participants