Skip to content

Investigate shell integration in terms of Python REPL  #21966

@anthonykim1

Description

@anthonykim1

Investigate into VS Code's shell integration and how it can be used in terms of Python REPL.

Success/Failure decoration can be implemented by defining our own .pythonrc file and then having environment variable PYTHONSTARTUP to point to the .pythonrc file.

Leverage PYTHONSTARTUP:
PYTHONSTARTUP = "If this is the name of a readable file, the Python commands in that file are executed before the first prompt is displayed in interactive mode. The file is executed in the same namespace where interactive commands are executed so that objects defined or imported in it can be used without qualification in the interactive session."

Leverage sys.ps1 and sys.ps2:
"If a non-string object is assigned to either variable, its str() is re-evaluated each time the interpreter prepares to read a new interactive command; this can be used to implement a dynamic prompt"
This is great, since it means we can inject sequences like exit code that is needed to get the shell integration decoration show up for Python REPL in VS Code.

Related or blocked by:
microsoft/vscode#202299
microsoft/vscode#199770
microsoft/vscode#155530

Metadata

Metadata

Assignees

Labels

area-replfeature-requestRequest for new features or functionalityneeds spikeLabel for issues that need investigation before they can be worked on.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions