-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add __repr__ to custom PS1 class #25568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Anthony Kim <[email protected]>
|
@anthonykim1 lmk when you need my review here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a __repr__ method to the PS1 class in pythonrc.py to improve debugging experience during development and implementation work related to issue #25521.
Key Changes:
- Added
__repr__method to the PS1 class that returns a descriptive string representation
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return result | ||
|
|
||
| def __repr__(self): | ||
| return "<Custom PS1 for VS Code Python Shell Integration>" |
Copilot
AI
Dec 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The __repr__ method should follow Python conventions by including the class name. A typical pattern for __repr__ when the object cannot be recreated from the string is <ClassName: description>. Consider changing this to something like <PS1: Custom PS1 for VS Code Python Shell Integration> or <pythonrc.PS1 object at {hex(id(self))}> to make it clearer what type of object this represents.
| return "<Custom PS1 for VS Code Python Shell Integration>" | |
| return "<PS1: Custom PS1 for VS Code Python Shell Integration>" |
| def __repr__(self): | ||
| return "<Custom PS1 for VS Code Python Shell Integration>" |
Copilot
AI
Dec 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new __repr__ method lacks test coverage. Since the PS1 class already has comprehensive tests in test_shell_integration.py covering __str__ and other functionality, a test should be added to verify that repr(ps1) returns the expected string representation. This ensures the debugging enhancement mentioned in the PR description works as intended.
During my debugging and implementation of #25521, I find a descriptive
__repr__()for the custom PS1 object very helpful, so this PR comes as an addition for #25521.