Skip to content

Conversation

@JelleZijlstra
Copy link
Member

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.

JelleZijlstra and others added 2 commits January 6, 2017 13:54
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.
@gvanrossum
Copy link
Member

Can you file a separate issue with the mypy project about special-casing __new__ and __init_subclass__? I think there are few enough of these that we should be able to just have a list of these exceptions in the mypy source code, no need to invent a new notation to put in the stubs.

@gvanrossum gvanrossum closed this Jan 6, 2017
@gvanrossum gvanrossum reopened this Jan 6, 2017
@gvanrossum
Copy link
Member

(Sorry, closed by mistake.)

@JelleZijlstra
Copy link
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.

@gvanrossum
Copy link
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
```
@JelleZijlstra
Copy link
Member Author

Mypy changes are at python/mypy#2654. I think this can be merged independently of that change though.

@gvanrossum gvanrossum merged commit f9135c5 into python:master Jan 9, 2017
@gvanrossum
Copy link
Member

Thanks! This will go out in the next mypy release (0.4.7) later this week.

@JelleZijlstra JelleZijlstra deleted the patch-4 branch May 4, 2017 03:49
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