Skip to content

Add support for __init_subclass__ - #2654

Merged
gvanrossum merged 3 commits into
python:masterfrom
JelleZijlstra:initsubclass
Jan 9, 2017
Merged

gvanrossum merged 3 commits into
python:masterfrom
JelleZijlstra:initsubclass

Conversation

@JelleZijlstra

Copy link
Copy Markdown
Member

Python 3.6 added the new _init_subclass__ magic method, which requires special support because its first argument is not self (similar to __new__).

I submitted a separate pull request to typeshed (python/typeshed#813) to add the new method to stubs.

@JelleZijlstra JelleZijlstra changed the title Add support for __Init_subclass__ Add support for __init_subclass__ Jan 7, 2017
@elazarg

elazarg commented Jan 7, 2017

Copy link
Copy Markdown
Contributor

I think it should be subsumed by #2475, or merged afterwards.

@JelleZijlstra

Copy link
Copy Markdown
Member Author

I haven't reviewed your patch in detail, but I think the functionality implemented by this patch is pretty independent from metaclass support. There's some more work possible to typecheck class definitions with __init_subclass__ better (e.g. #2653), but those changes could be done later.


[case testSelfTypeOverride]
from typing import TypeVar, cast

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Next time you submit a PR, can you instruct your editor not to clean up trailing whitespace on lines you otherwise didn't touch? While it looks better, the many trivial chunks in the diff are distracting during a review.

@gvanrossum
gvanrossum merged commit d6e5fe7 into python:master Jan 9, 2017
@gvanrossum

Copy link
Copy Markdown
Member

Thanks!

gvanrossum pushed a commit to python/typeshed that referenced this pull request Jan 9, 2017
@JelleZijlstra
JelleZijlstra deleted the initsubclass branch May 4, 2017 04:06
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.

3 participants