Skip to content

Using smart send with REPL leads to NameError for every line of code #25117

Open
@John-Polo

Description

@John-Polo

Type: Bug

Behaviour

Expected behavior: Inside a Python file, at a line, for example:
import numpy as np
use smart send ('shift+enter') to run REPL and watch code results. Move to next line and do the same thing.

Actual behavior: Editing in a Python file (.py) and using Smart Send with the VS Code REPL, each line of code sends as "deprecated", which in turn returns a NameError in the REPL window.

This doesn't happen in interactive sessions in the Python terminal in Code.

Steps to reproduce:

  1. Start Code with 'code .' from cmd prompt window where I've activated a conda environment.
  2. In current .py file in editor, use 'shift+enter' to run line.
  3. Python REPL window prints "deprecated" and reports a traceback with error:
    Traceback (most recent call last):
    File "c:\Users\japolo.vscode\extensions\ms-python.python-2025.6.1-win32-x64\python_files\python_server.py", line 133, in exec_user_input
    retval = callable_(user_input, user_globals)
    File "", line 1, in
    NameError: name 'deprecated' is not defined

Diagnostic data

There are no logs in the Output Panel. There are messages in the Problems panel:
[{
"resource": "Untitled-1.ipynb",
"owner": "python",
"severity": 8,
"message": ""return" can be used only within a function",
"source": "Pylance",
"startLineNumber": 1,
"startColumn": 1,
"endLineNumber": 1,
"endColumn": 7
},{
"resource": "Untitled-1.ipynb",
"owner": "python",
"code": {
"value": "reportUndefinedVariable",
"target": {
"$mid": 1,
"path": "/microsoft/pylance-release/blob/main/docs/diagnostics/reportUndefinedVariable.md",
"scheme": "https",
"authority": "github.com"
}
},
"severity": 4,
"message": ""directory" is not defined",
"source": "Pylance",
"startLineNumber": 1,
"startColumn": 31,
"endLineNumber": 1,
"endColumn": 40
},{
"resource": "Untitled-1.ipynb",
"owner": "python",
"code": {
"value": "reportUndefinedVariable",
"target": {
"$mid": 1,
"path": "/microsoft/pylance-release/blob/main/docs/diagnostics/reportUndefinedVariable.md",
"scheme": "https",
"authority": "github.com"
}
},
"severity": 4,
"message": ""extension" is not defined",
"source": "Pylance",
"startLineNumber": 1,
"startColumn": 54,
"endLineNumber": 1,
"endColumn": 63
},{
"resource": "Untitled-1.ipynb",
"owner": "python",
"code": {
"value": "reportUndefinedVariable",
"target": {
"$mid": 1,
"path": "/microsoft/pylance-release/blob/main/docs/diagnostics/reportUndefinedVariable.md",
"scheme": "https",
"authority": "github.com"
}
},
"severity": 4,
"message": ""deprecated" is not defined",
"source": "Pylance",
"startLineNumber": 1,
"startColumn": 1,
"endLineNumber": 1,
"endColumn": 11
},{
"resource": "Untitled-1.ipynb",
"owner": "python",
"code": {
"value": "reportUndefinedVariable",
"target": {
"$mid": 1,
"path": "/microsoft/pylance-release/blob/main/docs/diagnostics/reportUndefinedVariable.md",
"scheme": "https",
"authority": "github.com"
}
},
"severity": 4,
"message": ""deprecated" is not defined",
"source": "Pylance",
"startLineNumber": 1,
"startColumn": 1,
"endLineNumber": 1,
"endColumn": 11
},{
"resource": "Untitled-1.ipynb",
"owner": "python",
"code": {
"value": "reportUndefinedVariable",
"target": {
"$mid": 1,
"path": "/microsoft/pylance-release/blob/main/docs/diagnostics/reportUndefinedVariable.md",
"scheme": "https",
"authority": "github.com"
}
},
"severity": 4,
"message": ""deprecated" is not defined",
"source": "Pylance",
"startLineNumber": 1,
"startColumn": 1,
"endLineNumber": 1,
"endColumn": 11
},{
"resource": "Untitled-1.ipynb",
"owner": "python",
"code": {
"value": "reportUndefinedVariable",
"target": {
"$mid": 1,
"path": "/microsoft/pylance-release/blob/main/docs/diagnostics/reportUndefinedVariable.md",
"scheme": "https",
"authority": "github.com"
}
},
"severity": 4,
"message": ""deprecated" is not defined",
"source": "Pylance",
"startLineNumber": 1,
"startColumn": 1,
"endLineNumber": 1,
"endColumn": 11
},{
"resource": "Untitled-1.ipynb",
"owner": "python",
"code": {
"value": "reportUndefinedVariable",
"target": {
"$mid": 1,
"path": "/microsoft/pylance-release/blob/main/docs/diagnostics/reportUndefinedVariable.md",
"scheme": "https",
"authority": "github.com"
}
},
"severity": 4,
"message": ""deprecated" is not defined",
"source": "Pylance",
"startLineNumber": 1,
"startColumn": 1,
"endLineNumber": 1,
"endColumn": 11
},{
"resource": "Untitled-1.ipynb",
"owner": "python",
"code": {
"value": "reportUndefinedVariable",
"target": {
"$mid": 1,
"path": "/microsoft/pylance-release/blob/main/docs/diagnostics/reportUndefinedVariable.md",
"scheme": "https",
"authority": "github.com"
}
},
"severity": 4,
"message": ""deprecated" is not defined",
"source": "Pylance",
"startLineNumber": 1,
"startColumn": 1,
"endLineNumber": 1,
"endColumn": 11
},{
"resource": "Untitled-1.ipynb",
"owner": "python",
"code": {
"value": "reportUndefinedVariable",
"target": {
"$mid": 1,
"path": "/microsoft/pylance-release/blob/main/docs/diagnostics/reportUndefinedVariable.md",
"scheme": "https",
"authority": "github.com"
}
},
"severity": 4,
"message": ""deprecated" is not defined",
"source": "Pylance",
"startLineNumber": 1,
"startColumn": 1,
"endLineNumber": 1,
"endColumn": 11
},{
"resource": "Untitled-1.ipynb",
"owner": "python",
"code": {
"value": "reportUndefinedVariable",
"target": {
"$mid": 1,
"path": "/microsoft/pylance-release/blob/main/docs/diagnostics/reportUndefinedVariable.md",
"scheme": "https",
"authority": "github.com"
}
},
"severity": 4,
"message": ""deprecated" is not defined",
"source": "Pylance",
"startLineNumber": 1,
"startColumn": 1,
"endLineNumber": 1,
"endColumn": 11
}]
[{
"resource": "Untitled-2",
"owner": "python",
"severity": 8,
"message": "Expected one or more symbol names after "import"",
"source": "Pylance",
"startLineNumber": 8,
"startColumn": 17,
"endLineNumber": 9,
"endColumn": 1
}]
[{
"resource": "Untitled-1",
"owner": "python",
"code": {
"value": "reportUndefinedVariable",
"target": {
"$mid": 1,
"path": "/microsoft/pylance-release/blob/main/docs/diagnostics/reportUndefinedVariable.md",
"scheme": "https",
"authority": "github.com"
}
},
"severity": 4,
"message": ""os" is not defined",
"source": "Pylance",
"startLineNumber": 7,
"startColumn": 17,
"endLineNumber": 7,
"endColumn": 19
}]

Image

Metadata

Metadata

Assignees

Labels

triage-neededNeeds assignment to the proper sub-team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions