Skip to content
2 changes: 0 additions & 2 deletions mypy/typeshed/stdlib/VERSIONS
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,6 @@ posixpath: 3.0-
pprint: 3.0-
profile: 3.0-
profiling: 3.15-
profiling.sampling: 3.15-
profiling.tracing: 3.15-
pstats: 3.0-
pty: 3.0-
pwd: 3.0-
Expand Down
32 changes: 16 additions & 16 deletions mypy/typeshed/stdlib/_curses.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ class window: # undocumented
def chgat(self, y: int, x: int, num: int, attr: int) -> None: ...

def clear(self) -> None: ...
def clearok(self, yes: int) -> None: ...
def clearok(self, flag: bool, /) -> None: ...
def clrtobot(self) -> None: ...
def clrtoeol(self) -> None: ...
def cursyncup(self) -> None: ...
Expand Down Expand Up @@ -480,9 +480,9 @@ class window: # undocumented
@overload
def hline(self, y: int, x: int, ch: _ChType, n: int) -> None: ...

def idcok(self, flag: bool) -> None: ...
def idlok(self, yes: bool) -> None: ...
def immedok(self, flag: bool) -> None: ...
def idcok(self, flag: bool, /) -> None: ...
def idlok(self, flag: bool, /) -> None: ...
def immedok(self, flag: bool, /) -> None: ...

@overload
def inch(self) -> int: ...
Expand All @@ -494,7 +494,7 @@ class window: # undocumented
@overload
def insch(self, y: int, x: int, ch: _ChType, attr: int = ...) -> None: ...

def insdelln(self, nlines: int) -> None: ...
def insdelln(self, nlines: int, /) -> None: ...
def insertln(self) -> None: ...

@overload
Expand All @@ -514,13 +514,13 @@ class window: # undocumented

def is_linetouched(self, line: int, /) -> bool: ...
def is_wintouched(self) -> bool: ...
def keypad(self, yes: bool, /) -> None: ...
def leaveok(self, yes: bool) -> None: ...
def move(self, new_y: int, new_x: int) -> None: ...
def mvderwin(self, y: int, x: int) -> None: ...
def mvwin(self, new_y: int, new_x: int) -> None: ...
def nodelay(self, yes: bool) -> None: ...
def notimeout(self, yes: bool) -> None: ...
def keypad(self, flag: bool, /) -> None: ...
def leaveok(self, flag: bool, /) -> None: ...
def move(self, new_y: int, new_x: int, /) -> None: ...
def mvderwin(self, y: int, x: int, /) -> None: ...
def mvwin(self, new_y: int, new_x: int, /) -> None: ...
def nodelay(self, flag: bool, /) -> None: ...
def notimeout(self, flag: bool, /) -> None: ...

@overload
def noutrefresh(self) -> None: ...
Expand Down Expand Up @@ -550,9 +550,9 @@ class window: # undocumented
@overload
def refresh(self, pminrow: int, pmincol: int, sminrow: int, smincol: int, smaxrow: int, smaxcol: int) -> None: ...

def resize(self, nlines: int, ncols: int) -> None: ...
def resize(self, nlines: int, ncols: int, /) -> None: ...
def scroll(self, lines: int = 1) -> None: ...
def scrollok(self, flag: bool) -> None: ...
def scrollok(self, flag: bool, /) -> None: ...
def setscrreg(self, top: int, bottom: int, /) -> None: ...
def standend(self) -> None: ...
def standout(self) -> None: ...
Expand All @@ -568,9 +568,9 @@ class window: # undocumented
def subwin(self, nlines: int, ncols: int, begin_y: int, begin_x: int) -> window: ...

def syncdown(self) -> None: ...
def syncok(self, flag: bool) -> None: ...
def syncok(self, flag: bool, /) -> None: ...
def syncup(self) -> None: ...
def timeout(self, delay: int) -> None: ...
def timeout(self, delay: int, /) -> None: ...
def touchline(self, start: int, count: int, changed: bool = True) -> None: ...
def touchwin(self) -> None: ...
def untouchwin(self) -> None: ...
Expand Down
21 changes: 19 additions & 2 deletions mypy/typeshed/stdlib/ast.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -956,14 +956,27 @@ class DictComp(expr):
else:
value: expr
generators: list[comprehension]
if sys.version_info >= (3, 13):
if sys.version_info >= (3, 15):
def __init__(
self, key: expr, value: expr | None = None, generators: list[comprehension] = ..., **kwargs: Unpack[_Attributes]
) -> None: ...
elif sys.version_info >= (3, 13):
def __init__(
self, key: expr, value: expr, generators: list[comprehension] = ..., **kwargs: Unpack[_Attributes]
) -> None: ...
else:
def __init__(self, key: expr, value: expr, generators: list[comprehension], **kwargs: Unpack[_Attributes]) -> None: ...

if sys.version_info >= (3, 14):
if sys.version_info >= (3, 15):
def __replace__(
self,
*,
key: expr = ...,
value: expr | None = ...,
generators: list[comprehension] = ...,
**kwargs: Unpack[_Attributes],
) -> Self: ...
elif sys.version_info >= (3, 14):
def __replace__(
self, *, key: expr = ..., value: expr = ..., generators: list[comprehension] = ..., **kwargs: Unpack[_Attributes]
) -> Self: ...
Expand Down Expand Up @@ -2147,6 +2160,10 @@ class NodeVisitor:
def visit_TypeVarTuple(self, node: TypeVarTuple) -> Any: ...
def visit_TypeAlias(self, node: TypeAlias) -> Any: ...

if sys.version_info >= (3, 14):
def visit_TemplateStr(self, node: TemplateStr) -> Any: ...
def visit_Interpolation(self, node: Interpolation) -> Any: ...

# visit methods for deprecated nodes
def visit_ExtSlice(self, node: ExtSlice) -> Any: ...
def visit_Index(self, node: Index) -> Any: ...
Expand Down
14 changes: 8 additions & 6 deletions mypy/typeshed/stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ from _typeshed import (
from collections.abc import Awaitable, Callable, Iterable, Iterator, MutableSet, Reversible, Set as AbstractSet, Sized
from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper
from os import PathLike
from types import CellType, CodeType, EllipsisType, GenericAlias, NotImplementedType, TracebackType
from types import CellType, CodeType, EllipsisType, GenericAlias, NotImplementedType, TracebackType, UnionType

# mypy crashes if any of {ByteString, Sequence, MutableSequence, Mapping, MutableMapping}
# are imported from collections.abc in builtins.pyi
Expand Down Expand Up @@ -2080,11 +2080,13 @@ if sys.version_info >= (3, 15):
class sentinel:
__name__: str
__module__: str
def __new__(cls, name: str, /, *, repr: str | None = None) -> Self: ...
def __copy__(self, /) -> Self: ...
def __deepcopy__(self, memo: Any, /) -> Self: ...
def __or__(self, other: Any, /) -> Any: ...
def __ror__(self, other: Any, /) -> Any: ...
def __new__(cls, name: str, /, *, repr: str | None = None) -> sentinel: ...
def __copy__(self, /) -> sentinel: ...
def __deepcopy__(self, memo: Any, /) -> sentinel: ...
# `other` can be any legal form for unions.
# `x | x` creates a `sentinel` instance if `x` is a sentinel, not a `UnionType` instance.
def __or__(self, other: Any, /) -> UnionType | sentinel: ...
def __ror__(self, other: Any, /) -> UnionType | sentinel: ...

@overload
def sorted(
Expand Down
7 changes: 4 additions & 3 deletions mypy/typeshed/stdlib/fnmatch.pyi
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import sys
from collections.abc import Iterable
from os import PathLike
from typing import AnyStr

__all__ = ["filter", "fnmatch", "fnmatchcase", "translate"]
if sys.version_info >= (3, 14):
__all__ += ["filterfalse"]

def fnmatch(name: AnyStr, pat: AnyStr) -> bool: ...
def fnmatch(name: AnyStr | PathLike[AnyStr], pat: AnyStr | PathLike[AnyStr]) -> bool: ...
def fnmatchcase(name: AnyStr, pat: AnyStr) -> bool: ...
def filter(names: Iterable[AnyStr], pat: AnyStr) -> list[AnyStr]: ...
def filter(names: Iterable[AnyStr | PathLike[AnyStr]], pat: AnyStr | PathLike[AnyStr]) -> list[AnyStr]: ...
def translate(pat: str) -> str: ...

if sys.version_info >= (3, 14):
def filterfalse(names: Iterable[AnyStr], pat: AnyStr) -> list[AnyStr]: ...
def filterfalse(names: Iterable[AnyStr | PathLike[AnyStr]], pat: AnyStr | PathLike[AnyStr]) -> list[AnyStr]: ...
3 changes: 3 additions & 0 deletions mypy/typeshed/stdlib/html/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import re

__all__ = ["escape", "unescape"]

def escape(s: str, quote: bool = True) -> str: ...
def unescape(s: str) -> str: ...
def _replace_charref(s: re.Match[str]) -> str: ...
10 changes: 5 additions & 5 deletions mypy/typeshed/stdlib/inspect.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ from typing import (
overload,
type_check_only,
)
from typing_extensions import Self, TypeIs, deprecated, disjoint_base
from typing_extensions import Never, Self, TypeIs, deprecated, disjoint_base

if sys.version_info >= (3, 14):
from annotationlib import Format
Expand Down Expand Up @@ -217,7 +217,7 @@ if sys.version_info >= (3, 11):

def getmodulename(path: StrPath) -> str | None: ...
def ismodule(object: object) -> TypeIs[ModuleType]: ...
def isclass(object: object) -> TypeIs[type[Any]]: ...
def isclass(object: object) -> TypeIs[type[object]]: ...
def ismethod(object: object) -> TypeIs[MethodType]: ...

if sys.version_info >= (3, 14):
Expand Down Expand Up @@ -245,7 +245,7 @@ def iscoroutinefunction(obj: Callable[_P, object]) -> TypeGuard[Callable[_P, Cor
@overload
def iscoroutinefunction(obj: object) -> TypeGuard[Callable[..., CoroutineType[Any, Any, Any]]]: ...

def isgenerator(object: object) -> TypeIs[GeneratorType[Any, Any, Any]]: ...
def isgenerator(object: object) -> TypeIs[GeneratorType[object, Never, object]]: ...
def iscoroutine(object: object) -> TypeIs[CoroutineType[Any, Any, Any]]: ...
def isawaitable(object: object) -> TypeIs[Awaitable[Any]]: ...

Expand All @@ -264,7 +264,7 @@ class _SupportsSet(Protocol[_T_contra, _V_contra]):
class _SupportsDelete(Protocol[_T_contra]):
def __delete__(self, instance: _T_contra, /) -> None: ...

def isasyncgen(object: object) -> TypeIs[AsyncGeneratorType[Any, Any]]: ...
def isasyncgen(object: object) -> TypeIs[AsyncGeneratorType[object, Never]]: ...
def istraceback(object: object) -> TypeIs[TracebackType]: ...
def isframe(object: object) -> TypeIs[FrameType]: ...
def iscode(object: object) -> TypeIs[CodeType]: ...
Expand All @@ -289,7 +289,7 @@ def ismethoddescriptor(object: object) -> TypeIs[MethodDescriptorType]: ...
def ismemberdescriptor(object: object) -> TypeIs[MemberDescriptorType]: ...
def isabstract(object: object) -> bool: ...
def isgetsetdescriptor(object: object) -> TypeIs[GetSetDescriptorType]: ...
def isdatadescriptor(object: object) -> TypeIs[_SupportsSet[Any, Any] | _SupportsDelete[Any]]: ...
def isdatadescriptor(object: object) -> TypeIs[_SupportsSet[Never, Never] | _SupportsDelete[Never]]: ...

#
# Retrieving source code
Expand Down
102 changes: 100 additions & 2 deletions mypy/typeshed/stdlib/profiling/sampling/gecko_collector.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,109 @@
from _typeshed import StrOrBytesPath
from collections.abc import Sequence
from _typeshed import Incomplete, StrOrBytesPath, StrPath
from collections.abc import Generator, Sequence
from tempfile import TemporaryDirectory
from typing import Any, ClassVar, Final, TypedDict, type_check_only

from _remote_debugging import AwaitedInfo, InterpreterInfo

from .collector import Collector, _Timestamps

@type_check_only
class _GeckoCategory(TypedDict):
name: str
color: str
subcategories: list[str]

THREAD_STATUS_HAS_GIL: Final[int]
THREAD_STATUS_ON_CPU: Final[int]
THREAD_STATUS_UNKNOWN: Final[int]
THREAD_STATUS_GIL_REQUESTED: Final[int]
THREAD_STATUS_HAS_EXCEPTION: Final[int]
THREAD_STATUS_MAIN_THREAD: Final[int]

GECKO_CATEGORIES: Final[list[_GeckoCategory]]

CATEGORY_OTHER: Final = 0
CATEGORY_PYTHON: Final = 1
CATEGORY_NATIVE: Final = 2
CATEGORY_GC: Final = 3
CATEGORY_GIL: Final = 4
CATEGORY_CPU: Final = 5
CATEGORY_CODE_TYPE: Final = 6
CATEGORY_OPCODES: Final = 7
CATEGORY_EXCEPTION: Final = 8

DEFAULT_SUBCATEGORY: Final = 0

GECKO_FORMAT_VERSION: Final = 32
GECKO_PREPROCESSED_VERSION: Final = 57

RESOURCE_TYPE_LIBRARY: Final = 1

FRAME_ADDRESS_NONE: Final = -1
FRAME_INLINE_DEPTH_ROOT: Final = 0

PROCESS_TYPE_MAIN: Final = 0
STACKWALK_DISABLED: Final = 0

DEFAULT_SPILL_BUFFER_BYTES: Final[int]

class SpillColumn:
path: str
buffer: bytearray

def __init__(self, directory: StrPath, basename: StrPath, *, buffer_bytes: int | None = None) -> None: ...
# "value" accepts the same types as json.JSONEncoder.encode()
def append(self, value: Any) -> None: ...
def flush(self) -> None: ...
def iter_tokens(self) -> Generator[str]: ...

class GeckoThreadSpill:
sample_count: int
marker_count: int
def __init__(self, directory: StrPath, tid: int) -> None: ...
def append_sample(self, stack_index: int, time_ms: float) -> None: ...
def append_marker(
self, name_idx: int, start_time: float, end_time: float, phase: int, category: int, data: dict[str, Any]
) -> None: ...
def prepare_read(self) -> None: ...

class GeckoCollector(Collector):
aggregating: ClassVar[bool]

sample_interval_usec: int
skip_idle: bool
opcodes_enabled: bool
start_time: float

global_strings: list[str]
global_string_map: dict[str, int]

threads: dict[int, dict[str, Any]]
spill_dir: TemporaryDirectory[str] | None
exported: bool

libs: list[Incomplete]

sample_count: int
last_sample_time: float
interval: float

has_gil_start: dict[Incomplete, Incomplete]
no_gil_start: dict[Incomplete, Incomplete]
on_cpu_start: dict[Incomplete, Incomplete]
off_cpu_start: dict[Incomplete, Incomplete]
python_code_start: dict[Incomplete, Incomplete]
native_code_start: dict[Incomplete, Incomplete]
gil_wait_start: dict[Incomplete, Incomplete]
exception_start: dict[Incomplete, Incomplete]
no_exception_start: dict[Incomplete, Incomplete]

gc_start_per_thread: dict[int, float]

initialized_threads: set[Incomplete]

opcode_state: dict[int, tuple[Incomplete, int, int, str, str, float]]

def __init__(self, sample_interval_usec: int, *, skip_idle: bool = False, opcodes: bool = False) -> None: ...
def collect(
self, stack_frames: Sequence[InterpreterInfo] | Sequence[AwaitedInfo], timestamps_us: _Timestamps = None
Expand Down
6 changes: 4 additions & 2 deletions mypy/typeshed/stdlib/types.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,10 @@ class GenericAlias:
@property
def __typing_unpacked_tuple_args__(self) -> tuple[Any, ...] | None: ...

def __or__(self, value: Any, /) -> UnionType: ...
def __ror__(self, value: Any, /) -> UnionType: ...
# `other` can be any legal form for unions.
# `list[int] | list[int]` creates a `GenericAlias` instance, not a `UnionType` instance
def __or__(self, value: Any, /) -> UnionType | GenericAlias: ...
def __ror__(self, value: Any, /) -> UnionType | GenericAlias: ...

# GenericAlias delegates attr access to `__origin__`
def __getattr__(self, name: str) -> Any: ...
Expand Down
Loading
Loading