Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions rich/pretty.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import builtins
import collections
import pathlib
import dataclasses
import inspect
import os
Expand Down Expand Up @@ -816,6 +817,12 @@ def iter_attrs() -> (
child_node.key_separator = "="
append(child_node)
pop_visited(obj_id)

# START of new code block
elif isinstance(obj, pathlib.Path):
node = Node(value_repr=repr(str(obj)))
# END of new code block

elif _safe_isinstance(obj, _CONTAINERS):
for container_type in _CONTAINERS:
if _safe_isinstance(obj, container_type):
Expand Down
11 changes: 11 additions & 0 deletions test_my_fix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# test_my_fix.py
import pathlib
from rich.pretty import pprint

# Create a Path object to test
my_file_path = pathlib.Path("./my_folder/my_script.py")

# This will use the code you just modified!
print("--- Running test with the fix ---")
pprint(my_file_path)
print("-------------------------------")