Skip to content

Commit

Permalink
Sync typeshed (#14295)
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Dec 15, 2022
1 parent d62be28 commit 3695250
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 26 deletions.
6 changes: 3 additions & 3 deletions mypy/typeshed/stdlib/_ast.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ class Assign(stmt):
class AugAssign(stmt):
if sys.version_info >= (3, 10):
__match_args__ = ("target", "op", "value")
target: expr
target: Name | Attribute | Subscript
op: operator
value: expr

class AnnAssign(stmt):
if sys.version_info >= (3, 10):
__match_args__ = ("target", "annotation", "value", "simple")
target: expr
target: Name | Attribute | Subscript
annotation: expr
value: expr | None
simple: int
Expand Down Expand Up @@ -355,7 +355,7 @@ if sys.version_info >= (3, 8):
class NamedExpr(expr):
if sys.version_info >= (3, 10):
__match_args__ = ("target", "value")
target: expr
target: Name
value: expr

class Attribute(expr):
Expand Down
9 changes: 8 additions & 1 deletion mypy/typeshed/stdlib/asyncio/runners.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ from _typeshed import Self
from collections.abc import Callable, Coroutine
from contextvars import Context
from typing import Any, TypeVar
from typing_extensions import final

from .events import AbstractEventLoop

Expand All @@ -13,6 +14,7 @@ else:
_T = TypeVar("_T")

if sys.version_info >= (3, 11):
@final
class Runner:
def __init__(self, *, debug: bool | None = ..., loop_factory: Callable[[], AbstractEventLoop] | None = ...) -> None: ...
def __enter__(self: Self) -> Self: ...
Expand All @@ -21,7 +23,12 @@ if sys.version_info >= (3, 11):
def get_loop(self) -> AbstractEventLoop: ...
def run(self, coro: Coroutine[Any, Any, _T], *, context: Context | None = ...) -> _T: ...

if sys.version_info >= (3, 8):
if sys.version_info >= (3, 12):
def run(
main: Coroutine[Any, Any, _T], *, debug: bool | None = ..., loop_factory: Callable[[], AbstractEventLoop] | None = ...
) -> _T: ...

elif sys.version_info >= (3, 8):
def run(main: Coroutine[Any, Any, _T], *, debug: bool | None = ...) -> _T: ...

else:
Expand Down
7 changes: 5 additions & 2 deletions mypy/typeshed/stdlib/email/message.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ from email.charset import Charset
from email.contentmanager import ContentManager
from email.errors import MessageDefect
from email.policy import Policy
from typing import Any, TypeVar
from typing import Any, TypeVar, overload
from typing_extensions import TypeAlias

__all__ = ["Message", "EmailMessage"]
Expand Down Expand Up @@ -54,7 +54,10 @@ class Message:
def get_filename(self, failobj: _T = ...) -> _T | str: ...
def get_boundary(self, failobj: _T = ...) -> _T | str: ...
def set_boundary(self, boundary: str) -> None: ...
def get_content_charset(self, failobj: _T = ...) -> _T | str: ...
@overload
def get_content_charset(self) -> str | None: ...
@overload
def get_content_charset(self, failobj: _T) -> str | _T: ...
def get_charsets(self, failobj: _T = ...) -> _T | list[str]: ...
def walk(self: Self) -> Generator[Self, None, None]: ...
def get_content_disposition(self) -> str | None: ...
Expand Down
8 changes: 7 additions & 1 deletion mypy/typeshed/stdlib/http/client.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,13 @@ class HTTPConnection:
blocksize: int = ...,
) -> None: ...
def request(
self, method: str, url: str, body: _DataType | None = ..., headers: Mapping[str, str] = ..., *, encode_chunked: bool = ...
self,
method: str,
url: str,
body: _DataType | str | None = ...,
headers: Mapping[str, str] = ...,
*,
encode_chunked: bool = ...,
) -> None: ...
def getresponse(self) -> HTTPResponse: ...
def set_debuglevel(self, level: int) -> None: ...
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/multiprocessing/context.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ctypes
import sys
from collections.abc import Callable, Iterable, Sequence
from ctypes import _CData
from logging import Logger
from logging import Logger, _Level as _LoggingLevel
from multiprocessing import popen_fork, popen_forkserver, popen_spawn_posix, popen_spawn_win32, queues, synchronize
from multiprocessing.managers import SyncManager
from multiprocessing.pool import Pool as _Pool
Expand Down Expand Up @@ -107,7 +107,7 @@ class BaseContext:
) -> Any: ...
def freeze_support(self) -> None: ...
def get_logger(self) -> Logger: ...
def log_to_stderr(self, level: str | None = ...) -> Logger: ...
def log_to_stderr(self, level: _LoggingLevel | None = ...) -> Logger: ...
def allow_connection_pickling(self) -> None: ...
def set_executable(self, executable: str) -> None: ...
def set_forkserver_preload(self, module_names: list[str]) -> None: ...
Expand Down
4 changes: 2 additions & 2 deletions mypy/typeshed/stdlib/multiprocessing/util.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import threading
from _typeshed import Incomplete, ReadableBuffer, SupportsTrunc
from collections.abc import Callable, Iterable, Mapping, MutableMapping, Sequence
from logging import Logger
from logging import Logger, _Level as _LoggingLevel
from typing import Any, SupportsInt
from typing_extensions import SupportsIndex

Expand Down Expand Up @@ -37,7 +37,7 @@ def debug(msg: object, *args: object) -> None: ...
def info(msg: object, *args: object) -> None: ...
def sub_warning(msg: object, *args: object) -> None: ...
def get_logger() -> Logger: ...
def log_to_stderr(level: int | None = ...) -> Logger: ...
def log_to_stderr(level: _LoggingLevel | None = ...) -> Logger: ...
def is_abstract_socket_namespace(address: str | bytes | None) -> bool: ...

abstract_sockets_supported: bool
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/types.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ _P = ParamSpec("_P")
# it's not really an Awaitable, but can be used in an await expression. Real type: Generator & Awaitable
# The type: ignore is due to overlapping overloads, not the use of ParamSpec
@overload
def coroutine(func: Callable[_P, Generator[_R, Any, Any]]) -> Callable[_P, Awaitable[_R]]: ... # type: ignore[misc]
def coroutine(func: Callable[_P, Generator[Any, Any, _R]]) -> Callable[_P, Awaitable[_R]]: ... # type: ignore[misc]
@overload
def coroutine(func: _Fn) -> _Fn: ...

Expand Down
7 changes: 5 additions & 2 deletions mypy/typeshed/stdlib/typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ class SupportsRound(Protocol[_T_co]):
def __round__(self, __ndigits: int) -> _T_co: ...

@runtime_checkable
class Sized(Protocol):
class Sized(Protocol, metaclass=ABCMeta):
@abstractmethod
def __len__(self) -> int: ...

Expand Down Expand Up @@ -452,7 +452,10 @@ class Container(Protocol[_T_co]):
def __contains__(self, __x: object) -> bool: ...

@runtime_checkable
class Collection(Sized, Iterable[_T_co], Container[_T_co], Protocol[_T_co]): ...
class Collection(Iterable[_T_co], Container[_T_co], Protocol[_T_co]):
# Implement Sized (but don't have it as a base class).
@abstractmethod
def __len__(self) -> int: ...

class Sequence(Collection[_T_co], Reversible[_T_co], Generic[_T_co]):
@overload
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/unittest/case.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class TestCase:
def tearDownClass(cls) -> None: ...
def run(self, result: unittest.result.TestResult | None = ...) -> unittest.result.TestResult | None: ...
def __call__(self, result: unittest.result.TestResult | None = ...) -> unittest.result.TestResult | None: ...
def skipTest(self, reason: Any) -> None: ...
def skipTest(self, reason: Any) -> NoReturn: ...
def subTest(self, msg: Any = ..., **params: Any) -> AbstractContextManager[None]: ...
def debug(self) -> None: ...
if sys.version_info < (3, 11):
Expand Down
28 changes: 17 additions & 11 deletions mypy/typeshed/stdlib/zipfile.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ _DateTuple: TypeAlias = tuple[int, int, int, int, int, int]
_ReadWriteMode: TypeAlias = Literal["r", "w"]
_ReadWriteBinaryMode: TypeAlias = Literal["r", "w", "rb", "wb"]
_ZipFileMode: TypeAlias = Literal["r", "w", "x", "a"]
_CompressionMode: TypeAlias = Literal[0, 8, 12, 14]

class BadZipFile(Exception): ...

Expand Down Expand Up @@ -100,7 +101,7 @@ class ZipFile:
fp: IO[bytes] | None
NameToInfo: dict[str, ZipInfo]
start_dir: int # undocumented
compression: int # undocumented
compression: _CompressionMode # undocumented
compresslevel: int | None # undocumented
mode: _ZipFileMode # undocumented
pwd: bytes | None # undocumented
Expand All @@ -110,7 +111,7 @@ class ZipFile:
self,
file: StrPath | IO[bytes],
mode: Literal["r"] = ...,
compression: int = ...,
compression: _CompressionMode = ...,
allowZip64: bool = ...,
compresslevel: int | None = ...,
*,
Expand All @@ -122,7 +123,7 @@ class ZipFile:
self,
file: StrPath | IO[bytes],
mode: _ZipFileMode = ...,
compression: int = ...,
compression: _CompressionMode = ...,
allowZip64: bool = ...,
compresslevel: int | None = ...,
*,
Expand All @@ -134,7 +135,7 @@ class ZipFile:
self,
file: StrPath | IO[bytes],
mode: _ZipFileMode = ...,
compression: int = ...,
compression: _CompressionMode = ...,
allowZip64: bool = ...,
compresslevel: int | None = ...,
*,
Expand All @@ -145,7 +146,7 @@ class ZipFile:
self,
file: StrPath | IO[bytes],
mode: _ZipFileMode = ...,
compression: int = ...,
compression: _CompressionMode = ...,
allowZip64: bool = ...,
compresslevel: int | None = ...,
) -> None: ...
Expand Down Expand Up @@ -184,14 +185,19 @@ class ZipFile:

class PyZipFile(ZipFile):
def __init__(
self, file: str | IO[bytes], mode: _ZipFileMode = ..., compression: int = ..., allowZip64: bool = ..., optimize: int = ...
self,
file: str | IO[bytes],
mode: _ZipFileMode = ...,
compression: _CompressionMode = ...,
allowZip64: bool = ...,
optimize: int = ...,
) -> None: ...
def writepy(self, pathname: str, basename: str = ..., filterfunc: Callable[[str], bool] | None = ...) -> None: ...

class ZipInfo:
filename: str
date_time: _DateTuple
compress_type: int
compress_type: _CompressionMode
comment: bytes
extra: bytes
create_system: int
Expand Down Expand Up @@ -269,10 +275,10 @@ if sys.version_info >= (3, 8):

def is_zipfile(filename: StrOrBytesPath | _SupportsReadSeekTell) -> bool: ...

ZIP_STORED: int
ZIP_DEFLATED: int
ZIP_STORED: Literal[0]
ZIP_DEFLATED: Literal[8]
ZIP64_LIMIT: int
ZIP_FILECOUNT_LIMIT: int
ZIP_MAX_COMMENT: int
ZIP_BZIP2: int
ZIP_LZMA: int
ZIP_BZIP2: Literal[12]
ZIP_LZMA: Literal[14]

0 comments on commit 3695250

Please sign in to comment.