Skip to content

Commit

Permalink
Sync typeshed
Browse files Browse the repository at this point in the history
  • Loading branch information
mypybot committed Aug 1, 2023
1 parent cb81325 commit 0e287b1
Show file tree
Hide file tree
Showing 41 changed files with 450 additions and 113 deletions.
2 changes: 2 additions & 0 deletions mypy/typeshed/stdlib/_collections_abc.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ _VT_co = TypeVar("_VT_co", covariant=True) # Value type covariant containers.

@final
class dict_keys(KeysView[_KT_co], Generic[_KT_co, _VT_co]): # undocumented
def __eq__(self, __value: object) -> bool: ...
if sys.version_info >= (3, 10):
@property
def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ...
Expand All @@ -81,6 +82,7 @@ class dict_values(ValuesView[_VT_co], Generic[_KT_co, _VT_co]): # undocumented

@final
class dict_items(ItemsView[_KT_co, _VT_co], Generic[_KT_co, _VT_co]): # undocumented
def __eq__(self, __value: object) -> bool: ...
if sys.version_info >= (3, 10):
@property
def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ...
Expand Down
6 changes: 5 additions & 1 deletion mypy/typeshed/stdlib/_ctypes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ class Array(Generic[_CT], _CData):
def _type_(self) -> type[_CT]: ...
@_type_.setter
def _type_(self, value: type[_CT]) -> None: ...
raw: bytes # Note: only available if _CT == c_char
# Note: only available if _CT == c_char
@property
def raw(self) -> bytes: ...
@raw.setter
def raw(self, value: ReadableBuffer) -> None: ...
value: Any # Note: bytes if _CT == c_char, str if _CT == c_wchar, unavailable otherwise
# TODO These methods cannot be annotated correctly at the moment.
# All of these "Any"s stand for the array's element type, but it's not possible to use _CT
Expand Down
3 changes: 3 additions & 0 deletions mypy/typeshed/stdlib/_weakref.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,20 @@ _T = TypeVar("_T")

@final
class CallableProxyType(Generic[_C]): # "weakcallableproxy"
def __eq__(self, __value: object) -> bool: ...
def __getattr__(self, attr: str) -> Any: ...
__call__: _C

@final
class ProxyType(Generic[_T]): # "weakproxy"
def __eq__(self, __value: object) -> bool: ...
def __getattr__(self, attr: str) -> Any: ...

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 __eq__(self, __value: object) -> bool: ...
def __hash__(self) -> int: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/abc.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def abstractmethod(funcobj: _FuncT) -> _FuncT: ...

class abstractclassmethod(classmethod[_T, _P, _R_co]):
__isabstractmethod__: Literal[True]
def __init__(self, callable: Callable[Concatenate[_T, _P], _R_co]) -> None: ...
def __init__(self, callable: Callable[Concatenate[type[_T], _P], _R_co]) -> None: ...

class abstractstaticmethod(staticmethod[_P, _R_co]):
__isabstractmethod__: Literal[True]
Expand Down
10 changes: 5 additions & 5 deletions mypy/typeshed/stdlib/argparse.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class _ActionsContainer:
self,
*name_or_flags: str,
action: _ActionStr | type[Action] = ...,
nargs: int | _NArgsStr | _SUPPRESS_T = ...,
nargs: int | _NArgsStr | _SUPPRESS_T | None = None,
const: Any = ...,
default: Any = ...,
type: Callable[[str], _T] | FileType = ...,
Expand Down Expand Up @@ -171,7 +171,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
) -> None: ...

@overload
def parse_args(self, args: Sequence[str] | None = None, namespace: Namespace | None = None) -> Namespace: ... # type: ignore[misc]
def parse_args(self, args: Sequence[str] | None = None, namespace: None = None) -> Namespace: ... # type: ignore[misc]
@overload
def parse_args(self, args: Sequence[str] | None, namespace: _N) -> _N: ...
@overload
Expand Down Expand Up @@ -210,7 +210,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
def format_usage(self) -> str: ...
def format_help(self) -> str: ...
@overload
def parse_known_args(self, args: Sequence[str] | None = None, namespace: Namespace | None = None) -> tuple[Namespace, list[str]]: ... # type: ignore[misc]
def parse_known_args(self, args: Sequence[str] | None = None, namespace: None = None) -> tuple[Namespace, list[str]]: ... # type: ignore[misc]
@overload
def parse_known_args(self, args: Sequence[str] | None, namespace: _N) -> tuple[_N, list[str]]: ...
@overload
Expand All @@ -219,13 +219,13 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
def exit(self, status: int = 0, message: str | None = None) -> NoReturn: ...
def error(self, message: str) -> NoReturn: ...
@overload
def parse_intermixed_args(self, args: Sequence[str] | None = None, namespace: Namespace | None = None) -> Namespace: ... # type: ignore[misc]
def parse_intermixed_args(self, args: Sequence[str] | None = None, namespace: None = None) -> Namespace: ... # type: ignore[misc]
@overload
def parse_intermixed_args(self, args: Sequence[str] | None, namespace: _N) -> _N: ...
@overload
def parse_intermixed_args(self, *, namespace: _N) -> _N: ...
@overload
def parse_known_intermixed_args(self, args: Sequence[str] | None = None, namespace: Namespace | None = None) -> tuple[Namespace, list[str]]: ... # type: ignore[misc]
def parse_known_intermixed_args(self, args: Sequence[str] | None = None, namespace: None = None) -> tuple[Namespace, list[str]]: ... # type: ignore[misc]
@overload
def parse_known_intermixed_args(self, args: Sequence[str] | None, namespace: _N) -> tuple[_N, list[str]]: ...
@overload
Expand Down
6 changes: 6 additions & 0 deletions mypy/typeshed/stdlib/array.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ from collections.abc import Iterable
from typing import Any, Generic, MutableSequence, TypeVar, overload # noqa: Y022
from typing_extensions import Literal, Self, SupportsIndex, TypeAlias

if sys.version_info >= (3, 12):
from types import GenericAlias

_IntTypeCode: TypeAlias = Literal["b", "B", "h", "H", "i", "I", "l", "L", "q", "Q"]
_FloatTypeCode: TypeAlias = Literal["f", "d"]
_UnicodeTypeCode: TypeAlias = Literal["u"]
Expand Down Expand Up @@ -70,6 +73,7 @@ class array(MutableSequence[_T], Generic[_T]):
def __setitem__(self, __key: slice, __value: array[_T]) -> None: ...
def __delitem__(self, __key: SupportsIndex | slice) -> None: ...
def __add__(self, __value: array[_T]) -> array[_T]: ...
def __eq__(self, __value: object) -> bool: ...
def __ge__(self, __value: array[_T]) -> bool: ...
def __gt__(self, __value: array[_T]) -> bool: ...
def __iadd__(self, __value: array[_T]) -> Self: ... # type: ignore[override]
Expand All @@ -82,5 +86,7 @@ class array(MutableSequence[_T], Generic[_T]):
def __deepcopy__(self, __unused: Any) -> array[_T]: ...
def __buffer__(self, __flags: int) -> memoryview: ...
def __release_buffer__(self, __buffer: memoryview) -> None: ...
if sys.version_info >= (3, 12):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...

ArrayType = array
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/asyncio/futures.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def isfuture(obj: object) -> TypeGuard[Future[Any]]: ...
class Future(Awaitable[_T], Iterable[_T]):
_state: str
@property
def _exception(self) -> BaseException: ...
def _exception(self) -> BaseException | None: ...
_blocking: bool
@property
def _log_traceback(self) -> bool: ...
Expand Down

0 comments on commit 0e287b1

Please sign in to comment.