Skip to content

Conversation

@iBug
Copy link

@iBug iBug commented Nov 7, 2025

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.

@anthonykim1 anthonykim1 self-assigned this Nov 10, 2025
@anthonykim1 anthonykim1 added the debt Covers everything internal: CI, testing, refactoring of the codebase, etc. label Nov 10, 2025
@anthonykim1 anthonykim1 added this to the November 2025 milestone Nov 10, 2025
Co-authored-by: Anthony Kim <[email protected]>
@eleanorjboyd
Copy link
Member

@anthonykim1 lmk when you need my review here

Copy link

Copilot AI left a 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>"
Copy link

Copilot AI Dec 12, 2025

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.

Suggested change
return "<Custom PS1 for VS Code Python Shell Integration>"
return "<PS1: Custom PS1 for VS Code Python Shell Integration>"

Copilot uses AI. Check for mistakes.
Comment on lines +78 to +79
def __repr__(self):
return "<Custom PS1 for VS Code Python Shell Integration>"
Copy link

Copilot AI Dec 12, 2025

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-repl debt Covers everything internal: CI, testing, refactoring of the codebase, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants