mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 04:54:47 +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,5 +1,5 @@
|
||||
import sys
|
||||
from typing import Any, BinaryIO, IO, Optional, Tuple, Union, overload
|
||||
from typing import Any, BinaryIO, IO, NamedTuple, Optional, Tuple, Union, overload
|
||||
|
||||
_chtype = Union[str, bytes, int]
|
||||
|
||||
@@ -452,3 +452,7 @@ class _CursesWindow:
|
||||
def vline(self, ch: _chtype, n: int) -> None: ...
|
||||
@overload
|
||||
def vline(self, y: int, x: int, ch: _chtype, n: int) -> None: ...
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
_ncurses_version = NamedTuple("ncurses_version", [("major", int), ("minor", int), ("patch", int)])
|
||||
ncurses_version: _ncurses_version
|
||||
|
||||
@@ -22,3 +22,6 @@ class Profile:
|
||||
def run(self: _SelfT, cmd: str) -> _SelfT: ...
|
||||
def runctx(self: _SelfT, cmd: str, globals: Dict[str, Any], locals: Dict[str, Any]) -> _SelfT: ...
|
||||
def runcall(self, func: Callable[..., _T], *args: Any, **kw: Any) -> _T: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def __enter__(self: _SelfT) -> _SelfT: ...
|
||||
def __exit__(self, *exc_info: Any) -> None: ...
|
||||
|
||||
@@ -35,7 +35,10 @@ class _mmap(Generic[AnyStr]):
|
||||
def close(self) -> None: ...
|
||||
def find(self, sub: AnyStr,
|
||||
start: int = ..., end: int = ...) -> int: ...
|
||||
def flush(self, offset: int = ..., size: int = ...) -> int: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def flush(self, offset: int = ..., size: int = ...) -> None: ...
|
||||
else:
|
||||
def flush(self, offset: int = ..., size: int = ...) -> int: ...
|
||||
def move(self, dest: int, src: int, count: int) -> None: ...
|
||||
def read(self, n: int = ...) -> AnyStr: ...
|
||||
def read_byte(self) -> AnyStr: ...
|
||||
|
||||
@@ -48,7 +48,8 @@ class Pickler:
|
||||
def dump(self, obj: Any) -> None: ...
|
||||
def clear_memo(self) -> None: ...
|
||||
def persistent_id(self, obj: Any) -> Any: ...
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
def reducer_override(self, obj: Any) -> Any: ...
|
||||
|
||||
class Unpickler:
|
||||
if sys.version_info >= (3, 0):
|
||||
|
||||
@@ -55,3 +55,11 @@ if sys.version_info < (3, 7):
|
||||
class Data:
|
||||
data: bytes
|
||||
def __init__(self, data: bytes) -> None: ...
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
class UID:
|
||||
data: int
|
||||
def __init__(self, data: int) -> None: ...
|
||||
def __index__(self) -> int: ...
|
||||
def __reduce__(self) -> Any: ...
|
||||
def __hash__(self) -> int: ...
|
||||
|
||||
@@ -585,6 +585,16 @@ class socket:
|
||||
def create_connection(address: Tuple[Optional[str], int],
|
||||
timeout: Optional[float] = ...,
|
||||
source_address: Tuple[Union[bytearray, bytes, Text], int] = ...) -> socket: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def has_dualstack_ipv6() -> bool: ...
|
||||
def create_server(
|
||||
address: Tuple[str, int],
|
||||
*,
|
||||
family: AddressFamily = ...,
|
||||
backlog: Optional[int] = ...,
|
||||
reuse_port: bool = ...,
|
||||
dualstack_ipv6: bool = ...,
|
||||
) -> socket: ...
|
||||
|
||||
# the 5th tuple item is an address
|
||||
# TODO the "Tuple[Any, ...]" should be "Union[Tuple[str, int], Tuple[str, int, int, int]]" but that triggers
|
||||
|
||||
@@ -207,6 +207,8 @@ class SSLSocket(socket.socket):
|
||||
def unwrap(self) -> socket.socket: ...
|
||||
def version(self) -> Optional[str]: ...
|
||||
def pending(self) -> int: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def verify_client_post_handshake(self) -> None: ...
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
class TLSVersion(enum.IntEnum):
|
||||
@@ -221,6 +223,8 @@ if sys.version_info >= (3, 7):
|
||||
class SSLContext:
|
||||
check_hostname: bool
|
||||
options: int
|
||||
if sys.version_info >= (3, 8):
|
||||
post_handshake_auth: bool
|
||||
@property
|
||||
def protocol(self) -> int: ...
|
||||
verify_flags: int
|
||||
@@ -285,6 +289,8 @@ if sys.version_info >= (3, 5):
|
||||
def do_handshake(self) -> None: ...
|
||||
def unwrap(self) -> None: ...
|
||||
def get_channel_binding(self, cb_type: str = ...) -> Optional[bytes]: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def verify_client_post_handshake(self) -> None: ...
|
||||
|
||||
class MemoryBIO:
|
||||
pending: int
|
||||
|
||||
@@ -29,6 +29,9 @@ def enumerate() -> List[Thread]: ...
|
||||
if sys.version_info >= (3, 4):
|
||||
def main_thread() -> Thread: ...
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from _thread import get_native_id as get_native_id
|
||||
|
||||
def settrace(func: _TF) -> None: ...
|
||||
def setprofile(func: Optional[_PF]) -> None: ...
|
||||
def stack_size(size: int = ...) -> int: ...
|
||||
@@ -67,6 +70,9 @@ class Thread:
|
||||
def join(self, timeout: Optional[float] = ...) -> None: ...
|
||||
def getName(self) -> str: ...
|
||||
def setName(self, name: str) -> None: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
@property
|
||||
def native_id(self) -> Optional[int]: ... # only available on some platforms
|
||||
def is_alive(self) -> bool: ...
|
||||
def isAlive(self) -> bool: ...
|
||||
def isDaemon(self) -> bool: ...
|
||||
@@ -160,6 +166,9 @@ class Event:
|
||||
def clear(self) -> None: ...
|
||||
def wait(self, timeout: Optional[float] = ...) -> bool: ...
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from _thread import _ExceptHookArgs as ExceptHookArgs, ExceptHookArgs as _ExceptHookArgs # don't ask
|
||||
excepthook: Callable[[_ExceptHookArgs], Any]
|
||||
|
||||
class Timer(Thread):
|
||||
if sys.version_info >= (3,):
|
||||
|
||||
@@ -21,13 +21,15 @@ if sys.version_info >= (3, 7) and sys.platform != 'win32':
|
||||
CLOCK_UPTIME: int # FreeBSD, OpenBSD
|
||||
|
||||
if sys.version_info >= (3, 3) and sys.platform != 'win32':
|
||||
CLOCK_HIGHRES: int = ... # Solaris only
|
||||
CLOCK_MONOTONIC: int = ... # Unix only
|
||||
CLOCK_MONOTONIC_RAW: int = ... # Linux 2.6.28 or later
|
||||
CLOCK_PROCESS_CPUTIME_ID: int = ... # Unix only
|
||||
CLOCK_REALTIME: int = ... # Unix only
|
||||
CLOCK_THREAD_CPUTIME_ID: int = ... # Unix only
|
||||
CLOCK_HIGHRES: int # Solaris only
|
||||
CLOCK_MONOTONIC: int # Unix only
|
||||
CLOCK_MONOTONIC_RAW: int # Linux 2.6.28 or later
|
||||
CLOCK_PROCESS_CPUTIME_ID: int # Unix only
|
||||
CLOCK_REALTIME: int # Unix only
|
||||
CLOCK_THREAD_CPUTIME_ID: int # Unix only
|
||||
|
||||
if sys.version_info >= (3, 8) and sys.platform == "darwin":
|
||||
CLOCK_UPTIME_RAW: int
|
||||
|
||||
if sys.version_info >= (3, 3):
|
||||
class struct_time(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Stubs for unicodedata (Python 2.7 and 3.4)
|
||||
import sys
|
||||
from typing import Any, Text, TypeVar, Union
|
||||
|
||||
ucd_3_2_0: UCD
|
||||
@@ -14,6 +14,8 @@ def decimal(__chr: Text, __default: _default = ...) -> Union[int, _default]: ...
|
||||
def decomposition(__chr: Text) -> Text: ...
|
||||
def digit(__chr: Text, __default: _default = ...) -> Union[int, _default]: ...
|
||||
def east_asian_width(__chr: Text) -> Text: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
def is_normalized(__form: str, __unistr: str) -> bool: ...
|
||||
def lookup(__name: Union[Text, bytes]) -> Text: ...
|
||||
def mirrored(__chr: Text) -> int: ...
|
||||
def name(__chr: Text, __default: _default = ...) -> Union[Text, _default]: ...
|
||||
|
||||
@@ -1,6 +1,26 @@
|
||||
# Stubs for xml.etree.ElementTree
|
||||
|
||||
from typing import Any, Callable, Dict, Generator, IO, ItemsView, Iterable, Iterator, KeysView, List, MutableSequence, Optional, overload, Sequence, Text, Tuple, TypeVar, Union
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
Dict,
|
||||
Generator,
|
||||
IO,
|
||||
ItemsView,
|
||||
Iterable,
|
||||
Iterator,
|
||||
KeysView,
|
||||
List,
|
||||
MutableSequence,
|
||||
Optional,
|
||||
Protocol,
|
||||
Sequence,
|
||||
Text,
|
||||
Tuple,
|
||||
TypeVar,
|
||||
Union,
|
||||
overload,
|
||||
)
|
||||
import io
|
||||
import sys
|
||||
|
||||
@@ -43,6 +63,41 @@ else:
|
||||
# _fixtext function in the source). Client code knows best:
|
||||
_str_result_type = Any
|
||||
|
||||
_file_or_filename = Union[str, bytes, int, IO[Any]]
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
class _Writeable(Protocol):
|
||||
def write(self, __s: str) -> Any: ...
|
||||
|
||||
@overload
|
||||
def canonicalize(
|
||||
xml_data: Optional[_parser_input_type] = ...,
|
||||
*,
|
||||
out: None = ...,
|
||||
from_file: Optional[_file_or_filename] = ...,
|
||||
with_comments: bool = ...,
|
||||
strip_text: bool = ...,
|
||||
rewrite_prefixes: bool = ...,
|
||||
qname_aware_tags: Optional[Iterable[str]] = ...,
|
||||
qname_aware_attrs: Optional[Iterable[str]] = ...,
|
||||
exclude_attrs: Optional[Iterable[str]] = ...,
|
||||
exclude_tags: Optional[Iterable[str]] = ...,
|
||||
) -> str: ...
|
||||
@overload
|
||||
def canonicalize(
|
||||
xml_data: Optional[_parser_input_type] = ...,
|
||||
*,
|
||||
out: _Writeable,
|
||||
from_file: Optional[_file_or_filename] = ...,
|
||||
with_comments: bool = ...,
|
||||
strip_text: bool = ...,
|
||||
rewrite_prefixes: bool = ...,
|
||||
qname_aware_tags: Optional[Iterable[str]] = ...,
|
||||
qname_aware_attrs: Optional[Iterable[str]] = ...,
|
||||
exclude_attrs: Optional[Iterable[str]] = ...,
|
||||
exclude_tags: Optional[Iterable[str]] = ...,
|
||||
) -> None: ...
|
||||
|
||||
class Element(MutableSequence[Element]):
|
||||
tag: _str_result_type
|
||||
attrib: Dict[_str_result_type, _str_result_type]
|
||||
@@ -100,9 +155,6 @@ class QName:
|
||||
text: str
|
||||
def __init__(self, text_or_uri: _str_argument_type, tag: Optional[_str_argument_type] = ...) -> None: ...
|
||||
|
||||
|
||||
_file_or_filename = Union[str, bytes, int, IO[Any]]
|
||||
|
||||
class ElementTree:
|
||||
def __init__(self, element: Optional[Element] = ..., file: Optional[_file_or_filename] = ...) -> None: ...
|
||||
def getroot(self) -> Element: ...
|
||||
@@ -176,6 +228,22 @@ class TreeBuilder:
|
||||
def start(self, tag: _parser_input_type, attrs: Dict[_parser_input_type, _parser_input_type]) -> Element: ...
|
||||
def end(self, tag: _parser_input_type) -> Element: ...
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
class C14NWriterTarget:
|
||||
def __init__(
|
||||
self,
|
||||
write: Callable[[str], Any],
|
||||
*,
|
||||
with_comments: bool = ...,
|
||||
strip_text: bool = ...,
|
||||
rewrite_prefixes: bool = ...,
|
||||
qname_aware_tags: Optional[Iterable[str]] = ...,
|
||||
qname_aware_attrs: Optional[Iterable[str]] = ...,
|
||||
exclude_attrs: Optional[Iterable[str]] = ...,
|
||||
exclude_tags: Optional[Iterable[str]] = ...,
|
||||
) -> None: ...
|
||||
|
||||
|
||||
class XMLParser:
|
||||
parser: Any
|
||||
target: TreeBuilder
|
||||
|
||||
@@ -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
|
||||
|
||||
2
third_party/2/pathlib2.pyi
vendored
2
third_party/2/pathlib2.pyi
vendored
@@ -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): ...
|
||||
|
||||
2
third_party/2and3/mock.pyi
vendored
2
third_party/2and3/mock.pyi
vendored
@@ -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