samuelcolvin / python-devtools

Dev tools for python
https://python-devtools.helpmanual.io/
MIT License
985 stars 47 forks source link

Nested dataclasses fail to get formatted properly #98

Closed thesadru closed 2 years ago

thesadru commented 2 years ago

Reproducible code

import dataclasses
import devtools

@dataclasses.dataclass
class Foo:
    x: int

@dataclasses.dataclass
class Bar:
    a: float
    b: Foo

devtools.debug(foo=Foo(1), bar=Bar(1.0, b=Foo(1)))

Output

test.py:16 <module>
    foo: Foo(x=1) (Foo)
    bar: Bar(
        a=1.0,
        b={'x': 1},
    ) (Bar)

Expected output

test.py:16 <module>
    foo: Foo(x=1) (Foo)
    bar: Bar(
        a=1.0,
        b=Foo(x=1),
    ) (Bar)