@@ -8486,7 +8486,7 @@ class C:
8486
8486
[builtins fixtures/property.pyi]
8487
8487
8488
8488
[case testPropertySetterDecorated]
8489
- from typing import Callable, TypeVar
8489
+ from typing import Callable, TypeVar, Generic
8490
8490
8491
8491
class B:
8492
8492
def __init__(self) -> None:
@@ -8514,12 +8514,23 @@ class C(B):
8514
8514
@deco_untyped
8515
8515
def baz(self, x: int) -> None: ...
8516
8516
8517
+ @property
8518
+ def tricky(self) -> int: ...
8519
+ @baz.setter
8520
+ @deco_instance
8521
+ def tricky(self, x: int) -> None: ...
8522
+
8517
8523
c: C
8518
8524
c.baz = "yes" # OK, because of untyped decorator
8525
+ c.tricky = 1 # E: Incompatible types in assignment (expression has type "int", variable has type "List[int]")
8519
8526
8520
8527
T = TypeVar("T")
8521
8528
def deco(fn: Callable[[T, int, int], None]) -> Callable[[T, int], None]: ...
8522
8529
def deco_untyped(fn): ...
8530
+
8531
+ class Wrapper(Generic[T]):
8532
+ def __call__(self, s: T, x: list[int]) -> None: ...
8533
+ def deco_instance(fn: Callable[[T, int], None]) -> Wrapper[T]: ...
8523
8534
[builtins fixtures/property.pyi]
8524
8535
8525
8536
[case testPropertyDeleterBodyChecked]
@@ -8538,3 +8549,40 @@ class C:
8538
8549
def bar(self) -> None:
8539
8550
1() # E: "int" not callable
8540
8551
[builtins fixtures/property.pyi]
8552
+
8553
+ [case testSettablePropertyGetterDecorated]
8554
+ from typing import Callable, TypeVar, Generic
8555
+
8556
+ class C:
8557
+ @property
8558
+ @deco
8559
+ def foo(self, ok: int) -> str: ...
8560
+ @foo.setter
8561
+ def foo(self, x: str) -> None: ...
8562
+
8563
+ @property
8564
+ @deco_instance
8565
+ def bar(self, ok: int) -> int: ...
8566
+ @bar.setter
8567
+ def bar(self, x: int) -> None: ...
8568
+
8569
+ @property
8570
+ @deco_untyped
8571
+ def baz(self) -> int: ...
8572
+ @baz.setter
8573
+ def baz(self, x: int) -> None: ...
8574
+
8575
+ c: C
8576
+ reveal_type(c.foo) # N: Revealed type is "builtins.list[builtins.str]"
8577
+ reveal_type(c.bar) # N: Revealed type is "builtins.list[builtins.int]"
8578
+ reveal_type(c.baz) # N: Revealed type is "Any"
8579
+
8580
+ T = TypeVar("T")
8581
+ R = TypeVar("R")
8582
+ def deco(fn: Callable[[T, int], R]) -> Callable[[T], list[R]]: ...
8583
+ def deco_untyped(fn): ...
8584
+
8585
+ class Wrapper(Generic[T, R]):
8586
+ def __call__(self, s: T) -> list[R]: ...
8587
+ def deco_instance(fn: Callable[[T, int], R]) -> Wrapper[T, R]: ...
8588
+ [builtins fixtures/property.pyi]
0 commit comments