Closed mishamsk closed 4 months ago
So, basically this would fail at code compile time:
import enum from dataclasses import dataclass from mashumaro import DataClassDictMixin class MyStrEnum(str, enum.Enum): VAL1 = "val1" @dataclass class MyClass(DataClassDictMixin): o: str = MyStrEnum.VAL1 class Config(BaseConfig): omit_default = False
because repr is used to generate a string version of a default value. I've changed it to only use repr on exact type match and added a test.
repr
PS. not sure if using repr worth it at all in this function, but this PR at least fixes it for subtypes of some of the base types.
Oh, good catch. Thanks!
PS. not sure if using repr worth it at all in this function
It's just a small optimization — when we compare a variable with a literal value, we don't need an additional LOAD_NAME.
LOAD_NAME
So, basically this would fail at code compile time:
because
repr
is used to generate a string version of a default value. I've changed it to only use repr on exact type match and added a test.PS. not sure if using repr worth it at all in this function, but this PR at least fixes it for subtypes of some of the base types.