Repository navigation
Conversation
Co-authored-by: Anthony Kim <anthonykim@microsoft.com>
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
I have made the requested changes; please review again |
|
Thanks for making the requested changes! @brettcannon: please review the changes made to this pull request. |
Preserve both ANY and MagicMock when merging the interactive console tests, keeping upstream prompt coverage and statement-submitted hook coverage intact. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 51fc76fa-b241-49aa-830c-840d2d812b54
|
@pablogsal @ambv feel free to review, but if you're too busy I will just plan to merge in about a week. |
Supersedes #144724
Adds a
statement_submitted_hookhook to_pyrepl.simple_interactthat gets triggered after the user has submitted a statement (not necessarily a line) but before it is executed.Rationale
This should be configurable by external tools such as IDEs who may want to perform an action before a statement is executed, such as displaying custom escape sequences for terminal integration, handling custom logging logic, performing analysis, etc.
This hook should allow said tools to perform an action.
Example (Timer)
Example (VSCode)
VS Code uses custom escape sequences to indicate when a command execution has started and finished. Here, the hook could be used to print an invisible escape sequence to the terminal. (Note that the example uses
### EXEC ###to represent it visually, but escape sequences are invisible)With error reporting
AI Usage
AI was used to help with merge conflicts