8000 Add Type[C] "implementation" by gvanrossum · Pull Request #224 · python/typing · GitHub
[go: up one dir, main page]

Skip to content

Add Type[C] "implementation" #224

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

Merged
merged 4 commits into from
May 24, 2016
Merged

Add Type[C] "implementation" #224

merged 4 commits into from
May 24, 2016

Conversation

gvanrossum
Copy link
Member

It turns out this is a fairly vanilla generic class inheriting from type.

Should the CT variable be declared covariant?

This is one of the items we need to do before closing #107

class ProUser(User): pass

def new_user(user_class):
# type: (Type[User]) -> None
Copy link
Contributor

Choose a reason for hiding this comment

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

@gvanrossum This may be a stupid question but shouldn't this (and https://github.com/python/typing/pull/224/files#diff-f9eeb4530dadc70935c11fff001ec7acR1385) be marked as returning User?

Copy link
Member Author

Choose a reason for hiding this comment

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

It doesn't matter (mypy can't analyze typing.py) but you're right. Fixing...

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, I just thought for a minute I was missing some crucial detail here.

@JukkaL
Copy link
Contributor
JukkaL commented May 20, 2016

Similar to python/typeshed#216 (comment), it might be better to create a special type for Type[C], similar to Callable. I'm not sure if using Generic will result in any immediate problems, but we may have to reimplement it in the future if we decide to add support for __init__ argument types, for example, and this could break stuff if people start assuming that Type[] is a subclass of Generic.

@gvanrossum
Copy link
Member Author
gvanrossum commented May 20, 2016 via email

@gvanrossum gvanrossum merged commit 09f9cab into master May 24, 2016
@gvanrossum gvanrossum deleted the typec2 branch June 6, 2016 22:23
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
0