@@ -2890,20 +2890,28 @@ def test_function():
28902890
28912891[case testMypycAttrNativeClassDunder]
28922892from mypy_extensions import mypyc_attr
2893- from typing import Generic, TypeVar
2893+ from typing import Generic, Optional, TypeVar
28942894
28952895_T = TypeVar("_T")
28962896
2897+ get_count = set_count = del_count = 0
2898+
28972899@mypyc_attr(native_class=False)
28982900class Bar(Generic[_T]):
28992901 # Note the lack of __deletable__
29002902 def __init__(self) -> None:
29012903 self.value: str = 'start'
2902- def __get__(self, instance: _T, owner: type[_T] | None = None) -> str:
2904+ def __get__(self, instance: _T, owner: Optional[type[_T]] = None) -> str:
2905+ global get_count
2906+ get_count += 1
29032907 return self.value
29042908 def __set__(self, instance: _T, value: str) -> None:
2909+ global set_count
2910+ set_count += 1
29052911 self.value = value
29062912 def __delete__(self, instance: _T) -> None:
2913+ global del_count
2914+ del_count += 1
29072915 del self.value
29082916
29092917@mypyc_attr(native_class=False)
@@ -2915,11 +2923,15 @@ import native
29152923
29162924f = native.Foo()
29172925assert(hasattr(f, 'bar'))
2926+ assert(native.get_count == 1)
29182927assert(f.bar == 'start')
2928+ assert(native.get_count == 2)
29192929f.bar = 'test'
29202930assert(f.bar == 'test')
2931+ assert(native.set_count == 1)
29212932del f.bar
29222933assert(not hasattr(f, 'bar'))
2934+ assert(native.del_count == 1)
29232935
29242936[case testMypycAttrNativeClassMeta]
29252937from mypy_extensions import mypyc_attr
0 commit comments