-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for str
subclasses
#348
Labels
Comments
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 |
This seems to be fixed as of version 0.5.9 (PR #375). Please reopen if the issue persists. |
This issue was closed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: