Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mypy/fastparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -2060,7 +2060,7 @@ def visit_Constant(self, n: Constant) -> Type:
contents = bytes_to_human_readable_repr(val)
return RawExpressionType(contents, "builtins.bytes", self.line, column=n.col_offset)
# Everything else is invalid.
return self.invalid_type(n)
return self.invalid_type(n) # type: ignore[unreachable]

# UnaryOp(op, operand)
def visit_UnaryOp(self, n: UnaryOp) -> Type:
Expand Down
1 change: 1 addition & 0 deletions mypy/typeshed/stdlib/_asyncio.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,4 @@ if sys.version_info >= (3, 12):
if sys.version_info >= (3, 14):
def future_discard_from_awaited_by(future: Future[Any], waiter: Future[Any], /) -> None: ...
def future_add_to_awaited_by(future: Future[Any], waiter: Future[Any], /) -> None: ...
def all_tasks(loop: AbstractEventLoop | None = None) -> set[Task[Any]]: ...
2 changes: 2 additions & 0 deletions mypy/typeshed/stdlib/_ctypes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class _CData:
_objects: Mapping[Any, int] | None
def __buffer__(self, flags: int, /) -> memoryview: ...
def __ctypes_from_outparam__(self, /) -> Self: ...
if sys.version_info >= (3, 14):
__pointer_type__: type

# this is a union of all the subclasses of _CData, which is useful because of
# the methods that are present on each of those subclasses which are not present
Expand Down
3 changes: 3 additions & 0 deletions mypy/typeshed/stdlib/_curses.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ def has_colors() -> bool: ...
if sys.version_info >= (3, 10):
def has_extended_color_support() -> bool: ...

if sys.version_info >= (3, 14):
def assume_default_colors(fg: int, bg: int, /) -> None: ...

def has_ic() -> bool: ...
def has_il() -> bool: ...
def has_key(key: int, /) -> bool: ...
Expand Down
12 changes: 10 additions & 2 deletions mypy/typeshed/stdlib/_heapq.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import sys
from typing import Any, Final, TypeVar

_T = TypeVar("_T")
_T = TypeVar("_T") # list items must be comparable

__about__: Final[str]

def heapify(heap: list[Any], /) -> None: ...
def heapify(heap: list[Any], /) -> None: ... # list items must be comparable
def heappop(heap: list[_T], /) -> _T: ...
def heappush(heap: list[_T], item: _T, /) -> None: ...
def heappushpop(heap: list[_T], item: _T, /) -> _T: ...
def heapreplace(heap: list[_T], item: _T, /) -> _T: ...

if sys.version_info >= (3, 14):
def heapify_max(heap: list[Any], /) -> None: ... # list items must be comparable
def heappop_max(heap: list[_T], /) -> _T: ...
def heappush_max(heap: list[_T], item: _T, /) -> None: ...
def heappushpop_max(heap: list[_T], item: _T, /) -> _T: ...
def heapreplace_max(heap: list[_T], item: _T, /) -> _T: ...
2 changes: 2 additions & 0 deletions mypy/typeshed/stdlib/_imp.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ from importlib.machinery import ModuleSpec
from typing import Any

check_hash_based_pycs: str
if sys.version_info >= (3, 14):
pyc_magic_number_token: int

def source_hash(key: int, source: ReadableBuffer) -> bytes: ...
def create_builtin(spec: ModuleSpec, /) -> types.ModuleType: ...
Expand Down
79 changes: 53 additions & 26 deletions mypy/typeshed/stdlib/_posixsubprocess.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,56 @@ from collections.abc import Callable, Sequence
from typing import SupportsIndex

if sys.platform != "win32":
def fork_exec(
args: Sequence[StrOrBytesPath] | None,
executable_list: Sequence[bytes],
close_fds: bool,
pass_fds: tuple[int, ...],
cwd: str,
env: Sequence[bytes] | None,
p2cread: int,
p2cwrite: int,
c2pread: int,
c2pwrite: int,
errread: int,
errwrite: int,
errpipe_read: int,
errpipe_write: int,
restore_signals: int,
call_setsid: int,
pgid_to_set: int,
gid: SupportsIndex | None,
extra_groups: list[int] | None,
uid: SupportsIndex | None,
child_umask: int,
preexec_fn: Callable[[], None],
allow_vfork: bool,
/,
) -> int: ...
if sys.version_info >= (3, 14):
def fork_exec(
args: Sequence[StrOrBytesPath] | None,
executable_list: Sequence[bytes],
close_fds: bool,
pass_fds: tuple[int, ...],
cwd: str,
env: Sequence[bytes] | None,
p2cread: int,
p2cwrite: int,
c2pread: int,
c2pwrite: int,
errread: int,
errwrite: int,
errpipe_read: int,
errpipe_write: int,
restore_signals: int,
call_setsid: int,
pgid_to_set: int,
gid: SupportsIndex | None,
extra_groups: list[int] | None,
uid: SupportsIndex | None,
child_umask: int,
preexec_fn: Callable[[], None],
/,
) -> int: ...
else:
def fork_exec(
args: Sequence[StrOrBytesPath] | None,
executable_list: Sequence[bytes],
close_fds: bool,
pass_fds: tuple[int, ...],
cwd: str,
env: Sequence[bytes] | None,
p2cread: int,
p2cwrite: int,
c2pread: int,
c2pwrite: int,
errread: int,
errwrite: int,
errpipe_read: int,
errpipe_write: int,
restore_signals: bool,
call_setsid: bool,
pgid_to_set: int,
gid: SupportsIndex | None,
extra_groups: list[int] | None,
uid: SupportsIndex | None,
child_umask: int,
preexec_fn: Callable[[], None],
allow_vfork: bool,
/,
) -> int: ...
5 changes: 5 additions & 0 deletions mypy/typeshed/stdlib/_thread.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class RLock:
def release(self) -> None: ...
__enter__ = acquire
def __exit__(self, t: type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ...
if sys.version_info >= (3, 14):
def locked(self) -> bool: ...

if sys.version_info >= (3, 13):
@final
Expand Down Expand Up @@ -105,6 +107,9 @@ _excepthook: Callable[[_ExceptHookArgs], Any]
if sys.version_info >= (3, 12):
def daemon_threads_allowed() -> bool: ...

if sys.version_info >= (3, 14):
def set_name(name: str) -> None: ...

class _local:
def __getattribute__(self, name: str, /) -> Any: ...
def __setattr__(self, name: str, value: Any, /) -> None: ...
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/_tkinter.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class TkappType:
def globalgetvar(self, *args, **kwargs): ...
def globalsetvar(self, *args, **kwargs): ...
def globalunsetvar(self, *args, **kwargs): ...
def interpaddr(self): ...
def interpaddr(self) -> int: ...
def loadtk(self) -> None: ...
def mainloop(self, threshold: int = 0, /): ...
def quit(self): ...
Expand Down
3 changes: 0 additions & 3 deletions mypy/typeshed/stdlib/_typeshed/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,6 @@ class SupportsGetItemBuffer(SliceableBuffer, IndexableBuffer, Protocol):

class SizedBuffer(Sized, Buffer, Protocol): ...

# for compatibility with third-party stubs that may use this
_BufferWithLen: TypeAlias = SizedBuffer # not stable # noqa: Y047

ExcInfo: TypeAlias = tuple[type[BaseException], BaseException, TracebackType]
OptExcInfo: TypeAlias = ExcInfo | tuple[None, None, None]

Expand Down
8 changes: 1 addition & 7 deletions mypy/typeshed/stdlib/argparse.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,7 @@ class HelpFormatter:

if sys.version_info >= (3, 14):
def __init__(
self,
prog: str,
indent_increment: int = 2,
max_help_position: int = 24,
width: int | None = None,
prefix_chars: str = "-",
color: bool = False,
self, prog: str, indent_increment: int = 2, max_help_position: int = 24, width: int | None = None, color: bool = False
) -> None: ...
else:
def __init__(
Expand Down
36 changes: 24 additions & 12 deletions mypy/typeshed/stdlib/ast.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1095,20 +1095,28 @@ if sys.version_info >= (3, 14):
**kwargs: Unpack[_Attributes],
) -> Self: ...

if sys.version_info >= (3, 10):
from types import EllipsisType

_ConstantValue: typing_extensions.TypeAlias = str | bytes | bool | int | float | complex | None | EllipsisType
else:
# Rely on builtins.ellipsis
_ConstantValue: typing_extensions.TypeAlias = str | bytes | bool | int | float | complex | None | ellipsis # noqa: F821

class Constant(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("value", "kind")
value: Any # None, str, bytes, bool, int, float, complex, Ellipsis
value: _ConstantValue
kind: str | None
if sys.version_info < (3, 14):
# Aliases for value, for backwards compatibility
s: Any
n: int | float | complex
s: _ConstantValue
n: _ConstantValue

def __init__(self, value: Any, kind: str | None = None, **kwargs: Unpack[_Attributes]) -> None: ...
def __init__(self, value: _ConstantValue, kind: str | None = None, **kwargs: Unpack[_Attributes]) -> None: ...

if sys.version_info >= (3, 14):
def __replace__(self, *, value: Any = ..., kind: str | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
def __replace__(self, *, value: _ConstantValue = ..., kind: str | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ...

class Attribute(expr):
if sys.version_info >= (3, 10):
Expand Down Expand Up @@ -1429,15 +1437,19 @@ class keyword(AST):
def __replace__(self, *, arg: str | None = ..., value: expr = ..., **kwargs: Unpack[_Attributes]) -> Self: ...

class alias(AST):
lineno: int
col_offset: int
end_lineno: int | None
end_col_offset: int | None
if sys.version_info >= (3, 10):
__match_args__ = ("name", "asname")
name: str
asname: str | None
def __init__(self, name: str, asname: str | None = None, **kwargs: Unpack[_Attributes]) -> None: ...
if sys.version_info >= (3, 10):
lineno: int
col_offset: int
end_lineno: int | None
end_col_offset: int | None
if sys.version_info >= (3, 10):
__match_args__ = ("name", "asname")
if sys.version_info >= (3, 10):
def __init__(self, name: str, asname: str | None = None, **kwargs: Unpack[_Attributes]) -> None: ...
else:
def __init__(self, name: str, asname: str | None = None) -> None: ...

if sys.version_info >= (3, 14):
def __replace__(self, *, name: str = ..., asname: str | None = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
Expand Down
16 changes: 10 additions & 6 deletions mypy/typeshed/stdlib/asyncio/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ if sys.platform == "win32":
"Server", # from base_events
"iscoroutinefunction", # from coroutines
"iscoroutine", # from coroutines
"AbstractEventLoopPolicy", # from events
"_AbstractEventLoopPolicy", # from events
"AbstractEventLoop", # from events
"AbstractServer", # from events
"Handle", # from events
"TimerHandle", # from events
"_get_event_loop_policy", # from events
"get_event_loop_policy", # from events
"_set_event_loop_policy", # from events
"set_event_loop_policy", # from events
"get_event_loop", # from events
"set_event_loop", # from events
Expand Down Expand Up @@ -132,9 +134,9 @@ if sys.platform == "win32":
"SelectorEventLoop", # from windows_events
"ProactorEventLoop", # from windows_events
"IocpProactor", # from windows_events
"DefaultEventLoopPolicy", # from windows_events
"WindowsSelectorEventLoopPolicy", # from windows_events
"WindowsProactorEventLoopPolicy", # from windows_events
"_DefaultEventLoopPolicy", # from windows_events
"_WindowsSelectorEventLoopPolicy", # from windows_events
"_WindowsProactorEventLoopPolicy", # from windows_events
"EventLoop", # from windows_events
)
elif sys.version_info >= (3, 13):
Expand Down Expand Up @@ -515,12 +517,14 @@ else:
"Server", # from base_events
"iscoroutinefunction", # from coroutines
"iscoroutine", # from coroutines
"AbstractEventLoopPolicy", # from events
"_AbstractEventLoopPolicy", # from events
"AbstractEventLoop", # from events
"AbstractServer", # from events
"Handle", # from events
"TimerHandle", # from events
"_get_event_loop_policy", # from events
"get_event_loop_policy", # from events
"_set_event_loop_policy", # from events
"set_event_loop_policy", # from events
"get_event_loop", # from events
"set_event_loop", # from events
Expand Down Expand Up @@ -606,7 +610,7 @@ else:
"DatagramTransport", # from transports
"SubprocessTransport", # from transports
"SelectorEventLoop", # from unix_events
"DefaultEventLoopPolicy", # from unix_events
"_DefaultEventLoopPolicy", # from unix_events
"EventLoop", # from unix_events
)
elif sys.version_info >= (3, 13):
Expand Down
38 changes: 30 additions & 8 deletions mypy/typeshed/stdlib/asyncio/events.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ if sys.version_info < (3, 14):
# Keep asyncio.__all__ updated with any changes to __all__ here
if sys.version_info >= (3, 14):
__all__ = (
"AbstractEventLoopPolicy",
"_AbstractEventLoopPolicy",
"AbstractEventLoop",
"AbstractServer",
"Handle",
"TimerHandle",
"_get_event_loop_policy",
"get_event_loop_policy",
"_set_event_loop_policy",
"set_event_loop_policy",
"get_event_loop",
"set_event_loop",
Expand Down Expand Up @@ -600,7 +602,7 @@ class AbstractEventLoop:
@abstractmethod
async def shutdown_default_executor(self) -> None: ...

class AbstractEventLoopPolicy:
class _AbstractEventLoopPolicy:
@abstractmethod
def get_event_loop(self) -> AbstractEventLoop: ...
@abstractmethod
Expand All @@ -622,13 +624,33 @@ class AbstractEventLoopPolicy:
@abstractmethod
def set_child_watcher(self, watcher: AbstractChildWatcher) -> None: ...

class BaseDefaultEventLoopPolicy(AbstractEventLoopPolicy, metaclass=ABCMeta):
def get_event_loop(self) -> AbstractEventLoop: ...
def set_event_loop(self, loop: AbstractEventLoop | None) -> None: ...
def new_event_loop(self) -> AbstractEventLoop: ...
if sys.version_info < (3, 14):
AbstractEventLoopPolicy = _AbstractEventLoopPolicy

if sys.version_info >= (3, 14):
class _BaseDefaultEventLoopPolicy(_AbstractEventLoopPolicy, metaclass=ABCMeta):
def get_event_loop(self) -> AbstractEventLoop: ...
def set_event_loop(self, loop: AbstractEventLoop | None) -> None: ...
def new_event_loop(self) -> AbstractEventLoop: ...

else:
class BaseDefaultEventLoopPolicy(_AbstractEventLoopPolicy, metaclass=ABCMeta):
def get_event_loop(self) -> AbstractEventLoop: ...
def set_event_loop(self, loop: AbstractEventLoop | None) -> None: ...
def new_event_loop(self) -> AbstractEventLoop: ...

if sys.version_info >= (3, 14):
def _get_event_loop_policy() -> _AbstractEventLoopPolicy: ...
def _set_event_loop_policy(policy: _AbstractEventLoopPolicy | None) -> None: ...
@deprecated("Deprecated as of Python 3.14; will be removed in Python 3.16")
def get_event_loop_policy() -> _AbstractEventLoopPolicy: ...
@deprecated("Deprecated as of Python 3.14; will be removed in Python 3.16")
def set_event_loop_policy(policy: _AbstractEventLoopPolicy | None) -> None: ...

else:
def get_event_loop_policy() -> _AbstractEventLoopPolicy: ...
def set_event_loop_policy(policy: _AbstractEventLoopPolicy | None) -> None: ...

def get_event_loop_policy() -> AbstractEventLoopPolicy: ...
def set_event_loop_policy(policy: AbstractEventLoopPolicy | None) -> None: ...
def set_event_loop(loop: AbstractEventLoop | None) -> None: ...
def new_event_loop() -> AbstractEventLoop: ...

Expand Down
Loading