ericvsmith / dataclasses

Apache License 2.0
587 stars 53 forks source link

Failure with slots and default values #18

Closed ericvsmith closed 7 years ago

ericvsmith commented 7 years ago
        @dataclass(slots=True)
        class C:
            x: int
            y: int = 0

        c = C(10)
        self.assertEqual(repr(c), 'C(x=10,y=0)')

Fails with:

Traceback (most recent call last):
  File "/cygdrive/c/home/eric/local/dataclasses/tst.py", line 627, in test_slots
    self.assertEqual(repr(c), 'C(x=10,y=0)')
AssertionError: "C(x=10,y=<member 'y' of 'C' objects>)" != 'C(x=10,y=0)'
- C(x=10,y=<member 'y' of 'C' objects>)
+ C(x=10,y=0)