Skip to content
Merged
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
9 changes: 3 additions & 6 deletions mypy/typeshed/stdlib/_collections_abc.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import sys
from abc import abstractmethod
from types import MappingProxyType
from typing import ( # noqa: Y022,Y038,UP035
from typing import ( # noqa: Y022,Y038,UP035,Y057
AbstractSet as Set,
AsyncGenerator as AsyncGenerator,
AsyncIterable as AsyncIterable,
AsyncIterator as AsyncIterator,
Awaitable as Awaitable,
ByteString as ByteString,
Callable as Callable,
ClassVar,
Collection as Collection,
Expand Down Expand Up @@ -59,12 +60,8 @@ __all__ = [
"ValuesView",
"Sequence",
"MutableSequence",
"ByteString",
]
if sys.version_info < (3, 14):
from typing import ByteString as ByteString # noqa: Y057,UP035

__all__ += ["ByteString"]

if sys.version_info >= (3, 12):
__all__ += ["Buffer"]

Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/_frozen_importlib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def __import__(
name: str,
globals: Mapping[str, object] | None = None,
locals: Mapping[str, object] | None = None,
fromlist: Sequence[str] = (),
fromlist: Sequence[str] | None = (),
level: int = 0,
) -> ModuleType: ...
def spec_from_loader(
Expand Down
40 changes: 20 additions & 20 deletions mypy/typeshed/stdlib/_tkinter.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -54,34 +54,34 @@ _TkinterTraceFunc: TypeAlias = Callable[[tuple[str, ...]], object]
@final
class TkappType:
# Please keep in sync with tkinter.Tk
def adderrorinfo(self, msg, /): ...
def adderrorinfo(self, msg: str, /): ...
def call(self, command: Any, /, *args: Any) -> Any: ...
def createcommand(self, name, func, /): ...
def createcommand(self, name: str, func, /): ...
if sys.platform != "win32":
def createfilehandler(self, file, mask, func, /): ...
def deletefilehandler(self, file, /): ...
def createfilehandler(self, file, mask: int, func, /): ...
def deletefilehandler(self, file, /) -> None: ...

def createtimerhandler(self, milliseconds, func, /): ...
def deletecommand(self, name, /): ...
def createtimerhandler(self, milliseconds: int, func, /): ...
def deletecommand(self, name: str, /): ...
def dooneevent(self, flags: int = 0, /): ...
def eval(self, script: str, /) -> str: ...
def evalfile(self, fileName, /): ...
def exprboolean(self, s, /): ...
def exprdouble(self, s, /): ...
def exprlong(self, s, /): ...
def exprstring(self, s, /): ...
def getboolean(self, arg, /): ...
def getdouble(self, arg, /): ...
def getint(self, arg, /): ...
def evalfile(self, fileName: str, /): ...
def exprboolean(self, s: str, /): ...
def exprdouble(self, s: str, /): ...
def exprlong(self, s: str, /): ...
def exprstring(self, s: str, /): ...
def getboolean(self, arg, /) -> bool: ...
def getdouble(self, arg, /) -> float: ...
def getint(self, arg, /) -> int: ...
def getvar(self, *args, **kwargs): ...
def globalgetvar(self, *args, **kwargs): ...
def globalsetvar(self, *args, **kwargs): ...
def globalunsetvar(self, *args, **kwargs): ...
def interpaddr(self) -> int: ...
def loadtk(self) -> None: ...
def mainloop(self, threshold: int = 0, /): ...
def quit(self): ...
def record(self, script, /): ...
def mainloop(self, threshold: int = 0, /) -> None: ...
def quit(self) -> None: ...
def record(self, script: str, /): ...
def setvar(self, *ags, **kwargs): ...
if sys.version_info < (3, 11):
@deprecated("Deprecated since Python 3.9; removed in Python 3.11. Use `splitlist()` instead.")
Expand All @@ -90,7 +90,7 @@ class TkappType:
def splitlist(self, arg, /): ...
def unsetvar(self, *args, **kwargs): ...
def wantobjects(self, *args, **kwargs): ...
def willdispatch(self): ...
def willdispatch(self) -> None: ...
if sys.version_info >= (3, 12):
def gettrace(self, /) -> _TkinterTraceFunc | None: ...
def settrace(self, func: _TkinterTraceFunc | None, /) -> None: ...
Expand Down Expand Up @@ -140,5 +140,5 @@ else:
/,
): ...

def getbusywaitinterval(): ...
def setbusywaitinterval(new_val, /): ...
def getbusywaitinterval() -> int: ...
def setbusywaitinterval(new_val: int, /) -> None: ...
5 changes: 5 additions & 0 deletions mypy/typeshed/stdlib/asyncio/tools.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
from collections.abc import Iterable
from enum import Enum
from typing import NamedTuple, SupportsIndex, type_check_only
Expand Down Expand Up @@ -37,5 +38,9 @@ class CycleFoundException(Exception):
def get_all_awaited_by(pid: SupportsIndex) -> list[_AwaitedInfo]: ...
def build_async_tree(result: Iterable[_AwaitedInfo], task_emoji: str = "(T)", cor_emoji: str = "") -> list[list[str]]: ...
def build_task_table(result: Iterable[_AwaitedInfo]) -> list[list[int | str]]: ...

if sys.version_info >= (3, 14):
def exit_with_permission_help_text() -> None: ...

def display_awaited_by_tasks_table(pid: SupportsIndex) -> None: ...
def display_awaited_by_tasks_tree(pid: SupportsIndex) -> None: ...
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1917,7 +1917,7 @@ def __import__(
name: str,
globals: Mapping[str, object] | None = None,
locals: Mapping[str, object] | None = None,
fromlist: Sequence[str] = (),
fromlist: Sequence[str] | None = (),
level: int = 0,
) -> types.ModuleType: ...
def __build_class__(func: Callable[[], CellType | Any], name: str, /, *bases: Any, metaclass: Any = ..., **kwds: Any) -> Any: ...
Expand Down
34 changes: 25 additions & 9 deletions mypy/typeshed/stdlib/concurrent/interpreters/_queues.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,30 @@ if sys.version_info >= (3, 13): # needed to satisfy pyright checks for Python <
def empty(self) -> bool: ...
def full(self) -> bool: ...
def qsize(self) -> int: ...
def put(
self,
obj: object,
timeout: SupportsIndex | None = None,
*,
unbounditems: _AnyUnbound | None = None,
_delay: float = 0.01,
) -> None: ...
if sys.version_info >= (3, 14):
def put(
self,
obj: object,
block: bool = True,
timeout: SupportsIndex | None = None,
*,
unbounditems: _AnyUnbound | None = None,
_delay: float = 0.01,
) -> None: ...
else:
def put(
self,
obj: object,
timeout: SupportsIndex | None = None,
*,
unbounditems: _AnyUnbound | None = None,
_delay: float = 0.01,
) -> None: ...

def put_nowait(self, obj: object, *, unbounditems: _AnyUnbound | None = None) -> None: ...
def get(self, timeout: SupportsIndex | None = None, *, _delay: float = 0.01) -> object: ...
if sys.version_info >= (3, 14):
def get(self, block: bool = True, timeout: SupportsIndex | None = None, *, _delay: float = 0.01) -> object: ...
else:
def get(self, timeout: SupportsIndex | None = None, *, _delay: float = 0.01) -> object: ...

def get_nowait(self) -> object: ...
6 changes: 3 additions & 3 deletions mypy/typeshed/stdlib/configparser.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ class RawConfigParser(_Parser):
) -> None: ...

def __len__(self) -> int: ...
def __getitem__(self, key: str) -> SectionProxy: ...
def __setitem__(self, key: str, value: _Section) -> None: ...
def __delitem__(self, key: str) -> None: ...
def __getitem__(self, key: _SectionName) -> SectionProxy: ...
def __setitem__(self, key: _SectionName, value: _Section) -> None: ...
def __delitem__(self, key: _SectionName) -> None: ...
def __iter__(self) -> Iterator[str]: ...
def __contains__(self, key: object) -> bool: ...
def defaults(self) -> _Section: ...
Expand Down
12 changes: 6 additions & 6 deletions mypy/typeshed/stdlib/copy.pyi
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import sys
from typing import Any, Protocol, TypeVar, type_check_only
from typing_extensions import Self

__all__ = ["Error", "copy", "deepcopy"]

_T = TypeVar("_T")
_SR = TypeVar("_SR", bound=_SupportsReplace)
_RT_co = TypeVar("_RT_co", covariant=True)

@type_check_only
class _SupportsReplace(Protocol):
# In reality doesn't support args, but there's no other great way to express this.
def __replace__(self, *args: Any, **kwargs: Any) -> Self: ...
class _SupportsReplace(Protocol[_RT_co]):
# In reality doesn't support args, but there's no great way to express this.
def __replace__(self, /, *_: Any, **changes: Any) -> _RT_co: ...

# None in CPython but non-None in Jython
PyStringMap: Any
Expand All @@ -21,7 +20,8 @@ def copy(x: _T) -> _T: ...

if sys.version_info >= (3, 13):
__all__ += ["replace"]
def replace(obj: _SR, /, **changes: Any) -> _SR: ...
# The types accepted by `**changes` match those of `obj.__replace__`.
def replace(obj: _SupportsReplace[_RT_co], /, **changes: Any) -> _RT_co: ...

class Error(Exception): ...

Expand Down
5 changes: 3 additions & 2 deletions mypy/typeshed/stdlib/curses/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ _T = TypeVar("_T")
_P = ParamSpec("_P")

# available after calling `curses.initscr()`
LINES: Final[int]
COLS: Final[int]
# not `Final` as it can change during the terminal resize:
LINES: int
COLS: int

# available after calling `curses.start_color()`
COLORS: Final[int]
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/dbm/sqlite3.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ class _Database(MutableMapping[bytes, bytes]):
def __enter__(self) -> Self: ...
def __exit__(self, *args: Unused) -> None: ...

def open(filename: StrOrBytesPath, /, flag: Literal["r", "w,", "c", "n"] = "r", mode: int = 0o666) -> _Database: ...
def open(filename: StrOrBytesPath, /, flag: Literal["r", "w", "c", "n"] = "r", mode: int = 0o666) -> _Database: ...
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/email/headerregistry.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class DateHeader:
max_count: ClassVar[Literal[1] | None]
def init(self, name: str, *, parse_tree: TokenList, defects: Iterable[MessageDefect], datetime: _datetime) -> None: ...
@property
def datetime(self) -> _datetime: ...
def datetime(self) -> _datetime | None: ...
@staticmethod
def value_parser(value: str) -> UnstructuredTokenList: ...
@classmethod
Expand Down
1 change: 1 addition & 0 deletions mypy/typeshed/stdlib/errno.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ if sys.platform == "darwin":
ESHLIBVERS: Final[int]
if sys.version_info >= (3, 11):
EQFULL: Final[int]
ENOTCAPABLE: Final[int] # available starting with 3.11.1

if sys.platform != "darwin":
EDEADLOCK: Final[int]
Expand Down
8 changes: 7 additions & 1 deletion mypy/typeshed/stdlib/faulthandler.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ if sys.version_info >= (3, 14):
def dump_c_stack(file: FileDescriptorLike = ...) -> None: ...

def dump_traceback_later(timeout: float, repeat: bool = ..., file: FileDescriptorLike = ..., exit: bool = ...) -> None: ...
def enable(file: FileDescriptorLike = ..., all_threads: bool = ...) -> None: ...

if sys.version_info >= (3, 14):
def enable(file: FileDescriptorLike = ..., all_threads: bool = ..., c_stack: bool = True) -> None: ...

else:
def enable(file: FileDescriptorLike = ..., all_threads: bool = ...) -> None: ...

def is_enabled() -> bool: ...

if sys.platform != "win32":
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/importlib/resources/_common.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if sys.version_info >= (3, 11):
@overload
def files(anchor: Anchor | None = None) -> Traversable: ...
@overload
@deprecated("First parameter to files is renamed to 'anchor'")
@deprecated("Deprecated since Python 3.12; will be removed in Python 3.15. Use `anchor` parameter instead.")
def files(package: Anchor | None = None) -> Traversable: ...

else:
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/multiprocessing/shared_memory.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SharedMemory:
def __init__(self, name: str | None = None, create: bool = False, size: int = 0) -> None: ...

@property
def buf(self) -> memoryview: ...
def buf(self) -> memoryview | None: ...
@property
def name(self) -> str: ...
@property
Expand Down
Loading