biqqles / dataclassy

A fast and flexible reimplementation of data classes
https://pypi.org/project/dataclassy
Mozilla Public License 2.0
82 stars 9 forks source link

Recursion error in repr #11

Closed wimglenn closed 3 years ago

wimglenn commented 3 years ago
>>> from typing import Optional
>>> import dataclassy as dataclass
>>> @dataclass.dataclass
... class Node:
...     value: str
...     linked_node: Optional[Node] = None
... 
>>> n = Node("n")
>>> n.linked_node = n
>>> n
---------------------------------------------------------------------------
RecursionError                            Traceback (most recent call last)
...
RecursionError: maximum recursion depth exceeded while calling a Python object

A stdlib tool to avoid this is reprlib.recursive_repr.

biqqles commented 3 years ago

Thanks for this, fixed!

>>> n
Node(value='n', linked_node=Node(this))