Closed a-mckinley closed 10 months ago
@a-mckinley can you try with subclass instead of the annotation?
Hi @george-zubrienko, changing to use the subclass instead of the decorator eliminates the beartype error.
from dataclasses import dataclass
from dataclasses_json import DataClassJsonMixin
from beartype import beartype
@beartype
@dataclass
class Testing(DataClassJsonMixin):
data: str
t = Testing(data='thing')
print(t)
Decorator has some issues we can't easily solve rn - thus #442 is in discussion. For v0 (current) API, I'd recommend to either avoid the decorator entirely or pair it with the subclass. We are looking into solving issues it causes with v1 API
Description
I realise this is not likely to be a real "bug", but I discovered an issue using dataclasses-json in conjunction with beartype>0.10.0 with dataclasses-json >0.5.8.
Beartype complains about:
beartype.roar.BeartypeDecorHintForwardRefException: Forward reference "dataclasses_json.api.SchemaType[A]" syntactically invalid as module attribute name.
Code snippet that reproduces the issue
Describe the results you expected
beartype compatibility working
Python version you are using
3.11.3
Environment description
Working environments:
pip install -U beartype==0.15.0 dataclasses_json==0.5.8 pip install -U beartype==0.10.0 dataclasses_json==0.5.13
Failing environment:
pip install -U beartype==0.15.0 dataclasses_json==0.5.13