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

Time magic causes the cell to lose its syntax highlight and autocompletion #11476

Closed
leocwolter opened this issue Sep 28, 2022 · 6 comments
Closed
Labels
bug Issue identified by VS Code Team member as probable bug notebook-intellisense Intellisense & other language features in notebook cells for any language upstream-pylance Blocked on upstream Pylance

Comments

@leocwolter
Copy link

leocwolter commented Sep 28, 2022

Environment data

  • VS Code version: 1.71.2
  • Jupyter Extension version (available under the Extensions sidebar): v2022.8.1002431955
  • Python Extension version (available under the Extensions sidebar): v2022.14.0
  • OS (Windows | Mac | Linux distro) and version: Ubuntu 20.04.3 LTS
  • Python and/or Anaconda version: 3.7.10
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): poetry virtualenv
  • Jupyter server running: Using Remote - SSH and Remote - Containers but not using the remote jupyter feature.

Expected behaviour

The cell using the %%time magic should continue to have syntax highlight and the autocompletion feature should continue working

Actual behaviour

The cell using the %%time magic loses its syntax highlight and autocompletion feature

Steps to reproduce:

  1. Create a notebook
  2. Add a cell containing the code
test  = "working"
  1. Add another cell containing the code
%%time
another_test = "not working"
test

image

Logs

No useful logs since you don't have to execute anything to reproduce the issue

@leocwolter leocwolter added the bug Issue identified by VS Code Team member as probable bug label Sep 28, 2022
@IanMatthewHuff IanMatthewHuff added the notebook-intellisense Intellisense & other language features in notebook cells for any language label Sep 28, 2022
@IanMatthewHuff
Copy link
Member

@leocwolter Thanks for the report. Makes sense what is going on here. Cells are getting sent to the language server (probably Pylance in this case), language server doesn't have knowledge of jupyter magics, so the cell doesn't get language features. I think that we have some ways we can work around this (either converting the magic to the underlying code that executes, or skipping it).

@leocwolter
Copy link
Author

leocwolter commented Sep 28, 2022

@IanMatthewHuff Yeah, it makes sense 🤔 how can I test those workarounds?

Also, I just noticed that variables declared at the cell using the %%time are not recognized by the other cells:
image

Variables declared on cells without the magic are recognized/autocompleted correctly:
image

@IanMatthewHuff
Copy link
Member

IanMatthewHuff commented Sep 28, 2022

@leocwolter My apologies. I don't know that you could really test those workarounds yourself, that was more just me thinking about how we could fix this. The issue that you just listed would be expected as well, the cell (with the magic) gets sent to the language server, the language server sees the magic and doesn't recognize it as python, so nothing else after that in the cell gets processed. The code runs, so the program should still work, but the language features miss that whole cell in their knowledge of what's going on.

@IanMatthewHuff IanMatthewHuff removed their assignment Nov 10, 2022
@DonJayamanne DonJayamanne added the upstream-pylance Blocked on upstream Pylance label Dec 8, 2022
@FlorinAndrei
Copy link

This bug is annoying, and old. Any progress recently?

@benlindsay
Copy link

@DonJayamanne I see you added the upstream-pylance tag. I guess I would have thought vscode-jupyter would remove or comment out jupyter magics before sending the code to pylance for analysis, but I'll take your word for it. Should we make a separate issue there then? I put together a list of all the syntax issues I noticed that jupyter magic like %%time can cause here

@DonJayamanne
Copy link
Contributor

Duplicate of #4588

@DonJayamanne DonJayamanne marked this as a duplicate of #4588 Dec 6, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2024
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 upstream-pylance Blocked on upstream Pylance
Projects
None yet
Development

No branches or pull requests

5 participants