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
This is basically just a duplicate of #2246. is_valid_inferred_type is False for [None] since it's technically invalid without a type annotation, so visit_conditional_expr just discards the type of that branch. Pretty sure fixing #2246 would also fix this.
This means mypy will no longer give Need type annotation for variable errors for assignments with values of type Generator[str, None, None] or List[None] or similar. However, lists, sets, and dicts that are initialized with None values that were previously inferred may now need type annotations. I.e. constructs that look like:
x = [None]
x.append(0)
will now be type errors unless they have explicit annotations.
Supplants #2225. Fixes#2246. Fixes#2195. Fixes#2258.
python3 -m mypy --strict-optional -c 'reveal_type([None] if bool() else [1])' <string>:1: error: Revealed type is 'builtins.list[builtins.int]'
The text was updated successfully, but these errors were encountered: