mirror of https://github.com/astral-sh/ruff
[ty] Sync vendored typeshed stubs (#21715)
Co-authored-by: typeshedbot <> Co-authored-by: David Peter <mail@david-peter.de>
This commit is contained in:
parent
d6e472f297
commit
b08f0b2caa
|
|
@ -145,14 +145,14 @@ mod tests {
|
|||
|
||||
assert_snapshot!(test.goto_type_definition(), @r"
|
||||
info[goto-type-definition]: Type definition
|
||||
--> stdlib/typing.pyi:770:1
|
||||
--> stdlib/typing.pyi:781:1
|
||||
|
|
||||
768 | def __class_getitem__(cls, args: TypeVar | tuple[TypeVar, ...]) -> _Final: ...
|
||||
769 |
|
||||
770 | Generic: type[_Generic]
|
||||
779 | def __class_getitem__(cls, args: TypeVar | tuple[TypeVar, ...]) -> _Final: ...
|
||||
780 |
|
||||
781 | Generic: type[_Generic]
|
||||
| ^^^^^^^
|
||||
771 |
|
||||
772 | class _ProtocolMeta(ABCMeta):
|
||||
782 |
|
||||
783 | class _ProtocolMeta(ABCMeta):
|
||||
|
|
||||
info: Source
|
||||
--> main.py:4:1
|
||||
|
|
|
|||
|
|
@ -91,14 +91,14 @@ error[missing-argument]: No argument provided for required parameter `arg` of bo
|
|||
7 | from typing_extensions import deprecated
|
||||
|
|
||||
info: Parameter declared here
|
||||
--> stdlib/typing_extensions.pyi:1000:28
|
||||
--> stdlib/typing_extensions.pyi:1001:28
|
||||
|
|
||||
998 | stacklevel: int
|
||||
999 | def __init__(self, message: LiteralString, /, *, category: type[Warning] | None = ..., stacklevel: int = 1) -> None: ...
|
||||
1000 | def __call__(self, arg: _T, /) -> _T: ...
|
||||
999 | stacklevel: int
|
||||
1000 | def __init__(self, message: LiteralString, /, *, category: type[Warning] | None = ..., stacklevel: int = 1) -> None: ...
|
||||
1001 | def __call__(self, arg: _T, /) -> _T: ...
|
||||
| ^^^^^^^
|
||||
1001 |
|
||||
1002 | @final
|
||||
1002 |
|
||||
1003 | @final
|
||||
|
|
||||
info: rule `missing-argument` is enabled by default
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
f8cdc0bd526301e873cd952eb0d457bdf2554e57
|
||||
ef2b90c67e5c668b91b3ae121baf00ee5165c30b
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -50,9 +50,12 @@ if sys.version_info >= (3, 11):
|
|||
|
||||
def get_loop(self) -> AbstractEventLoop:
|
||||
"""Return embedded event loop."""
|
||||
|
||||
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:
|
||||
"""Run code in the embedded event loop."""
|
||||
else:
|
||||
def run(self, coro: Coroutine[Any, Any, _T], *, context: Context | None = None) -> _T:
|
||||
"""Run a coroutine inside the embedded event loop."""
|
||||
|
||||
if sys.version_info >= (3, 12):
|
||||
def run(
|
||||
|
|
|
|||
|
|
@ -69,7 +69,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: ...
|
||||
|
|
|
|||
|
|
@ -64,10 +64,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:
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ class _BaseNetwork(_IPAddressBase, Generic[_A]):
|
|||
|
||||
"""
|
||||
|
||||
def hosts(self) -> Iterator[_A] | list[_A]:
|
||||
def hosts(self) -> Iterator[_A]:
|
||||
"""Generate Iterator over usable hosts in a network.
|
||||
|
||||
This is like __iter__ except it doesn't return the network
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ read_mime_types(file) -- parse one file, return a dictionary or None
|
|||
|
||||
import sys
|
||||
from _typeshed import StrPath
|
||||
from collections.abc import Sequence
|
||||
from collections.abc import Iterable
|
||||
from typing import IO
|
||||
|
||||
__all__ = [
|
||||
|
|
@ -93,8 +93,8 @@ def guess_extension(type: str, strict: bool = True) -> str | None:
|
|||
but non-standard types.
|
||||
"""
|
||||
|
||||
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:
|
||||
"""Add a mapping between a type and an extension.
|
||||
|
||||
|
|
@ -116,7 +116,7 @@ if sys.version_info >= (3, 13):
|
|||
"""
|
||||
|
||||
inited: bool
|
||||
knownfiles: list[str]
|
||||
knownfiles: list[StrPath]
|
||||
suffix_map: dict[str, str]
|
||||
encodings_map: dict[str, str]
|
||||
types_map: dict[str, str]
|
||||
|
|
@ -134,7 +134,7 @@ 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:
|
||||
"""Add a mapping between a type and an extension.
|
||||
|
||||
|
|
@ -196,7 +196,7 @@ class MimeTypes:
|
|||
but non-standard types.
|
||||
"""
|
||||
|
||||
def read(self, filename: str, strict: bool = True) -> None:
|
||||
def read(self, filename: StrPath, strict: bool = True) -> None:
|
||||
"""
|
||||
Read a single mime.types-format file, specified by pathname.
|
||||
|
||||
|
|
|
|||
|
|
@ -216,6 +216,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
|
||||
|
|
@ -429,8 +431,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):
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import sys
|
||||
from collections.abc import Callable, Iterable, Mapping
|
||||
from typing import Any
|
||||
|
||||
|
|
@ -33,6 +34,11 @@ class BaseProcess:
|
|||
"""
|
||||
Start child process
|
||||
"""
|
||||
if sys.version_info >= (3, 14):
|
||||
def interrupt(self) -> None:
|
||||
"""
|
||||
Terminate process; sends SIGINT signal
|
||||
"""
|
||||
|
||||
def terminate(self) -> None:
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import sys
|
||||
import threading
|
||||
from collections.abc import Callable
|
||||
from multiprocessing.context import BaseContext
|
||||
|
|
@ -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: ...
|
||||
|
|
|
|||
|
|
@ -256,6 +256,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):
|
||||
|
|
@ -336,7 +337,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__(
|
||||
|
|
@ -623,7 +624,7 @@ class Cursor:
|
|||
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: ...
|
||||
|
|
|
|||
|
|
@ -606,7 +606,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,
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ from builtins import object as _object
|
|||
from collections.abc import AsyncGenerator, Callable, Sequence
|
||||
from io import TextIOWrapper
|
||||
from types import FrameType, ModuleType, TracebackType
|
||||
from typing import Any, Final, Literal, NoReturn, Protocol, TextIO, TypeVar, final, type_check_only
|
||||
from typing import Any, Final, Literal, NoReturn, Protocol, TextIO, TypeVar, final, overload, type_check_only
|
||||
from typing_extensions import LiteralString, TypeAlias, deprecated
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
|
@ -648,7 +648,7 @@ if sys.platform == "android": # noqa: Y008
|
|||
def getallocatedblocks() -> int:
|
||||
"""Return the number of memory blocks currently allocated."""
|
||||
|
||||
def getdefaultencoding() -> str:
|
||||
def getdefaultencoding() -> Literal["utf-8"]:
|
||||
"""Return the current default encoding used by the Unicode implementation."""
|
||||
|
||||
if sys.platform != "win32":
|
||||
|
|
@ -658,10 +658,10 @@ if sys.platform != "win32":
|
|||
The flag constants are defined in the os module.
|
||||
"""
|
||||
|
||||
def getfilesystemencoding() -> str:
|
||||
def getfilesystemencoding() -> LiteralString:
|
||||
"""Return the encoding used to convert Unicode filenames to OS filenames."""
|
||||
|
||||
def getfilesystemencodeerrors() -> str:
|
||||
def getfilesystemencodeerrors() -> LiteralString:
|
||||
"""Return the error mode used Unicode to OS filename conversion."""
|
||||
|
||||
def getrefcount(object: Any, /) -> int:
|
||||
|
|
@ -755,7 +755,8 @@ if sys.platform == "win32":
|
|||
intended for identifying the OS rather than feature detection.
|
||||
"""
|
||||
|
||||
def intern(string: str, /) -> str:
|
||||
@overload
|
||||
def intern(string: LiteralString, /) -> LiteralString:
|
||||
"""``Intern'' the given string.
|
||||
|
||||
This enters the string in the (global) table of interned strings whose
|
||||
|
|
@ -763,6 +764,9 @@ def intern(string: str, /) -> str:
|
|||
the previously interned string object with the same value.
|
||||
"""
|
||||
|
||||
@overload
|
||||
def intern(string: str, /) -> str: ... # type: ignore[misc]
|
||||
|
||||
__interactivehook__: Callable[[], object]
|
||||
|
||||
if sys.version_info >= (3, 13):
|
||||
|
|
|
|||
|
|
@ -447,6 +447,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:
|
||||
"""Wait until notified or until a timeout occurs.
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -644,6 +644,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:
|
||||
|
|
@ -722,7 +723,17 @@ def no_type_check(arg: _F) -> _F:
|
|||
This mutates the function(s) or class(es) in place.
|
||||
"""
|
||||
|
||||
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]:
|
||||
"""Decorator to give another decorator the @no_type_check effect.
|
||||
|
||||
This wraps the decorator with something that wraps the decorated
|
||||
function in @no_type_check.
|
||||
"""
|
||||
|
||||
else:
|
||||
def no_type_check_decorator(decorator: Callable[_P, _T]) -> Callable[_P, _T]:
|
||||
"""Decorator to give another decorator the @no_type_check effect.
|
||||
|
||||
This wraps the decorator with something that wraps the decorated
|
||||
|
|
@ -1784,9 +1795,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: ...
|
||||
|
|
|
|||
|
|
@ -702,6 +702,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: ...
|
||||
|
|
|
|||
|
|
@ -322,6 +322,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:
|
||||
|
|
|
|||
|
|
@ -118,7 +118,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):
|
||||
|
|
|
|||
|
|
@ -260,6 +260,14 @@ class ElementTree(Generic[_Root]):
|
|||
def getroot(self) -> _Root:
|
||||
"""Return root element of this tree."""
|
||||
|
||||
def _setroot(self, element: Element[Any]) -> None:
|
||||
"""Replace root element of this tree.
|
||||
|
||||
This will discard the current contents of the tree and replace it
|
||||
with the given element. Use with care!
|
||||
|
||||
"""
|
||||
|
||||
def parse(self, source: _FileRead, parser: XMLParser | None = None) -> Element:
|
||||
"""Load external XML document into element tree.
|
||||
|
||||
|
|
|
|||
|
|
@ -483,6 +483,15 @@ class ZipInfo:
|
|||
decide based upon the file_size and compress_size, if known,
|
||||
False otherwise.
|
||||
"""
|
||||
if sys.version_info >= (3, 14):
|
||||
def _for_archive(self, archive: ZipFile) -> Self:
|
||||
"""Resolve suitable defaults from the archive.
|
||||
|
||||
Resolve the date_time, compression attributes, and external attributes
|
||||
to suitable defaults as used by :method:`ZipFile.writestr`.
|
||||
|
||||
Return self.
|
||||
"""
|
||||
|
||||
if sys.version_info >= (3, 12):
|
||||
from zipfile._path import CompleteDirs as CompleteDirs, Path as Path
|
||||
|
|
|
|||
Loading…
Reference in New Issue