You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi!
Just noticed that if i enable slots (to reduce memory usage) alias option doesn't work
@dataclass(slots=True)
class DataClass(DataClassJSONMixin):
a: int = field(metadata=field_options(alias="FieldA"))
b: int = field(metadata=field_options(alias="#invalid"))
x = DataClass.from_dict({"FieldA": 1, "#invalid": 2}) # DataClass(a=1, b=2)
print(x)
x.to_dict() # {"a": 1, "b": 2} # no aliases on serialization by default
got error
Traceback (most recent call last):
File "test.py", line 9, in <module>
x = DataClass.from_dict({"FieldA": 1, "#invalid": 2}) # DataClass(a=1, b=2)
File "<string>", line 26, in from_dict
TypeError: DataClass.__init__() missing 2 required positional arguments: 'a' and 'b'
don't know if there is some workaround, probably better to mention that in docs
The text was updated successfully, but these errors were encountered:
Hi!
Just noticed that if i enable slots (to reduce memory usage) alias option doesn't work
got error
don't know if there is some workaround, probably better to mention that in docs
The text was updated successfully, but these errors were encountered: