Method: rich.pretty._is_dataclass_repr
Calls: 12, Exceptions: 0, Paths: 1Back
Path 1: 12 calls (1.0)
test_reference_cycle_dataclass.
True (12)
1def _is_dataclass_repr(obj: object) -> bool:
2 """Check if an instance of a dataclass contains the default repr.
3
4 Args:
5 obj (object): A dataclass instance.
6
7 Returns:
8 bool: True if the default repr is used, False if there is a custom repr.
9 """
10 # Digging in to a lot of internals here
11 # Catching all exceptions in case something is missing on a non CPython implementation
12 try:
13 return obj.__repr__.__code__.co_filename == dataclasses.__file__
14 except Exception: # pragma: no coverage
15 return False