diff --git a/requirements-tests.txt b/requirements-tests.txt index 862278cccb52..293e12c6fa21 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -1,6 +1,6 @@ # Type checkers that we test our stubs against. These should always # be pinned to a specific version to make failure reproducible. -mypy==1.17.1 +mypy==1.18.1 pyright==1.1.405 # Libraries used by our various scripts. diff --git a/stubs/Authlib/@tests/stubtest_allowlist.txt b/stubs/Authlib/@tests/stubtest_allowlist.txt index 535d2f1b5e6a..8f5458773f6c 100644 --- a/stubs/Authlib/@tests/stubtest_allowlist.txt +++ b/stubs/Authlib/@tests/stubtest_allowlist.txt @@ -1,15 +1,5 @@ # TODO: check these entries authlib.jose.drafts._jwe_enc_cryptodome -authlib.oauth2.OAuth2Client.client_auth_class -authlib.oauth2.OAuth2Client.oauth_error_class -authlib.oauth2.OAuth2Client.token_auth_class -authlib.oauth2.client.OAuth2Client.client_auth_class -authlib.oauth2.client.OAuth2Client.oauth_error_class -authlib.oauth2.client.OAuth2Client.token_auth_class -authlib.oauth2.rfc7521.AssertionClient.oauth_error_class -authlib.oauth2.rfc7521.client.AssertionClient.oauth_error_class -authlib.oauth2.rfc7523.JWTBearerTokenValidator.token_cls -authlib.oauth2.rfc7523.validator.JWTBearerTokenValidator.token_cls # Are set to `None` by default, initialized later: authlib.jose.drafts._jwe_algorithms.ECDH1PUAlgorithm.description diff --git a/stubs/PyMySQL/@tests/stubtest_allowlist.txt b/stubs/PyMySQL/@tests/stubtest_allowlist.txt index e7a8053fb866..688b3058dbd2 100644 --- a/stubs/PyMySQL/@tests/stubtest_allowlist.txt +++ b/stubs/PyMySQL/@tests/stubtest_allowlist.txt @@ -1,3 +1,7 @@ # DictCursorMixin changes method types of inherited classes, but doesn't contain much at runtime pymysql.cursors.DictCursorMixin.__iter__ pymysql.cursors.DictCursorMixin.fetch[a-z]* + +# FIXME: new stubtest errors from mypy v1.18.1 that need to be looked at more closely. +# See https://github.com/python/typeshed/pull/14699 +pymysql.connections.Connection.__init__ diff --git a/stubs/cffi/_cffi_backend.pyi b/stubs/cffi/_cffi_backend.pyi index 25e444825ada..7362010e2049 100644 --- a/stubs/cffi/_cffi_backend.pyi +++ b/stubs/cffi/_cffi_backend.pyi @@ -3,7 +3,7 @@ import types from _typeshed import Incomplete, ReadableBuffer, WriteableBuffer from collections.abc import Callable, Hashable from typing import Any, ClassVar, Literal, Protocol, SupportsIndex, TypeVar, final, overload, type_check_only -from typing_extensions import TypeAlias +from typing_extensions import Self, TypeAlias _T = TypeVar("_T") @@ -92,7 +92,7 @@ class _CDataBase: @final class buffer: __hash__: ClassVar[None] # type: ignore[assignment] - def __init__(self, *args, **kwargs) -> None: ... + def __new__(cls, *args, **kwargs) -> Self: ... def __buffer__(self, flags: int, /) -> memoryview: ... def __delitem__(self, other, /) -> None: ... def __eq__(self, other, /): ... diff --git a/stubs/django-filter/@tests/stubtest_allowlist.txt b/stubs/django-filter/@tests/stubtest_allowlist.txt index 4a0cd56cafbd..c07147364eeb 100644 --- a/stubs/django-filter/@tests/stubtest_allowlist.txt +++ b/stubs/django-filter/@tests/stubtest_allowlist.txt @@ -1,9 +1,3 @@ -# Iterator class attributes: Runtime behavior differs due to Django 5.0 compatibility logic in choice setters -django_filters.fields.ChoiceField.iterator -django_filters.fields.ModelChoiceField.iterator -django_filters.fields.ModelMultipleChoiceField.iterator -django_filters.fields.MultipleChoiceField.iterator - # Lookup NamedTuple: Parameter name mismatch between inferred stub and runtime django_filters.fields.Lookup.__new__ django_filters.fields.Lookup.__doc__ @@ -20,3 +14,7 @@ django_filters.fields.MultipleChoiceField.__init__ django_filters.fields.RangeField.__init__ django_filters.filters.QuerySetRequestMixin.__init__ django_filters.widgets.CSVWidget.__init__ + +# FIXME: new stubtest errors from mypy v1.18.1 that need to be looked at more closely. +# See https://github.com/python/typeshed/pull/14699 +django_filters(\.\w+)*\.OrderingFilter.field_class diff --git a/stubs/docutils/@tests/stubtest_allowlist.txt b/stubs/docutils/@tests/stubtest_allowlist.txt index 5e747c6670f6..2760c63b104d 100644 --- a/stubs/docutils/@tests/stubtest_allowlist.txt +++ b/stubs/docutils/@tests/stubtest_allowlist.txt @@ -36,3 +36,9 @@ docutils.readers.TYPE_CHECKING docutils.utils.TYPE_CHECKING docutils.writers.TYPE_CHECKING docutils.writers._html_base.TYPE_CHECKING + +# FIXME: new stubtest errors from mypy v1.18.1 that need to be looked at more closely. +# See https://github.com/python/typeshed/pull/14699 +docutils\.nodes\.\w+\.content_model +docutils.parsers.docutils_xml.Unknown.content_model +docutils.transforms.universal.SmartQuotes.nodes_to_skip diff --git a/stubs/docutils/docutils/nodes.pyi b/stubs/docutils/docutils/nodes.pyi index d3607e94a531..05e07d976717 100644 --- a/stubs/docutils/docutils/nodes.pyi +++ b/stubs/docutils/docutils/nodes.pyi @@ -112,7 +112,6 @@ class Text(Node, str): # we omit the rawsource parameter because it has been deprecated and is ignored def __new__(cls, data: str) -> Self: ... - def __init__(self, data: str) -> None: ... def shortrepr(self, maxlen: int = 18) -> str: ... def copy(self) -> Self: ... def deepcopy(self) -> Self: ... diff --git a/stubs/gevent/gevent/local.pyi b/stubs/gevent/gevent/local.pyi index 30b149cbf3c5..ac2642fbe6a9 100644 --- a/stubs/gevent/gevent/local.pyi +++ b/stubs/gevent/gevent/local.pyi @@ -11,7 +11,7 @@ class local: "_local_type", "_local_type_set_or_del_descriptors", ) - def __init__(self, *args: object, **kwargs: object) -> None: ... + def __new__(cls, *args: object, **kwargs: object) -> Self: ... def __copy__(self) -> Self: ... def __getattribute__(self, name: str, /) -> Any: ... def __delattr__(self, name: str, /) -> None: ... diff --git a/stubs/grpcio/grpc/aio/__init__.pyi b/stubs/grpcio/grpc/aio/__init__.pyi index 04d98877f7d9..092f87080a72 100644 --- a/stubs/grpcio/grpc/aio/__init__.pyi +++ b/stubs/grpcio/grpc/aio/__init__.pyi @@ -248,14 +248,14 @@ class ServicerContext(Generic[_TRequest, _TResponse], metaclass=abc.ABCMeta): # Client-Side Interceptor: class ClientCallDetails(abc.ABC): - def __init__( - self, + def __new__( + _cls, method: str, timeout: float | None, metadata: Metadata | None, credentials: CallCredentials | None, wait_for_ready: bool | None, - ) -> None: ... + ) -> Self: ... method: str timeout: float | None diff --git a/stubs/hvac/@tests/stubtest_allowlist.txt b/stubs/hvac/@tests/stubtest_allowlist.txt deleted file mode 100644 index 76a1cde4de00..000000000000 --- a/stubs/hvac/@tests/stubtest_allowlist.txt +++ /dev/null @@ -1,3 +0,0 @@ -# stubtest does not understand that the adapter argument type is an adapter and not abc.ABC -hvac.Client.__init__ -hvac.v1.Client.__init__ diff --git a/stubs/icalendar/@tests/stubtest_allowlist.txt b/stubs/icalendar/@tests/stubtest_allowlist.txt index 517487d97d7d..086f94be4c60 100644 --- a/stubs/icalendar/@tests/stubtest_allowlist.txt +++ b/stubs/icalendar/@tests/stubtest_allowlist.txt @@ -13,12 +13,3 @@ icalendar.cal.Component.set_inline # Stubtest gets confused by multiple inheritance. icalendar.prop.vSkip.__new__ icalendar.vSkip.__new__ - -# Stubtest incorrectly reports that stub argument "cls" should be -# positional or keyword. -icalendar.vBoolean.__new__ -icalendar.vFloat.__new__ -icalendar.vInt.__new__ -icalendar.prop.vBoolean.__new__ -icalendar.prop.vFloat.__new__ -icalendar.prop.vInt.__new__ diff --git a/stubs/lupa/lupa/lua51.pyi b/stubs/lupa/lupa/lua51.pyi index 3d4de040e93d..a46b772bec38 100644 --- a/stubs/lupa/lupa/lua51.pyi +++ b/stubs/lupa/lupa/lua51.pyi @@ -1,7 +1,7 @@ from _typeshed import MaybeNone from collections.abc import Callable, Iterable from typing import Any, Final, Generic, TypeVar, type_check_only -from typing_extensions import TypeAlias +from typing_extensions import Self, TypeAlias __all__ = [ "LUA_VERSION", @@ -78,7 +78,7 @@ class LuaRuntime: lua_implementation: Final[str] lua_version: Final[tuple[int, int]] - def __init__(self, /, unpack_returned_tuples: bool) -> None: ... + def __new__(cls, /, unpack_returned_tuples: bool) -> Self: ... # def add_pending_unref(self, ref: int) -> None: ... # def clean_up_pending_unrefs(self) -> int: ... def get_max_memory(self, total: bool = False) -> int | MaybeNone: ... diff --git a/stubs/lupa/lupa/lua52.pyi b/stubs/lupa/lupa/lua52.pyi index 3d4de040e93d..a46b772bec38 100644 --- a/stubs/lupa/lupa/lua52.pyi +++ b/stubs/lupa/lupa/lua52.pyi @@ -1,7 +1,7 @@ from _typeshed import MaybeNone from collections.abc import Callable, Iterable from typing import Any, Final, Generic, TypeVar, type_check_only -from typing_extensions import TypeAlias +from typing_extensions import Self, TypeAlias __all__ = [ "LUA_VERSION", @@ -78,7 +78,7 @@ class LuaRuntime: lua_implementation: Final[str] lua_version: Final[tuple[int, int]] - def __init__(self, /, unpack_returned_tuples: bool) -> None: ... + def __new__(cls, /, unpack_returned_tuples: bool) -> Self: ... # def add_pending_unref(self, ref: int) -> None: ... # def clean_up_pending_unrefs(self) -> int: ... def get_max_memory(self, total: bool = False) -> int | MaybeNone: ... diff --git a/stubs/lupa/lupa/lua53.pyi b/stubs/lupa/lupa/lua53.pyi index 3d4de040e93d..a46b772bec38 100644 --- a/stubs/lupa/lupa/lua53.pyi +++ b/stubs/lupa/lupa/lua53.pyi @@ -1,7 +1,7 @@ from _typeshed import MaybeNone from collections.abc import Callable, Iterable from typing import Any, Final, Generic, TypeVar, type_check_only -from typing_extensions import TypeAlias +from typing_extensions import Self, TypeAlias __all__ = [ "LUA_VERSION", @@ -78,7 +78,7 @@ class LuaRuntime: lua_implementation: Final[str] lua_version: Final[tuple[int, int]] - def __init__(self, /, unpack_returned_tuples: bool) -> None: ... + def __new__(cls, /, unpack_returned_tuples: bool) -> Self: ... # def add_pending_unref(self, ref: int) -> None: ... # def clean_up_pending_unrefs(self) -> int: ... def get_max_memory(self, total: bool = False) -> int | MaybeNone: ... diff --git a/stubs/lupa/lupa/lua54.pyi b/stubs/lupa/lupa/lua54.pyi index 3d4de040e93d..a46b772bec38 100644 --- a/stubs/lupa/lupa/lua54.pyi +++ b/stubs/lupa/lupa/lua54.pyi @@ -1,7 +1,7 @@ from _typeshed import MaybeNone from collections.abc import Callable, Iterable from typing import Any, Final, Generic, TypeVar, type_check_only -from typing_extensions import TypeAlias +from typing_extensions import Self, TypeAlias __all__ = [ "LUA_VERSION", @@ -78,7 +78,7 @@ class LuaRuntime: lua_implementation: Final[str] lua_version: Final[tuple[int, int]] - def __init__(self, /, unpack_returned_tuples: bool) -> None: ... + def __new__(cls, /, unpack_returned_tuples: bool) -> Self: ... # def add_pending_unref(self, ref: int) -> None: ... # def clean_up_pending_unrefs(self) -> int: ... def get_max_memory(self, total: bool = False) -> int | MaybeNone: ... diff --git a/stubs/networkx/@tests/stubtest_allowlist.txt b/stubs/networkx/@tests/stubtest_allowlist.txt index 16085bf5b6c6..b53baec2a0d1 100644 --- a/stubs/networkx/@tests/stubtest_allowlist.txt +++ b/stubs/networkx/@tests/stubtest_allowlist.txt @@ -37,6 +37,3 @@ networkx\._typing # "..._DT is not present at runtime" but we don't set it in stubs, I don't understand this one networkx(\.algorithms)?(\.tree)?(\.mst)?\.SpanningTreeIterator\.Partition\._DT networkx(\.algorithms)?(\.tree)?(\.branchings)?\.ArborescenceIterator\.Partition\._DT - -# variable differs from runtime type abc.ABCMeta -networkx\.classes\.reportviews\.\w*EdgeView\.dataview diff --git a/stubs/openpyxl/@tests/stubtest_allowlist.txt b/stubs/openpyxl/@tests/stubtest_allowlist.txt index d548945f4d0c..a01ce24b836c 100644 --- a/stubs/openpyxl/@tests/stubtest_allowlist.txt +++ b/stubs/openpyxl/@tests/stubtest_allowlist.txt @@ -26,14 +26,6 @@ openpyxl.descriptors.nested.NestedMinMax.__get__ openpyxl.descriptors.nested.NestedText.__get__ openpyxl.descriptors.nested.NestedValue.__get__ -# Stubtest sees and type[T] as different: https://github.com/python/mypy/issues/13316 -openpyxl.chart.descriptors.NumberFormatDescriptor.expected_type -openpyxl.chart.title.TitleDescriptor.expected_type -openpyxl.drawing.colors.ColorChoiceDescriptor.expected_type -openpyxl.packaging.relationship.RelationshipList.expected_type -openpyxl.styles.colors.ColorDescriptor.expected_type -openpyxl.styles.fills.StopList.expected_type - # Stubtest doesn't like generics here openpyxl\.descriptors\.(base\.)?Bool\.allow_none openpyxl\.descriptors\.(base\.)?DateTime\.allow_none @@ -195,3 +187,7 @@ openpyxl.worksheet.smart_tag.CellSmartTagPr.__init__ openpyxl.worksheet.smart_tag.CellSmartTags.__init__ openpyxl.worksheet.table.TableColumn.__init__ openpyxl.worksheet.table.XMLColumnProps.__init__ + +# FIXME: new stubtest errors from mypy v1.18.1 that need to be looked at more closely. +# See https://github.com/python/typeshed/pull/14699 +openpyxl.descriptors.sequence.UniqueSequence.seq_types diff --git a/stubs/openpyxl/openpyxl/styles/cell_style.pyi b/stubs/openpyxl/openpyxl/styles/cell_style.pyi index 6852b377d20b..dc7f6c278449 100644 --- a/stubs/openpyxl/openpyxl/styles/cell_style.pyi +++ b/stubs/openpyxl/openpyxl/styles/cell_style.pyi @@ -31,7 +31,6 @@ class StyleArray(array[int]): quotePrefix: ArrayDescriptor[int] xfId: ArrayDescriptor[int] def __new__(cls, args: bytes | bytearray | Iterable[int] = [0, 0, 0, 0, 0, 0, 0, 0, 0]) -> Self: ... - def __init__(self, args: bytes | bytearray | Iterable[int] = [0, 0, 0, 0, 0, 0, 0, 0, 0]) -> None: ... def __hash__(self) -> int: ... # type: ignore[override] def __copy__(self) -> StyleArray: ... def __deepcopy__(self, memo: Unused) -> StyleArray: ... diff --git a/stubs/pika/@tests/stubtest_allowlist.txt b/stubs/pika/@tests/stubtest_allowlist.txt index dd96c9e0e66c..954ad6ddc224 100644 --- a/stubs/pika/@tests/stubtest_allowlist.txt +++ b/stubs/pika/@tests/stubtest_allowlist.txt @@ -1,10 +1,3 @@ -# Stubtest doesn't understand that a property alias is also read-only. -# https://github.com/python/mypy/issues/6700 -pika(\.adapters)?(\.blocking_connection)?\.BlockingConnection\.basic_nack -pika(\.adapters)?(\.blocking_connection)?\.BlockingConnection\.consumer_cancel_notify -pika(\.adapters)?(\.blocking_connection)?\.BlockingConnection\.exchange_exchange_bindings -pika(\.adapters)?(\.blocking_connection)?\.BlockingConnection\.publisher_confirms - # The implementation has defaults for the arguments that would make the # created instances unusable, so we require the arguments in the stub. pika.spec.Queue.DeclareOk.__init__ diff --git a/stubs/protobuf/google/_upb/_message.pyi b/stubs/protobuf/google/_upb/_message.pyi index dd741f8a034c..3ebfc2808dd8 100644 --- a/stubs/protobuf/google/_upb/_message.pyi +++ b/stubs/protobuf/google/_upb/_message.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete from typing import ClassVar, final +from typing_extensions import Self default_pool: DescriptorPool @@ -28,14 +29,14 @@ class Descriptor: nested_types_by_name: Incomplete oneofs: Incomplete oneofs_by_name: Incomplete - def __init__(self, *args, **kwargs) -> None: ... # incomplete + def __new__(cls, *args, **kwargs) -> Self: ... # incomplete def CopyToProto(self, object, /): ... def EnumValueName(self, *args, **kwargs): ... # incomplete def GetOptions(self): ... @final class DescriptorPool: - def __init__(self, *args, **kwargs) -> None: ... # incomplete + def __new__(cls, *args, **kwargs) -> Self: ... # incomplete def Add(self, object, /): ... def AddSerializedFile(self, object, /): ... def FindAllExtensions(self, object, /): ... @@ -62,7 +63,7 @@ class EnumDescriptor: values: Incomplete values_by_name: Incomplete values_by_number: Incomplete - def __init__(self, *args, **kwargs) -> None: ... # incomplete + def __new__(cls, *args, **kwargs) -> Self: ... # incomplete def CopyToProto(self, object, /): ... def GetOptions(self): ... @@ -73,7 +74,7 @@ class EnumValueDescriptor: name: Incomplete number: Incomplete type: Incomplete - def __init__(self, *args, **kwargs) -> None: ... # incomplete + def __new__(cls, *args, **kwargs) -> Self: ... # incomplete def GetOptions(self): ... @final @@ -151,7 +152,7 @@ class FieldDescriptor: name: Incomplete number: Incomplete type: Incomplete - def __init__(self, *args, **kwargs) -> None: ... # incomplete + def __new__(cls, *args, **kwargs) -> Self: ... # incomplete def GetOptions(self): ... @final @@ -167,7 +168,7 @@ class FileDescriptor: public_dependencies: Incomplete serialized_pb: Incomplete services_by_name: Incomplete - def __init__(self, *args, **kwargs) -> None: ... # incomplete + def __new__(cls, *args, **kwargs) -> Self: ... # incomplete def CopyToProto(self, object, /): ... def GetOptions(self): ... @@ -179,7 +180,7 @@ class MapIterator: @final class Message: Extensions: Incomplete - def __init__(self, *args, **kwargs) -> None: ... # incomplete # incomplete + def __init__(self, *args, **kwargs) -> None: ... # incomplete def ByteSize(self): ... def Clear(self): ... def ClearExtension(self, object, /): ... @@ -225,7 +226,7 @@ class MethodDescriptor: name: Incomplete output_type: Incomplete server_streaming: Incomplete - def __init__(self, *args, **kwargs) -> None: ... # incomplete + def __new__(cls, *args, **kwargs) -> Self: ... # incomplete def CopyToProto(self, object, /): ... def GetOptions(self): ... @@ -237,12 +238,12 @@ class OneofDescriptor: has_options: Incomplete index: Incomplete name: Incomplete - def __init__(self, *args, **kwargs) -> None: ... # incomplete + def __new__(cls, *args, **kwargs) -> Self: ... # incomplete def GetOptions(self): ... @final class RepeatedCompositeContainer: - def __init__(self, *args, **kwargs) -> None: ... # incomplete + def __new__(cls, *args, **kwargs) -> Self: ... # incomplete def MergeFrom(self, object, /): ... def add(self, *args, **kwargs): ... # incomplete def append(self, object, /): ... @@ -266,7 +267,7 @@ class RepeatedCompositeContainer: @final class RepeatedScalarContainer: - def __init__(self, *args, **kwargs) -> None: ... # incomplete + def __new__(cls, *args, **kwargs) -> Self: ... # incomplete def MergeFrom(self, object, /): ... def append(self, object, /): ... def extend(self, object, /): ... @@ -296,14 +297,14 @@ class ServiceDescriptor: methods: Incomplete methods_by_name: Incomplete name: Incomplete - def __init__(self, *args, **kwargs) -> None: ... # incomplete + def __new__(cls, *args, **kwargs) -> Self: ... # incomplete def CopyToProto(self, object, /): ... def FindMethodByName(self, object, /): ... def GetOptions(self): ... @final class UnknownFieldSet: - def __init__(self, *args, **kwargs) -> None: ... # incomplete + def __new__(cls, *args, **kwargs) -> Self: ... # incomplete def __getitem__(self, index, /): ... def __len__(self) -> int: ... diff --git a/stubs/protobuf/google/protobuf/message.pyi b/stubs/protobuf/google/protobuf/message.pyi index 73eb6b411e41..5145b5330a2c 100644 --- a/stubs/protobuf/google/protobuf/message.pyi +++ b/stubs/protobuf/google/protobuf/message.pyi @@ -43,4 +43,4 @@ class Message: def ClearField(self, field_name: Any) -> None: ... def WhichOneof(self, oneof_group: Any) -> Any: ... # TODO: check kwargs - def __init__(self, *args, **kwargs) -> None: ... + def __new__(cls, *args, **kwargs) -> Self: ... diff --git a/stubs/pyasn1/@tests/stubtest_allowlist.txt b/stubs/pyasn1/@tests/stubtest_allowlist.txt deleted file mode 100644 index 2a78f0ed6873..000000000000 --- a/stubs/pyasn1/@tests/stubtest_allowlist.txt +++ /dev/null @@ -1,3 +0,0 @@ -# typeshed typing differences with runtime collections.OrderedDict and builtins.dict -pyasn1.codec.native.encoder.SequenceEncoder.protoDict -pyasn1.codec.native.encoder.SetEncoder.protoDict diff --git a/stubs/pyserial/@tests/stubtest_allowlist_win32.txt b/stubs/pyserial/@tests/stubtest_allowlist_win32.txt index 75273f1f2bc8..8e962557c5b2 100644 --- a/stubs/pyserial/@tests/stubtest_allowlist_win32.txt +++ b/stubs/pyserial/@tests/stubtest_allowlist_win32.txt @@ -10,3 +10,7 @@ serial.tools.list_ports_posix # Posix only # io.RawIOBase but at runtime they are normal arguments that don't have consistent # names. serial.serialwin32.Serial.write + +# FIXME: new stubtest errors from mypy v1.18.1 that need to be looked at more closely. +# See https://github.com/python/typeshed/pull/14699 +serial.win32.ULONG_PTR diff --git a/stubs/pywin32/_win32typing.pyi b/stubs/pywin32/_win32typing.pyi index 3dd44c61c1e1..becc168ca7f0 100644 --- a/stubs/pywin32/_win32typing.pyi +++ b/stubs/pywin32/_win32typing.pyi @@ -385,7 +385,7 @@ class PyCOMSTAT: @final class PyCOORD: - def __init__(self, X: int = ..., Y: int = ...) -> None: ... + def __new__(self, X: int = ..., Y: int = ...) -> Self: ... X: int Y: int @@ -573,7 +573,7 @@ class PyCTL_USAGE: ... @final class PyConsoleScreenBuffer: - def __init__(self, Handle) -> None: ... + def __new__(self, Handle) -> Self: ... def SetConsoleActiveScreenBuffer(self) -> None: ... def GetConsoleCursorInfo(self) -> tuple[Incomplete, Incomplete]: ... def SetConsoleCursorInfo(self, Size, Visible) -> None: ... @@ -918,7 +918,7 @@ class PyHANDLE: @final class PyHDESK: - def __init__(self, handle) -> None: ... + def __new__(self, handle) -> Self: ... def SetThreadDesktop(self) -> None: ... def EnumDesktopWindows(self) -> tuple[int, ...]: ... def SwitchDesktop(self) -> None: ... @@ -1056,7 +1056,7 @@ class PyHTHEME: ... @final class PyHWINSTA: - def __init__(self, handle) -> None: ... + def __new__(self, handle) -> Self: ... def EnumDesktops(self) -> tuple[Incomplete, ...]: ... def SetProcessWindowStation(self) -> None: ... def CloseWindowStation(self) -> None: ... @@ -1069,7 +1069,7 @@ class PyIID: ... @final class PyINPUT_RECORD: - def __init__(self, EventType: int) -> None: ... + def __new__(self, EventType: int) -> Self: ... EventType: int KeyDown: int | bool RepeatCount: int @@ -1628,7 +1628,7 @@ class PySIZE: ... @final class PySMALL_RECT: - def __init__(self, Left: int = ..., Top: int = ..., Right: int = ..., Bottom: int = ...) -> None: ... + def __new__(self, Left: int = ..., Top: int = ..., Right: int = ..., Bottom: int = ...) -> Self: ... Left: int Top: int Right: int @@ -1651,7 +1651,7 @@ class PySTARTUPINFO: lpTitle: str class PySecBuffer: - def __init__(self, BufferSize, BufferType) -> None: ... + def __new__(self, BufferSize, BufferType) -> Self: ... @property def BufferType(self): ... @property @@ -1663,7 +1663,7 @@ class PySecBuffer: def Clear(self) -> None: ... class PySecBufferDesc: - def __init__(self, Version=...) -> None: ... + def __new__(self, Version=...) -> Self: ... Version: Incomplete Buffer: Incomplete def append(self, buffer, /) -> None: ... @@ -4747,9 +4747,9 @@ class PyPROPERTYKEY: ... class PyPROPVARIANT: @overload @deprecated("Support for passing two ints to create a 64-bit value is deprecated; pass a single int instead") - def __init__(self, Value: tuple[int, int], Type=...) -> None: ... + def __new__(self, Value: tuple[int, int], Type=...) -> Self: ... @overload - def __init__(self, Value, Type=...) -> None: ... + def __new__(self, Value, Type=...) -> Self: ... @property def vt(self): ... def GetValue(self): ... diff --git a/stubs/pywin32/win32/lib/pywintypes.pyi b/stubs/pywin32/win32/lib/pywintypes.pyi index 395e911dde8e..c5f83fb354b3 100644 --- a/stubs/pywin32/win32/lib/pywintypes.pyi +++ b/stubs/pywin32/win32/lib/pywintypes.pyi @@ -17,7 +17,7 @@ class error(Exception): class com_error(Exception): ... class HANDLEType: - def __init__(self, *args: Never) -> NoReturn: ... + def __new__(self, *args: Never) -> NoReturn: ... @property def handle(self) -> int: ... def Close(self) -> None: ... diff --git a/stubs/qrcode/@tests/stubtest_allowlist.txt b/stubs/qrcode/@tests/stubtest_allowlist.txt index d7f76b7b226f..dca40d4e194f 100644 --- a/stubs/qrcode/@tests/stubtest_allowlist.txt +++ b/stubs/qrcode/@tests/stubtest_allowlist.txt @@ -11,10 +11,6 @@ qrcode._types qrcode\.make qrcode\.main\.make -# Stubtest hiccup: It doesn't recognize that the annotated type is a base -# class of the default class assigned to the attribute. -qrcode\.image\..*\.default_drawer_class - # Implementation has marked these methods as abstract without the class # or its bases deriving from abc.ABCMeta qrcode\.image\.base\.BaseImage\.(drawrect|new_image|save) diff --git a/stubs/reportlab/@tests/stubtest_allowlist.txt b/stubs/reportlab/@tests/stubtest_allowlist.txt index 859113c22aae..4d0f9ed51ff3 100644 --- a/stubs/reportlab/@tests/stubtest_allowlist.txt +++ b/stubs/reportlab/@tests/stubtest_allowlist.txt @@ -57,13 +57,6 @@ reportlab.lib.utils.CIDict.setdefault # it doesn't actually accept arbitrary arguments reportlab.platypus.doctemplate.PTCycle.__new__ -# type[Canvas] is a _CanvasMaker, for some reason stubtest trips up -reportlab.platypus.BaseDocTemplate.build -reportlab.platypus.SimpleDocTemplate.build -reportlab.platypus.doctemplate.BaseDocTemplate.build -reportlab.platypus.doctemplate.SimpleDocTemplate.build -reportlab.platypus.tableofcontents.SimpleIndex.getCanvasMaker - # Error: not present in stub # ========================== diff --git a/stubs/seaborn/@tests/stubtest_allowlist.txt b/stubs/seaborn/@tests/stubtest_allowlist.txt index 72f2518d97d1..31b226b5a849 100644 --- a/stubs/seaborn/@tests/stubtest_allowlist.txt +++ b/stubs/seaborn/@tests/stubtest_allowlist.txt @@ -1,5 +1,4 @@ seaborn._core.scales.(Pipeline|TransFuncs) # aliases defined in `if TYPE_CHECKING` block -seaborn.external.docscrape.ClassDoc.__init__ # stubtest doesn't like ABC class as default value seaborn.external.docscrape.NumpyDocString.__str__ # weird signature seaborn.axisgrid.Grid.tight_layout # the method doesn't really take pos args but runtime has *args diff --git a/stubs/shapely/shapely/lib.pyi b/stubs/shapely/shapely/lib.pyi index 33546b37d28c..4bb5146b779f 100644 --- a/stubs/shapely/shapely/lib.pyi +++ b/stubs/shapely/shapely/lib.pyi @@ -1,5 +1,5 @@ from typing import Literal, SupportsIndex, final, overload -from typing_extensions import Never +from typing_extensions import Never, Self import numpy as np from numpy.typing import NDArray @@ -154,7 +154,7 @@ class Geometry: @final class STRtree: count: int - def __init__(self, geoms: NDArray[np.object_], node_capacity: SupportsIndex, /, **kwargs: object) -> None: ... + def __new__(cls, geoms: NDArray[np.object_], node_capacity: SupportsIndex, /, **kwargs: object) -> Self: ... def dwithin(self, geoms: NDArray[np.object_], distances: NDArray[np.float64], /) -> NDArray[np.int64]: ... def nearest(self, geoms: NDArray[np.object_], /) -> NDArray[np.int64]: ... def query(self, geoms: NDArray[np.object_], predicate: SupportsIndex, /) -> NDArray[np.int64]: ... diff --git a/stubs/xlrd/xlrd/formula.pyi b/stubs/xlrd/xlrd/formula.pyi index 4ed7928003cf..4082010b5c8c 100644 --- a/stubs/xlrd/xlrd/formula.pyi +++ b/stubs/xlrd/xlrd/formula.pyi @@ -1,5 +1,4 @@ from typing import Final -from typing_extensions import Self from .book import Book, Name from .timemachine import * @@ -64,8 +63,9 @@ class Ref3D(tuple[int, int, int, int, int, int, int, int, int, int, int, int]): rowxhi: int colxlo: int colxhi: int - def __new__(cls, atuple: tuple[int, int, int, int, int, int, int, int, int, int, int, int]) -> Self: ... - def __init__(self, atuple: tuple[int, int, int, int, int, int, int, int, int, int, int, int]) -> None: ... + def __init__( # pyright: ignore[reportInconsistentConstructor] + self, atuple: tuple[int, int, int, int, int, int, int, int, int, int, int, int] + ) -> None: ... def evaluate_name_formula(bk: Book, nobj: Name, namex: str, blah: int = 0, level: int = 0) -> None: ... def decompile_formula( diff --git a/tests/stubtest_third_party.py b/tests/stubtest_third_party.py index d2ea4190bc77..8224d22fd383 100755 --- a/tests/stubtest_third_party.py +++ b/tests/stubtest_third_party.py @@ -116,6 +116,8 @@ def run_stubtest(dist: Path, *, verbose: bool = False, ci_platforms_only: bool = *packages_to_check, *modules_to_check, *allowlist_stubtest_arguments(dist_name), + # FIXME: remove once issues are fixed, refs #14699 + "--ignore-disjoint-bases", ] stubs_dir = dist.parent