Skip to content

Commit 0c95ef4

Browse files
committed
feat: Conform to PEP 570 for descriptor protocols and dunder methods in hints.pyi.
Apply '/' marker to descriptor protocol and dunder methods, improving clarity and compliance with PEP 570.
1 parent 243a16b commit 0c95ef4

File tree

1 file changed

+32
-26
lines changed

1 file changed

+32
-26
lines changed

comtypes/hints.pyi

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -105,31 +105,35 @@ class _GetSetNormalProperty(Generic[_T_Inst, _R_Get, _T_SetVal]):
105105
fset: Callable[[_T_Inst, _T_SetVal], Any]
106106

107107
@overload
108-
def __get__(self, instance: None, owner: type[_T_Inst]) -> Self: ...
108+
def __get__(self, instance: None, owner: type[_T_Inst], /) -> Self: ...
109109
@overload
110-
def __get__(self, instance: _T_Inst, owner: Optional[type[_T_Inst]]) -> _R_Get: ...
111-
def __set__(self, instance: _T_Inst, value: _T_SetVal) -> None: ...
110+
def __get__(
111+
self, instance: _T_Inst, owner: Optional[type[_T_Inst]], /
112+
) -> _R_Get: ...
113+
def __set__(self, instance: _T_Inst, value: _T_SetVal, /) -> None: ...
112114

113115
class _GetOnlyNormalProperty(Generic[_T_Inst, _R_Get]):
114116
fget: Callable[[_T_Inst], Any]
115117

116118
@overload
117-
def __get__(self, instance: None, owner: type[_T_Inst]) -> Self: ...
119+
def __get__(self, instance: None, owner: type[_T_Inst], /) -> Self: ...
118120
@overload
119-
def __get__(self, instance: _T_Inst, owner: Optional[type[_T_Inst]]) -> _R_Get: ...
120-
def __set__(self, instance: _T_Inst, value: Any) -> NoReturn: ...
121+
def __get__(
122+
self, instance: _T_Inst, owner: Optional[type[_T_Inst]], /
123+
) -> _R_Get: ...
124+
def __set__(self, instance: _T_Inst, value: Any, /) -> NoReturn: ...
121125

122126
class _SetOnlyNormalProperty(Generic[_T_Inst, _T_SetVal]):
123127
fget: Callable[[_T_Inst], Any]
124128
fset: Callable[[_T_Inst, _T_SetVal], Any]
125129

126130
@overload
127-
def __get__(self, instance: None, owner: type[_T_Inst]) -> Self: ...
131+
def __get__(self, instance: None, owner: type[_T_Inst], /) -> Self: ...
128132
@overload
129133
def __get__(
130-
self, instance: _T_Inst, owner: Optional[type[_T_Inst]]
134+
self, instance: _T_Inst, owner: Optional[type[_T_Inst]], /
131135
) -> NoReturn: ...
132-
def __set__(self, instance: _T_Inst, value: _T_SetVal) -> None: ...
136+
def __set__(self, instance: _T_Inst, value: _T_SetVal, /) -> None: ...
133137

134138
@overload
135139
def normal_property(
@@ -149,9 +153,9 @@ class _GetSetBoundNamedProperty(Generic[_T_Inst, _P_Get, _R_Get, _P_Set]):
149153
fget: Callable[Concatenate[_T_Inst, _P_Get], _R_Get]
150154
fset: Callable[Concatenate[_T_Inst, _P_Set], Any]
151155
__doc__: Optional[str]
152-
def __getitem__(self, index: Any) -> _R_Get: ...
156+
def __getitem__(self, index: Any, /) -> _R_Get: ...
153157
def __call__(self, *args: _P_Get.args, **kwargs: _P_Get.kwargs) -> _R_Get: ...
154-
def __setitem__(self, index: Any, value: Any) -> None: ...
158+
def __setitem__(self, index: Any, value: Any, /) -> None: ...
155159
def __iter__(self) -> NoReturn: ...
156160

157161
class _GetSetNamedProperty(Generic[_T_Inst, _P_Get, _R_Get, _P_Set]):
@@ -161,20 +165,20 @@ class _GetSetNamedProperty(Generic[_T_Inst, _P_Get, _R_Get, _P_Set]):
161165
__doc__: Optional[str]
162166

163167
@overload
164-
def __get__(self, instance: None, owner: type[_T_Inst]) -> Self: ...
168+
def __get__(self, instance: None, owner: type[_T_Inst], /) -> Self: ...
165169
@overload
166170
def __get__(
167-
self, instance: _T_Inst, owner: Optional[type[_T_Inst]]
171+
self, instance: _T_Inst, owner: Optional[type[_T_Inst]], /
168172
) -> _GetSetBoundNamedProperty[_T_Inst, _P_Get, _R_Get, _P_Set]: ...
169-
def __set__(self, instance: _T_Inst, value: Any) -> NoReturn: ...
173+
def __set__(self, instance: _T_Inst, value: Any, /) -> NoReturn: ...
170174

171175
class _GetOnlyBoundNamedProperty(Generic[_T_Inst, _P_Get, _R_Get]):
172176
name: str
173177
fget: Callable[Concatenate[_T_Inst, _P_Get], _R_Get]
174178
__doc__: Optional[str]
175-
def __getitem__(self, index: Any) -> _R_Get: ...
179+
def __getitem__(self, index: Any, /) -> _R_Get: ...
176180
def __call__(self, *args: _P_Get.args, **kwargs: _P_Get.kwargs) -> _R_Get: ...
177-
def __setitem__(self, index: Any, value: Any) -> NoReturn: ...
181+
def __setitem__(self, index: Any, value: Any, /) -> NoReturn: ...
178182
def __iter__(self) -> NoReturn: ...
179183

180184
class _GetOnlyNamedProperty(Generic[_T_Inst, _P_Get, _R_Get]):
@@ -183,20 +187,20 @@ class _GetOnlyNamedProperty(Generic[_T_Inst, _P_Get, _R_Get]):
183187
__doc__: Optional[str]
184188

185189
@overload
186-
def __get__(self, instance: None, owner: type[_T_Inst]) -> Self: ...
190+
def __get__(self, instance: None, owner: type[_T_Inst], /) -> Self: ...
187191
@overload
188192
def __get__(
189-
self, instance: _T_Inst, owner: Optional[type[_T_Inst]]
193+
self, instance: _T_Inst, owner: Optional[type[_T_Inst]], /
190194
) -> _GetOnlyBoundNamedProperty[_T_Inst, _P_Get, _R_Get]: ...
191-
def __set__(self, instance: _T_Inst, value: Any) -> NoReturn: ...
195+
def __set__(self, instance: _T_Inst, value: Any, /) -> NoReturn: ...
192196

193197
class _SetOnlyBoundNamedProperty(Generic[_T_Inst, _P_Set]):
194198
name: str
195199
fset: Callable[Concatenate[_T_Inst, _P_Set], Any]
196200
__doc__: Optional[str]
197-
def __getitem__(self, index: Any) -> NoReturn: ...
201+
def __getitem__(self, index: Any, /) -> NoReturn: ...
198202
def __call__(self, *args: Any, **kwargs: Any) -> NoReturn: ...
199-
def __setitem__(self, index: Any, value: Any) -> None: ...
203+
def __setitem__(self, index: Any, value: Any, /) -> None: ...
200204
def __iter__(self) -> NoReturn: ...
201205

202206
class _SetOnlyNamedProperty(Generic[_T_Inst, _P_Set]):
@@ -205,12 +209,12 @@ class _SetOnlyNamedProperty(Generic[_T_Inst, _P_Set]):
205209
__doc__: Optional[str]
206210

207211
@overload
208-
def __get__(self, instance: None, owner: type[_T_Inst]) -> Self: ...
212+
def __get__(self, instance: None, owner: type[_T_Inst], /) -> Self: ...
209213
@overload
210214
def __get__(
211-
self, instance: _T_Inst, owner: Optional[type[_T_Inst]]
215+
self, instance: _T_Inst, owner: Optional[type[_T_Inst]], /
212216
) -> _SetOnlyBoundNamedProperty[_T_Inst, _P_Set]: ...
213-
def __set__(self, instance: _T_Inst, value: Any) -> NoReturn: ...
217+
def __set__(self, instance: _T_Inst, value: Any, /) -> NoReturn: ...
214218

215219
@overload
216220
def named_property(
@@ -231,9 +235,11 @@ def named_property(
231235

232236
class _Descriptor(Protocol[_T_Inst, _R_Get]):
233237
@overload
234-
def __get__(self, instance: None, owner: type[_T_Inst]) -> Self: ...
238+
def __get__(self, instance: None, owner: type[_T_Inst], /) -> Self: ...
235239
@overload
236-
def __get__(self, instance: _T_Inst, owner: Optional[type[_T_Inst]]) -> _R_Get: ...
240+
def __get__(
241+
self, instance: _T_Inst, owner: Optional[type[_T_Inst]], /
242+
) -> _R_Get: ...
237243

238244
# `__len__` for objects with `Count`
239245
@overload

0 commit comments

Comments
 (0)