-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
add __init_subclass__ to 3.6 #813
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
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.
Can you file a separate issue with the mypy project about special-casing |
(Sorry, closed by mistake.) |
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. |
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 ```
Mypy changes are at python/mypy#2654. I think this can be merged independently of that change though. |
Thanks! This will go out in the next mypy release (0.4.7) later this week. |
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.