You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The behaviour for the third case is wrong: Union[str, bytes] is not a valid value for C.
A constrained type variable can only be resolved to one of the options, so Thing[int] is valid, Thing[str] is valid, but Thing[str | int], Thing[Literal[0]], Thing[str | Literal[0]], and Thing[bool] are all invalid. (see the specification on TypeVars)
In other words, TypeVar("S", str, int) is not the same as TypeVar("S", bound=str | int).
From the docs:
The behaviour for the third case is wrong:
Union[str, bytes]
is not a valid value forC
.A constrained type variable can only be resolved to one of the options, so
Thing[int]
is valid,Thing[str]
is valid, butThing[str | int]
,Thing[Literal[0]]
,Thing[str | Literal[0]]
, andThing[bool]
are all invalid. (see the specification on TypeVars)In other words,
TypeVar("S", str, int)
is not the same asTypeVar("S", bound=str | int)
.Example code:
Possible solutions:
Thing[str]
is legal as the second argument toload
,Thing
is not)Thing
with no parameter to meanThing[str] | Thing[int]
The text was updated successfully, but these errors were encountered: