Repository navigation
Using smart send with REPL leads to NameError for every line of code #25117
Description
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:
- Start Code with 'code .' from cmd prompt window where I've activated a conda environment.
- In current .py file in editor, use 'shift+enter' to run line.
- 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
}]

Activity
github-actions commentedon May 29, 2025
Hi John Polo (@John-Polo), I'm an AI Support assistant here to help with your issue. While the team reviews your request, I wanted to provide some possible tips and documentation that might help you in the meantime.
Potentially Related Issues:
The team will respond to your issue shortly. Please note this is a trial feature and may not be fully accurate. I hope these suggestions are helpful in the meantime. If this comment helped you, please give it a 👍. If the suggestion was not helpful or was incorrect, please give it a 👎. Your feedback helps us improve!
anthonykim1 commentedon Jun 19, 2025
Hi John Polo (@John-Polo) Apologies for late response.
Do you mind sharing your content of the Python file?
I believe this is happening because you have either deprecated (python2 code) in your Python file, or smart send is failing somehow with some code in your Python file.
It would also help to turn off the smart send setting in your case via
python.REPL.enableREPLSmartSendjlewonick commentedon Jun 20, 2025
Also ran into this. I'm following along Python's tutorial and I'm saving files for each chapter.
https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions
[x, x**2 for x in range(6)]was my offending line - I commented it out but I put it in there so I could see the error in action
https://pastebin.com/1NLeALQy
John-Polo commentedon Jun 23, 2025
Anthony Kim (@anthonykim1) This is the code:
I don't know what's different this time around, but the REPL is working. Thanks for following up. I'll close this.
John-Polo commentedon Jun 23, 2025
jlewonick I don't know a lot about Python, so take my comment with some caution. Python's list comprehensions are definitely compliant with Python 3. While you may be getting an error from executing a list comprehension, I don't think it's actually behind the "deprecated" error you're getting. There might be another issue that's eliciting that error. Sorry, I don't know anything more to tell you. Maybe Anthony Kim (@anthonykim1) will weigh in on the issue. Good luck.
guoci commentedon Aug 26, 2025
This can be reproduced by having a syntax error anywhere in the file. I have just sent a pull request #25421 to clarify the warning message.