Skip to content
Open
Show file tree
Hide file tree
Changes from all 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 stdlib/@tests/test_cases/builtins/check_pow.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# that passing 0 for the third argument will lead to an exception being raised
# (see discussion in #8566)
#
# assert_type(pow(2, 4, 0), NoReturn)
# assert_type(pow(2, 4, 0), Never)

assert_type(pow(2, 4), int)
# pyright infers a literal type here, but mypy does not.
Expand Down
5 changes: 3 additions & 2 deletions 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 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
5 changes: 3 additions & 2 deletions 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
10 changes: 5 additions & 5 deletions 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, 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_extensions import Never, Self, deprecated

__all__ = [
"ArgumentParser",
Expand Down Expand Up @@ -123,7 +123,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 @@ -264,8 +264,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
14 changes: 7 additions & 7 deletions stdlib/asyncio/trsock.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ from _typeshed import ReadableBuffer
from builtins import type as Type # alias to avoid name clashes with property named "type"
from collections.abc import Iterable
from types import TracebackType
from typing import Any, BinaryIO, NoReturn, TypeAlias, overload
from typing_extensions import deprecated
from typing import Any, BinaryIO, TypeAlias, overload
from typing_extensions import Never, deprecated

# These are based in socket, maybe move them out into _typeshed.pyi or such
_Address: TypeAlias = socket._Address
Expand All @@ -22,7 +22,7 @@ class TransportSocket:
def type(self) -> int: ...
@property
def proto(self) -> int: ...
def __getstate__(self) -> NoReturn: ...
def __getstate__(self) -> Never: ...
def fileno(self) -> int: ...
def dup(self) -> socket.socket: ...
def get_inheritable(self) -> bool: ...
Expand All @@ -40,7 +40,7 @@ class TransportSocket:

def getpeername(self) -> _RetAddress: ...
def getsockname(self) -> _RetAddress: ...
def getsockbyname(self) -> NoReturn: ... # This method doesn't exist on socket, yet is passed through?
def getsockbyname(self) -> Never: ... # This method doesn't exist on socket, yet is passed through?
def settimeout(self, value: float | None) -> None: ...
def gettimeout(self) -> float | None: ...
def setblocking(self, flag: bool) -> None: ...
Expand All @@ -60,7 +60,7 @@ class TransportSocket:
def ioctl(self, control: int, option: int | tuple[int, int, int] | bool) -> None: ...
else:
@deprecated("Removed in Python 3.11")
def ioctl(self, control: int, option: int | tuple[int, int, int] | bool) -> NoReturn: ...
def ioctl(self, control: int, option: int | tuple[int, int, int] | bool) -> Never: ...

@deprecated("Removed in Python 3.11")
def listen(self, backlog: int = ..., /) -> None: ...
Expand All @@ -82,7 +82,7 @@ class TransportSocket:
@deprecated("Removed in Python 3.11.")
def sendmsg_afalg(
self, msg: Iterable[ReadableBuffer] = ..., *, op: int, iv: Any = ..., assoclen: int = ..., flags: int = 0
) -> NoReturn: ...
) -> Never: ...

@deprecated("Removed in Python 3.11.")
def sendmsg(
Expand Down Expand Up @@ -113,7 +113,7 @@ class TransportSocket:
def share(self, process_id: int) -> bytes: ...
else:
@deprecated("Removed in Python 3.11.")
def share(self, process_id: int) -> NoReturn: ...
def share(self, process_id: int) -> Never: ...

@deprecated("Removed in Python 3.11.")
def recv_into(self, buffer: _WriteBuffer, nbytes: int = 0, flags: int = 0) -> int: ...
Expand Down
11 changes: 6 additions & 5 deletions stdlib/asyncio/windows_events.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import socket
import sys
from _typeshed import Incomplete, ReadableBuffer, WriteableBuffer
from collections.abc import Callable
from typing import IO, Any, ClassVar, Final, NoReturn
from typing import IO, Any, ClassVar, Final
from typing_extensions import Never

from . import events, futures, proactor_events, selector_events, streams, windows_utils

Expand Down Expand Up @@ -105,13 +106,13 @@ if sys.platform == "win32":
else:
class WindowsSelectorEventLoopPolicy(events.BaseDefaultEventLoopPolicy):
_loop_factory: ClassVar[type[SelectorEventLoop]]
def get_child_watcher(self) -> NoReturn: ...
def set_child_watcher(self, watcher: Any) -> NoReturn: ...
def get_child_watcher(self) -> Never: ...
def set_child_watcher(self, watcher: Any) -> Never: ...

class WindowsProactorEventLoopPolicy(events.BaseDefaultEventLoopPolicy):
_loop_factory: ClassVar[type[ProactorEventLoop]]
def get_child_watcher(self) -> NoReturn: ...
def set_child_watcher(self, watcher: Any) -> NoReturn: ...
def get_child_watcher(self) -> Never: ...
def set_child_watcher(self, watcher: Any) -> Never: ...

if sys.version_info >= (3, 14):
_DefaultEventLoopPolicy = _WindowsProactorEventLoopPolicy
Expand Down
2 changes: 1 addition & 1 deletion stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2112,7 +2112,7 @@ _SupportsSomeKindOfPow = ( # noqa: Y026 # TODO: Use TypeAlias once mypy bugs a
)

# TODO: `pow(int, int, Literal[0])` fails at runtime,
# but adding a `NoReturn` overload isn't a good solution for expressing that (see #8566).
# but adding a `Never` overload isn't a good solution for expressing that (see #8566).
@overload
def pow(base: int, exp: int, mod: int) -> int: ...
@overload
Expand Down
6 changes: 3 additions & 3 deletions stdlib/collections/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ from collections.abc import (
ValuesView,
)
from types import GenericAlias
from typing import Any, ClassVar, Generic, NoReturn, SupportsIndex, TypeVar, final, overload, type_check_only
from typing_extensions import Self, disjoint_base
from typing import Any, ClassVar, Generic, SupportsIndex, TypeVar, final, overload, type_check_only
from typing_extensions import Never, Self, disjoint_base

if sys.version_info >= (3, 15):
from builtins import frozendict
Expand Down Expand Up @@ -300,7 +300,7 @@ class Counter(dict[_T, int], Generic[_T]):
def elements(self) -> Iterator[_T]: ...
def most_common(self, n: int | None = None) -> list[tuple[_T, int]]: ...
@classmethod
def fromkeys(cls, iterable: Any, v: int | None = None) -> NoReturn: ... # type: ignore[override]
def fromkeys(cls, iterable: Any, v: int | None = None) -> Never: ... # type: ignore[override]

@overload
def subtract(self, iterable: None = None, /) -> None: ...
Expand Down
6 changes: 3 additions & 3 deletions stdlib/datetime.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import sys
from abc import abstractmethod
from time import struct_time
from typing import ClassVar, Final, NoReturn, SupportsIndex, TypeAlias, final, overload, type_check_only
from typing_extensions import CapsuleType, Self, deprecated, disjoint_base
from typing import ClassVar, Final, SupportsIndex, TypeAlias, final, overload, type_check_only
from typing_extensions import CapsuleType, Never, Self, deprecated, disjoint_base

if sys.version_info >= (3, 11):
__all__ = ("date", "datetime", "time", "timedelta", "timezone", "tzinfo", "MINYEAR", "MAXYEAR", "UTC")
Expand Down Expand Up @@ -114,7 +114,7 @@ class date:
def __radd__(self, value: timedelta, /) -> Self: ...

@overload
def __sub__(self, value: datetime, /) -> NoReturn: ...
def __sub__(self, value: datetime, /) -> Never: ...
@overload
def __sub__(self, value: Self, /) -> timedelta: ...
@overload
Expand Down
2 changes: 1 addition & 1 deletion stdlib/decimal.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class Context:
# even settable attributes like `prec` and `rounding`,
# but that's inexpressible in the stub.
# Type checkers either ignore it or misinterpret it
# if you add a `def __delattr__(self, name: str, /) -> NoReturn` method to the stub
# if you add a `def __delattr__(self, name: str, /) -> Never` method to the stub
prec: int
rounding: str
Emin: int
Expand Down
8 changes: 4 additions & 4 deletions stdlib/importlib/readers.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ from _typeshed import StrPath
from collections.abc import Iterable, Iterator
from importlib._bootstrap_external import FileLoader
from io import BufferedReader
from typing import Literal, NoReturn, TypeVar
from typing import Literal, TypeVar
from typing_extensions import Never
from zipimport import zipimporter

Expand Down Expand Up @@ -43,8 +43,8 @@ class ZipReader(abc.TraversableResources):
class MultiplexedPath(abc.Traversable):
def __init__(self, *paths: abc.Traversable) -> None: ...
def iterdir(self) -> Iterator[abc.Traversable]: ...
def read_bytes(self) -> NoReturn: ...
def read_text(self, *args: Never, **kwargs: Never) -> NoReturn: ... # type: ignore[override]
def read_bytes(self) -> Never: ...
def read_text(self, *args: Never, **kwargs: Never) -> Never: ... # type: ignore[override]
def is_dir(self) -> Literal[True]: ...
def is_file(self) -> Literal[False]: ...

Expand All @@ -58,7 +58,7 @@ class MultiplexedPath(abc.Traversable):
if sys.version_info < (3, 12):
__truediv__ = joinpath

def open(self, *args: Never, **kwargs: Never) -> NoReturn: ... # type: ignore[override]
def open(self, *args: Never, **kwargs: Never) -> Never: ... # type: ignore[override]
@property
def name(self) -> str: ...

Expand Down
6 changes: 3 additions & 3 deletions stdlib/importlib/resources/simple.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import sys
from _typeshed import StrPath
from collections.abc import Iterator
from io import TextIOWrapper
from typing import IO, Any, BinaryIO, Literal, NoReturn, overload
from typing import IO, Any, BinaryIO, Literal, overload
from typing_extensions import Never

if sys.version_info >= (3, 11):
Expand Down Expand Up @@ -43,15 +43,15 @@ if sys.version_info >= (3, 11):
@overload
def open(self, mode: str) -> IO[Any]: ...

def joinpath(self, name: Never) -> NoReturn: ... # type: ignore[override]
def joinpath(self, name: Never) -> Never: ... # type: ignore[override]

class ResourceContainer(Traversable, metaclass=abc.ABCMeta):
reader: SimpleReader
def __init__(self, reader: SimpleReader) -> None: ...
def is_dir(self) -> Literal[True]: ...
def is_file(self) -> Literal[False]: ...
def iterdir(self) -> Iterator[ResourceHandle | ResourceContainer]: ...
def open(self, *args: Never, **kwargs: Never) -> NoReturn: ... # type: ignore[override]
def open(self, *args: Never, **kwargs: Never) -> Never: ... # type: ignore[override]
if sys.version_info < (3, 12):
def joinpath(self, *descendants: StrPath) -> Traversable: ...

Expand Down
7 changes: 4 additions & 3 deletions stdlib/lib2to3/pgen2/pgen.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from _typeshed import Incomplete, StrPath
from collections.abc import Iterable, Iterator
from typing import IO, ClassVar, NoReturn, overload
from typing import IO, ClassVar, overload
from typing_extensions import Never

from . import grammar
from .tokenize import _TokenInfo
Expand Down Expand Up @@ -31,9 +32,9 @@ class ParserGenerator:
def gettoken(self) -> None: ...

@overload
def raise_error(self, msg: object) -> NoReturn: ...
def raise_error(self, msg: object) -> Never: ...
@overload
def raise_error(self, msg: str, *args: object) -> NoReturn: ...
def raise_error(self, msg: str, *args: object) -> Never: ...

class NFAState:
arcs: list[tuple[str | None, NFAState]]
Expand Down
5 changes: 3 additions & 2 deletions stdlib/lib2to3/refactor.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ from collections.abc import Container, Generator, Iterable, Mapping
from logging import Logger, _ExcInfoType
from multiprocessing import JoinableQueue
from multiprocessing.synchronize import Lock
from typing import Any, ClassVar, Final, NoReturn, overload
from typing import Any, ClassVar, Final, overload
from typing_extensions import Never

from .btm_matcher import BottomMatcher
from .fixer_base import BaseFix
Expand Down Expand Up @@ -39,7 +40,7 @@ class RefactoringTool:
self, fixer_names: Iterable[str], options: Mapping[str, object] | None = None, explicit: Container[str] | None = None
) -> None: ...
def get_fixers(self) -> tuple[list[BaseFix], list[BaseFix]]: ...
def log_error(self, msg: str, *args: Iterable[str], **kwargs: _ExcInfoType) -> NoReturn: ...
def log_error(self, msg: str, *args: Iterable[str], **kwargs: _ExcInfoType) -> Never: ...

@overload
def log_message(self, msg: object) -> None: ...
Expand Down
6 changes: 3 additions & 3 deletions stdlib/mmap.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import os
import sys
from _typeshed import ReadableBuffer, Unused
from collections.abc import Iterator
from typing import Final, Literal, NoReturn, SupportsIndex, overload
from typing_extensions import Self, disjoint_base
from typing import Final, Literal, SupportsIndex, overload
from typing_extensions import Never, Self, disjoint_base

ACCESS_DEFAULT: Final = 0
ACCESS_READ: Final = 1
Expand Down Expand Up @@ -113,7 +113,7 @@ class mmap:
@overload
def __getitem__(self, key: slice[SupportsIndex | None], /) -> bytes: ...

def __delitem__(self, key: SupportsIndex | slice[SupportsIndex | None], /) -> NoReturn: ...
def __delitem__(self, key: SupportsIndex | slice[SupportsIndex | None], /) -> Never: ...

@overload
def __setitem__(self, key: SupportsIndex, value: int, /) -> None: ...
Expand Down
8 changes: 4 additions & 4 deletions stdlib/optparse.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import builtins
from _typeshed import MaybeNone, SupportsWrite
from abc import abstractmethod
from collections.abc import Callable, Iterable, Mapping, Sequence
from typing import Any, ClassVar, Final, Literal, NoReturn, overload
from typing_extensions import Self
from typing import Any, ClassVar, Final, Literal, overload
from typing_extensions import Never, Self

__all__ = [
"Option",
Expand Down Expand Up @@ -291,8 +291,8 @@ class OptionParser(OptionContainer):
def check_values(self, values: Values, args: list[str]) -> tuple[Values, list[str]]: ...
def disable_interspersed_args(self) -> None: ...
def enable_interspersed_args(self) -> None: ...
def error(self, msg: str) -> NoReturn: ...
def exit(self, status: int = 0, msg: str | None = None) -> NoReturn: ...
def error(self, msg: str) -> Never: ...
def exit(self, status: int = 0, msg: str | None = None) -> Never: ...
def expand_prog_name(self, s: str) -> str: ...
def format_epilog(self, formatter: HelpFormatter) -> str: ...
def format_help(self, formatter: HelpFormatter | None = None) -> str: ...
Expand Down
Loading
Loading