Skip to content

Conversation

Anandraj-prog
Copy link

Summary

This PR improves the pretty-printing of pathlib.Path objects by rendering them as strings instead of their default object representation.

Problem

Currently, rich.pretty.pprint displays a pathlib.Path object using its default __repr__, which looks like PosixPath('/path/to/file.txt'). While technically correct, this is verbose and doesn't stand out in complex outputs where file paths are common.

Solution

The changes in this PR intercept pathlib.Path objects during the rendering process and convert them to their string equivalent.

Before:
PosixPath('my_folder/my_script.py')

After:
'my_folder/my_script.py' (This will be colored as a string by the highlighter)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant