Skip to content
Merged
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 3fa6658041d3ccd7f2a4bd725e21fa9768bf6ebc Mon Sep 17 00:00:00 2001
From 3715a29572ebccffe78c508da15e99ab10dc15d3 Mon Sep 17 00:00:00 2001
From: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Date: Sat, 15 Feb 2025 20:11:06 +0100
Subject: [PATCH] Partially revert Clean up argparse hacks
Expand All @@ -8,16 +8,16 @@ Subject: [PATCH] Partially revert Clean up argparse hacks
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/mypy/typeshed/stdlib/argparse.pyi b/mypy/typeshed/stdlib/argparse.pyi
index 22d330a08..fa22f842d 100644
index 36ea1981a..6ee01a82d 100644
--- a/mypy/typeshed/stdlib/argparse.pyi
+++ b/mypy/typeshed/stdlib/argparse.pyi
@@ -2,7 +2,7 @@ import sys
from _typeshed import SupportsWrite, sentinel
from collections.abc import Callable, Generator, Iterable, Sequence
from re import Pattern
-from typing import IO, Any, ClassVar, Final, Generic, NoReturn, Protocol, TypeAlias, TypeVar, overload, type_check_only
+from typing import IO, Any, ClassVar, Final, Generic, NewType, NoReturn, Protocol, TypeAlias, TypeVar, overload, type_check_only
from typing_extensions import Self, deprecated
-from typing import IO, Any, ClassVar, Final, Generic, Protocol, TypeAlias, TypeVar, overload, type_check_only
+from typing import IO, Any, ClassVar, Final, Generic, NewType, Protocol, TypeAlias, TypeVar, overload, type_check_only
from typing_extensions import Never, Self, deprecated

__all__ = [
@@ -36,7 +36,9 @@ ONE_OR_MORE: Final = "+"
Expand All @@ -41,5 +41,5 @@ index 22d330a08..fa22f842d 100644
default: Any = ...,
type: _ActionType = ...,
--
2.54.0
2.55.0

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From b5d1e4c76d8139e1a20f9178e8123f3ee39084d2 Mon Sep 17 00:00:00 2001
From aedaebba6e477469af6bc21ffb60ff6fc5def01e Mon Sep 17 00:00:00 2001
From: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Date: Sat, 21 Dec 2024 22:36:38 +0100
Subject: [PATCH] Revert Remove redundant inheritances from Iterator in
Expand Down Expand Up @@ -36,10 +36,10 @@ index 242093e1e..92bb4e5f4 100644
@property
def _exception(self) -> BaseException | None: ...
diff --git a/mypy/typeshed/stdlib/builtins.pyi b/mypy/typeshed/stdlib/builtins.pyi
index e63b74214..9ea382dd6 100644
index ec72c308e..d0963d5b7 100644
--- a/mypy/typeshed/stdlib/builtins.pyi
+++ b/mypy/typeshed/stdlib/builtins.pyi
@@ -1368,7 +1368,7 @@ class frozenset(AbstractSet[_T_co]):
@@ -1376,7 +1376,7 @@ class frozenset(AbstractSet[_T_co]):
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...

@disjoint_base
Expand All @@ -48,7 +48,7 @@ index e63b74214..9ea382dd6 100644
def __new__(cls, iterable: Iterable[_T], start: int = 0) -> Self: ...
def __iter__(self) -> Self: ...
def __next__(self) -> tuple[int, _T]: ...
@@ -1634,7 +1634,7 @@ else:
@@ -1642,7 +1642,7 @@ else:
exit: _sitebuiltins.Quitter

@disjoint_base
Expand All @@ -57,7 +57,7 @@ index e63b74214..9ea382dd6 100644
@overload
def __new__(cls, function: None, iterable: Iterable[_T | None], /) -> Self: ...
@overload
@@ -1705,7 +1705,7 @@ license: _sitebuiltins._Printer
@@ -1713,7 +1713,7 @@ license: _sitebuiltins._Printer
def locals() -> dict[str, Any]: ...

@disjoint_base
Expand All @@ -66,16 +66,16 @@ index e63b74214..9ea382dd6 100644
# 3.14 adds `strict` argument.
if sys.version_info >= (3, 14):
@overload
@@ -2021,7 +2021,7 @@ def pow(base: _SupportsSomeKindOfPow, exp: complex, mod: None = None) -> complex
quit: _sitebuiltins.Quitter
@@ -2033,7 +2033,7 @@ class _SupportsReversed(Protocol[_T_co]):
def __reversed__(self) -> _T_co: ...

@disjoint_base
-class reversed(Generic[_T]):
+class reversed(Iterator[_T]):
-class reversed(Generic[_T_co]):
+class reversed(Iterator[_T_co]):
@overload
def __new__(cls, sequence: Reversible[_T], /) -> Iterator[_T]: ... # type: ignore[misc]
def __new__(cls, sequence: _SupportsReversed[_T], /) -> _T: ... # type: ignore[misc]
@overload
@@ -2101,7 +2101,7 @@ def vars(object: type, /) -> types.MappingProxyType[str, Any]: ...
@@ -2113,7 +2113,7 @@ def vars(object: type, /) -> types.MappingProxyType[str, Any]: ...
def vars(object: Any = ..., /) -> dict[str, Any]: ...

@disjoint_base
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 92a0169fa37f3ff1c41beb98ae0f61e3b3ff19dc Mon Sep 17 00:00:00 2001
From f164b6f2926819cab52cca1e83b62f597d0aa82b Mon Sep 17 00:00:00 2001
From: Ivan Levkivskyi <levkivskyi@gmail.com>
Date: Wed, 8 Apr 2026 00:01:44 +0100
Subject: [PATCH] Revert dict.__or__ typeshed change
Expand All @@ -8,10 +8,10 @@ Subject: [PATCH] Revert dict.__or__ typeshed change
1 file changed, 20 insertions(+)

diff --git a/mypy/typeshed/stdlib/builtins.pyi b/mypy/typeshed/stdlib/builtins.pyi
index 9db6f4fc7..7ec0e2d7c 100644
index d0963d5b7..532ba324d 100644
--- a/mypy/typeshed/stdlib/builtins.pyi
+++ b/mypy/typeshed/stdlib/builtins.pyi
@@ -1228,14 +1228,27 @@ class dict(MutableMapping[_KT, _VT]):
@@ -1235,15 +1235,28 @@ class dict(MutableMapping[_KT, _VT]):
__hash__: ClassVar[None] # type: ignore[assignment]
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
if sys.version_info >= (3, 15):
Expand All @@ -28,6 +28,7 @@ index 9db6f4fc7..7ec0e2d7c 100644
+ def __ror__(self, value: frozendict[_KT, _VT], /) -> frozendict[_KT, _VT]: ...
+ @overload
def __ror__(self, value: frozendict[_T1, _T2], /) -> frozendict[_KT | _T1, _VT | _T2]: ...

else:
+ @overload
+ def __or__(self, value: dict[_KT, _VT], /) -> dict[_KT, _VT]: ...
Expand All @@ -39,7 +40,7 @@ index 9db6f4fc7..7ec0e2d7c 100644
def __ror__(self, value: dict[_T1, _T2], /) -> dict[_KT | _T1, _VT | _T2]: ...

# dict.__ior__ should be kept roughly in line with MutableMapping.update()
@@ -1290,11 +1303,18 @@ if sys.version_info >= (3, 15):
@@ -1297,11 +1310,18 @@ if sys.version_info >= (3, 15):
def __iter__(self) -> Iterator[_KT]: ...
def __hash__(self) -> int: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
Expand All @@ -59,5 +60,5 @@ index 9db6f4fc7..7ec0e2d7c 100644

@disjoint_base
--
2.54.0
2.55.0

2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/__main__.pyi
Original file line number Diff line number Diff line change
@@ -1 +1 @@
def __getattr__(name: str): ... # incomplete module
def __getattr__(name: str, /): ... # incomplete module
10 changes: 5 additions & 5 deletions mypy/typeshed/stdlib/_ctypes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class _UnionType(_CTypeBaseType):
# At runtime, various attributes are created on a Union subclass based
# on its _fields_. This method doesn't exist, but represents those
# dynamically created attributes.
def __getattr__(self, name: str) -> _CField[Any, Any, Any]: ...
def __getattr__(self, name: str, /) -> _CField[Any, Any, Any]: ...
if sys.version_info < (3, 13):
# Inherited from CType_Type starting on 3.13
def __mul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
Expand All @@ -263,8 +263,8 @@ class Union(_CData, metaclass=_UnionType):
_align_: ClassVar[int]

def __init__(self, *args: Any, **kw: Any) -> None: ...
def __getattr__(self, name: str) -> Any: ...
def __setattr__(self, name: str, value: Any) -> None: ...
def __getattr__(self, name: str, /) -> Any: ...
def __setattr__(self, name: str, value: Any, /) -> None: ...

# This class is not exposed. It calls itself _ctypes.PyCStructType.
@type_check_only
Expand All @@ -277,7 +277,7 @@ class _PyCStructType(_CTypeBaseType):
# At runtime, various attributes are created on a Structure subclass based
# on its _fields_. This method doesn't exist, but represents those
# dynamically created attributes.
def __getattr__(self, name: str) -> _CField[Any, Any, Any]: ...
def __getattr__(self, name: str, /) -> _CField[Any, Any, Any]: ...
if sys.version_info < (3, 13):
# Inherited from CType_Type starting on 3.13
def __mul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
Expand All @@ -295,7 +295,7 @@ class Structure(_CData, metaclass=_PyCStructType):
_layout_: ClassVar[Literal["ms", "gcc-sysv"]]

def __init__(self, *args: Any, **kw: Any) -> None: ...
def __getattr__(self, name: str) -> Any: ...
def __getattr__(self, name: str, /) -> Any: ...
def __setattr__(self, name: str, value: Any) -> None: ...

# This class is not exposed. It calls itself _ctypes.PyCArrayType.
Expand Down
5 changes: 3 additions & 2 deletions mypy/typeshed/stdlib/_sitebuiltins.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import sys
from collections.abc import Iterable
from typing import ClassVar, Literal, NoReturn
from typing import ClassVar, Literal
from typing_extensions import Never

class Quitter:
name: str
eof: str
def __init__(self, name: str, eof: str) -> None: ...
def __call__(self, code: sys._ExitCode = None) -> NoReturn: ...
def __call__(self, code: sys._ExitCode = None) -> Never: ...

class _Printer:
MAXLINES: ClassVar[Literal[23]]
Expand Down
8 changes: 4 additions & 4 deletions mypy/typeshed/stdlib/_thread.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ from _typeshed import structseq
from collections.abc import Callable
from threading import Thread
from types import TracebackType
from typing import Any, Final, NoReturn, final, overload
from typing_extensions import TypeVarTuple, Unpack, deprecated, disjoint_base
from typing import Any, Final, final, overload
from typing_extensions import Never, TypeVarTuple, Unpack, deprecated, disjoint_base

_Ts = TypeVarTuple("_Ts")

Expand Down Expand Up @@ -82,9 +82,9 @@ def start_new(function: Callable[[Unpack[_Ts]], object], args: tuple[Unpack[_Ts]
def start_new(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any], /) -> int: ... # undocumented

def interrupt_main(signum: signal.Signals = signal.SIGINT, /) -> None: ...
def exit() -> NoReturn: ...
def exit() -> Never: ...
@deprecated("Obsolete synonym. Use `exit()` instead.")
def exit_thread() -> NoReturn: ... # undocumented
def exit_thread() -> Never: ... # undocumented
def allocate_lock() -> LockType: ...
@deprecated("Obsolete synonym. Use `allocate_lock()` instead.")
def allocate() -> LockType: ... # undocumented
Expand Down
8 changes: 8 additions & 0 deletions mypy/typeshed/stdlib/_typeshed/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ Unused: TypeAlias = object # stable
# for more information.
MaybeNone: TypeAlias = Any # stable

# typeshed-internal type aliases to facilitate transition from
# `float` to either `float | int` or `float` (and similar for `complex`).
# When you encounter one of these type aliases, you are encouraged to
# replace them with the correct type. Please don't use them outside typeshed.
# See https://github.com/python/typeshed/issues/16059 for details.
FloatInt: TypeAlias = float | int
ComplexInt: TypeAlias = complex | float | int

# Used to mark arguments that default to a sentinel value. This prevents
# stubtest from complaining about the default value not matching.
#
Expand Down
8 changes: 6 additions & 2 deletions mypy/typeshed/stdlib/_winapi.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import sys
from _typeshed import ReadableBuffer
from collections.abc import Sequence
from typing import Any, Final, Literal, NoReturn, final, overload
from typing import Any, Final, Literal, final, overload
from typing_extensions import Never

if sys.platform == "win32":
ABOVE_NORMAL_PRIORITY_CLASS: Final = 0x8000
Expand Down Expand Up @@ -238,7 +239,7 @@ if sys.platform == "win32":
options: int = 0,
/,
) -> int: ...
def ExitProcess(ExitCode: int, /) -> NoReturn: ...
def ExitProcess(ExitCode: int, /) -> Never: ...
def GetACP() -> int: ...
if sys.version_info >= (3, 15):
def DeregisterEventSource(handle: int, /) -> None: ...
Expand Down Expand Up @@ -312,3 +313,6 @@ if sys.platform == "win32":
if sys.version_info >= (3, 12):
def CopyFile2(existing_file_name: str, new_file_name: str, flags: int, progress_routine: int | None = None) -> int: ...
def NeedCurrentDirectoryForExePath(exe_name: str, /) -> bool: ...

if sys.version_info >= (3, 15):
def GetTickCount64() -> int: ...
16 changes: 8 additions & 8 deletions mypy/typeshed/stdlib/argparse.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import sys
from _typeshed import SupportsWrite, sentinel
from collections.abc import Callable, Generator, Iterable, Sequence
from re import Pattern
from typing import IO, Any, ClassVar, Final, Generic, NewType, NoReturn, Protocol, TypeAlias, TypeVar, overload, type_check_only
from typing_extensions import Self, deprecated
from typing import IO, Any, ClassVar, Final, Generic, NewType, Protocol, TypeAlias, TypeVar, overload, type_check_only
from typing_extensions import Never, Self, deprecated

__all__ = [
"ArgumentParser",
Expand Down Expand Up @@ -105,7 +105,7 @@ class _ActionsContainer:
conflict_handler: str = ...,
) -> _ArgumentGroup: ...
@overload
@deprecated("The `prefix_chars` parameter deprecated since Python 3.14.")
@deprecated("The `prefix_chars` parameter is deprecated.")
def add_argument_group(
self,
title: str | None = None,
Expand All @@ -125,7 +125,7 @@ class _ActionsContainer:
def _pop_action_class(self, kwargs: Any, default: type[Action] | None = None) -> type[Action]: ...
def _get_handler(self) -> Callable[[Action, Iterable[tuple[str, Action]]], Any]: ...
def _check_conflict(self, action: Action) -> None: ...
def _handle_conflict_error(self, action: Action, conflicting_actions: Iterable[tuple[str, Action]]) -> NoReturn: ...
def _handle_conflict_error(self, action: Action, conflicting_actions: Iterable[tuple[str, Action]]) -> Never: ...
def _handle_conflict_resolve(self, action: Action, conflicting_actions: Iterable[tuple[str, Action]]) -> None: ...

@type_check_only
Expand Down Expand Up @@ -266,8 +266,8 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
def parse_known_args(self, *, namespace: _N) -> tuple[_N, list[str]]: ...

def convert_arg_line_to_args(self, arg_line: str) -> list[str]: ...
def exit(self, status: int = 0, message: str | None = None) -> NoReturn: ...
def error(self, message: str) -> NoReturn: ...
def exit(self, status: int = 0, message: str | None = None) -> Never: ...
def error(self, message: str) -> Never: ...

@overload
def parse_intermixed_args(self, args: Iterable[str] | None = None, namespace: None = None) -> Namespace: ...
Expand Down Expand Up @@ -532,7 +532,7 @@ class Namespace(_AttributeHolder):
def __eq__(self, other: object) -> bool: ...
__hash__: ClassVar[None] # type: ignore[assignment]

@deprecated("Deprecated since Python 3.14. Open files after parsing arguments instead.")
@deprecated("Deprecated; may leave files open. Open files after parsing arguments instead.")
class FileType:
# undocumented
_mode: str
Expand All @@ -558,7 +558,7 @@ class _ArgumentGroup(_ActionsContainer):
conflict_handler: str = ...,
) -> None: ...
@overload
@deprecated("Undocumented `prefix_chars` parameter is deprecated since Python 3.14.")
@deprecated("Undocumented `prefix_chars` parameter is deprecated.")
def __init__(
self,
container: _ActionsContainer,
Expand Down
8 changes: 4 additions & 4 deletions mypy/typeshed/stdlib/asyncio/coroutines.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ def iscoroutine(obj: object) -> TypeIs[Coroutine[Any, Any, Any]]: ...

if sys.version_info >= (3, 11):
@overload
@deprecated("Deprecated since Python 3.14. Use `inspect.iscoroutinefunction()` instead.")
@deprecated("Deprecated; will be removed in Python 3.16. Use `inspect.iscoroutinefunction()` instead.")
def iscoroutinefunction(func: Callable[..., Coroutine[Any, Any, Any]]) -> bool: ...
@overload
@deprecated("Deprecated since Python 3.14. Use `inspect.iscoroutinefunction()` instead.")
@deprecated("Deprecated; will be removed in Python 3.16. Use `inspect.iscoroutinefunction()` instead.")
def iscoroutinefunction(func: Callable[_P, Awaitable[_T]]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, _T]]]: ...
@overload
@deprecated("Deprecated since Python 3.14. Use `inspect.iscoroutinefunction()` instead.")
@deprecated("Deprecated; will be removed in Python 3.16. Use `inspect.iscoroutinefunction()` instead.")
def iscoroutinefunction(func: Callable[_P, object]) -> TypeGuard[Callable[_P, Coroutine[Any, Any, Any]]]: ...
@overload
@deprecated("Deprecated since Python 3.14. Use `inspect.iscoroutinefunction()` instead.")
@deprecated("Deprecated; will be removed in Python 3.16. Use `inspect.iscoroutinefunction()` instead.")
def iscoroutinefunction(func: object) -> TypeGuard[Callable[..., Coroutine[Any, Any, Any]]]: ...
else:
# Sometimes needed in Python < 3.11 due to the fact that it supports @coroutine
Expand Down
12 changes: 6 additions & 6 deletions mypy/typeshed/stdlib/asyncio/events.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -633,10 +633,10 @@ else:
def new_event_loop(self) -> AbstractEventLoop: ...
# Child processes handling (Unix only).
@abstractmethod
@deprecated("Deprecated since Python 3.12; removed in Python 3.14.")
@deprecated("Deprecated; removed in Python 3.14.")
def get_child_watcher(self) -> AbstractChildWatcher: ...
@abstractmethod
@deprecated("Deprecated since Python 3.12; removed in Python 3.14.")
@deprecated("Deprecated; removed in Python 3.14.")
def set_child_watcher(self, watcher: AbstractChildWatcher) -> None: ...

AbstractEventLoopPolicy = _AbstractEventLoopPolicy
Expand All @@ -657,15 +657,15 @@ if sys.version_info >= (3, 14):
def _get_event_loop_policy() -> _AbstractEventLoopPolicy: ...
def _set_event_loop_policy(policy: _AbstractEventLoopPolicy | None) -> None: ...

@deprecated("Deprecated since Python 3.14; will be removed in Python 3.16.")
@deprecated("Deprecated; will be removed in Python 3.16.")
def get_event_loop_policy() -> _AbstractEventLoopPolicy: ...
@deprecated("Deprecated since Python 3.14; will be removed in Python 3.16.")
@deprecated("Deprecated; will be removed in Python 3.16.")
def set_event_loop_policy(policy: _AbstractEventLoopPolicy | None) -> None: ...
def set_event_loop(loop: AbstractEventLoop | None) -> None: ...
def new_event_loop() -> AbstractEventLoop: ...

if sys.version_info < (3, 14):
@deprecated("Deprecated since Python 3.12; removed in Python 3.14.")
@deprecated("Deprecated; removed in Python 3.14.")
def get_child_watcher() -> AbstractChildWatcher: ...
@deprecated("Deprecated since Python 3.12; removed in Python 3.14.")
@deprecated("Deprecated; removed in Python 3.14.")
def set_child_watcher(watcher: AbstractChildWatcher) -> None: ...
8 changes: 3 additions & 5 deletions mypy/typeshed/stdlib/asyncio/protocols.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ class BufferedProtocol(BaseProtocol):
class DatagramProtocol(BaseProtocol):
__slots__ = ()
def connection_made(self, transport: transports.DatagramTransport) -> None: ... # type: ignore[override]
# addr can be a tuple[int, int] for some unusual protocols like socket.AF_NETLINK.
# Use tuple[str | Any, int] to not cause typechecking issues on most usual cases.
# This could be improved by using tuple[AnyOf[str, int], int] if the AnyOf feature is accepted.
# See https://github.com/python/typing/issues/566
def datagram_received(self, data: bytes, addr: tuple[str | Any, int]) -> None: ...
# addr is a tuple[str, int] for IPv4 or tuple[str, int, int, int] for IPv6.
# It can also be a tuple[int, int] for unusual protocols like socket.AF_NETLINK.
def datagram_received(self, data: bytes, addr: tuple[Any, ...]) -> None: ...
def error_received(self, exc: Exception) -> None: ...

class SubprocessProtocol(BaseProtocol):
Expand Down
Loading
Loading