TypeForm + TypeVar #9462
Answered
by
erictraut
superlopuh
asked this question in
Q&A
TypeForm + TypeVar
#9462
-
I have a question about passing from typing_extensions import TypeForm, TypeVar
class A: ...
B = TypeVar("B", bound=A)
def func(tf: TypeForm[A]) -> TypeForm[A]: ...
def this_works(val: B) -> B:
# B is a valid spelling of a type in this context
val0: B = val
# Argument of type "TypeVar" cannot be assigned to parameter "tf" of type "TypeForm[A]" in function "func" "TypeVar" is not assignable to "TypeForm[A]" (reportArgumentType)
val1 = func(B)
return val0 |
Beta Was this translation helpful? Give feedback.
Answered by
erictraut
Nov 14, 2024
Replies: 1 comment 3 replies
-
You need to set Code sample in pyright playground |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
superlopuh
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to set
"enableExperimentalFeatures"
to true to enableTypeForm
support. Once you do this, the above code type checks without error.Code sample in pyright playground