Conversation
python2/test_typing.py
Outdated
| class ProUser(User): pass | ||
|
|
||
| def new_user(user_class): | ||
| # type: (Type[User]) -> None |
There was a problem hiding this comment.
@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?
There was a problem hiding this comment.
It doesn't matter (mypy can't analyze typing.py) but you're right. Fixing...
There was a problem hiding this comment.
Thanks, I just thought for a minute I was missing some crucial detail here.
|
Similar to python/typeshed#216 (comment), it might be better to create a special type for |
|
Yeah, here I'm just being lazy. The proper way requires an extra metaclass.
Maybe we can put a check in mypy that prevents misusing this? Or we could
just document "only use this in annotations".
|
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