Fix dunder-method positional-only parameter discrepancies in third-party stubs (#14529)

This commit is contained in:
Brian Schubert
2025-08-08 06:12:44 -04:00
committed by GitHub
parent 2e3203fdff
commit 11907e2825
11 changed files with 113 additions and 99 deletions
@@ -4,4 +4,4 @@ class AttributeGetter:
def __init__(self, attributes: dict[str, Any] | None = None) -> None: ...
# This doesn't exist at runtime, but subclasses should define their own fields populated by attributes in __init__
# Until that's done, keep __getattribute__ to fill in the gaps
def __getattribute__(self, name: str) -> Any: ...
def __getattribute__(self, name: str, /) -> Any: ...
+16 -14
View File
@@ -62,30 +62,32 @@ class Lib:
@final
class _CDataBase:
__name__: ClassVar[str]
def __add__(self, other): ...
def __add__(self, other, /): ...
def __bool__(self) -> bool: ...
def __call__(self, *args, **kwargs): ...
def __complex__(self) -> complex: ...
def __delitem__(self, other) -> None: ...
def __delitem__(self, other, /) -> None: ...
def __dir__(self): ...
def __enter__(self): ...
def __eq__(self, other): ...
def __exit__(self, type: type[BaseException] | None, value: BaseException | None, traceback: types.TracebackType | None): ...
def __eq__(self, other, /): ...
def __exit__(
self, type: type[BaseException] | None, value: BaseException | None, traceback: types.TracebackType | None, /
): ...
def __float__(self) -> float: ...
def __ge__(self, other): ...
def __getitem__(self, index: SupportsIndex | slice): ...
def __gt__(self, other): ...
def __ge__(self, other, /): ...
def __getitem__(self, index: SupportsIndex | slice, /): ...
def __gt__(self, other, /): ...
def __hash__(self) -> int: ...
def __int__(self) -> int: ...
def __iter__(self): ...
def __le__(self, other): ...
def __le__(self, other, /): ...
def __len__(self) -> int: ...
def __lt__(self, other): ...
def __ne__(self, other): ...
def __radd__(self, other): ...
def __rsub__(self, other): ...
def __setitem__(self, index: SupportsIndex | slice, object) -> None: ...
def __sub__(self, other): ...
def __lt__(self, other, /): ...
def __ne__(self, other, /): ...
def __radd__(self, other, /): ...
def __rsub__(self, other, /): ...
def __setitem__(self, index: SupportsIndex | slice, object, /) -> None: ...
def __sub__(self, other, /): ...
@final
class buffer:
+24 -24
View File
@@ -83,29 +83,29 @@ class Value:
def __index__(self) -> int: ...
def __int__(self) -> int: ...
def __float__(self) -> float: ...
def __add__(self, other: _ValueOrNative) -> Value: ...
def __radd__(self, other: _ValueOrNative) -> Value: ...
def __sub__(self, other: _ValueOrNative) -> Value: ...
def __rsub__(self, other: _ValueOrNative) -> Value: ...
def __mul__(self, other: _ValueOrNative) -> Value: ...
def __rmul__(self, other: _ValueOrNative) -> Value: ...
def __truediv__(self, other: _ValueOrNative) -> Value: ...
def __rtruediv__(self, other: _ValueOrNative) -> Value: ...
def __mod__(self, other: _ValueOrNative) -> Value: ...
def __rmod__(self, other: _ValueOrNative) -> Value: ...
def __pow__(self, other: _ValueOrNative, mod: None = None) -> Value: ...
def __and__(self, other: _ValueOrNative) -> Value: ...
def __or__(self, other: _ValueOrNative) -> Value: ...
def __xor__(self, other: _ValueOrNative) -> Value: ...
def __lshift__(self, other: _ValueOrNative) -> Value: ...
def __rshift__(self, other: _ValueOrNative) -> Value: ...
def __eq__(self, other: _ValueOrNative) -> bool: ... # type: ignore[override]
def __ne__(self, other: _ValueOrNative) -> bool: ... # type: ignore[override]
def __lt__(self, other: _ValueOrNative) -> bool: ...
def __le__(self, other: _ValueOrNative) -> bool: ...
def __gt__(self, other: _ValueOrNative) -> bool: ...
def __ge__(self, other: _ValueOrNative) -> bool: ...
def __getitem__(self, key: int | str | Field) -> Value: ...
def __add__(self, other: _ValueOrNative, /) -> Value: ...
def __radd__(self, other: _ValueOrNative, /) -> Value: ...
def __sub__(self, other: _ValueOrNative, /) -> Value: ...
def __rsub__(self, other: _ValueOrNative, /) -> Value: ...
def __mul__(self, other: _ValueOrNative, /) -> Value: ...
def __rmul__(self, other: _ValueOrNative, /) -> Value: ...
def __truediv__(self, other: _ValueOrNative, /) -> Value: ...
def __rtruediv__(self, other: _ValueOrNative, /) -> Value: ...
def __mod__(self, other: _ValueOrNative, /) -> Value: ...
def __rmod__(self, other: _ValueOrNative, /) -> Value: ...
def __pow__(self, other: _ValueOrNative, mod: None = None, /) -> Value: ...
def __and__(self, other: _ValueOrNative, /) -> Value: ...
def __or__(self, other: _ValueOrNative, /) -> Value: ...
def __xor__(self, other: _ValueOrNative, /) -> Value: ...
def __lshift__(self, other: _ValueOrNative, /) -> Value: ...
def __rshift__(self, other: _ValueOrNative, /) -> Value: ...
def __eq__(self, other: _ValueOrNative, /) -> bool: ... # type: ignore[override]
def __ne__(self, other: _ValueOrNative, /) -> bool: ... # type: ignore[override]
def __lt__(self, other: _ValueOrNative, /) -> bool: ...
def __le__(self, other: _ValueOrNative, /) -> bool: ...
def __gt__(self, other: _ValueOrNative, /) -> bool: ...
def __ge__(self, other: _ValueOrNative, /) -> bool: ...
def __getitem__(self, key: int | str | Field, /) -> Value: ...
def __call__(self, *args: _ValueOrNative) -> Value: ...
def __init__(self, val: _ValueOrNative) -> None: ...
def cast(self, type: Type) -> Value: ...
@@ -175,7 +175,7 @@ class Type(Mapping[str, Field]):
def get(self, key: str, default: Any = ...) -> Field | Any: ...
def has_key(self, key: str) -> bool: ...
def __len__(self) -> int: ...
def __getitem__(self, key: str) -> Field: ...
def __getitem__(self, key: str, /) -> Field: ...
def __iter__(self) -> TypeIterator[str]: ...
_T = TypeVar("_T")
+3 -3
View File
@@ -4,8 +4,8 @@ from typing_extensions import Self
class local:
def __init__(self, *args: object, **kwargs: object) -> None: ...
def __copy__(self) -> Self: ...
def __getattribute__(self, name: str) -> Any: ...
def __delattr__(self, name: str) -> None: ...
def __setattr__(self, name: str, value: Any) -> None: ...
def __getattribute__(self, name: str, /) -> Any: ...
def __delattr__(self, name: str, /) -> None: ...
def __setattr__(self, name: str, value: Any, /) -> None: ...
__all__ = ["local"]
+2 -2
View File
@@ -8,8 +8,8 @@ class ResultRow:
def __len__(self) -> int: ...
@overload
def __getitem__(self, index: int) -> Any: ...
def __getitem__(self, index: int, /) -> Any: ...
@overload
def __getitem__(self, index: slice) -> Sequence[Any]: ...
def __getitem__(self, index: slice, /) -> Sequence[Any]: ...
def __iter__(self) -> Iterator[Any]: ...
# __next__, __delitem__, __setitem__ are technically defined but lead always to an error
+18 -6
View File
@@ -1,7 +1,19 @@
from enum import Enum
import sys
class ExchangeType(Enum):
direct = "direct"
fanout = "fanout"
headers = "headers"
topic = "topic"
if sys.version_info >= (3, 11):
from enum import StrEnum
class ExchangeType(StrEnum):
direct = "direct"
fanout = "fanout"
headers = "headers"
topic = "topic"
else:
from enum import Enum
class ExchangeType(str, Enum):
direct = "direct"
fanout = "fanout"
headers = "headers"
topic = "topic"
+38 -38
View File
@@ -78,18 +78,18 @@ class EnumValueDescriptor:
@final
class ExtensionDict:
def __contains__(self, other) -> bool: ...
def __delitem__(self, other) -> None: ...
def __eq__(self, other: object) -> bool: ...
def __ge__(self, other: object) -> bool: ...
def __getitem__(self, index): ...
def __gt__(self, other: object) -> bool: ...
def __contains__(self, other, /) -> bool: ...
def __delitem__(self, other, /) -> None: ...
def __eq__(self, other: object, /) -> bool: ...
def __ge__(self, other: object, /) -> bool: ...
def __getitem__(self, index, /): ...
def __gt__(self, other: object, /) -> bool: ...
def __iter__(self): ...
def __le__(self, other: object) -> bool: ...
def __le__(self, other: object, /) -> bool: ...
def __len__(self) -> int: ...
def __lt__(self, other: object) -> bool: ...
def __ne__(self, other: object) -> bool: ...
def __setitem__(self, index, object) -> None: ...
def __lt__(self, other: object, /) -> bool: ...
def __ne__(self, other: object, /) -> bool: ...
def __setitem__(self, index, object, /) -> None: ...
@final
class ExtensionIterator:
@@ -201,16 +201,16 @@ class Message:
def SetInParent(self): ...
def UnknownFields(self): ...
def WhichOneof(self, object, /): ...
def __contains__(self, other) -> bool: ...
def __contains__(self, other, /) -> bool: ...
def __deepcopy__(self, memo=None): ...
def __delattr__(self, name): ...
def __eq__(self, other: object) -> bool: ...
def __ge__(self, other: object) -> bool: ...
def __gt__(self, other: object) -> bool: ...
def __le__(self, other: object) -> bool: ...
def __lt__(self, other: object) -> bool: ...
def __ne__(self, other: object) -> bool: ...
def __setattr__(self, name, value): ...
def __delattr__(self, name, /): ...
def __eq__(self, other: object, /) -> bool: ...
def __ge__(self, other: object, /) -> bool: ...
def __gt__(self, other: object, /) -> bool: ...
def __le__(self, other: object, /) -> bool: ...
def __lt__(self, other: object, /) -> bool: ...
def __ne__(self, other: object, /) -> bool: ...
def __setattr__(self, name, value, /): ...
@final
class MessageMeta(type): ...
@@ -253,16 +253,16 @@ class RepeatedCompositeContainer:
def reverse(self): ...
def sort(self, *args, **kwargs): ... # incomplete
def __deepcopy__(self, memo=None): ...
def __delitem__(self, other) -> None: ...
def __eq__(self, other: object) -> bool: ...
def __ge__(self, other: object) -> bool: ...
def __getitem__(self, index): ...
def __gt__(self, other: object) -> bool: ...
def __le__(self, other: object) -> bool: ...
def __delitem__(self, other, /) -> None: ...
def __eq__(self, other: object, /) -> bool: ...
def __ge__(self, other: object, /) -> bool: ...
def __getitem__(self, index, /): ...
def __gt__(self, other: object, /) -> bool: ...
def __le__(self, other: object, /) -> bool: ...
def __len__(self) -> int: ...
def __lt__(self, other: object) -> bool: ...
def __ne__(self, other: object) -> bool: ...
def __setitem__(self, index, object) -> None: ...
def __lt__(self, other: object, /) -> bool: ...
def __ne__(self, other: object, /) -> bool: ...
def __setitem__(self, index, object, /) -> None: ...
@final
class RepeatedScalarContainer:
@@ -276,17 +276,17 @@ class RepeatedScalarContainer:
def reverse(self): ...
def sort(self, *args, **kwargs): ... # incomplete
def __deepcopy__(self, memo=None): ...
def __delitem__(self, other) -> None: ...
def __eq__(self, other: object) -> bool: ...
def __ge__(self, other: object) -> bool: ...
def __getitem__(self, index): ...
def __gt__(self, other: object) -> bool: ...
def __le__(self, other: object) -> bool: ...
def __delitem__(self, other, /) -> None: ...
def __eq__(self, other: object, /) -> bool: ...
def __ge__(self, other: object, /) -> bool: ...
def __getitem__(self, index, /): ...
def __gt__(self, other: object, /) -> bool: ...
def __le__(self, other: object, /) -> bool: ...
def __len__(self) -> int: ...
def __lt__(self, other: object) -> bool: ...
def __ne__(self, other: object) -> bool: ...
def __lt__(self, other: object, /) -> bool: ...
def __ne__(self, other: object, /) -> bool: ...
def __reduce__(self): ...
def __setitem__(self, index, object) -> None: ...
def __setitem__(self, index, object, /) -> None: ...
@final
class ServiceDescriptor:
@@ -304,7 +304,7 @@ class ServiceDescriptor:
@final
class UnknownFieldSet:
def __init__(self, *args, **kwargs) -> None: ... # incomplete
def __getitem__(self, index): ...
def __getitem__(self, index, /): ...
def __len__(self) -> int: ...
def SetAllowOversizeProtos(object, /): ... # incomplete
+2 -2
View File
@@ -209,7 +209,7 @@ class Column:
def __len__(self) -> int: ...
def __lt__(self, other, /): ...
def __ne__(self, other, /): ...
def __setstate__(self, state): ...
def __setstate__(self, state, /): ...
class ConnectionInfo:
# Note: the following properties can be None if their corresponding libpq function
@@ -277,7 +277,7 @@ class Error(Exception):
pgerror: str | None
def __init__(self, *args, **kwargs) -> None: ...
def __reduce__(self): ...
def __setstate__(self, state): ...
def __setstate__(self, state, /): ...
class DatabaseError(Error): ...
class DataError(DatabaseError): ...
+1 -1
View File
@@ -1667,7 +1667,7 @@ class PySecBufferDesc:
Version: Incomplete
Buffer: Incomplete
def append(self, buffer, /) -> None: ...
def __getitem__(self, index: SupportsIndex) -> PySecBuffer: ...
def __getitem__(self, index: SupportsIndex, /) -> PySecBuffer: ...
class PyTOKEN_GROUPS: ...
class PyTOKEN_PRIVILEGES: ...
+2 -2
View File
@@ -63,8 +63,8 @@ class BaseGeometry(Geometry):
def __xor__(self, other: OptGeoArrayLikeSeq) -> GeoArray: ...
@overload
def __xor__(self, other: None) -> None: ...
def __eq__(self, other: object) -> bool: ...
def __ne__(self, other: object) -> bool: ...
def __eq__(self, other: object, /) -> bool: ...
def __ne__(self, other: object, /) -> bool: ...
def __hash__(self) -> int: ...
@property
def coords(self) -> CoordinateSequence: ...
+6 -6
View File
@@ -144,12 +144,12 @@ registry: list[type[Geometry]]
class Geometry:
def __hash__(self) -> int: ...
def __eq__(self, other: object) -> bool: ...
def __ne__(self, other: object) -> bool: ...
def __ge__(self, other: Never) -> bool: ...
def __gt__(self, other: Never) -> bool: ...
def __le__(self, other: Never) -> bool: ...
def __lt__(self, other: Never) -> bool: ...
def __eq__(self, other: object, /) -> bool: ...
def __ne__(self, other: object, /) -> bool: ...
def __ge__(self, other: Never, /) -> bool: ...
def __gt__(self, other: Never, /) -> bool: ...
def __le__(self, other: Never, /) -> bool: ...
def __lt__(self, other: Never, /) -> bool: ...
@final
class STRtree: