Skip to content

Commit c5562c5

Browse files
committed
More tests
1 parent badef4f commit c5562c5

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

test-data/unit/check-classes.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8738,7 +8738,7 @@ class NoopPowerResource:
87388738
[builtins fixtures/property.pyi]
87398739

87408740
[case testOverrideErrorReportingNoDuplicates]
8741-
from typing import Callable, Protocol, Generic, TypeVar
8741+
from typing import Callable, TypeVar
87428742

87438743
def nested() -> None:
87448744
class B:

test-data/unit/check-functions.test

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3655,3 +3655,42 @@ reveal_type(C().x6) # N: Revealed type is "def (x: builtins.int) -> builtins.st
36553655
reveal_type(C().x7) # E: Invalid self argument "C" to attribute function "x7" with type "Callable[[int], str]" \
36563656
# N: Revealed type is "def () -> builtins.str"
36573657
[builtins fixtures/classmethod.pyi]
3658+
3659+
[case testFunctionRedefinitionDeferred]
3660+
from typing import Callable, TypeVar
3661+
3662+
def outer() -> None:
3663+
if bool():
3664+
def inner() -> str: ...
3665+
else:
3666+
def inner() -> int: ... # E: All conditional function variants must have identical signatures \
3667+
# N: Original: \
3668+
# N: def inner() -> str \
3669+
# N: Redefinition: \
3670+
# N: def inner() -> int
3671+
x = defer()
3672+
3673+
T = TypeVar("T")
3674+
def deco(fn: Callable[[], T]) -> Callable[[], list[T]]: ...
3675+
3676+
@deco
3677+
def defer() -> int: ...
3678+
[builtins fixtures/list.pyi]
3679+
3680+
[case testCheckFunctionErrorContextDuplicateDeferred]
3681+
# flags: --show-error-context
3682+
from typing import Callable, TypeVar
3683+
3684+
def a() -> None:
3685+
def b() -> None:
3686+
1 + ""
3687+
x = defer()
3688+
3689+
T = TypeVar("T")
3690+
def deco(fn: Callable[[], T]) -> Callable[[], list[T]]: ...
3691+
3692+
@deco
3693+
def defer() -> int: ...
3694+
[out]
3695+
main: note: In function "a":
3696+
main:6: error: Unsupported operand types for + ("int" and "str")

test-data/unit/check-protocols.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4553,7 +4553,7 @@ reveal_type(t) # N: Revealed type is "__main__.Test[Any]"
45534553
[builtins fixtures/dict.pyi]
45544554

45554555
[case testProtocolErrorReportingNoDuplicates]
4556-
from typing import Callable, Protocol, Generic, TypeVar
4556+
from typing import Callable, Protocol, TypeVar
45574557

45584558
class P(Protocol):
45594559
def meth(self) -> int: ...

0 commit comments

Comments
 (0)