Skip to content

[BUG] rich doesn't respect custom repr on attrs class in REPL #3846

@ShaiAvr

Description

@ShaiAvr

Describe the bug
I was playing in the REPL with attrs, and I noticed that if I have a custom __repr__ on an attrs class, then rich will ignore it when displaying an instance of the class or when using rich.print:

Image

The same thing happens when using rich.print in a script:

from attrs import define
from rich import print as rprint

@define
class Foo:
    def __repr__(self) -> str:
        return "What"

print(Foo())  # prints "What"
rprint(Foo())  # prints "Foo()"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions