diff --git a/stdlib/_typeshed/__init__.pyi b/stdlib/_typeshed/__init__.pyi index 7915a2b0b..5be4f1ee1 100644 --- a/stdlib/_typeshed/__init__.pyi +++ b/stdlib/_typeshed/__init__.pyi @@ -174,11 +174,11 @@ class SupportsWrite(Protocol[_T_contra]): def write(self, __s: _T_contra) -> Any: ... if sys.version_info >= (3,): - ReadableBuffer = Union[bytes, bytearray, memoryview, array.array, mmap.mmap] - WriteableBuffer = Union[bytearray, memoryview, array.array, mmap.mmap] + ReadableBuffer = Union[bytes, bytearray, memoryview, array.array[Any], mmap.mmap] + WriteableBuffer = Union[bytearray, memoryview, array.array[Any], mmap.mmap] else: - ReadableBuffer = Union[bytes, bytearray, memoryview, array.array, mmap.mmap, buffer] - WriteableBuffer = Union[bytearray, memoryview, array.array, mmap.mmap, buffer] + ReadableBuffer = Union[bytes, bytearray, memoryview, array.array[Any], mmap.mmap, buffer] + WriteableBuffer = Union[bytearray, memoryview, array.array[Any], mmap.mmap, buffer] if sys.version_info >= (3, 10): from types import NoneType as NoneType diff --git a/stdlib/asyncio/format_helpers.pyi b/stdlib/asyncio/format_helpers.pyi index 5f2baf7b6..5c075a910 100644 --- a/stdlib/asyncio/format_helpers.pyi +++ b/stdlib/asyncio/format_helpers.pyi @@ -7,7 +7,7 @@ from typing import Any, Dict, Iterable, Optional, Tuple, Union, overload class _HasWrapper: __wrapper__: Union[_HasWrapper, FunctionType] -_FuncType = Union[FunctionType, _HasWrapper, functools.partial, functools.partialmethod] +_FuncType = Union[FunctionType, _HasWrapper, functools.partial[Any], functools.partialmethod[Any]] if sys.version_info >= (3, 7): @overload diff --git a/stdlib/asyncio/trsock.pyi b/stdlib/asyncio/trsock.pyi index db9efb08b..0bd3f0adb 100644 --- a/stdlib/asyncio/trsock.pyi +++ b/stdlib/asyncio/trsock.pyi @@ -5,7 +5,7 @@ from typing import Any, BinaryIO, Iterable, List, NoReturn, Optional, Tuple, Typ if sys.version_info >= (3, 8): # These are based in socket, maybe move them out into _typeshed.pyi or such - _Address = Union[tuple, str] + _Address = Union[Tuple[Any, ...], str] _RetAddress = Any _WriteBuffer = Union[bytearray, memoryview] _CMSG = Tuple[int, int, bytes] diff --git a/stdlib/ctypes/__init__.pyi b/stdlib/ctypes/__init__.pyi index f06fa7396..10a4287c8 100644 --- a/stdlib/ctypes/__init__.pyi +++ b/stdlib/ctypes/__init__.pyi @@ -72,7 +72,7 @@ pythonapi: PyDLL = ... # Anything that implements the read-write buffer interface. # The buffer interface is defined purely on the C level, so we cannot define a normal Protocol # for it. Instead we have to list the most common stdlib buffer classes in a Union. -_WritableBuffer = _UnionT[bytearray, memoryview, array, _CData] +_WritableBuffer = _UnionT[bytearray, memoryview, array[Any], _CData] # Same as _WritableBuffer, but also includes read-only buffer types (like bytes). _ReadOnlyBuffer = _UnionT[_WritableBuffer, bytes] diff --git a/stdlib/fcntl.pyi b/stdlib/fcntl.pyi index 7b94c6e94..42b88d020 100644 --- a/stdlib/fcntl.pyi +++ b/stdlib/fcntl.pyi @@ -86,7 +86,7 @@ def fcntl(__fd: FileDescriptorLike, __cmd: int, __arg: int = ...) -> int: ... def fcntl(__fd: FileDescriptorLike, __cmd: int, __arg: bytes) -> bytes: ... _ReadOnlyBuffer = bytes -_WritableBuffer = Union[bytearray, memoryview, array] +_WritableBuffer = Union[bytearray, memoryview, array[Any]] @overload def ioctl(__fd: FileDescriptorLike, __request: int, __arg: int = ..., __mutate_flag: bool = ...) -> int: ... @overload diff --git a/stdlib/importlib/resources.pyi b/stdlib/importlib/resources.pyi index 65beccba8..b60ca1d6b 100644 --- a/stdlib/importlib/resources.pyi +++ b/stdlib/importlib/resources.pyi @@ -1,4 +1,5 @@ import sys +from typing import Any # This is a >=3.7 module, so we conditionally include its source. if sys.version_info >= (3, 7): @@ -8,7 +9,7 @@ if sys.version_info >= (3, 7): from typing import BinaryIO, ContextManager, Iterator, TextIO, Union Package = Union[str, ModuleType] - Resource = Union[str, os.PathLike] + Resource = Union[str, os.PathLike[Any]] def open_binary(package: Package, resource: Resource) -> BinaryIO: ... def open_text(package: Package, resource: Resource, encoding: str = ..., errors: str = ...) -> TextIO: ... def read_binary(package: Package, resource: Resource) -> bytes: ... diff --git a/stdlib/pyexpat/__init__.pyi b/stdlib/pyexpat/__init__.pyi index c8305567e..65f6b0e9f 100644 --- a/stdlib/pyexpat/__init__.pyi +++ b/stdlib/pyexpat/__init__.pyi @@ -19,7 +19,7 @@ XML_PARAM_ENTITY_PARSING_NEVER: int XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE: int XML_PARAM_ENTITY_PARSING_ALWAYS: int -_Model = Tuple[int, int, Optional[str], tuple] +_Model = Tuple[int, int, Optional[str], Tuple[Any, ...]] class XMLParserType(object): def Parse(self, __data: Union[Text, bytes], __isfinal: bool = ...) -> int: ... diff --git a/stdlib/socket.pyi b/stdlib/socket.pyi index da8fbcf56..1d315fc12 100644 --- a/stdlib/socket.pyi +++ b/stdlib/socket.pyi @@ -604,7 +604,7 @@ class timeout(error): # Addresses can be either tuples of varying lengths (AF_INET, AF_INET6, # AF_NETLINK, AF_TIPC) or strings (AF_UNIX). -_Address = Union[tuple, str] +_Address = Union[Tuple[Any, ...], str] _RetAddress = Any # TODO Most methods allow bytes as address objects diff --git a/stdlib/struct.pyi b/stdlib/struct.pyi index 9edf6842b..096f8b7b8 100644 --- a/stdlib/struct.pyi +++ b/stdlib/struct.pyi @@ -8,7 +8,7 @@ class error(Exception): ... _FmtType = Union[bytes, Text] if sys.version_info >= (3,): _BufferType = Union[array[int], bytes, bytearray, memoryview, mmap] - _WriteBufferType = Union[array, bytearray, memoryview, mmap] + _WriteBufferType = Union[array[Any], bytearray, memoryview, mmap] else: _BufferType = Union[array[int], bytes, bytearray, buffer, memoryview, mmap] _WriteBufferType = Union[array[Any], bytearray, buffer, memoryview, mmap] diff --git a/stdlib/xmlrpc/client.pyi b/stdlib/xmlrpc/client.pyi index 412382297..d90012e18 100644 --- a/stdlib/xmlrpc/client.pyi +++ b/stdlib/xmlrpc/client.pyi @@ -13,7 +13,7 @@ class _SupportsTimeTuple(Protocol): def timetuple(self) -> time.struct_time: ... _DateTimeComparable = Union[DateTime, datetime, str, _SupportsTimeTuple] -_Marshallable = Union[None, bool, int, float, str, bytes, tuple, list, dict, datetime, DateTime, Binary] +_Marshallable = Union[None, bool, int, float, str, bytes, Tuple[Any, ...], List[Any], Dict[Any, Any], datetime, DateTime, Binary] _XMLDate = Union[int, datetime, Tuple[int, ...], time.struct_time] _HostType = Union[Tuple[str, Dict[str, str]], str] diff --git a/stdlib/xmlrpc/server.pyi b/stdlib/xmlrpc/server.pyi index 8cdcf499a..f6a097d91 100644 --- a/stdlib/xmlrpc/server.pyi +++ b/stdlib/xmlrpc/server.pyi @@ -7,7 +7,7 @@ from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Patte from xmlrpc.client import Fault _Marshallable = Union[ - None, bool, int, float, str, bytes, tuple, list, dict, datetime + None, bool, int, float, str, bytes, Tuple[Any, ...], List[Any], Dict[Any, Any], datetime ] # TODO: Recursive type on tuple, list, dict # The dispatch accepts anywhere from 0 to N arguments, no easy way to allow this in mypy