@@ -1393,23 +1393,35 @@ x = None # type: Any
13931393if x:
13941394 def f(x: int) -> None: pass
13951395else:
1396- def f(x): pass # E: All conditional function variants must have identical signatures
1396+ def f(x): pass # E: All conditional function variants must have identical signatures \
1397+ # N: Original: \
1398+ # N: def f(x: int) -> None \
1399+ # N: Redefinition: \
1400+ # N: def f(x: Any) -> Any
13971401
13981402[case testIncompatibleConditionalFunctionDefinition2]
13991403from typing import Any
14001404x = None # type: Any
14011405if x:
14021406 def f(x: int) -> None: pass
14031407else:
1404- def f(y: int) -> None: pass # E: All conditional function variants must have identical signatures
1408+ def f(y: int) -> None: pass # E: All conditional function variants must have identical signatures \
1409+ # N: Original: \
1410+ # N: def f(x: int) -> None \
1411+ # N: Redefinition: \
1412+ # N: def f(y: int) -> None
14051413
14061414[case testIncompatibleConditionalFunctionDefinition3]
14071415from typing import Any
14081416x = None # type: Any
14091417if x:
14101418 def f(x: int) -> None: pass
14111419else:
1412- def f(x: int = 0) -> None: pass # E: All conditional function variants must have identical signatures
1420+ def f(x: int = 0) -> None: pass # E: All conditional function variants must have identical signatures \
1421+ # N: Original: \
1422+ # N: def f(x: int) -> None \
1423+ # N: Redefinition: \
1424+ # N: def f(x: int = ...) -> None
14131425
14141426[case testConditionalFunctionDefinitionUsingDecorator1]
14151427from typing import Callable
@@ -1467,14 +1479,22 @@ from typing import Any
14671479def f(x: str) -> None: pass
14681480x = None # type: Any
14691481if x:
1470- def f(x: int) -> None: pass # E: All conditional function variants must have identical signatures
1482+ def f(x: int) -> None: pass # E: All conditional function variants must have identical signatures \
1483+ # N: Original: \
1484+ # N: def f(x: str) -> None \
1485+ # N: Redefinition: \
1486+ # N: def f(x: int) -> None
14711487
14721488[case testConditionalRedefinitionOfAnUnconditionalFunctionDefinition2]
14731489from typing import Any
14741490def f(x: int) -> None: pass # N: "f" defined here
14751491x = None # type: Any
14761492if x:
1477- def f(y: int) -> None: pass # E: All conditional function variants must have identical signatures
1493+ def f(y: int) -> None: pass # E: All conditional function variants must have identical signatures \
1494+ # N: Original: \
1495+ # N: def f(x: int) -> None \
1496+ # N: Redefinition: \
1497+ # N: def f(y: int) -> None
14781498f(x=1) # The first definition takes precedence.
14791499f(y=1) # E: Unexpected keyword argument "y" for "f"
14801500
@@ -1640,7 +1660,11 @@ class A:
16401660 if x:
16411661 def f(self, x: int) -> None: pass
16421662 else:
1643- def f(self, x): pass # E: All conditional function variants must have identical signatures
1663+ def f(self, x): pass # E: All conditional function variants must have identical signatures \
1664+ # N: Original: \
1665+ # N: def f(self: A, x: int) -> None \
1666+ # N: Redefinition: \
1667+ # N: def f(self: A, x: Any) -> Any
16441668[out]
16451669
16461670[case testConditionalFunctionDefinitionInTry]
0 commit comments