Skip to content

Commit d01dc82

Browse files
Mark various dunder methods as positional-only in the stdlib (#14528)
1 parent 953e21b commit d01dc82

File tree

7 files changed

+27
-26
lines changed

7 files changed

+27
-26
lines changed

stdlib/_contextvars.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Token(Generic[_T]):
3939
if sys.version_info >= (3, 14):
4040
def __enter__(self) -> Self: ...
4141
def __exit__(
42-
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
42+
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None, /
4343
) -> None: ...
4444

4545
def copy_context() -> Context: ...

stdlib/_interpchannels.pyi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ class ChannelID:
1717
def send(self) -> Self: ...
1818
@property
1919
def recv(self) -> Self: ...
20-
def __eq__(self, other: object) -> bool: ...
21-
def __ge__(self, other: ChannelID) -> bool: ...
22-
def __gt__(self, other: ChannelID) -> bool: ...
20+
def __eq__(self, other: object, /) -> bool: ...
21+
def __ge__(self, other: ChannelID, /) -> bool: ...
22+
def __gt__(self, other: ChannelID, /) -> bool: ...
2323
def __hash__(self) -> int: ...
2424
def __index__(self) -> int: ...
2525
def __int__(self) -> int: ...
26-
def __le__(self, other: ChannelID) -> bool: ...
27-
def __lt__(self, other: ChannelID) -> bool: ...
28-
def __ne__(self, other: object) -> bool: ...
26+
def __le__(self, other: ChannelID, /) -> bool: ...
27+
def __lt__(self, other: ChannelID, /) -> bool: ...
28+
def __ne__(self, other: object, /) -> bool: ...
2929

3030
@final
3131
class ChannelInfo(structseq[int], tuple[bool, bool, bool, int, int, int, int, int]):

stdlib/array.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class array(MutableSequence[_T]):
5858
def tounicode(self) -> str: ...
5959

6060
__hash__: ClassVar[None] # type: ignore[assignment]
61+
def __contains__(self, value: object, /) -> bool: ...
6162
def __len__(self) -> int: ...
6263
@overload
6364
def __getitem__(self, key: SupportsIndex, /) -> _T: ...

stdlib/importlib/metadata/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ class EntryPoint(_EntryPointBase):
8989
) -> bool: ... # undocumented
9090

9191
def __hash__(self) -> int: ...
92-
def __eq__(self, other: object) -> bool: ...
9392
if sys.version_info >= (3, 11):
93+
def __eq__(self, other: object) -> bool: ...
9494
def __lt__(self, other: object) -> bool: ...
9595
if sys.version_info < (3, 12):
9696
def __iter__(self) -> Iterator[Any]: ... # result of iter((str, Self)), really

stdlib/typing.pyi

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,12 @@ class TypeVar:
207207
contravariant: bool = False,
208208
) -> None: ...
209209
if sys.version_info >= (3, 10):
210-
def __or__(self, right: Any) -> _SpecialForm: ... # AnnotationForm
211-
def __ror__(self, left: Any) -> _SpecialForm: ... # AnnotationForm
210+
def __or__(self, right: Any, /) -> _SpecialForm: ... # AnnotationForm
211+
def __ror__(self, left: Any, /) -> _SpecialForm: ... # AnnotationForm
212212
if sys.version_info >= (3, 11):
213-
def __typing_subst__(self, arg: Any) -> Any: ...
213+
def __typing_subst__(self, arg: Any, /) -> Any: ...
214214
if sys.version_info >= (3, 13):
215-
def __typing_prepare_subst__(self, alias: Any, args: Any) -> tuple[Any, ...]: ...
215+
def __typing_prepare_subst__(self, alias: Any, args: Any, /) -> tuple[Any, ...]: ...
216216
def has_default(self) -> bool: ...
217217
if sys.version_info >= (3, 14):
218218
@property
@@ -273,8 +273,8 @@ if sys.version_info >= (3, 11):
273273
def __init__(self, name: str) -> None: ...
274274

275275
def __iter__(self) -> Any: ...
276-
def __typing_subst__(self, arg: Never) -> Never: ...
277-
def __typing_prepare_subst__(self, alias: Any, args: Any) -> tuple[Any, ...]: ...
276+
def __typing_subst__(self, arg: Never, /) -> Never: ...
277+
def __typing_prepare_subst__(self, alias: Any, args: Any, /) -> tuple[Any, ...]: ...
278278
if sys.version_info >= (3, 14):
279279
@property
280280
def evaluate_default(self) -> EvaluateFunc | None: ...
@@ -289,7 +289,7 @@ if sys.version_info >= (3, 10):
289289
else:
290290
def __init__(self, origin: ParamSpec) -> None: ...
291291

292-
def __eq__(self, other: object) -> bool: ...
292+
def __eq__(self, other: object, /) -> bool: ...
293293
__hash__: ClassVar[None] # type: ignore[assignment]
294294

295295
@final
@@ -301,7 +301,7 @@ if sys.version_info >= (3, 10):
301301
else:
302302
def __init__(self, origin: ParamSpec) -> None: ...
303303

304-
def __eq__(self, other: object) -> bool: ...
304+
def __eq__(self, other: object, /) -> bool: ...
305305
__hash__: ClassVar[None] # type: ignore[assignment]
306306

307307
@final
@@ -365,11 +365,11 @@ if sys.version_info >= (3, 10):
365365
@property
366366
def kwargs(self) -> ParamSpecKwargs: ...
367367
if sys.version_info >= (3, 11):
368-
def __typing_subst__(self, arg: Any) -> Any: ...
369-
def __typing_prepare_subst__(self, alias: Any, args: Any) -> tuple[Any, ...]: ...
368+
def __typing_subst__(self, arg: Any, /) -> Any: ...
369+
def __typing_prepare_subst__(self, alias: Any, args: Any, /) -> tuple[Any, ...]: ...
370370

371-
def __or__(self, right: Any) -> _SpecialForm: ...
372-
def __ror__(self, left: Any) -> _SpecialForm: ...
371+
def __or__(self, right: Any, /) -> _SpecialForm: ...
372+
def __ror__(self, left: Any, /) -> _SpecialForm: ...
373373
if sys.version_info >= (3, 13):
374374
def has_default(self) -> bool: ...
375375
if sys.version_info >= (3, 14):
@@ -1115,9 +1115,9 @@ if sys.version_info >= (3, 12):
11151115
# It's writable on types, but not on instances of TypeAliasType.
11161116
@property
11171117
def __module__(self) -> str | None: ... # type: ignore[override]
1118-
def __getitem__(self, parameters: Any) -> GenericAlias: ... # AnnotationForm
1119-
def __or__(self, right: Any) -> _SpecialForm: ...
1120-
def __ror__(self, left: Any) -> _SpecialForm: ...
1118+
def __getitem__(self, parameters: Any, /) -> GenericAlias: ... # AnnotationForm
1119+
def __or__(self, right: Any, /) -> _SpecialForm: ...
1120+
def __ror__(self, left: Any, /) -> _SpecialForm: ...
11211121
if sys.version_info >= (3, 14):
11221122
@property
11231123
def evaluate_value(self) -> EvaluateFunc: ...

stdlib/typing_extensions.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,8 @@ else:
593593
def __getitem__(self, parameters: Incomplete | tuple[Incomplete, ...]) -> AnnotationForm: ...
594594
def __init_subclass__(cls, *args: Unused, **kwargs: Unused) -> NoReturn: ...
595595
if sys.version_info >= (3, 10):
596-
def __or__(self, right: Any) -> _SpecialForm: ...
597-
def __ror__(self, left: Any) -> _SpecialForm: ...
596+
def __or__(self, right: Any, /) -> _SpecialForm: ...
597+
def __ror__(self, left: Any, /) -> _SpecialForm: ...
598598

599599
# PEP 727
600600
class Doc:

stdlib/winreg.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ if sys.platform == "win32":
123123
def __int__(self) -> int: ...
124124
def __enter__(self) -> Self: ...
125125
def __exit__(
126-
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
126+
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None, /
127127
) -> bool | None: ...
128128
def Close(self) -> None: ...
129129
def Detach(self) -> int: ...

0 commit comments

Comments
 (0)