microsoft / vscode-jupyter

VS Code Jupyter extension

Home Page:https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

First cell delimiter is ignored when using "Run All Cells" or "Run Current File in Interactive Window" from script

wjandrea opened this issue · comments

Environment data

Codespace

  • VS Code version: 1.88.1
  • Jupyter Extension version: v2024.3.1
  • Python Extension version: v2024.4.1
  • OS and version: Ubuntu 20.04.6
  • Python and/or Anaconda version: 3.10
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): (whatever a codespace uses by default)
  • Jupyter server running: (whatever a codespace uses by default)

Problem

When running the below script with Run All Cells or Run Current File in Interactive Window, "Start" is printed even though it's not in a cell.

If you enable Magic Commands as Comments (jupyter.magicCommandsAsComments), it's even worse: the shebang is executed as if it were a command.

#!/usr/bin/env python3
print('Start')
# %%
# ! %pwd
# %%
print('End')

For more details, see #11140. The only difference is that now Run Current File in Interactive Window is doing the same thing as Run All Cells. I'm not sure if it was ever resolved because I'm using VSCodium and its version of the Jupyter extension has been delayed, but I had a workaround so didn't need to worry about it.

(Can provide GIF if needed)

Logs

(Can provide if needed, but I provided some in #11140)

#14551 might be related