-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Support TypeAliasType
explicit call
#16644
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 comment has been minimized.
This comment has been minimized.
I will try to find how to fix typevar representation change without code modifications, I think that this has to do with my |
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
One big advantage of from typing import TypeVar
from typing_extensions import TypeAliasType
K = TypeVar("K")
V = TypeVar("V")
InvertedDict = TypeAliasType("InvertedDict", dict[K, V], type_params=(V, K))
def f(x: InvertedDict[int, str]) -> None:
reveal_type(x) pyright correctly reveals the type as
|
I don't think we should claim support for TypeAliasType without checking the type_params. Explicit type_params are the main differentiating factor that sets the new syntax apart. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be fine with this PR if we issue an error if type_params is provided
Also thanks for good detail spot tmke8!
Hello @sobolevn, I'd like to try and finish up this PR if that's OK with you. |
@hamdanal please, go ahead :) |
Merged #16926 instead, thanks for your work here! |
The implementation turned out to be quite simple for the common cases.
Note: Right now there's no check that
type_params=
is correct, I am not sure that this is even required for a type-checker (in any case, this can and should be done in a follow-up PR)Refs #16614