@@ -8486,7 +8486,7 @@ class C:
84868486[builtins fixtures/property.pyi]
84878487
84888488[case testPropertySetterDecorated]
8489- from typing import Callable, TypeVar
8489+ from typing import Callable, TypeVar, Generic
84908490
84918491class B:
84928492 def __init__(self) -> None:
@@ -8514,12 +8514,23 @@ class C(B):
85148514 @deco_untyped
85158515 def baz(self, x: int) -> None: ...
85168516
8517+ @property
8518+ def tricky(self) -> int: ...
8519+ @baz.setter
8520+ @deco_instance
8521+ def tricky(self, x: int) -> None: ...
8522+
85178523c: C
85188524c.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]")
85198526
85208527T = TypeVar("T")
85218528def deco(fn: Callable[[T, int, int], None]) -> Callable[[T, int], None]: ...
85228529def 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]: ...
85238534[builtins fixtures/property.pyi]
85248535
85258536[case testPropertyDeleterBodyChecked]
@@ -8538,3 +8549,40 @@ class C:
85388549 def bar(self) -> None:
85398550 1() # E: "int" not callable
85408551[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