The second call at the bottom of this example generates an unexpected error, but only in Python 2 mode:
from typing import Any, Literal, overload
@overload
def f(
x, # type: Any
y, # type: Literal[True]
):
# type: (...) -> None
pass
@overload
def f(
x, # type: Any
y, # type: Literal[False]
):
# type: (...) -> None
pass
def f(x, y):
pass
f(1, False) # OK
f((1 if int() else 1), False) # Error
Here's the output:
t.py:23: error: No overload variant of "f" matches argument types "int", "bool"
t.py:23: note: Possible overload variants:
t.py:23: note: def f(x: Any, y: Literal[True]) -> None
t.py:23: note: def f(x: Any, y: Literal[False]) -> None
This is a regression from mypy 0.910.
The second call at the bottom of this example generates an unexpected error, but only in Python 2 mode:
Here's the output:
This is a regression from mypy 0.910.