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
Users are often confused by compatibility of invariant collection types. Here is an example from #3351:
fromtypingimportList, Uniondefmean(numbers: List[Union[int, float]]) ->float:
returnsum(numbers) /len(numbers)
some_numbers= [1, 2, 3, 4]
mean(some_numbers) # Argument 1 to "mean" has incompatible type List[int]; # expected List[Union[int, float]]
It might be helpful to add a note with more details, since the message doesn't really provide enough context to start googling for help. Here is one idea:
program.py:23:note: "List" is invariant -- see <link to docs>
program.py:23:note: Maybe you can use "Sequence" as the target type, which is covariant?
The text was updated successfully, but these errors were encountered:
Fixes#1115 and #3352 by providing a link to docs and a suggestion.
This currently only takes care of 'List' and 'Dict', which are the most typical for this kind of errors.
Users are often confused by compatibility of invariant collection types. Here is an example from #3351:
It might be helpful to add a note with more details, since the message doesn't really provide enough context to start googling for help. Here is one idea:
The text was updated successfully, but these errors were encountered: