@@ -1621,8 +1621,7 @@ class A:
16211621 self.x = 1
16221622 self.x = '' # E: Incompatible types in assignment (expression has type "str", variable has type "int")
16231623 return ''
1624- [builtins fixtures/property.pyi]
1625- [out]
1624+ [builtins fixtures/property-full.pyi]
16261625
16271626[case testDynamicallyTypedProperty]
16281627import typing
@@ -1632,7 +1631,7 @@ class A:
16321631a = A()
16331632a.f.xx
16341633a.f = '' # E: Property "f" defined in "A" is read-only
1635- [builtins fixtures/property.pyi]
1634+ [builtins fixtures/property-full .pyi]
16361635
16371636[case testPropertyWithSetter]
16381637import typing
@@ -1649,7 +1648,7 @@ a.f.x # E: "int" has no attribute "x"
16491648a.f = '' # E: Incompatible types in assignment (expression has type "str", variable has type "int")
16501649a.f = 1
16511650reveal_type(a.f) # N: Revealed type is "builtins.int"
1652- [builtins fixtures/property.pyi]
1651+ [builtins fixtures/property-full .pyi]
16531652
16541653[case testPropertyWithDeleterButNoSetter]
16551654import typing
@@ -1663,7 +1662,60 @@ class A:
16631662a = A()
16641663a.f = a.f # E: Property "f" defined in "A" is read-only
16651664a.f.x # E: "int" has no attribute "x"
1666- [builtins fixtures/property.pyi]
1665+ [builtins fixtures/property-full.pyi]
1666+
1667+ [case testPropertyAccessOnClass]
1668+ class Foo:
1669+ @property
1670+ def bar(self) -> bool:
1671+ return True
1672+
1673+ reveal_type(bar) # N: Revealed type is "builtins.property"
1674+
1675+ reveal_type(Foo.bar) # N: Revealed type is "builtins.property"
1676+ reveal_type(Foo.bar(Foo())) # E: "property" not callable \
1677+ # N: Revealed type is "Any"
1678+ reveal_type(Foo.bar.fget(Foo())) # E: "None" not callable \
1679+ # N: Revealed type is "Any"
1680+
1681+ class Bar:
1682+ @property
1683+ def bar(self) -> bool:
1684+ return True
1685+ @bar.setter
1686+ def bar(self, bar: bool) -> None:
1687+ pass
1688+
1689+ reveal_type(bar) # N: Revealed type is "builtins.property"
1690+
1691+ reveal_type(Bar.bar) # N: Revealed type is "builtins.property"
1692+ reveal_type(Bar.bar(Bar())) # E: "property" not callable \
1693+ # N: Revealed type is "Any"
1694+ reveal_type(Bar.bar.fget(Bar())) # E: "None" not callable \
1695+ # N: Revealed type is "Any"
1696+ [builtins fixtures/property-full.pyi]
1697+
1698+ [case testPropertyAccessOnClass2]
1699+ import functools
1700+ from functools import cached_property
1701+
1702+ class Foo:
1703+ @cached_property
1704+ def foo(self) -> bool:
1705+ return True
1706+
1707+ @functools.cached_property
1708+ def bar(self) -> bool:
1709+ return True
1710+
1711+ reveal_type(foo) # N: Revealed type is "functools.cached_property[Any]"
1712+ reveal_type(bar) # N: Revealed type is "functools.cached_property[Any]"
1713+
1714+ reveal_type(Foo.foo) # N: Revealed type is "functools.cached_property[Any]"
1715+ reveal_type(Foo.bar) # N: Revealed type is "functools.cached_property[Any]"
1716+ Foo.foo(Foo()) # E: "cached_property[Any]" not callable
1717+ Foo.bar(Foo()) # E: "cached_property[Any]" not callable
1718+ [builtins fixtures/property-full.pyi]
16671719
16681720-- Descriptors
16691721-- -----------
0 commit comments