Closed
Description
Related but maybe not the same #3354
Given
from typing import List, Tuple
l: List[Tuple[int, str]] = []
v = max(l, key=lambda item: item[0], default=None)
reveal_type(v)
mypy complains about the item[0]
usage in the key function:
Value of type "Optional[Tuple[int, str]]" is not indexable
Revealed type is 'Union[Tuple[builtins.int, builtins.str], None]'
Also interesting that it shows two different representations for the inferred type.
For user ergonomics the revealed type should be 'Optional[Tuple[int, str]]' as well, no?
Metadata
Metadata
Assignees
Labels
No labels