Skip to content

Commit b1397be

Browse files
authored
Merge pull request #3455 from jjhelmus/dataclasses_3.13
Handle dataclasses with Python 3.13 default repr
2 parents 035f3ea + d6abebd commit b1397be

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
- Progress track thread is now a daemon thread https://github.com/Textualize/rich/pull/3402
1818
- Fixed cached hash preservation upon clearing meta and links https://github.com/Textualize/rich/issues/2942
1919
- Fixed overriding the `background_color` of `Syntax` not including padding https://github.com/Textualize/rich/issues/3295
20+
- Fixed pretty printing of dataclasses with a default repr in Python 3.13 https://github.com/Textualize/rich/pull/3455
2021
- Fixed selective enabling of highlighting when disabled in the `Console` https://github.com/Textualize/rich/issues/3419
2122
- Fixed BrokenPipeError writing an error message https://github.com/Textualize/rich/pull/3468
2223
- Fixed superfluous space above Markdown tables https://github.com/Textualize/rich/pull/3469

CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,4 @@ The following people have contributed to the development of Rich:
8686
- [Pierro](https://github.com/xpierroz)
8787
- [Bernhard Wagner](https://github.com/bwagner)
8888
- [Aaron Beaudoin](https://github.com/AaronBeaudoin)
89+
- [Jonathan Helmus](https://github.com/jjhelmus)

rich/pretty.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import dataclasses
44
import inspect
55
import os
6+
import reprlib
67
import sys
78
from array import array
89
from collections import Counter, UserDict, UserList, defaultdict, deque
@@ -78,7 +79,10 @@ def _is_dataclass_repr(obj: object) -> bool:
7879
# Digging in to a lot of internals here
7980
# Catching all exceptions in case something is missing on a non CPython implementation
8081
try:
81-
return obj.__repr__.__code__.co_filename == dataclasses.__file__
82+
return obj.__repr__.__code__.co_filename in (
83+
dataclasses.__file__,
84+
reprlib.__file__,
85+
)
8286
except Exception: # pragma: no coverage
8387
return False
8488

0 commit comments

Comments
 (0)