mirror of
https://github.com/Textualize/rich.git
synced 2025-08-04 18:18:22 +00:00
allow repr to be a callable
This commit is contained in:
parent
75d6658f8d
commit
f0b16ba2c2
2 changed files with 13 additions and 7 deletions
|
@ -197,11 +197,12 @@ def test_attrs():
|
|||
class Point:
|
||||
x: int
|
||||
y: int
|
||||
foo: str = attr.field(repr=str.upper)
|
||||
z: int = 0
|
||||
|
||||
result = pretty_repr(Point(1, 2))
|
||||
result = pretty_repr(Point(1, 2, foo="bar"))
|
||||
print(repr(result))
|
||||
expected = "Point(x=1, y=2, z=0)"
|
||||
expected = "Point(x=1, y=2, foo=BAR, z=0)"
|
||||
assert result == expected
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue