Skip to content
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

make subclasses of DataClassMeta compatible with __init__ #13

Closed
wants to merge 1 commit into from

Conversation

hroskes
Copy link
Contributor

@hroskes hroskes commented Jan 12, 2021

If there's not __init__ function defined, __new__ of DataClassMeta uses the actual mcs, which works well with subclasses because mcs is the actual subclass. However, if __init__ is defined, __new__ is hardcoded to use DataClassInit. This PR fixes that and instead creates a subclass of DataClassInit for each subclass of DataClassMeta, as needed.

@biqqles
Copy link
Owner

biqqles commented Jan 12, 2021

Thanks for this nice PR! Unfortunately, DataClassInit will shortly be removed when the changes discussed in #12 are merged, which will render this fix redundant. However the added tests might be useful in their own right. I will get back to you then.

@hroskes
Copy link
Contributor Author

hroskes commented Jan 13, 2021

Thank you! I'll go ahead and close this.

@hroskes hroskes closed this Jan 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants