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
7 changes: 5 additions & 2 deletions mypy/typeshed/stdlib/asyncio/runners.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
from _typeshed import Unused
from collections.abc import Callable, Coroutine
from collections.abc import Awaitable, Callable, Coroutine
from contextvars import Context
from typing import Any, TypeVar, final
from typing_extensions import Self
Expand All @@ -22,7 +22,10 @@ if sys.version_info >= (3, 11):
def __exit__(self, exc_type: Unused, exc_val: Unused, exc_tb: Unused) -> None: ...
def close(self) -> None: ...
def get_loop(self) -> AbstractEventLoop: ...
def run(self, coro: Coroutine[Any, Any, _T], *, context: Context | None = None) -> _T: ...
if sys.version_info >= (3, 14):
def run(self, coro: Awaitable[_T], *, context: Context | None = None) -> _T: ...
else:
def run(self, coro: Coroutine[Any, Any, _T], *, context: Context | None = None) -> _T: ...

if sys.version_info >= (3, 12):
def run(
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/asyncio/trsock.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class TransportSocket:
def listen(self, backlog: int = ..., /) -> None: ...
@deprecated("Removed in Python 3.11")
def makefile(self) -> BinaryIO: ...
@deprecated("Rmoved in Python 3.11")
@deprecated("Removed in Python 3.11")
def sendfile(self, file: BinaryIO, offset: int = 0, count: int | None = None) -> int: ...
@deprecated("Removed in Python 3.11")
def close(self) -> None: ...
Expand Down
4 changes: 3 additions & 1 deletion mypy/typeshed/stdlib/calendar.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@ if sys.version_info >= (3, 12):

_LocaleType: TypeAlias = tuple[str | None, str | None]

class IllegalMonthError(ValueError):
class IllegalMonthError(ValueError, IndexError):
month: int
def __init__(self, month: int) -> None: ...

class IllegalWeekdayError(ValueError):
weekday: int
def __init__(self, weekday: int) -> None: ...

def isleap(year: int) -> bool: ...
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/ipaddress.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class _BaseNetwork(_IPAddressBase, Generic[_A]):
@property
def broadcast_address(self) -> _A: ...
def compare_networks(self, other: Self) -> int: ...
def hosts(self) -> Iterator[_A] | list[_A]: ...
def hosts(self) -> Iterator[_A]: ...
@property
def is_global(self) -> bool: ...
@property
Expand Down
12 changes: 6 additions & 6 deletions mypy/typeshed/stdlib/mimetypes.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
from _typeshed import StrPath
from collections.abc import Sequence
from collections.abc import Iterable
from typing import IO

__all__ = [
Expand All @@ -25,15 +25,15 @@ if sys.version_info >= (3, 13):
def guess_type(url: StrPath, strict: bool = True) -> tuple[str | None, str | None]: ...
def guess_all_extensions(type: str, strict: bool = True) -> list[str]: ...
def guess_extension(type: str, strict: bool = True) -> str | None: ...
def init(files: Sequence[str] | None = None) -> None: ...
def read_mime_types(file: str) -> dict[str, str] | None: ...
def init(files: Iterable[StrPath] | None = None) -> None: ...
def read_mime_types(file: StrPath) -> dict[str, str] | None: ...
def add_type(type: str, ext: str, strict: bool = True) -> None: ...

if sys.version_info >= (3, 13):
def guess_file_type(path: StrPath, *, strict: bool = True) -> tuple[str | None, str | None]: ...

inited: bool
knownfiles: list[str]
knownfiles: list[StrPath]
suffix_map: dict[str, str]
encodings_map: dict[str, str]
types_map: dict[str, str]
Expand All @@ -44,12 +44,12 @@ class MimeTypes:
encodings_map: dict[str, str]
types_map: tuple[dict[str, str], dict[str, str]]
types_map_inv: tuple[dict[str, str], dict[str, str]]
def __init__(self, filenames: tuple[str, ...] = (), strict: bool = True) -> None: ...
def __init__(self, filenames: Iterable[StrPath] = (), strict: bool = True) -> None: ...
def add_type(self, type: str, ext: str, strict: bool = True) -> None: ...
def guess_extension(self, type: str, strict: bool = True) -> str | None: ...
def guess_type(self, url: StrPath, strict: bool = True) -> tuple[str | None, str | None]: ...
def guess_all_extensions(self, type: str, strict: bool = True) -> list[str]: ...
def read(self, filename: str, strict: bool = True) -> None: ...
def read(self, filename: StrPath, strict: bool = True) -> None: ...
def readfp(self, fp: IO[str], strict: bool = True) -> None: ...
def read_windows_registry(self, strict: bool = True) -> None: ...
if sys.version_info >= (3, 13):
Expand Down
5 changes: 4 additions & 1 deletion mypy/typeshed/stdlib/multiprocessing/managers.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ class BaseListProxy(BaseProxy, MutableSequence[_T]):
def count(self, value: _T, /) -> int: ...
def insert(self, index: SupportsIndex, object: _T, /) -> None: ...
def remove(self, value: _T, /) -> None: ...
if sys.version_info >= (3, 14):
def copy(self) -> list[_T]: ...
# Use BaseListProxy[SupportsRichComparisonT] for the first overload rather than [SupportsRichComparison]
# to work around invariance
@overload
Expand Down Expand Up @@ -326,8 +328,9 @@ class SyncManager(BaseManager):
def dict(self, iterable: Iterable[list[str]], /) -> DictProxy[str, str]: ...
@overload
def dict(self, iterable: Iterable[list[bytes]], /) -> DictProxy[bytes, bytes]: ...
# Overloads are copied from builtins.list.__init__
@overload
def list(self, sequence: Sequence[_T], /) -> ListProxy[_T]: ...
def list(self, iterable: Iterable[_T], /) -> ListProxy[_T]: ...
@overload
def list(self) -> ListProxy[Any]: ...
if sys.version_info >= (3, 14):
Expand Down
4 changes: 4 additions & 0 deletions mypy/typeshed/stdlib/multiprocessing/process.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
from collections.abc import Callable, Iterable, Mapping
from typing import Any

Expand All @@ -20,6 +21,9 @@ class BaseProcess:
) -> None: ...
def run(self) -> None: ...
def start(self) -> None: ...
if sys.version_info >= (3, 14):
def interrupt(self) -> None: ...

def terminate(self) -> None: ...
def kill(self) -> None: ...
def close(self) -> None: ...
Expand Down
3 changes: 3 additions & 0 deletions mypy/typeshed/stdlib/multiprocessing/synchronize.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
import threading
from collections.abc import Callable
from multiprocessing.context import BaseContext
Expand Down Expand Up @@ -45,6 +46,8 @@ class SemLock:
# These methods are copied from the wrapped _multiprocessing.SemLock object
def acquire(self, block: bool = True, timeout: float | None = None) -> bool: ...
def release(self) -> None: ...
if sys.version_info >= (3, 14):
def locked(self) -> bool: ...

class Lock(SemLock):
def __init__(self, *, ctx: BaseContext) -> None: ...
Expand Down
5 changes: 3 additions & 2 deletions mypy/typeshed/stdlib/sqlite3/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ _AdaptedInputData: TypeAlias = _SqliteData | Any
_Parameters: TypeAlias = SupportsLenAndGetItem[_AdaptedInputData] | Mapping[str, _AdaptedInputData]
# Controls the legacy transaction handling mode of sqlite3.
_IsolationLevel: TypeAlias = Literal["DEFERRED", "EXCLUSIVE", "IMMEDIATE"] | None
_RowFactoryOptions: TypeAlias = type[Row] | Callable[[Cursor, Row], object] | None

@type_check_only
class _AnyParamWindowAggregateClass(Protocol):
Expand Down Expand Up @@ -300,7 +301,7 @@ class Connection:
def autocommit(self) -> int: ...
@autocommit.setter
def autocommit(self, val: int) -> None: ...
row_factory: Any
row_factory: _RowFactoryOptions
text_factory: Any
if sys.version_info >= (3, 12):
def __init__(
Expand Down Expand Up @@ -416,7 +417,7 @@ class Cursor(Iterator[Any]):
def description(self) -> tuple[tuple[str, None, None, None, None, None, None], ...] | MaybeNone: ...
@property
def lastrowid(self) -> int | None: ...
row_factory: Callable[[Cursor, Row], object] | None
row_factory: _RowFactoryOptions
@property
def rowcount(self) -> int: ...
def __init__(self, cursor: Connection, /) -> None: ...
Expand Down
1 change: 0 additions & 1 deletion mypy/typeshed/stdlib/subprocess.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,6 @@ elif sys.version_info >= (3, 10):
) -> CompletedProcess[Any]: ...

else:
# 3.9 adds arguments "user", "group", "extra_groups" and "umask"
@overload
def run(
args: _CMD,
Expand Down
3 changes: 3 additions & 0 deletions mypy/typeshed/stdlib/threading.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ class Condition:
) -> None: ...
def acquire(self, blocking: bool = True, timeout: float = -1) -> bool: ...
def release(self) -> None: ...
if sys.version_info >= (3, 14):
def locked(self) -> bool: ...

def wait(self, timeout: float | None = None) -> bool: ...
def wait_for(self, predicate: Callable[[], _T], timeout: float | None = None) -> _T: ...
def notify(self, n: int = 1) -> None: ...
Expand Down
12 changes: 6 additions & 6 deletions mypy/typeshed/stdlib/tkinter/constants.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from typing import Final

# These are not actually bools. See #4669
NO: Final[bool]
YES: Final[bool]
TRUE: Final[bool]
FALSE: Final[bool]
ON: Final[bool]
OFF: Final[bool]
YES: Final = True
NO: Final = False
TRUE: Final = True
FALSE: Final = False
ON: Final = True
OFF: Final = False
N: Final = "n"
S: Final = "s"
W: Final = "w"
Expand Down
13 changes: 9 additions & 4 deletions mypy/typeshed/stdlib/typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ if sys.version_info >= (3, 10):
def __or__(self, other: Any) -> _SpecialForm: ...
def __ror__(self, other: Any) -> _SpecialForm: ...
__supertype__: type | NewType
__name__: str

else:
def NewType(name: str, tp: Any) -> Any: ...
Expand All @@ -408,7 +409,13 @@ _TC = TypeVar("_TC", bound=type[object])

def overload(func: _F) -> _F: ...
def no_type_check(arg: _F) -> _F: ...
def no_type_check_decorator(decorator: Callable[_P, _T]) -> Callable[_P, _T]: ...

if sys.version_info >= (3, 13):
@deprecated("Deprecated since Python 3.13; removed in Python 3.15.")
def no_type_check_decorator(decorator: Callable[_P, _T]) -> Callable[_P, _T]: ...

else:
def no_type_check_decorator(decorator: Callable[_P, _T]) -> Callable[_P, _T]: ...

# This itself is only available during type checking
def type_check_only(func_or_cls: _FT) -> _FT: ...
Expand Down Expand Up @@ -1000,9 +1007,7 @@ class NamedTuple(tuple[Any, ...]):
@overload
def __init__(self, typename: str, fields: Iterable[tuple[str, Any]], /) -> None: ...
@overload
@typing_extensions.deprecated(
"Creating a typing.NamedTuple using keyword arguments is deprecated and support will be removed in Python 3.15"
)
@deprecated("Creating a typing.NamedTuple using keyword arguments is deprecated and support will be removed in Python 3.15")
def __init__(self, typename: str, fields: None = None, /, **kwargs: Any) -> None: ...
@classmethod
def _make(cls, iterable: Iterable[Any]) -> typing_extensions.Self: ...
Expand Down
1 change: 1 addition & 0 deletions mypy/typeshed/stdlib/typing_extensions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ else:
def __init__(self, name: str, tp: AnnotationForm) -> None: ...
def __call__(self, obj: _T, /) -> _T: ...
__supertype__: type | NewType
__name__: str
if sys.version_info >= (3, 10):
def __or__(self, other: Any) -> _SpecialForm: ...
def __ror__(self, other: Any) -> _SpecialForm: ...
Expand Down
1 change: 1 addition & 0 deletions mypy/typeshed/stdlib/unittest/mock.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ class NonCallableMock(Base, Any):
call_count: int
call_args: _Call | MaybeNone
call_args_list: _CallList
method_calls: _CallList
mock_calls: _CallList
def _format_mock_call_signature(self, args: Any, kwargs: Any) -> str: ...
def _call_matcher(self, _call: tuple[_Call, ...]) -> _Call: ...
Expand Down
7 changes: 7 additions & 0 deletions mypy/typeshed/stdlib/urllib/request.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,14 @@ if sys.version_info < (3, 14):
__all__ += ["URLopener", "FancyURLopener"]

_T = TypeVar("_T")

# The actual type is `addinfourl | HTTPResponse`, but users would need to use `typing.cast` or `isinstance` to narrow the type,
# so we use `Any` instead.
# See
# - https://github.com/python/typeshed/pull/15042
# - https://github.com/python/typing/issues/566
_UrlopenRet: TypeAlias = Any

_DataType: TypeAlias = ReadableBuffer | SupportsRead[bytes] | Iterable[bytes] | None

if sys.version_info >= (3, 13):
Expand Down
1 change: 1 addition & 0 deletions mypy/typeshed/stdlib/xml/etree/ElementTree.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ _Root = TypeVar("_Root", Element, Element | None, default=Element | None)
class ElementTree(Generic[_Root]):
def __init__(self, element: Element[Any] | None = None, file: _FileRead | None = None) -> None: ...
def getroot(self) -> _Root: ...
def _setroot(self, element: Element[Any]) -> None: ...
def parse(self, source: _FileRead, parser: XMLParser | None = None) -> Element: ...
def iter(self, tag: str | None = None) -> Generator[Element, None, None]: ...
def find(self, path: str, namespaces: dict[str, str] | None = None) -> Element | None: ...
Expand Down
2 changes: 2 additions & 0 deletions mypy/typeshed/stdlib/zipfile/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ class ZipInfo:
def from_file(cls, filename: StrPath, arcname: StrPath | None = None, *, strict_timestamps: bool = True) -> Self: ...
def is_dir(self) -> bool: ...
def FileHeader(self, zip64: bool | None = None) -> bytes: ...
if sys.version_info >= (3, 14):
def _for_archive(self, archive: ZipFile) -> Self: ...

if sys.version_info >= (3, 12):
from zipfile._path import CompleteDirs as CompleteDirs, Path as Path
Expand Down