mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-26 05:41:11 +08:00
Annotations for remaining Python 3.8 additions (#3358)
* Add os.add_dll_directory() * Add memfd_create() and flags * Add type annotation to flags * Add stat_result.st_reparse_tag and flags * Add ncurses_version * Add Path.link_to() * Add Picker.reducer_override() * Add plistlib.UID * Add has_dualstack_ipv6() and create_server() * Add shlex.join() * Add SSL methods and fields * Add Python 3.8 statistics functions and classes * Remove obsolete sys.subversion * Add sys.unraisablehook * Add threading.excepthook * Add get_native_id() and Thread.native_id * Add Python 3.8 tkinter methods * Add CLOCK_UPTIME_RAW * Add SupportsIndex * Add typing.get_origin() and get_args() * Add unicodedata.is_normalized * Add unittest.mock.AsyncMock Currently this is just an alias for Any like Mock and MagicMock. All of these classes should probably be sub-classing Any and add their own methods. See also #3224. * Add unittest cleanup methods * Add IsolatedAsyncioTestCase * Add ElementTree.canonicalize() and C14NWriterTarget * cProfile.Profile can be used as a context manager * Add asyncio task name handling * mmap.flush() now always returns None * Add posonlyargcount to CodeType
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
# Stubs for _thread
|
||||
|
||||
import sys
|
||||
from threading import Thread
|
||||
from types import TracebackType
|
||||
from typing import Any, Callable, Dict, NoReturn, Optional, Tuple, Type
|
||||
from typing import Any, Callable, Dict, NamedTuple, NoReturn, Optional, Tuple, Type
|
||||
|
||||
error = RuntimeError
|
||||
|
||||
@@ -29,3 +31,18 @@ def get_ident() -> int: ...
|
||||
def stack_size(size: int = ...) -> int: ...
|
||||
|
||||
TIMEOUT_MAX: int
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
def get_native_id() -> int: ... # only available on some platforms
|
||||
|
||||
ExceptHookArgs = NamedTuple(
|
||||
"ExceptHookArgs",
|
||||
[
|
||||
("exc_type", Type[BaseException]),
|
||||
("exc_value", Optional[BaseException]),
|
||||
("exc_traceback", Optional[TracebackType]),
|
||||
("thread", Optional[Thread]),
|
||||
]
|
||||
)
|
||||
def _ExceptHookArgs(args) -> ExceptHookArgs: ...
|
||||
_excepthook: Callable[[ExceptHookArgs], Any]
|
||||
|
||||
@@ -44,7 +44,12 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
|
||||
# Future methods
|
||||
def create_future(self) -> Future[Any]: ...
|
||||
# Tasks methods
|
||||
def create_task(self, coro: Union[Awaitable[_T], Generator[Any, None, _T]]) -> Task[_T]: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def create_task(
|
||||
self, coro: Union[Awaitable[_T], Generator[Any, None, _T]], *, name: Optional[str] = ...,
|
||||
) -> Task[_T]: ...
|
||||
else:
|
||||
def create_task(self, coro: Union[Awaitable[_T], Generator[Any, None, _T]]) -> Task[_T]: ...
|
||||
def set_task_factory(self, factory: Optional[Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]]]) -> None: ...
|
||||
def get_task_factory(self) -> Optional[Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]]]: ...
|
||||
# Methods for interacting with threads
|
||||
|
||||
@@ -80,8 +80,14 @@ class AbstractEventLoop(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def create_future(self) -> Future[Any]: ...
|
||||
# Tasks methods
|
||||
@abstractmethod
|
||||
def create_task(self, coro: Union[Awaitable[_T], Generator[Any, None, _T]]) -> Task[_T]: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
@abstractmethod
|
||||
def create_task(
|
||||
self, coro: Union[Awaitable[_T], Generator[Any, None, _T]], *, name: Optional[str] = ...,
|
||||
) -> Task[_T]: ...
|
||||
else:
|
||||
@abstractmethod
|
||||
def create_task(self, coro: Union[Awaitable[_T], Generator[Any, None, _T]]) -> Task[_T]: ...
|
||||
@abstractmethod
|
||||
def set_task_factory(self, factory: Optional[Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]]]) -> None: ...
|
||||
@abstractmethod
|
||||
|
||||
@@ -98,6 +98,9 @@ class Task(Future[_T], Generic[_T]):
|
||||
def all_tasks(cls, loop: Optional[AbstractEventLoop] = ...) -> Set[Task[Any]]: ...
|
||||
def __init__(self, coro: Union[Generator[Any, None, _T], Awaitable[_T]], *, loop: AbstractEventLoop = ...) -> None: ...
|
||||
def __repr__(self) -> str: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def get_name(self) -> str: ...
|
||||
def set_name(self, value: object) -> None: ...
|
||||
def get_stack(self, *, limit: int = ...) -> List[FrameType]: ...
|
||||
def print_stack(self, *, limit: int = ..., file: TextIO = ...) -> None: ...
|
||||
def cancel(self) -> bool: ...
|
||||
@@ -106,5 +109,10 @@ class Task(Future[_T], Generic[_T]):
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
def all_tasks(loop: Optional[AbstractEventLoop] = ...) -> Set[Task[Any]]: ...
|
||||
def create_task(coro: Union[Generator[Any, None, _T], Awaitable[_T]]) -> Task[Any]: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def create_task(
|
||||
coro: Union[Generator[Any, None, _T], Awaitable[_T]], *, name: Optional[str] = ...,
|
||||
) -> Task[Any]: ...
|
||||
else:
|
||||
def create_task(coro: Union[Generator[Any, None, _T], Awaitable[_T]]) -> Task[Any]: ...
|
||||
def current_task(loop: Optional[AbstractEventLoop] = ...) -> Optional[Task[Any]]: ...
|
||||
|
||||
@@ -210,6 +210,8 @@ class stat_result:
|
||||
st_atime_ns: int # time of most recent access, in nanoseconds
|
||||
st_mtime_ns: int # time of most recent content modification in nanoseconds
|
||||
st_ctime_ns: int # platform dependent (time of most recent metadata change on Unix, or the time of creation on Windows) in nanoseconds
|
||||
if sys.version_info >= (3, 8) and sys.platform == "win32":
|
||||
st_reparse_tag: int
|
||||
|
||||
def __getitem__(self, i: int) -> int: ...
|
||||
|
||||
@@ -631,3 +633,31 @@ else:
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
def register_at_fork(func: Callable[..., object], when: str) -> None: ...
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
if sys.platform == "win32":
|
||||
class _AddedDllDirectory:
|
||||
path: Optional[str]
|
||||
def close(self) -> None: ...
|
||||
def __enter__(self: _T) -> _T: ...
|
||||
def __exit__(self, *args: Any) -> None: ...
|
||||
def add_dll_directory(path: str) -> _AddedDllDirectory: ...
|
||||
if sys.platform == "linux":
|
||||
MFD_CLOEXEC: int
|
||||
MFD_ALLOW_SEALING: int
|
||||
MFD_HUGETLB: int
|
||||
MFD_HUGE_SHIFT: int
|
||||
MFD_HUGE_MASK: int
|
||||
MFD_HUGE_64KB: int
|
||||
MFD_HUGE_512KB: int
|
||||
MFD_HUGE_1MB: int
|
||||
MFD_HUGE_2MB: int
|
||||
MFD_HUGE_8MB: int
|
||||
MFD_HUGE_16MB: int
|
||||
MFD_HUGE_32MB: int
|
||||
MFD_HUGE_256MB: int
|
||||
MFD_HUGE_512MB: int
|
||||
MFD_HUGE_1GB: int
|
||||
MFD_HUGE_2GB: int
|
||||
MFD_HUGE_16GB: int
|
||||
def memfd_create(name: str, flags: int = ...) -> int: ...
|
||||
|
||||
@@ -127,6 +127,8 @@ class Path(PurePath):
|
||||
def write_bytes(self, data: bytes) -> int: ...
|
||||
def write_text(self, data: str, encoding: Optional[str] = ...,
|
||||
errors: Optional[str] = ...) -> int: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def link_to(self, target: Union[str, bytes, os.PathLike[str]]) -> None: ...
|
||||
|
||||
|
||||
class PosixPath(Path, PurePosixPath): ...
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
# Stubs for shlex
|
||||
|
||||
# Based on http://docs.python.org/3.2/library/shlex.html
|
||||
|
||||
from typing import List, Tuple, Any, TextIO, Union, Optional, Iterable, TypeVar
|
||||
import sys
|
||||
|
||||
def split(s: str, comments: bool = ...,
|
||||
posix: bool = ...) -> List[str]: ...
|
||||
|
||||
# Added in 3.3, use (undocumented) pipes.quote in previous versions.
|
||||
def split(s: str, comments: bool = ..., posix: bool = ...) -> List[str]: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def join(split_command: Iterable[str]) -> str: ...
|
||||
def quote(s: str) -> str: ...
|
||||
|
||||
_SLT = TypeVar('_SLT', bound=shlex)
|
||||
|
||||
@@ -17,58 +17,81 @@ def S_IFMT(mode: int) -> int: ...
|
||||
|
||||
def filemode(mode: int) -> str: ...
|
||||
|
||||
ST_MODE = 0
|
||||
ST_INO = 0
|
||||
ST_DEV = 0
|
||||
ST_NLINK = 0
|
||||
ST_UID = 0
|
||||
ST_GID = 0
|
||||
ST_SIZE = 0
|
||||
ST_ATIME = 0
|
||||
ST_MTIME = 0
|
||||
ST_CTIME = 0
|
||||
ST_MODE: int
|
||||
ST_INO: int
|
||||
ST_DEV: int
|
||||
ST_NLINK: int
|
||||
ST_UID: int
|
||||
ST_GID: int
|
||||
ST_SIZE: int
|
||||
ST_ATIME: int
|
||||
ST_MTIME: int
|
||||
ST_CTIME: int
|
||||
|
||||
S_IFSOCK = 0
|
||||
S_IFLNK = 0
|
||||
S_IFREG = 0
|
||||
S_IFBLK = 0
|
||||
S_IFDIR = 0
|
||||
S_IFCHR = 0
|
||||
S_IFIFO = 0
|
||||
S_ISUID = 0
|
||||
S_ISGID = 0
|
||||
S_ISVTX = 0
|
||||
S_IFSOCK: int
|
||||
S_IFLNK: int
|
||||
S_IFREG: int
|
||||
S_IFBLK: int
|
||||
S_IFDIR: int
|
||||
S_IFCHR: int
|
||||
S_IFIFO: int
|
||||
S_ISUID: int
|
||||
S_ISGID: int
|
||||
S_ISVTX: int
|
||||
|
||||
S_IRWXU = 0
|
||||
S_IRUSR = 0
|
||||
S_IWUSR = 0
|
||||
S_IXUSR = 0
|
||||
S_IRWXU: int
|
||||
S_IRUSR: int
|
||||
S_IWUSR: int
|
||||
S_IXUSR: int
|
||||
|
||||
S_IRWXG = 0
|
||||
S_IRGRP = 0
|
||||
S_IWGRP = 0
|
||||
S_IXGRP = 0
|
||||
S_IRWXG: int
|
||||
S_IRGRP: int
|
||||
S_IWGRP: int
|
||||
S_IXGRP: int
|
||||
|
||||
S_IRWXO = 0
|
||||
S_IROTH = 0
|
||||
S_IWOTH = 0
|
||||
S_IXOTH = 0
|
||||
S_IRWXO: int
|
||||
S_IROTH: int
|
||||
S_IWOTH: int
|
||||
S_IXOTH: int
|
||||
|
||||
S_ENFMT = 0
|
||||
S_IREAD = 0
|
||||
S_IWRITE = 0
|
||||
S_IEXEC = 0
|
||||
S_ENFMT: int
|
||||
S_IREAD: int
|
||||
S_IWRITE: int
|
||||
S_IEXEC: int
|
||||
|
||||
UF_NODUMP = 0
|
||||
UF_IMMUTABLE = 0
|
||||
UF_APPEND = 0
|
||||
UF_OPAQUE = 0
|
||||
UF_NOUNLINK = 0
|
||||
UF_NODUMP: int
|
||||
UF_IMMUTABLE: int
|
||||
UF_APPEND: int
|
||||
UF_OPAQUE: int
|
||||
UF_NOUNLINK: int
|
||||
if sys.platform == 'darwin':
|
||||
UF_COMPRESSED = 0 # OS X 10.6+ only
|
||||
UF_HIDDEN = 0 # OX X 10.5+ only
|
||||
SF_ARCHIVED = 0
|
||||
SF_IMMUTABLE = 0
|
||||
SF_APPEND = 0
|
||||
SF_NOUNLINK = 0
|
||||
SF_SNAPSHOT = 0
|
||||
UF_COMPRESSED: int # OS X 10.6+ only
|
||||
UF_HIDDEN: int # OX X 10.5+ only
|
||||
SF_ARCHIVED: int
|
||||
SF_IMMUTABLE: int
|
||||
SF_APPEND: int
|
||||
SF_NOUNLINK: int
|
||||
SF_SNAPSHOT: int
|
||||
|
||||
FILE_ATTRIBUTE_ARCHIVE: int
|
||||
FILE_ATTRIBUTE_COMPRESSED: int
|
||||
FILE_ATTRIBUTE_DEVICE: int
|
||||
FILE_ATTRIBUTE_DIRECTORY: int
|
||||
FILE_ATTRIBUTE_ENCRYPTED: int
|
||||
FILE_ATTRIBUTE_HIDDEN: int
|
||||
FILE_ATTRIBUTE_INTEGRITY_STREAM: int
|
||||
FILE_ATTRIBUTE_NORMAL: int
|
||||
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED: int
|
||||
FILE_ATTRIBUTE_NO_SCRUB_DATA: int
|
||||
FILE_ATTRIBUTE_OFFLINE: int
|
||||
FILE_ATTRIBUTE_READONLY: int
|
||||
FILE_ATTRIBUTE_REPARSE_POINT: int
|
||||
FILE_ATTRIBUTE_SPARSE_FILE: int
|
||||
FILE_ATTRIBUTE_SYSTEM: int
|
||||
FILE_ATTRIBUTE_TEMPORARY: int
|
||||
FILE_ATTRIBUTE_VIRTUAL: int
|
||||
|
||||
if sys.platform == "win32" and sys.version_info >= (3, 8):
|
||||
IO_REPARSE_TAG_SYMLINK: int
|
||||
IO_REPARSE_TAG_MOUNT_POINT: int
|
||||
IO_REPARSE_TAG_APPEXECLINK: int
|
||||
|
||||
@@ -3,13 +3,17 @@
|
||||
from decimal import Decimal
|
||||
from fractions import Fraction
|
||||
import sys
|
||||
from typing import Iterable, Optional, TypeVar
|
||||
from typing import Any, Iterable, List, Optional, SupportsFloat, Type, TypeVar, Union
|
||||
|
||||
_T = TypeVar("_T")
|
||||
# Most functions in this module accept homogeneous collections of one of these types
|
||||
_Number = TypeVar('_Number', float, Decimal, Fraction)
|
||||
|
||||
class StatisticsError(ValueError): ...
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
def fmean(data: Iterable[SupportsFloat]) -> float: ...
|
||||
def geometric_mean(data: Iterable[SupportsFloat]) -> float: ...
|
||||
def mean(data: Iterable[_Number]) -> _Number: ...
|
||||
if sys.version_info >= (3, 6):
|
||||
def harmonic_mean(data: Iterable[_Number]) -> _Number: ...
|
||||
@@ -18,7 +22,43 @@ def median_low(data: Iterable[_Number]) -> _Number: ...
|
||||
def median_high(data: Iterable[_Number]) -> _Number: ...
|
||||
def median_grouped(data: Iterable[_Number]) -> _Number: ...
|
||||
def mode(data: Iterable[_Number]) -> _Number: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def multimode(data: Iterable[_T]) -> List[_T]: ...
|
||||
def pstdev(data: Iterable[_Number], mu: Optional[_Number] = ...) -> _Number: ...
|
||||
def pvariance(data: Iterable[_Number], mu: Optional[_Number] = ...) -> _Number: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def quantiles(data: Iterable[_Number], *, n: int = ..., method: str = ...) -> List[_Number]: ...
|
||||
def stdev(data: Iterable[_Number], xbar: Optional[_Number] = ...) -> _Number: ...
|
||||
def variance(data: Iterable[_Number], xbar: Optional[_Number] = ...) -> _Number: ...
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
class NormalDist:
|
||||
def __init__(self, mu: float = ..., sigma: float = ...) -> None: ...
|
||||
@property
|
||||
def mean(self) -> float: ...
|
||||
@property
|
||||
def median(self) -> float: ...
|
||||
@property
|
||||
def mode(self) -> float: ...
|
||||
@property
|
||||
def stdev(self) -> float: ...
|
||||
@property
|
||||
def variance(self) -> float: ...
|
||||
@classmethod
|
||||
def from_samples(cls: Type[_T], data: Iterable[SupportsFloat]) -> _T: ...
|
||||
def samples(self, n: int, *, seed: Optional[Any]) -> List[float]: ...
|
||||
def pdf(self, x: float) -> float: ...
|
||||
def cdf(self, x: float) -> float: ...
|
||||
def inv_cdf(self, p: float) -> float: ...
|
||||
def overlap(self, other: NormalDist) -> float: ...
|
||||
def quantiles(self, n: int = ...) -> List[float]: ...
|
||||
def __add__(self, x2: Union[float, NormalDist]) -> NormalDist: ...
|
||||
def __sub__(self, x2: Union[float, NormalDist]) -> NormalDist: ...
|
||||
def __mul__(self, x2: float) -> NormalDist: ...
|
||||
def __truediv__(self, x2: float) -> NormalDist: ...
|
||||
def __pos__(self) -> NormalDist: ...
|
||||
def __neg__(self) -> NormalDist: ...
|
||||
__radd__ = __add__
|
||||
def __rsub__(self, x2: Union[float, NormalDist]) -> NormalDist: ...
|
||||
__rmul__ = __mul__
|
||||
def __hash__(self) -> int: ...
|
||||
|
||||
@@ -54,8 +54,6 @@ stderr: TextIO
|
||||
__stdin__: TextIO
|
||||
__stdout__: TextIO
|
||||
__stderr__: TextIO
|
||||
# deprecated and removed in Python 3.3:
|
||||
subversion: Tuple[str, str, str]
|
||||
tracebacklimit: int
|
||||
version: str
|
||||
api_version: int
|
||||
@@ -198,3 +196,13 @@ def setswitchinterval(interval: float) -> None: ...
|
||||
def settscdump(on_flag: bool) -> None: ...
|
||||
|
||||
def gettotalrefcount() -> int: ... # Debug builds only
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
# not exported by sys
|
||||
class UnraisableHookArgs:
|
||||
exc_type: Type[BaseException]
|
||||
exc_value: Optional[BaseException]
|
||||
exc_traceback: Optional[TracebackType]
|
||||
err_msg: Optional[str]
|
||||
object: Optional[object]
|
||||
unraisablehook: Callable[[UnraisableHookArgs], Any]
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import sys
|
||||
from types import TracebackType
|
||||
from typing import Any, Optional, Dict, Callable, Type
|
||||
from typing import Any, Optional, Dict, Callable, Tuple, Type, Union
|
||||
from tkinter.constants import * # noqa: F403
|
||||
|
||||
TclError: Any
|
||||
@@ -389,6 +390,8 @@ class Canvas(Widget, XView, YView):
|
||||
def tag_lower(self, *args): ...
|
||||
lower: Any
|
||||
def move(self, *args): ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def moveto(self, tagOrId: Union[int, str], x: str = ..., y: str = ...) -> None: ...
|
||||
def postscript(self, cnf=..., **kw): ...
|
||||
def tag_raise(self, *args): ...
|
||||
lift: Any
|
||||
@@ -615,6 +618,9 @@ class PhotoImage(Image):
|
||||
def get(self, x, y): ...
|
||||
def put(self, data, to: Optional[Any] = ...): ...
|
||||
def write(self, filename, format: Optional[Any] = ..., from_coords: Optional[Any] = ...): ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def transparency_get(self, x: int, y: int) -> bool: ...
|
||||
def transparency_set(self, x: int, y: int, boolean: bool) -> None: ...
|
||||
|
||||
class BitmapImage(Image):
|
||||
def __init__(self, name: Optional[Any] = ..., cnf=..., master: Optional[Any] = ..., **kw): ...
|
||||
@@ -635,10 +641,15 @@ class Spinbox(Widget, XView):
|
||||
def scan(self, *args): ...
|
||||
def scan_mark(self, x): ...
|
||||
def scan_dragto(self, x): ...
|
||||
def selection(self, *args): ...
|
||||
def selection(self, *args: Any) -> Tuple[int, ...]: ...
|
||||
def selection_adjust(self, index): ...
|
||||
def selection_clear(self): ...
|
||||
def selection_element(self, element: Optional[Any] = ...): ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def selection_from(self, index: int) -> None: ...
|
||||
def selection_present(self) -> None: ...
|
||||
def selection_range(self, start: int, end: int) -> None: ...
|
||||
def selection_to(self, index: int) -> None: ...
|
||||
|
||||
class LabelFrame(Widget):
|
||||
def __init__(self, master: Optional[Any] = ..., cnf=..., **kw): ...
|
||||
|
||||
@@ -40,6 +40,8 @@ LambdaType = FunctionType
|
||||
class CodeType:
|
||||
"""Create a code object. Not for the faint of heart."""
|
||||
co_argcount: int
|
||||
if sys.version_info >= (3, 8):
|
||||
co_posonlyargcount: int
|
||||
co_kwonlyargcount: int
|
||||
co_nlocals: int
|
||||
co_stacksize: int
|
||||
@@ -54,24 +56,45 @@ class CodeType:
|
||||
co_lnotab: bytes
|
||||
co_freevars: Tuple[str, ...]
|
||||
co_cellvars: Tuple[str, ...]
|
||||
def __init__(
|
||||
self,
|
||||
argcount: int,
|
||||
kwonlyargcount: int,
|
||||
nlocals: int,
|
||||
stacksize: int,
|
||||
flags: int,
|
||||
codestring: bytes,
|
||||
constants: Tuple[Any, ...],
|
||||
names: Tuple[str, ...],
|
||||
varnames: Tuple[str, ...],
|
||||
filename: str,
|
||||
name: str,
|
||||
firstlineno: int,
|
||||
lnotab: bytes,
|
||||
freevars: Tuple[str, ...] = ...,
|
||||
cellvars: Tuple[str, ...] = ...,
|
||||
) -> None: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def __init__(
|
||||
self,
|
||||
argcount: int,
|
||||
posonlyargcount: int,
|
||||
kwonlyargcount: int,
|
||||
nlocals: int,
|
||||
stacksize: int,
|
||||
flags: int,
|
||||
codestring: bytes,
|
||||
constants: Tuple[Any, ...],
|
||||
names: Tuple[str, ...],
|
||||
varnames: Tuple[str, ...],
|
||||
filename: str,
|
||||
name: str,
|
||||
firstlineno: int,
|
||||
lnotab: bytes,
|
||||
freevars: Tuple[str, ...] = ...,
|
||||
cellvars: Tuple[str, ...] = ...,
|
||||
) -> None: ...
|
||||
else:
|
||||
def __init__(
|
||||
self,
|
||||
argcount: int,
|
||||
kwonlyargcount: int,
|
||||
nlocals: int,
|
||||
stacksize: int,
|
||||
flags: int,
|
||||
codestring: bytes,
|
||||
constants: Tuple[Any, ...],
|
||||
names: Tuple[str, ...],
|
||||
varnames: Tuple[str, ...],
|
||||
filename: str,
|
||||
name: str,
|
||||
firstlineno: int,
|
||||
lnotab: bytes,
|
||||
freevars: Tuple[str, ...] = ...,
|
||||
cellvars: Tuple[str, ...] = ...,
|
||||
) -> None: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def replace(
|
||||
self,
|
||||
|
||||
@@ -99,6 +99,12 @@ class SupportsBytes(Protocol, metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def __bytes__(self) -> bytes: ...
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
@runtime_checkable
|
||||
class SupportsIndex(Protocol, metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def __index__(self) -> int: ...
|
||||
|
||||
@runtime_checkable
|
||||
class SupportsAbs(Protocol[_T_co]):
|
||||
@abstractmethod
|
||||
@@ -590,6 +596,9 @@ class Pattern(Generic[AnyStr]):
|
||||
def get_type_hints(
|
||||
obj: Callable[..., Any], globalns: Optional[Dict[str, Any]] = ..., localns: Optional[Dict[str, Any]] = ...,
|
||||
) -> Dict[str, Any]: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def get_origin(tp: Any) -> Optional[Any]: ...
|
||||
def get_args(tp: Any) -> Tuple[Any, ...]: ...
|
||||
|
||||
@overload
|
||||
def cast(tp: Type[_T], obj: Any) -> _T: ...
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
from typing import Iterable, List, Optional, Type, Union
|
||||
from types import ModuleType
|
||||
|
||||
from unittest.async_case import *
|
||||
from unittest.case import *
|
||||
from unittest.loader import *
|
||||
from unittest.result import *
|
||||
|
||||
9
stdlib/3/unittest/async_case.pyi
Normal file
9
stdlib/3/unittest/async_case.pyi
Normal file
@@ -0,0 +1,9 @@
|
||||
import sys
|
||||
from typing import Any, Awaitable, Callable
|
||||
from .case import TestCase
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
class IsolatedAsyncioTestCase(TestCase):
|
||||
async def asyncSetUp(self) -> None: ...
|
||||
async def asyncTearDown(self) -> None: ...
|
||||
def addAsyncCleanup(self, __func: Callable[..., Awaitable[Any]], *args: Any, **kwargs: Any) -> None: ...
|
||||
@@ -1,16 +1,19 @@
|
||||
import logging
|
||||
import sys
|
||||
import unittest.result
|
||||
from types import TracebackType
|
||||
from typing import (
|
||||
Any, AnyStr, Callable, Container, ContextManager, Dict, FrozenSet, Generic,
|
||||
Iterable, List, NoReturn, Optional, overload, Pattern, Sequence, Set,
|
||||
Tuple, Type, TypeVar, Union,
|
||||
)
|
||||
import logging
|
||||
import unittest.result
|
||||
from types import TracebackType
|
||||
|
||||
|
||||
_E = TypeVar('_E', bound=BaseException)
|
||||
_FT = TypeVar('_FT', bound=Callable[..., Any])
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
def addModuleCleanup(__function: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ...
|
||||
def doModuleCleanups() -> None: ...
|
||||
|
||||
def expectedFailure(func: _FT) -> _FT: ...
|
||||
def skip(reason: str) -> Callable[[_FT], _FT]: ...
|
||||
@@ -154,6 +157,11 @@ class TestCase:
|
||||
def addCleanup(self, function: Callable[..., Any], *args: Any,
|
||||
**kwargs: Any) -> None: ...
|
||||
def doCleanups(self) -> None: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
@classmethod
|
||||
def addClassCleanup(cls, __function: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ...
|
||||
@classmethod
|
||||
def doClassCleanups(cls) -> None: ...
|
||||
def _formatMessage(self, msg: Optional[str], standardMsg: str) -> str: ... # undocumented
|
||||
def _getAssertEqualityFunc(self, first: Any, second: Any) -> Callable[..., None]: ... # undocumented
|
||||
# below is deprecated
|
||||
|
||||
@@ -98,6 +98,8 @@ class MagicMixin:
|
||||
|
||||
NonCallableMagicMock = Any
|
||||
MagicMock = Any
|
||||
if sys.version_info >= (3, 8):
|
||||
AsyncMock = Any
|
||||
|
||||
class MagicProxy:
|
||||
name: Any
|
||||
|
||||
Reference in New Issue
Block a user