@@ -127,21 +127,25 @@ class _PyCPointerType(_CTypeBaseType):
127127class _Pointer (_PointerLike , _CData , Generic [_CT ], metaclass = _PyCPointerType ):
128128 _type_ : type [_CT ]
129129 contents : _CT
130+
130131 @overload
131132 def __init__ (self ) -> None : ...
132133 @overload
133134 def __init__ (self , arg : _CT ) -> None : ...
135+
134136 @overload
135137 def __getitem__ (self , key : int , / ) -> Any : ...
136138 @overload
137139 def __getitem__ (self , key : slice [SupportsIndex | None ], / ) -> list [Any ]: ...
140+
138141 def __setitem__ (self , key : int , value : Any , / ) -> None : ...
139142
140143if sys .version_info < (3 , 14 ):
141144 @overload
142145 def POINTER (type : None , / ) -> type [c_void_p ]: ...
143146 @overload
144147 def POINTER (type : type [_CT ], / ) -> type [_Pointer [_CT ]]: ...
148+
145149 def pointer (obj : _CT , / ) -> _Pointer [_CT ]: ...
146150
147151# This class is not exposed. It calls itself _ctypes.CArgObject.
@@ -177,6 +181,7 @@ class CFuncPtr(_PointerLike, _CData, metaclass=_PyCFuncPtrType):
177181 errcheck : _ECT
178182 # Abstract attribute that must be defined on subclasses
179183 _flags_ : ClassVar [int ]
184+
180185 @overload
181186 def __new__ (cls ) -> Self : ...
182187 @overload
@@ -209,10 +214,12 @@ if sys.version_info >= (3, 14):
209214 bit_offset : int
210215 bit_size : int
211216 is_anonymous : bool
217+
212218 @overload
213219 def __get__ (self , instance : None , owner : builtins .type [Any ] | None = None , / ) -> Self : ...
214220 @overload
215221 def __get__ (self , instance : Any , owner : builtins .type [Any ] | None = None , / ) -> _GetT : ...
222+
216223 def __set__ (self , instance : Any , value : _SetT , / ) -> None : ...
217224
218225 _CField = CField
@@ -223,10 +230,12 @@ else:
223230 class _CField (Generic [_CT , _GetT , _SetT ]):
224231 offset : int
225232 size : int
233+
226234 @overload
227235 def __get__ (self , instance : None , owner : type [Any ] | None = None , / ) -> Self : ...
228236 @overload
229237 def __get__ (self , instance : Any , owner : type [Any ] | None = None , / ) -> _GetT : ...
238+
230239 def __set__ (self , instance : Any , value : _SetT , / ) -> None : ...
231240
232241# This class is not exposed. It calls itself _ctypes.UnionType.
@@ -308,16 +317,19 @@ class Array(_CData, Generic[_CT], metaclass=_PyCArrayType):
308317 def _length_ (self ) -> int : ...
309318 @_length_ .setter
310319 def _length_ (self , value : int ) -> None : ...
320+
311321 @property
312322 @abstractmethod
313323 def _type_ (self ) -> type [_CT ]: ...
314324 @_type_ .setter
315325 def _type_ (self , value : type [_CT ]) -> None : ...
326+
316327 # Note: only available if _CT == c_char
317328 @property
318329 def raw (self ) -> bytes : ...
319330 @raw .setter
320331 def raw (self , value : ReadableBuffer ) -> None : ...
332+
321333 value : Any # Note: bytes if _CT == c_char, str if _CT == c_wchar, unavailable otherwise
322334 # TODO: These methods cannot be annotated correctly at the moment.
323335 # All of these "Any"s stand for the array's element type, but it's not possible to use _CT
@@ -332,14 +344,17 @@ class Array(_CData, Generic[_CT], metaclass=_PyCArrayType):
332344 # This special behavior is not easy to model in a stub, so for now all places where
333345 # the array element type would belong are annotated with Any instead.
334346 def __init__ (self , * args : Any ) -> None : ...
347+
335348 @overload
336349 def __getitem__ (self , key : int , / ) -> Any : ...
337350 @overload
338351 def __getitem__ (self , key : slice [SupportsIndex | None ], / ) -> list [Any ]: ...
352+
339353 @overload
340354 def __setitem__ (self , key : int , value : Any , / ) -> None : ...
341355 @overload
342356 def __setitem__ (self , key : slice [SupportsIndex | None ], value : Iterable [Any ], / ) -> None : ...
357+
343358 def __iter__ (self ) -> Iterator [Any ]: ...
344359 # Can't inherit from Sized because the metaclass conflict between
345360 # Sized and _CData prevents using _CDataMeta.
0 commit comments