Textualize / rich

Rich is a Python library for rich text and beautiful formatting in the terminal.
https://rich.readthedocs.io/en/latest/
MIT License
49.04k stars 1.71k forks source link

[BUG] Test failures with Python 3.13.0b1: test_pretty.py and dataclass repr #3368

Closed befeleme closed 1 month ago

befeleme commented 4 months ago

Describe the bug

3 of test_pretty fail with Python 3.13.0b1:

=================================== FAILURES ===================================
____________________________ test_pretty_dataclass _____________________________

    def test_pretty_dataclass():
        dc = ExampleDataclass(1000, "Hello, World", 999, ["foo", "bar", "baz"])
        result = pretty_repr(dc, max_width=80)
        print(repr(result))
        assert (
            result
            == "ExampleDataclass(foo=1000, bar='Hello, World', baz=['foo', 'bar', 'baz'])"
        )
        result = pretty_repr(dc, max_width=16)
        print(repr(result))
>       assert (
            result
            == "ExampleDataclass(\n    foo=1000,\n    bar='Hello, World',\n    baz=[\n        'foo',\n        'bar',\n        'baz'\n    ]\n)"
        )
E       assert "ExampleDataclass(foo=1000, bar='Hello, World', baz=['foo', 'bar', 'baz'])" == "ExampleDataclass(\n    foo=1000,\n    bar='Hello, World',\n    baz=[\n        'foo',\n        'bar',\n        'baz'\n    ]\n)"
E         + ExampleDataclass(foo=1000, bar='Hello, World', baz=['foo', 'bar', 'baz'])
E         - ExampleDataclass(
E         -     foo=1000,
E         -     bar='Hello, World',
E         -     baz=[
E         -         'foo',
E         -         'bar',
E         -         'baz'
E         -     ]
E         - )

tests/test_pretty.py:184: AssertionError
----------------------------- Captured stdout call -----------------------------
"ExampleDataclass(foo=1000, bar='Hello, World', baz=['foo', 'bar', 'baz'])"
"ExampleDataclass(foo=1000, bar='Hello, World', baz=['foo', 'bar', 'baz'])"
________________________ test_reference_cycle_dataclass ________________________

    def test_reference_cycle_dataclass():
        @dataclass
        class Example:
            x: int
            y: Any

        test = Example(1, None)
        test.y = test
        res = pretty_repr(test)
>       assert res == "Example(x=1, y=...)"
E       AssertionError: assert 'test_reference_cycle_dataclass.<locals>.Example(x=1, y=...)' == 'Example(x=1, y=...)'
E         - Example(x=1, y=...)
E         + test_reference_cycle_dataclass.<locals>.Example(x=1, y=...)

tests/test_pretty.py:356: AssertionError
___________________________ test_max_depth_dataclass ___________________________

    def test_max_depth_dataclass():
        @dataclass
        class Foo:
            foo: object

        @dataclass
        class Bar:
            bar: object

>       assert (
            pretty_repr(Foo(foo=Bar(bar=Foo(foo=[]))), max_depth=2)
            == "Foo(foo=Bar(bar=Foo(...)))"
        )
E       AssertionError: assert 'test_max_depth_dataclass.<locals>.Foo(foo=test_max_depth_dataclass.<locals>.Bar(bar=test_max_depth_dataclass.<locals>.Foo(foo=[])))' == 'Foo(foo=Bar(bar=Foo(...)))'
E         - Foo(foo=Bar(bar=Foo(...)))
E         + test_max_depth_dataclass.<locals>.Foo(foo=test_max_depth_dataclass.<locals>.Bar(bar=test_max_depth_dataclass.<locals>.Foo(foo=[])))

tests/test_pretty.py:487: AssertionError
=========================== short test summary info ============================
FAILED tests/test_pretty.py::test_pretty_dataclass - assert "ExampleDataclass...
FAILED tests/test_pretty.py::test_reference_cycle_dataclass - AssertionError:...
FAILED tests/test_pretty.py::test_max_depth_dataclass - AssertionError: asser...
============= 3 failed, 799 passed, 24 skipped, 1 warning in 4.76s =============

Edit this with a clear and concise description of what the bug.

Provide a minimal code example that demonstrates the issue if you can. If the issue is visual in nature, consider posting a screenshot.

Platform

Click to expand Fedora Linux 41
github-actions[bot] commented 4 months ago

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

github-actions[bot] commented 1 month ago

I hope we solved your problem.

If you like using Rich, you might also enjoy Textual

github-actions[bot] commented 1 month ago

I hope we solved your problem.

If you like using Rich, you might also enjoy Textual