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
To work around this, you must override the decoder. But this must be done in every dataclass that references that type. Alternatively, we can add this decoder to the global config. but this can be cumbersome if you are subclassing str many times.
For context, I have a subclassed str into ValidatedStr which provides validation (regex, length constraints) against the string. I vend this ValidatedStr class for usage across other packages. I do not want to require others using this subclass to have to explicitly specify the decoder every time or update a global config.
Feature Request
Modify the decode_dataclass logic to further distinguish between custom subclassed str classes.
The text was updated successfully, but these errors were encountered:
I think you should use composition instead of inheritance for this use case - would make life much easier. As for the library behaviour, I agree this code should not raise
Problem
as of v0.5.7, any subclassed
str
classes are instantiated using the defaultstr
class.Example
To work around this, you must override the
decoder
. But this must be done in every dataclass that references that type. Alternatively, we can add this decoder to the global config. but this can be cumbersome if you are subclassing str many times.For context, I have a subclassed
str
intoValidatedStr
which provides validation (regex, length constraints) against the string. I vend thisValidatedStr
class for usage across other packages. I do not want to require others using this subclass to have to explicitly specify the decoder every time or update a global config.Feature Request
Modify the
decode_dataclass
logic to further distinguish between custom subclassedstr
classes.The text was updated successfully, but these errors were encountered: