-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Type variables bounded by generic types cannot be used with Type
#3148
Comments
PEP 484 and
I could see possible benefits for allowing also type variables, but I think this needs discussion. |
Here is my use case for this feature. BTW, if type variables are prohibited in
|
@pkch Good point, there is some contradiction in PEP 484, on one hand it prohibits anything except classes, unions of classes, and |
I guess we'll have to update that part of PEP 484. |
At first glance, this is a duplicate of #2756 . However, that issue is about the first error message, and this issue is about the second.
In #2756 (as here), the "Invalid type test.T" message goes away once we provide a concrete parameter for
X
, likeU = TypeVar('U', bound=X[int])
. The"Unsupported type Type["U"]
message, however, never goes away as long asX
remains generic.I have a use case:
f
is supposed to convert some data into aU
; the first argument is the class into which it is supposed to convert. The function uses some methods that are defined inclass X
, that's why I need to boundU
.The text was updated successfully, but these errors were encountered: