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
I find when I define a TypeVar variables of that type are always serialized with the first type listed in the TypeVar definition.
In an attempt to fix that I tired to set a global serialization strategy, however that strategy was never selected, rather, the selection seems to be also based on the first type listed in the TypeVar. Quite a bit of the code in metaprograming.py seems to handle a TypeVar so I wonder if I have something else missing?
The basic code is:
Numeric = TypeVar('Numeric', float, int) # <== here float is first in the list, seems to be selected as the key for serialization strategy.
class NumericStrategy(SerializationStrategy):
def serialize(self, value):
return int(value)
def deserialize(self, value):
return int(value)
@dataclass
class foo(DataClassYAMLMixin):
bar: Numeric = 1
class Config(BaseConfig):
serialization_strategy = {
Numeric: NumericStrategy(), # <== this is the line I think should activate the strategy
int: NumericStrategy(),
#float: NumericStrategy(), # <== it seems that only this line would activate the strategy
}
The text was updated successfully, but these errors were encountered:
I find when I define a TypeVar variables of that type are always serialized with the first type listed in the TypeVar definition.
In an attempt to fix that I tired to set a global serialization strategy, however that strategy was never selected, rather, the selection seems to be also based on the first type listed in the TypeVar. Quite a bit of the code in metaprograming.py seems to handle a TypeVar so I wonder if I have something else missing?
The basic code is:
The text was updated successfully, but these errors were encountered: