@@ -772,7 +772,7 @@ class A:
772772class B(A):
773773 @property
774774 def f(self) -> Callable[[object], None]: pass
775- @func .setter
775+ @f .setter
776776 def f(self, x: object) -> None: pass
777777[builtins fixtures/property.pyi]
778778
@@ -786,7 +786,7 @@ class A:
786786class B(A):
787787 @property
788788 def f(self) -> Callable[[object], None]: pass
789- @func .setter
789+ @f .setter
790790 def f(self, x: object) -> None: pass
791791[builtins fixtures/property.pyi]
792792
@@ -1622,7 +1622,81 @@ class A:
16221622 self.x = '' # E: Incompatible types in assignment (expression has type "str", variable has type "int")
16231623 return ''
16241624[builtins fixtures/property.pyi]
1625+
1626+ [case testPropertyNameIsChecked]
1627+ class A:
1628+ @property
1629+ def f(self) -> str: ...
1630+ @not_f.setter # E: Only supported top decorators are "@f.setter" and "@f.deleter"
1631+ def f(self, val: str) -> None: ...
1632+
1633+ a = A()
1634+ reveal_type(a.f) # N: Revealed type is "builtins.str"
1635+ a.f = '' # E: Property "f" defined in "A" is read-only
1636+
1637+ class B:
1638+ @property
1639+ def f(self) -> str: ...
1640+ @not_f.deleter # E: Only supported top decorators are "@f.setter" and "@f.deleter"
1641+ def f(self) -> None: ...
1642+
1643+ class C:
1644+ @property
1645+ def f(self) -> str: ...
1646+ @not_f.setter # E: Only supported top decorators are "@f.setter" and "@f.deleter"
1647+ def f(self, val: str) -> None: ...
1648+ @not_f.deleter # E: Only supported top decorators are "@f.setter" and "@f.deleter"
1649+ def f(self) -> None: ...
1650+ [builtins fixtures/property.pyi]
1651+
1652+ [case testPropertyAttributeIsChecked]
1653+ class A:
1654+ @property
1655+ def f(self) -> str: ...
1656+ @f.unknown # E: Only supported top decorators are "@f.setter" and "@f.deleter"
1657+ def f(self, val: str) -> None: ...
1658+ @f.bad.setter # E: Only supported top decorators are "@f.setter" and "@f.deleter"
1659+ def f(self, val: str) -> None: ...
1660+ @f # E: Only supported top decorators are "@f.setter" and "@f.deleter"
1661+ def f(self, val: str) -> None: ...
1662+ @int # E: Only supported top decorators are "@f.setter" and "@f.deleter"
1663+ def f(self, val: str) -> None: ...
1664+ [builtins fixtures/property.pyi]
1665+
1666+ [case testPropertyNameAndAttributeIsCheckedPretty]
1667+ # flags: --pretty
1668+ class A:
1669+ @property
1670+ def f(self) -> str: ...
1671+ @not_f.setter
1672+ def f(self, val: str) -> None: ...
1673+ @not_f.deleter
1674+ def f(self) -> None: ...
1675+
1676+ class B:
1677+ @property
1678+ def f(self) -> str: ...
1679+ @f.unknown
1680+ def f(self, val: str) -> None: ...
1681+ [builtins fixtures/property.pyi]
16251682[out]
1683+ main:5: error: Only supported top decorators are "@f.setter" and "@f.deleter"
1684+ @not_f.setter
1685+ ^~~~~~~~~~~~
1686+ main:7: error: Only supported top decorators are "@f.setter" and "@f.deleter"
1687+ @not_f.deleter
1688+ ^~~~~~~~~~~~~
1689+ main:13: error: Only supported top decorators are "@f.setter" and "@f.deleter"
1690+ @f.unknown
1691+ ^~~~~~~~~
1692+
1693+ [case testPropertyGetterDecoratorIsRejected]
1694+ class A:
1695+ @property
1696+ def f(self) -> str: ...
1697+ @f.getter # E: Only supported top decorators are "@f.setter" and "@f.deleter"
1698+ def f(self, val: str) -> None: ...
1699+ [builtins fixtures/property.pyi]
16261700
16271701[case testDynamicallyTypedProperty]
16281702import typing
@@ -7739,7 +7813,7 @@ class A:
77397813 def y(self) -> int: ...
77407814 @y.setter
77417815 def y(self, value: int) -> None: ...
7742- @dec # E: Only supported top decorator is @y.setter
7816+ @dec # E: Only supported top decorators are " @y.setter" and "@y.deleter"
77437817 def y(self) -> None: ...
77447818
77457819reveal_type(A().y) # N: Revealed type is "builtins.int"
0 commit comments