from datetime import date
import dataclasses
@dataclasses.dataclass(frozen=True)
class A:
date: date = dataclasses.field()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/dataclasses.py", line 1002, in wrap
return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen)
File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/dataclasses.py", line 979, in _process_class
str(inspect.signature(cls)).replace(' -> None', ''))
File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/inspect.py", line 3040, in __str__
formatted = str(param)
File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/inspect.py", line 2558, in __str__
formatannotation(self._annotation))
File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/inspect.py", line 1199, in formatannotation
return repr(annotation)
File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/dataclasses.py", line 249, in __repr__
return ('Field('
File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/dataclasses.py", line 249, in __repr__
return ('Field('
File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/dataclasses.py", line 249, in __repr__
return ('Field('
[Previous line repeated 491 more times]
RecursionError: maximum recursion depth exceeded
But this works:
@dataclasses.dataclass(frozen=True)
class A:
date: date
So does this:
@dataclasses.dataclass(frozen=True)
class A:
date_: date = dataclasses.field()
But this works:
So does this: