Skip to content

Sync typeshed #15681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 15, 2023
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
1 change: 1 addition & 0 deletions mypy/typeshed/stdlib/_decimal.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class Decimal:
def from_float(cls, __f: float) -> Self: ...
def __bool__(self) -> bool: ...
def compare(self, other: _Decimal, context: Context | None = None) -> Decimal: ...
def __hash__(self) -> int: ...
def as_tuple(self) -> DecimalTuple: ...
def as_integer_ratio(self) -> tuple[int, int]: ...
def to_eng_string(self, context: Context | None = None) -> str: ...
Expand Down
1 change: 1 addition & 0 deletions mypy/typeshed/stdlib/_weakref.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ReferenceType(Generic[_T]):
__callback__: Callable[[ReferenceType[_T]], Any]
def __new__(cls, __o: _T, __callback: Callable[[ReferenceType[_T]], Any] | None = ...) -> Self: ...
def __call__(self) -> _T | None: ...
def __hash__(self) -> int: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...

Expand Down
1 change: 1 addition & 0 deletions mypy/typeshed/stdlib/asyncio/events.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class TimerHandle(Handle):
loop: AbstractEventLoop,
context: Context | None = None,
) -> None: ...
def __hash__(self) -> int: ...
def when(self) -> float: ...
def __lt__(self, other: TimerHandle) -> bool: ...
def __le__(self, other: TimerHandle) -> bool: ...
Expand Down
8 changes: 5 additions & 3 deletions mypy/typeshed/stdlib/asyncio/taskgroups.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# This only exists in 3.11+. See VERSIONS.

import sys
from contextvars import Context
from types import TracebackType
from typing import TypeVar
Expand All @@ -8,7 +7,10 @@ from typing_extensions import Self
from . import _CoroutineLike
from .tasks import Task

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

_T = TypeVar("_T")

Expand Down
11 changes: 11 additions & 0 deletions mypy/typeshed/stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ class int:
def __float__(self) -> float: ...
def __int__(self) -> int: ...
def __abs__(self) -> int: ...
def __hash__(self) -> int: ...
def __bool__(self) -> bool: ...
def __index__(self) -> int: ...

Expand Down Expand Up @@ -378,6 +379,7 @@ class float:
def __int__(self) -> int: ...
def __float__(self) -> float: ...
def __abs__(self) -> float: ...
def __hash__(self) -> int: ...
def __bool__(self) -> bool: ...

class complex:
Expand Down Expand Up @@ -417,6 +419,7 @@ class complex:
def __neg__(self) -> complex: ...
def __pos__(self) -> complex: ...
def __abs__(self) -> float: ...
def __hash__(self) -> int: ...
def __bool__(self) -> bool: ...
if sys.version_info >= (3, 11):
def __complex__(self) -> complex: ...
Expand Down Expand Up @@ -504,6 +507,7 @@ class str(Sequence[str]):
def __ge__(self, __value: str) -> bool: ...
def __getitem__(self, __key: SupportsIndex | slice) -> str: ...
def __gt__(self, __value: str) -> bool: ...
def __hash__(self) -> int: ...
def __iter__(self) -> Iterator[str]: ... # type: ignore[misc]
def __le__(self, __value: str) -> bool: ...
def __len__(self) -> int: ...
Expand Down Expand Up @@ -597,6 +601,7 @@ class bytes(Sequence[int]):
def maketrans(__frm: ReadableBuffer, __to: ReadableBuffer) -> bytes: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[int]: ...
def __hash__(self) -> int: ...
@overload
def __getitem__(self, __key: SupportsIndex) -> int: ...
@overload
Expand Down Expand Up @@ -1004,7 +1009,13 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
__hash__: ClassVar[None] # type: ignore[assignment]
if sys.version_info >= (3, 9):
def __class_getitem__(cls, __item: Any) -> GenericAlias: ...
@overload
def __or__(self, __value: Mapping[_KT, _VT]) -> dict[_KT, _VT]: ...
@overload
def __or__(self, __value: Mapping[_T1, _T2]) -> dict[_KT | _T1, _VT | _T2]: ...
@overload
def __ror__(self, __value: Mapping[_KT, _VT]) -> dict[_KT, _VT]: ...
@overload
def __ror__(self, __value: Mapping[_T1, _T2]) -> dict[_KT | _T1, _VT | _T2]: ...
# dict.__ior__ should be kept roughly in line with MutableMapping.update()
@overload # type: ignore[misc]
Expand Down
23 changes: 22 additions & 1 deletion mypy/typeshed/stdlib/collections/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,14 @@ class UserDict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
@overload
def fromkeys(cls, iterable: Iterable[_T], value: _S) -> UserDict[_T, _S]: ...
if sys.version_info >= (3, 9):
@overload
def __or__(self, other: UserDict[_KT, _VT] | dict[_KT, _VT]) -> Self: ...
@overload
def __or__(self, other: UserDict[_T1, _T2] | dict[_T1, _T2]) -> UserDict[_KT | _T1, _VT | _T2]: ...
def __ror__(self, other: UserDict[_T1, _T2] | dict[_T1, _T2]) -> UserDict[_KT | _T1, _VT | _T2]: ... # type: ignore[misc]
@overload # type: ignore[misc]
def __ror__(self, other: UserDict[_KT, _VT] | dict[_KT, _VT]) -> Self: ...
@overload # type: ignore[misc]
def __ror__(self, other: UserDict[_T1, _T2] | dict[_T1, _T2]) -> UserDict[_KT | _T1, _VT | _T2]: ...
# UserDict.__ior__ should be kept roughly in line with MutableMapping.update()
@overload # type: ignore[misc]
def __ior__(self, other: SupportsKeysAndGetItem[_KT, _VT]) -> Self: ...
Expand Down Expand Up @@ -391,6 +397,15 @@ class defaultdict(dict[_KT, _VT], Generic[_KT, _VT]):
def __missing__(self, __key: _KT) -> _VT: ...
def __copy__(self) -> Self: ...
def copy(self) -> Self: ...
if sys.version_info >= (3, 9):
@overload
def __or__(self, __value: Mapping[_KT, _VT]) -> Self: ...
@overload
def __or__(self, __value: Mapping[_T1, _T2]) -> defaultdict[_KT | _T1, _VT | _T2]: ...
@overload
def __ror__(self, __value: Mapping[_KT, _VT]) -> Self: ...
@overload
def __ror__(self, __value: Mapping[_T1, _T2]) -> defaultdict[_KT | _T1, _VT | _T2]: ...

class ChainMap(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
maps: list[MutableMapping[_KT, _VT]]
Expand Down Expand Up @@ -425,7 +440,13 @@ class ChainMap(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
@overload
def fromkeys(cls, __iterable: Iterable[_T], __value: _S) -> ChainMap[_T, _S]: ...
if sys.version_info >= (3, 9):
@overload
def __or__(self, other: Mapping[_KT, _VT]) -> Self: ...
@overload
def __or__(self, other: Mapping[_T1, _T2]) -> ChainMap[_KT | _T1, _VT | _T2]: ...
@overload
def __ror__(self, other: Mapping[_KT, _VT]) -> Self: ...
@overload
def __ror__(self, other: Mapping[_T1, _T2]) -> ChainMap[_KT | _T1, _VT | _T2]: ...
# ChainMap.__ior__ should be kept roughly in line with MutableMapping.update()
@overload # type: ignore[misc]
Expand Down
4 changes: 4 additions & 0 deletions mypy/typeshed/stdlib/datetime.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class timezone(tzinfo):
def tzname(self, __dt: datetime | None) -> str: ...
def utcoffset(self, __dt: datetime | None) -> timedelta: ...
def dst(self, __dt: datetime | None) -> None: ...
def __hash__(self) -> int: ...

if sys.version_info >= (3, 11):
UTC: timezone
Expand Down Expand Up @@ -106,6 +107,7 @@ class date:
@overload
def __sub__(self, __value: date) -> timedelta: ...

def __hash__(self) -> int: ...
def weekday(self) -> int: ...
def isoweekday(self) -> int: ...
if sys.version_info >= (3, 9):
Expand Down Expand Up @@ -143,6 +145,7 @@ class time:
def __lt__(self, __value: time) -> bool: ...
def __ge__(self, __value: time) -> bool: ...
def __gt__(self, __value: time) -> bool: ...
def __hash__(self) -> int: ...
def isoformat(self, timespec: str = ...) -> str: ...
@classmethod
def fromisoformat(cls, __time_string: str) -> Self: ...
Expand Down Expand Up @@ -217,6 +220,7 @@ class timedelta:
def __ge__(self, __value: timedelta) -> bool: ...
def __gt__(self, __value: timedelta) -> bool: ...
def __bool__(self) -> bool: ...
def __hash__(self) -> int: ...

class datetime(date):
min: ClassVar[datetime]
Expand Down
3 changes: 3 additions & 0 deletions mypy/typeshed/stdlib/doctest.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class Example:
indent: int = 0,
options: dict[int, bool] | None = None,
) -> None: ...
def __hash__(self) -> int: ...
def __eq__(self, other: object) -> bool: ...

class DocTest:
Expand All @@ -103,6 +104,7 @@ class DocTest:
lineno: int | None,
docstring: str | None,
) -> None: ...
def __hash__(self) -> int: ...
def __lt__(self, other: DocTest) -> bool: ...
def __eq__(self, other: object) -> bool: ...

Expand Down Expand Up @@ -210,6 +212,7 @@ class DocTestCase(unittest.TestCase):
) -> None: ...
def runTest(self) -> None: ...
def format_failure(self, err: str) -> str: ...
def __hash__(self) -> int: ...
def __eq__(self, other: object) -> bool: ...

class SkipDocTestCase(DocTestCase):
Expand Down
9 changes: 7 additions & 2 deletions mypy/typeshed/stdlib/email/charset.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from collections.abc import Iterator
from collections.abc import Callable, Iterator
from email.message import Message
from typing import overload

__all__ = ["Charset", "add_alias", "add_charset", "add_codec"]

Expand All @@ -14,10 +16,13 @@ class Charset:
input_codec: str | None
output_codec: str | None
def __init__(self, input_charset: str = "us-ascii") -> None: ...
def get_body_encoding(self) -> str: ...
def get_body_encoding(self) -> str | Callable[[Message], None]: ...
def get_output_charset(self) -> str | None: ...
def header_encode(self, string: str) -> str: ...
def header_encode_lines(self, string: str, maxlengths: Iterator[int]) -> list[str]: ...
@overload
def body_encode(self, string: None) -> None: ...
@overload
def body_encode(self, string: str) -> str: ...
def __eq__(self, other: object) -> bool: ...
def __ne__(self, __value: object) -> bool: ...
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/email/utils.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ else:
def localtime(dt: datetime.datetime | None = None, isdst: int = -1) -> datetime.datetime: ...

def make_msgid(idstring: str | None = None, domain: str | None = None) -> str: ...
def decode_rfc2231(s: str) -> tuple[str | None, str | None, str]: ...
def decode_rfc2231(s: str) -> tuple[str | None, str | None, str]: ... # May return list[str]. See issue #10431 for details.
def encode_rfc2231(s: str, charset: str | None = None, language: str | None = None) -> str: ...
def collapse_rfc2231_value(value: _ParamType, errors: str = "replace", fallback_charset: str = "us-ascii") -> str: ...
def decode_params(params: list[tuple[str, str]]) -> list[tuple[str, _ParamType]]: ...
14 changes: 8 additions & 6 deletions mypy/typeshed/stdlib/errno.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,15 @@ ECANCELED: int # undocumented
ENOTRECOVERABLE: int # undocumented
EOWNERDEAD: int # undocumented

if sys.platform == "sunos5" or sys.platform == "solaris": # noqa: Y008
ELOCKUNMAPPED: int
ENOTACTIVE: int

if sys.platform != "win32":
ENOTBLK: int
EMULTIHOP: int

if sys.platform == "darwin":
# All of the below are undocumented
EAUTH: int
EBADARCH: int
Expand All @@ -112,9 +118,8 @@ if sys.platform != "win32":
EPWROFF: int
ERPCMISMATCH: int
ESHLIBVERS: int

if sys.platform != "darwin" or sys.version_info >= (3, 11):
EQFULL: int # undocumented
if sys.version_info >= (3, 11):
EQFULL: int

if sys.platform != "darwin":
EDEADLOCK: int
Expand Down Expand Up @@ -164,9 +169,6 @@ if sys.platform != "win32" and sys.platform != "darwin":
ENOKEY: int
ENOMEDIUM: int
ERFKILL: int
EL: int
ELOCKUNMAPPED: int
ENOTACTIVE: int

if sys.platform == "win32":
# All of these are undocumented
Expand Down
1 change: 1 addition & 0 deletions mypy/typeshed/stdlib/ipaddress.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class _IPAddressBase:
class _BaseAddress(_IPAddressBase, SupportsInt):
def __init__(self, address: object) -> None: ...
def __add__(self, other: int) -> Self: ...
def __hash__(self) -> int: ...
def __int__(self) -> int: ...
def __sub__(self, other: int) -> Self: ...
if sys.version_info >= (3, 9):
Expand Down
9 changes: 0 additions & 9 deletions mypy/typeshed/stdlib/json/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sys
from _typeshed import SupportsRead, SupportsWrite
from collections.abc import Callable
from typing import Any
Expand All @@ -7,8 +6,6 @@ from .decoder import JSONDecodeError as JSONDecodeError, JSONDecoder as JSONDeco
from .encoder import JSONEncoder as JSONEncoder

__all__ = ["dump", "dumps", "load", "loads", "JSONDecoder", "JSONDecodeError", "JSONEncoder"]
if sys.version_info >= (3, 12):
__all__ += ["AttrDict"]

def dumps(
obj: Any,
Expand Down Expand Up @@ -62,9 +59,3 @@ def load(
**kwds: Any,
) -> Any: ...
def detect_encoding(b: bytes | bytearray) -> str: ... # undocumented

if sys.version_info >= (3, 12):
class AttrDict(dict[str, Any]):
def __getattr__(self, name: str) -> Any: ...
def __setattr__(self, name: str, value: Any) -> None: ...
def __delattr__(self, name: str) -> None: ...
6 changes: 3 additions & 3 deletions mypy/typeshed/stdlib/linecache.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
from typing import Any, Protocol
from collections.abc import Callable
from typing import Any
from typing_extensions import TypeAlias

if sys.version_info >= (3, 9):
Expand All @@ -10,8 +11,7 @@ else:
_ModuleGlobals: TypeAlias = dict[str, Any]
_ModuleMetadata: TypeAlias = tuple[int, float | None, list[str], str]

class _SourceLoader(Protocol):
def __call__(self) -> str | None: ...
_SourceLoader: TypeAlias = tuple[Callable[[], str | None]]

cache: dict[str, _SourceLoader | _ModuleMetadata] # undocumented

Expand Down
1 change: 1 addition & 0 deletions mypy/typeshed/stdlib/pathlib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class PurePath(PathLike[str]):
@property
def stem(self) -> str: ...
def __new__(cls, *args: StrPath) -> Self: ...
def __hash__(self) -> int: ...
def __eq__(self, other: object) -> bool: ...
def __fspath__(self) -> str: ...
def __lt__(self, other: PurePath) -> bool: ...
Expand Down
1 change: 1 addition & 0 deletions mypy/typeshed/stdlib/plistlib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ if sys.version_info >= (3, 8):
def __init__(self, data: int) -> None: ...
def __index__(self) -> int: ...
def __reduce__(self) -> tuple[type[Self], tuple[int]]: ...
def __hash__(self) -> int: ...
def __eq__(self, other: object) -> bool: ...

class InvalidFileException(ValueError):
Expand Down
20 changes: 20 additions & 0 deletions mypy/typeshed/stdlib/sqlite3/dbapi2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,25 @@ if sys.version_info >= (3, 11):
SQLITE_WARNING: int
SQLITE_WARNING_AUTOINDEX: int

if sys.version_info >= (3, 12):
LEGACY_TRANSACTION_CONTROL: int
SQLITE_DBCONFIG_DEFENSIVE: int
SQLITE_DBCONFIG_DQS_DDL: int
SQLITE_DBCONFIG_DQS_DML: int
SQLITE_DBCONFIG_ENABLE_FKEY: int
SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER: int
SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION: int
SQLITE_DBCONFIG_ENABLE_QPSG: int
SQLITE_DBCONFIG_ENABLE_TRIGGER: int
SQLITE_DBCONFIG_ENABLE_VIEW: int
SQLITE_DBCONFIG_LEGACY_ALTER_TABLE: int
SQLITE_DBCONFIG_LEGACY_FILE_FORMAT: int
SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE: int
SQLITE_DBCONFIG_RESET_DATABASE: int
SQLITE_DBCONFIG_TRIGGER_EQP: int
SQLITE_DBCONFIG_TRUSTED_SCHEMA: int
SQLITE_DBCONFIG_WRITABLE_SCHEMA: int

# Can take or return anything depending on what's in the registry.
@overload
def adapt(__obj: Any, __proto: Any) -> Any: ...
Expand Down Expand Up @@ -419,6 +438,7 @@ class Row:
def __getitem__(self, __key: int | str) -> Any: ...
@overload
def __getitem__(self, __key: slice) -> tuple[Any, ...]: ...
def __hash__(self) -> int: ...
def __iter__(self) -> Iterator[Any]: ...
def __len__(self) -> int: ...
# These return NotImplemented for anything that is not a Row.
Expand Down
1 change: 1 addition & 0 deletions mypy/typeshed/stdlib/statistics.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ if sys.version_info >= (3, 8):
__radd__ = __add__
def __rsub__(self, x2: float | NormalDist) -> NormalDist: ...
__rmul__ = __mul__
def __hash__(self) -> int: ...

if sys.version_info >= (3, 12):
def correlation(
Expand Down
Loading