Repository navigation
add __init_subclass__ to 3.6 - #813
Merged
Merged
Conversation
This will require a bit of additional work in mypy because `__init_subclass__` is an implicit classmethod, like `__new__`. It might be good to provide a way to express this in the stubs.
Member
|
Can you file a separate issue with the mypy project about special-casing |
Member
|
(Sorry, closed by mistake.) |
Member
Author
|
Yes, I'm working on a separate pull request to mypy; agree that special-casing there is probably sufficient. I think that doesn't need to block this change though. Thanks for fixing the whitespace issue. |
Member
|
Can you just link to the mypy PR then? |
`object.__init_subclass__` does not actually take arbitrary kwargs: ``` In [2]: object.__init_subclass__() In [3]: object.__init_subclass__(3) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-3-d0998253fcfc> in <module>() ----> 1 object.__init_subclass__(3) TypeError: __init_subclass__() takes no arguments (1 given) In [4]: object.__init_subclass__(x=3) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-4-81fc49abae69> in <module>() ----> 1 object.__init_subclass__(x=3) TypeError: __init_subclass__() takes no keyword arguments ```
Member
Author
|
Mypy changes are at python/mypy#2654. I think this can be merged independently of that change though. |
Member
|
Thanks! This will go out in the next mypy release (0.4.7) later this week. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This will require a bit of additional work in mypy because
__init_subclass__is an implicit classmethod, like__new__. It might be good to provide a way to express this in the stubs.