Skip to content

Commit 11907e2

Browse files
Fix dunder-method positional-only parameter discrepancies in third-party stubs (#14529)
1 parent 2e3203f commit 11907e2

File tree

11 files changed

+113
-99
lines changed

11 files changed

+113
-99
lines changed

stubs/braintree/braintree/attribute_getter.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ class AttributeGetter:
44
def __init__(self, attributes: dict[str, Any] | None = None) -> None: ...
55
# This doesn't exist at runtime, but subclasses should define their own fields populated by attributes in __init__
66
# Until that's done, keep __getattribute__ to fill in the gaps
7-
def __getattribute__(self, name: str) -> Any: ...
7+
def __getattribute__(self, name: str, /) -> Any: ...

stubs/cffi/_cffi_backend.pyi

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,30 +62,32 @@ class Lib:
6262
@final
6363
class _CDataBase:
6464
__name__: ClassVar[str]
65-
def __add__(self, other): ...
65+
def __add__(self, other, /): ...
6666
def __bool__(self) -> bool: ...
6767
def __call__(self, *args, **kwargs): ...
6868
def __complex__(self) -> complex: ...
69-
def __delitem__(self, other) -> None: ...
69+
def __delitem__(self, other, /) -> None: ...
7070
def __dir__(self): ...
7171
def __enter__(self): ...
72-
def __eq__(self, other): ...
73-
def __exit__(self, type: type[BaseException] | None, value: BaseException | None, traceback: types.TracebackType | None): ...
72+
def __eq__(self, other, /): ...
73+
def __exit__(
74+
self, type: type[BaseException] | None, value: BaseException | None, traceback: types.TracebackType | None, /
75+
): ...
7476
def __float__(self) -> float: ...
75-
def __ge__(self, other): ...
76-
def __getitem__(self, index: SupportsIndex | slice): ...
77-
def __gt__(self, other): ...
77+
def __ge__(self, other, /): ...
78+
def __getitem__(self, index: SupportsIndex | slice, /): ...
79+
def __gt__(self, other, /): ...
7880
def __hash__(self) -> int: ...
7981
def __int__(self) -> int: ...
8082
def __iter__(self): ...
81-
def __le__(self, other): ...
83+
def __le__(self, other, /): ...
8284
def __len__(self) -> int: ...
83-
def __lt__(self, other): ...
84-
def __ne__(self, other): ...
85-
def __radd__(self, other): ...
86-
def __rsub__(self, other): ...
87-
def __setitem__(self, index: SupportsIndex | slice, object) -> None: ...
88-
def __sub__(self, other): ...
85+
def __lt__(self, other, /): ...
86+
def __ne__(self, other, /): ...
87+
def __radd__(self, other, /): ...
88+
def __rsub__(self, other, /): ...
89+
def __setitem__(self, index: SupportsIndex | slice, object, /) -> None: ...
90+
def __sub__(self, other, /): ...
8991

9092
@final
9193
class buffer:

stubs/gdb/gdb/__init__.pyi

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -83,29 +83,29 @@ class Value:
8383
def __index__(self) -> int: ...
8484
def __int__(self) -> int: ...
8585
def __float__(self) -> float: ...
86-
def __add__(self, other: _ValueOrNative) -> Value: ...
87-
def __radd__(self, other: _ValueOrNative) -> Value: ...
88-
def __sub__(self, other: _ValueOrNative) -> Value: ...
89-
def __rsub__(self, other: _ValueOrNative) -> Value: ...
90-
def __mul__(self, other: _ValueOrNative) -> Value: ...
91-
def __rmul__(self, other: _ValueOrNative) -> Value: ...
92-
def __truediv__(self, other: _ValueOrNative) -> Value: ...
93-
def __rtruediv__(self, other: _ValueOrNative) -> Value: ...
94-
def __mod__(self, other: _ValueOrNative) -> Value: ...
95-
def __rmod__(self, other: _ValueOrNative) -> Value: ...
96-
def __pow__(self, other: _ValueOrNative, mod: None = None) -> Value: ...
97-
def __and__(self, other: _ValueOrNative) -> Value: ...
98-
def __or__(self, other: _ValueOrNative) -> Value: ...
99-
def __xor__(self, other: _ValueOrNative) -> Value: ...
100-
def __lshift__(self, other: _ValueOrNative) -> Value: ...
101-
def __rshift__(self, other: _ValueOrNative) -> Value: ...
102-
def __eq__(self, other: _ValueOrNative) -> bool: ... # type: ignore[override]
103-
def __ne__(self, other: _ValueOrNative) -> bool: ... # type: ignore[override]
104-
def __lt__(self, other: _ValueOrNative) -> bool: ...
105-
def __le__(self, other: _ValueOrNative) -> bool: ...
106-
def __gt__(self, other: _ValueOrNative) -> bool: ...
107-
def __ge__(self, other: _ValueOrNative) -> bool: ...
108-
def __getitem__(self, key: int | str | Field) -> Value: ...
86+
def __add__(self, other: _ValueOrNative, /) -> Value: ...
87+
def __radd__(self, other: _ValueOrNative, /) -> Value: ...
88+
def __sub__(self, other: _ValueOrNative, /) -> Value: ...
89+
def __rsub__(self, other: _ValueOrNative, /) -> Value: ...
90+
def __mul__(self, other: _ValueOrNative, /) -> Value: ...
91+
def __rmul__(self, other: _ValueOrNative, /) -> Value: ...
92+
def __truediv__(self, other: _ValueOrNative, /) -> Value: ...
93+
def __rtruediv__(self, other: _ValueOrNative, /) -> Value: ...
94+
def __mod__(self, other: _ValueOrNative, /) -> Value: ...
95+
def __rmod__(self, other: _ValueOrNative, /) -> Value: ...
96+
def __pow__(self, other: _ValueOrNative, mod: None = None, /) -> Value: ...
97+
def __and__(self, other: _ValueOrNative, /) -> Value: ...
98+
def __or__(self, other: _ValueOrNative, /) -> Value: ...
99+
def __xor__(self, other: _ValueOrNative, /) -> Value: ...
100+
def __lshift__(self, other: _ValueOrNative, /) -> Value: ...
101+
def __rshift__(self, other: _ValueOrNative, /) -> Value: ...
102+
def __eq__(self, other: _ValueOrNative, /) -> bool: ... # type: ignore[override]
103+
def __ne__(self, other: _ValueOrNative, /) -> bool: ... # type: ignore[override]
104+
def __lt__(self, other: _ValueOrNative, /) -> bool: ...
105+
def __le__(self, other: _ValueOrNative, /) -> bool: ...
106+
def __gt__(self, other: _ValueOrNative, /) -> bool: ...
107+
def __ge__(self, other: _ValueOrNative, /) -> bool: ...
108+
def __getitem__(self, key: int | str | Field, /) -> Value: ...
109109
def __call__(self, *args: _ValueOrNative) -> Value: ...
110110
def __init__(self, val: _ValueOrNative) -> None: ...
111111
def cast(self, type: Type) -> Value: ...
@@ -175,7 +175,7 @@ class Type(Mapping[str, Field]):
175175
def get(self, key: str, default: Any = ...) -> Field | Any: ...
176176
def has_key(self, key: str) -> bool: ...
177177
def __len__(self) -> int: ...
178-
def __getitem__(self, key: str) -> Field: ...
178+
def __getitem__(self, key: str, /) -> Field: ...
179179
def __iter__(self) -> TypeIterator[str]: ...
180180

181181
_T = TypeVar("_T")

stubs/gevent/gevent/local.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ from typing_extensions import Self
44
class local:
55
def __init__(self, *args: object, **kwargs: object) -> None: ...
66
def __copy__(self) -> Self: ...
7-
def __getattribute__(self, name: str) -> Any: ...
8-
def __delattr__(self, name: str) -> None: ...
9-
def __setattr__(self, name: str, value: Any) -> None: ...
7+
def __getattribute__(self, name: str, /) -> Any: ...
8+
def __delattr__(self, name: str, /) -> None: ...
9+
def __setattr__(self, name: str, value: Any, /) -> None: ...
1010

1111
__all__ = ["local"]

stubs/hdbcli/hdbcli/resultrow.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ class ResultRow:
88

99
def __len__(self) -> int: ...
1010
@overload
11-
def __getitem__(self, index: int) -> Any: ...
11+
def __getitem__(self, index: int, /) -> Any: ...
1212
@overload
13-
def __getitem__(self, index: slice) -> Sequence[Any]: ...
13+
def __getitem__(self, index: slice, /) -> Sequence[Any]: ...
1414
def __iter__(self) -> Iterator[Any]: ...
1515
# __next__, __delitem__, __setitem__ are technically defined but lead always to an error

stubs/pika/pika/exchange_type.pyi

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1-
from enum import Enum
1+
import sys
22

3-
class ExchangeType(Enum):
4-
direct = "direct"
5-
fanout = "fanout"
6-
headers = "headers"
7-
topic = "topic"
3+
if sys.version_info >= (3, 11):
4+
from enum import StrEnum
5+
6+
class ExchangeType(StrEnum):
7+
direct = "direct"
8+
fanout = "fanout"
9+
headers = "headers"
10+
topic = "topic"
11+
12+
else:
13+
from enum import Enum
14+
15+
class ExchangeType(str, Enum):
16+
direct = "direct"
17+
fanout = "fanout"
18+
headers = "headers"
19+
topic = "topic"

stubs/protobuf/google/_upb/_message.pyi

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,18 @@ class EnumValueDescriptor:
7878

7979
@final
8080
class ExtensionDict:
81-
def __contains__(self, other) -> bool: ...
82-
def __delitem__(self, other) -> None: ...
83-
def __eq__(self, other: object) -> bool: ...
84-
def __ge__(self, other: object) -> bool: ...
85-
def __getitem__(self, index): ...
86-
def __gt__(self, other: object) -> bool: ...
81+
def __contains__(self, other, /) -> bool: ...
82+
def __delitem__(self, other, /) -> None: ...
83+
def __eq__(self, other: object, /) -> bool: ...
84+
def __ge__(self, other: object, /) -> bool: ...
85+
def __getitem__(self, index, /): ...
86+
def __gt__(self, other: object, /) -> bool: ...
8787
def __iter__(self): ...
88-
def __le__(self, other: object) -> bool: ...
88+
def __le__(self, other: object, /) -> bool: ...
8989
def __len__(self) -> int: ...
90-
def __lt__(self, other: object) -> bool: ...
91-
def __ne__(self, other: object) -> bool: ...
92-
def __setitem__(self, index, object) -> None: ...
90+
def __lt__(self, other: object, /) -> bool: ...
91+
def __ne__(self, other: object, /) -> bool: ...
92+
def __setitem__(self, index, object, /) -> None: ...
9393

9494
@final
9595
class ExtensionIterator:
@@ -201,16 +201,16 @@ class Message:
201201
def SetInParent(self): ...
202202
def UnknownFields(self): ...
203203
def WhichOneof(self, object, /): ...
204-
def __contains__(self, other) -> bool: ...
204+
def __contains__(self, other, /) -> bool: ...
205205
def __deepcopy__(self, memo=None): ...
206-
def __delattr__(self, name): ...
207-
def __eq__(self, other: object) -> bool: ...
208-
def __ge__(self, other: object) -> bool: ...
209-
def __gt__(self, other: object) -> bool: ...
210-
def __le__(self, other: object) -> bool: ...
211-
def __lt__(self, other: object) -> bool: ...
212-
def __ne__(self, other: object) -> bool: ...
213-
def __setattr__(self, name, value): ...
206+
def __delattr__(self, name, /): ...
207+
def __eq__(self, other: object, /) -> bool: ...
208+
def __ge__(self, other: object, /) -> bool: ...
209+
def __gt__(self, other: object, /) -> bool: ...
210+
def __le__(self, other: object, /) -> bool: ...
211+
def __lt__(self, other: object, /) -> bool: ...
212+
def __ne__(self, other: object, /) -> bool: ...
213+
def __setattr__(self, name, value, /): ...
214214

215215
@final
216216
class MessageMeta(type): ...
@@ -253,16 +253,16 @@ class RepeatedCompositeContainer:
253253
def reverse(self): ...
254254
def sort(self, *args, **kwargs): ... # incomplete
255255
def __deepcopy__(self, memo=None): ...
256-
def __delitem__(self, other) -> None: ...
257-
def __eq__(self, other: object) -> bool: ...
258-
def __ge__(self, other: object) -> bool: ...
259-
def __getitem__(self, index): ...
260-
def __gt__(self, other: object) -> bool: ...
261-
def __le__(self, other: object) -> bool: ...
256+
def __delitem__(self, other, /) -> None: ...
257+
def __eq__(self, other: object, /) -> bool: ...
258+
def __ge__(self, other: object, /) -> bool: ...
259+
def __getitem__(self, index, /): ...
260+
def __gt__(self, other: object, /) -> bool: ...
261+
def __le__(self, other: object, /) -> bool: ...
262262
def __len__(self) -> int: ...
263-
def __lt__(self, other: object) -> bool: ...
264-
def __ne__(self, other: object) -> bool: ...
265-
def __setitem__(self, index, object) -> None: ...
263+
def __lt__(self, other: object, /) -> bool: ...
264+
def __ne__(self, other: object, /) -> bool: ...
265+
def __setitem__(self, index, object, /) -> None: ...
266266

267267
@final
268268
class RepeatedScalarContainer:
@@ -276,17 +276,17 @@ class RepeatedScalarContainer:
276276
def reverse(self): ...
277277
def sort(self, *args, **kwargs): ... # incomplete
278278
def __deepcopy__(self, memo=None): ...
279-
def __delitem__(self, other) -> None: ...
280-
def __eq__(self, other: object) -> bool: ...
281-
def __ge__(self, other: object) -> bool: ...
282-
def __getitem__(self, index): ...
283-
def __gt__(self, other: object) -> bool: ...
284-
def __le__(self, other: object) -> bool: ...
279+
def __delitem__(self, other, /) -> None: ...
280+
def __eq__(self, other: object, /) -> bool: ...
281+
def __ge__(self, other: object, /) -> bool: ...
282+
def __getitem__(self, index, /): ...
283+
def __gt__(self, other: object, /) -> bool: ...
284+
def __le__(self, other: object, /) -> bool: ...
285285
def __len__(self) -> int: ...
286-
def __lt__(self, other: object) -> bool: ...
287-
def __ne__(self, other: object) -> bool: ...
286+
def __lt__(self, other: object, /) -> bool: ...
287+
def __ne__(self, other: object, /) -> bool: ...
288288
def __reduce__(self): ...
289-
def __setitem__(self, index, object) -> None: ...
289+
def __setitem__(self, index, object, /) -> None: ...
290290

291291
@final
292292
class ServiceDescriptor:
@@ -304,7 +304,7 @@ class ServiceDescriptor:
304304
@final
305305
class UnknownFieldSet:
306306
def __init__(self, *args, **kwargs) -> None: ... # incomplete
307-
def __getitem__(self, index): ...
307+
def __getitem__(self, index, /): ...
308308
def __len__(self) -> int: ...
309309

310310
def SetAllowOversizeProtos(object, /): ... # incomplete

stubs/psycopg2/psycopg2/_psycopg.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ class Column:
209209
def __len__(self) -> int: ...
210210
def __lt__(self, other, /): ...
211211
def __ne__(self, other, /): ...
212-
def __setstate__(self, state): ...
212+
def __setstate__(self, state, /): ...
213213

214214
class ConnectionInfo:
215215
# Note: the following properties can be None if their corresponding libpq function
@@ -277,7 +277,7 @@ class Error(Exception):
277277
pgerror: str | None
278278
def __init__(self, *args, **kwargs) -> None: ...
279279
def __reduce__(self): ...
280-
def __setstate__(self, state): ...
280+
def __setstate__(self, state, /): ...
281281

282282
class DatabaseError(Error): ...
283283
class DataError(DatabaseError): ...

stubs/pywin32/_win32typing.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1667,7 +1667,7 @@ class PySecBufferDesc:
16671667
Version: Incomplete
16681668
Buffer: Incomplete
16691669
def append(self, buffer, /) -> None: ...
1670-
def __getitem__(self, index: SupportsIndex) -> PySecBuffer: ...
1670+
def __getitem__(self, index: SupportsIndex, /) -> PySecBuffer: ...
16711671

16721672
class PyTOKEN_GROUPS: ...
16731673
class PyTOKEN_PRIVILEGES: ...

stubs/shapely/shapely/geometry/base.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ class BaseGeometry(Geometry):
6363
def __xor__(self, other: OptGeoArrayLikeSeq) -> GeoArray: ...
6464
@overload
6565
def __xor__(self, other: None) -> None: ...
66-
def __eq__(self, other: object) -> bool: ...
67-
def __ne__(self, other: object) -> bool: ...
66+
def __eq__(self, other: object, /) -> bool: ...
67+
def __ne__(self, other: object, /) -> bool: ...
6868
def __hash__(self) -> int: ...
6969
@property
7070
def coords(self) -> CoordinateSequence: ...

0 commit comments

Comments
 (0)