Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3k
Open
Description
Consider this example:
T=TypeVar('T')S=TypeVar('S')defadd(x:List[T],y:List[S])->List[Union[T,S]]: ...a:List[int]b:List[str]e:List[Union[int,str]]=add(a,b)
It fails on the last line with the following (I skip invariance notes):
error: Argument 1 to "add" has incompatible type "List[int]"; expected "List[Union[int, str]]"error: Argument 2 to "add" has incompatible type "List[str]"; expected "List[Union[int, str]]"
If I remove the annotation fore
, everything works fine.
When previously working on the external context issues, I found that I don't like how constrains for unions against unions are inferred (not that they are wrong, just counterintuitive). For example,Union[T, S] <: Union[str, int]
infersT < : Union[str, int] and S <: Union[str, int]
, which is technically fine, but leads to errors like above.
This blocks#5873