Skip to content

Sync typeshed #16382

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
Nov 1, 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
6 changes: 6 additions & 0 deletions mypy/typeshed/stdlib/VERSIONS
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,12 @@ imp: 2.7-3.11
importlib: 2.7-
importlib.metadata: 3.8-
importlib.metadata._meta: 3.10-
importlib.readers: 3.10-
importlib.resources: 3.7-
importlib.resources.abc: 3.11-
importlib.resources.readers: 3.11-
importlib.resources.simple: 3.11-
importlib.simple: 3.11-
inspect: 2.7-
io: 2.7-
ipaddress: 3.3-
Expand Down Expand Up @@ -181,6 +185,7 @@ multiprocessing.shared_memory: 3.8-
netrc: 2.7-
nis: 2.7-
nntplib: 2.7-
nt: 2.7-
ntpath: 2.7-
nturl2path: 2.7-
numbers: 2.7-
Expand Down Expand Up @@ -250,6 +255,7 @@ sunau: 2.7-
symbol: 2.7-3.9
symtable: 2.7-
sys: 2.7-
sys._monitoring: 3.12- # Doesn't actually exist. See comments in the stub.
sysconfig: 2.7-
syslog: 2.7-
tabnanny: 2.7-
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/_collections_abc.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class dict_values(ValuesView[_VT_co], Generic[_KT_co, _VT_co]): # undocumented
def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ...

@final
class dict_items(ItemsView[_KT_co, _VT_co], Generic[_KT_co, _VT_co]): # undocumented
class dict_items(ItemsView[_KT_co, _VT_co]): # undocumented
def __eq__(self, __value: object) -> bool: ...
if sys.version_info >= (3, 10):
@property
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/_typeshed/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Unused: TypeAlias = object
# _SentinelType = NewType("_SentinelType", object)
# sentinel: _SentinelType
# def foo(x: int | None | _SentinelType = ...) -> None: ...
sentinel = Any # noqa: Y026
sentinel: Any

# stable
class IdentityFunction(Protocol):
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/_weakrefset.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
from collections.abc import Iterable, Iterator, MutableSet
from typing import Any, Generic, TypeVar, overload
from typing import Any, TypeVar, overload
from typing_extensions import Self

if sys.version_info >= (3, 9):
Expand All @@ -11,7 +11,7 @@ __all__ = ["WeakSet"]
_S = TypeVar("_S")
_T = TypeVar("_T")

class WeakSet(MutableSet[_T], Generic[_T]):
class WeakSet(MutableSet[_T]):
@overload
def __init__(self, data: None = None) -> None: ...
@overload
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/_winapi.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ if sys.platform == "win32":
HIGH_PRIORITY_CLASS: Literal[0x80]
INFINITE: Literal[0xFFFFFFFF]
if sys.version_info >= (3, 8):
# Ignore the flake8 error -- flake8-pyi assumes
# Ignore the Flake8 error -- flake8-pyi assumes
# most numbers this long will be implementation details,
# but here we can see that it's a power of 2
INVALID_HANDLE_VALUE: Literal[0xFFFFFFFFFFFFFFFF] # noqa: Y054
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/array.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ from _typeshed import ReadableBuffer, SupportsRead, SupportsWrite
from collections.abc import Iterable

# pytype crashes if array inherits from collections.abc.MutableSequence instead of typing.MutableSequence
from typing import Any, Generic, MutableSequence, TypeVar, overload # noqa: Y022
from typing import Any, MutableSequence, TypeVar, overload # noqa: Y022
from typing_extensions import Literal, Self, SupportsIndex, TypeAlias

if sys.version_info >= (3, 12):
Expand All @@ -18,7 +18,7 @@ _T = TypeVar("_T", int, float, str)

typecodes: str

class array(MutableSequence[_T], Generic[_T]):
class array(MutableSequence[_T]):
@property
def typecode(self) -> _TypeCode: ...
@property
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/asyncio/tasks.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import concurrent.futures
import sys
from collections.abc import Awaitable, Coroutine, Generator, Iterable, Iterator
from types import FrameType
from typing import Any, Generic, Protocol, TextIO, TypeVar, overload
from typing import Any, Protocol, TextIO, TypeVar, overload
from typing_extensions import Literal, TypeAlias

from . import _CoroutineLike
Expand Down Expand Up @@ -379,7 +379,7 @@ else:
# While this is true in general, here it's sort-of okay to have a covariant subclass,
# since the only reason why `asyncio.Future` is invariant is the `set_result()` method,
# and `asyncio.Task.set_result()` always raises.
class Task(Future[_T_co], Generic[_T_co]): # type: ignore[type-var] # pyright: ignore[reportGeneralTypeIssues]
class Task(Future[_T_co]): # type: ignore[type-var] # pyright: ignore[reportGeneralTypeIssues]
if sys.version_info >= (3, 12):
def __init__(
self,
Expand Down
24 changes: 12 additions & 12 deletions mypy/typeshed/stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ class int:
def __pow__(self, __value: _PositiveInteger, __mod: None = None) -> int: ...
@overload
def __pow__(self, __value: _NegativeInteger, __mod: None = None) -> float: ...
# positive x -> int; negative x -> float
# positive __value -> int; negative __value -> float
# return type must be Any as `int | float` causes too many false-positive errors
@overload
def __pow__(self, __value: int, __mod: None = None) -> Any: ...
Expand Down Expand Up @@ -346,7 +346,7 @@ class float:
def __divmod__(self, __value: float) -> tuple[float, float]: ...
@overload
def __pow__(self, __value: int, __mod: None = None) -> float: ...
# positive x -> float; negative x -> complex
# positive __value -> float; negative __value -> complex
# return type must be Any as `float | complex` causes too many false-positive errors
@overload
def __pow__(self, __value: float, __mod: None = None) -> Any: ...
Expand Down Expand Up @@ -860,7 +860,7 @@ class slice:
__hash__: ClassVar[None] # type: ignore[assignment]
def indices(self, __len: SupportsIndex) -> tuple[int, int, int]: ...

class tuple(Sequence[_T_co], Generic[_T_co]):
class tuple(Sequence[_T_co]):
def __new__(cls, __iterable: Iterable[_T_co] = ...) -> Self: ...
def __len__(self) -> int: ...
def __contains__(self, __key: object) -> bool: ...
Expand Down Expand Up @@ -912,7 +912,7 @@ class function:
# mypy uses `builtins.function.__get__` to represent methods, properties, and getset_descriptors so we type the return as Any.
def __get__(self, __instance: object, __owner: type | None = None) -> Any: ...

class list(MutableSequence[_T], Generic[_T]):
class list(MutableSequence[_T]):
@overload
def __init__(self) -> None: ...
@overload
Expand Down Expand Up @@ -967,7 +967,7 @@ class list(MutableSequence[_T], Generic[_T]):
if sys.version_info >= (3, 9):
def __class_getitem__(cls, __item: Any) -> GenericAlias: ...

class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
class dict(MutableMapping[_KT, _VT]):
# __init__ should be kept roughly in line with `collections.UserDict.__init__`, which has similar semantics
# Also multiprocessing.managers.SyncManager.dict()
@overload
Expand Down Expand Up @@ -1040,7 +1040,7 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
@overload
def __ior__(self, __value: Iterable[tuple[_KT, _VT]]) -> Self: ...

class set(MutableSet[_T], Generic[_T]):
class set(MutableSet[_T]):
@overload
def __init__(self) -> None: ...
@overload
Expand Down Expand Up @@ -1080,7 +1080,7 @@ class set(MutableSet[_T], Generic[_T]):
if sys.version_info >= (3, 9):
def __class_getitem__(cls, __item: Any) -> GenericAlias: ...

class frozenset(AbstractSet[_T_co], Generic[_T_co]):
class frozenset(AbstractSet[_T_co]):
@overload
def __new__(cls) -> Self: ...
@overload
Expand Down Expand Up @@ -1109,7 +1109,7 @@ class frozenset(AbstractSet[_T_co], Generic[_T_co]):
if sys.version_info >= (3, 9):
def __class_getitem__(cls, __item: Any) -> GenericAlias: ...

class enumerate(Iterator[tuple[int, _T]], Generic[_T]):
class enumerate(Iterator[tuple[int, _T]]):
def __new__(cls, iterable: Iterable[_T], start: int = ...) -> Self: ...
def __iter__(self) -> Self: ...
def __next__(self) -> tuple[int, _T]: ...
Expand Down Expand Up @@ -1318,7 +1318,7 @@ else:

def exit(code: sys._ExitCode = None) -> NoReturn: ...

class filter(Iterator[_T], Generic[_T]):
class filter(Iterator[_T]):
@overload
def __new__(cls, __function: None, __iterable: Iterable[_T | None]) -> Self: ...
@overload
Expand Down Expand Up @@ -1377,7 +1377,7 @@ def len(__obj: Sized) -> int: ...
def license() -> None: ...
def locals() -> dict[str, Any]: ...

class map(Iterator[_S], Generic[_S]):
class map(Iterator[_S]):
@overload
def __new__(cls, __func: Callable[[_T1], _S], __iter1: Iterable[_T1]) -> Self: ...
@overload
Expand Down Expand Up @@ -1649,7 +1649,7 @@ else:

def quit(code: sys._ExitCode = None) -> NoReturn: ...

class reversed(Iterator[_T], Generic[_T]):
class reversed(Iterator[_T]):
@overload
def __init__(self, __sequence: Reversible[_T]) -> None: ...
@overload
Expand Down Expand Up @@ -1723,7 +1723,7 @@ def vars(__object: type) -> types.MappingProxyType[str, Any]: ... # type: ignor
@overload
def vars(__object: Any = ...) -> dict[str, Any]: ...

class zip(Iterator[_T_co], Generic[_T_co]):
class zip(Iterator[_T_co]):
if sys.version_info >= (3, 10):
@overload
def __new__(cls, *, strict: bool = ...) -> zip[Any]: ...
Expand Down
8 changes: 4 additions & 4 deletions mypy/typeshed/stdlib/collections/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def namedtuple(
defaults: Iterable[Any] | None = None,
) -> type[tuple[Any, ...]]: ...

class UserDict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
class UserDict(MutableMapping[_KT, _VT]):
data: dict[_KT, _VT]
# __init__ should be kept roughly in line with `dict.__init__`, which has the same semantics
@overload
Expand Down Expand Up @@ -228,7 +228,7 @@ class UserString(Sequence[UserString]):
def upper(self) -> Self: ...
def zfill(self, width: int) -> Self: ...

class deque(MutableSequence[_T], Generic[_T]):
class deque(MutableSequence[_T]):
@property
def maxlen(self) -> int | None: ...
@overload
Expand Down Expand Up @@ -383,7 +383,7 @@ class OrderedDict(dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]):
@overload
def __ror__(self, __value: dict[_T1, _T2]) -> OrderedDict[_KT | _T1, _VT | _T2]: ... # type: ignore[misc]

class defaultdict(dict[_KT, _VT], Generic[_KT, _VT]):
class defaultdict(dict[_KT, _VT]):
default_factory: Callable[[], _VT] | None
@overload
def __init__(self) -> None: ...
Expand Down Expand Up @@ -424,7 +424,7 @@ class defaultdict(dict[_KT, _VT], Generic[_KT, _VT]):
@overload
def __ror__(self, __value: dict[_T1, _T2]) -> defaultdict[_KT | _T1, _VT | _T2]: ... # type: ignore[misc]

class ChainMap(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
class ChainMap(MutableMapping[_KT, _VT]):
maps: list[MutableMapping[_KT, _VT]]
def __init__(self, *maps: MutableMapping[_KT, _VT]) -> None: ...
def new_child(self, m: MutableMapping[_KT, _VT] | None = None) -> Self: ...
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/contextlib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ if sys.version_info >= (3, 10):
) -> bool | None: ...

else:
class _AsyncGeneratorContextManager(AbstractAsyncContextManager[_T_co], Generic[_T_co]):
class _AsyncGeneratorContextManager(AbstractAsyncContextManager[_T_co]):
def __init__(self, func: Callable[..., AsyncIterator[_T_co]], args: tuple[Any, ...], kwds: dict[str, Any]) -> None: ...
gen: AsyncGenerator[_T_co, Any]
func: Callable[..., AsyncGenerator[_T_co, Any]]
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/csv.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ from _csv import (
)

if sys.version_info >= (3, 12):
from _csv import QUOTE_STRINGS as QUOTE_STRINGS, QUOTE_NOTNULL as QUOTE_NOTNULL
from _csv import QUOTE_NOTNULL as QUOTE_NOTNULL, QUOTE_STRINGS as QUOTE_STRINGS
from _typeshed import SupportsWrite
from collections.abc import Collection, Iterable, Iterator, Mapping, Sequence
from typing import Any, Generic, TypeVar, overload
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/fileinput.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import sys
from _typeshed import AnyStr_co, StrOrBytesPath
from collections.abc import Callable, Iterable, Iterator
from types import TracebackType
from typing import IO, Any, AnyStr, Generic, Protocol, overload
from typing import IO, Any, AnyStr, Protocol, overload
from typing_extensions import Literal, Self, TypeAlias

if sys.version_info >= (3, 9):
Expand Down Expand Up @@ -158,7 +158,7 @@ def fileno() -> int: ...
def isfirstline() -> bool: ...
def isstdin() -> bool: ...

class FileInput(Iterator[AnyStr], Generic[AnyStr]):
class FileInput(Iterator[AnyStr]):
if sys.version_info >= (3, 10):
# encoding and errors are added
@overload
Expand Down
9 changes: 1 addition & 8 deletions mypy/typeshed/stdlib/hashlib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,7 @@ shake_128 = _VarLenHash
shake_256 = _VarLenHash

def scrypt(
password: ReadableBuffer,
*,
salt: ReadableBuffer | None = None,
n: int | None = None,
r: int | None = None,
p: int | None = None,
maxmem: int = 0,
dklen: int = 64,
password: ReadableBuffer, *, salt: ReadableBuffer, n: int, r: int, p: int, maxmem: int = 0, dklen: int = 64
) -> bytes: ...
@final
class _BlakeHash(_Hash):
Expand Down
Loading