Merge stdlib/3.4 into stdlib/3 (#2303)

* Merge stdlib/3.4 into stdlib/3

* Move asyncio back to 3.4 for now
This commit is contained in:
Sebastian Rittau
2018-07-03 17:13:54 +02:00
committed by Jelle Zijlstra
parent 1ae2ba0fbe
commit 9229dd8f0c
8 changed files with 1 additions and 1 deletions

69
stdlib/3/_stat.pyi Normal file
View File

@@ -0,0 +1,69 @@
"""Stub file for the '_stat' module."""
SF_APPEND = ... # type: int
SF_ARCHIVED = ... # type: int
SF_IMMUTABLE = ... # type: int
SF_NOUNLINK = ... # type: int
SF_SNAPSHOT = ... # type: int
ST_ATIME = ... # type: int
ST_CTIME = ... # type: int
ST_DEV = ... # type: int
ST_GID = ... # type: int
ST_INO = ... # type: int
ST_MODE = ... # type: int
ST_MTIME = ... # type: int
ST_NLINK = ... # type: int
ST_SIZE = ... # type: int
ST_UID = ... # type: int
S_ENFMT = ... # type: int
S_IEXEC = ... # type: int
S_IFBLK = ... # type: int
S_IFCHR = ... # type: int
S_IFDIR = ... # type: int
S_IFDOOR = ... # type: int
S_IFIFO = ... # type: int
S_IFLNK = ... # type: int
S_IFPORT = ... # type: int
S_IFREG = ... # type: int
S_IFSOCK = ... # type: int
S_IFWHT = ... # type: int
S_IREAD = ... # type: int
S_IRGRP = ... # type: int
S_IROTH = ... # type: int
S_IRUSR = ... # type: int
S_IRWXG = ... # type: int
S_IRWXO = ... # type: int
S_IRWXU = ... # type: int
S_ISGID = ... # type: int
S_ISUID = ... # type: int
S_ISVTX = ... # type: int
S_IWGRP = ... # type: int
S_IWOTH = ... # type: int
S_IWRITE = ... # type: int
S_IWUSR = ... # type: int
S_IXGRP = ... # type: int
S_IXOTH = ... # type: int
S_IXUSR = ... # type: int
UF_APPEND = ... # type: int
UF_COMPRESSED = ... # type: int
UF_HIDDEN = ... # type: int
UF_IMMUTABLE = ... # type: int
UF_NODUMP = ... # type: int
UF_NOUNLINK = ... # type: int
UF_OPAQUE = ... # type: int
def S_IMODE(mode: int) -> int: ...
def S_IFMT(mode: int) -> int: ...
def S_ISBLK(mode: int) -> bool: ...
def S_ISCHR(mode: int) -> bool: ...
def S_ISDIR(mode: int) -> bool: ...
def S_ISDOOR(mode: int) -> bool: ...
def S_ISFIFO(mode: int) -> bool: ...
def S_ISLNK(mode: int) -> bool: ...
def S_ISPORT(mode: int) -> bool: ...
def S_ISREG(mode: int) -> bool: ...
def S_ISSOCK(mode: int) -> bool: ...
def S_ISWHT(mode: int) -> bool: ...
def filemode(mode: int) -> str: ...

26
stdlib/3/_tracemalloc.pyi Normal file
View File

@@ -0,0 +1,26 @@
"""Stub file for the '_tracemalloc' module."""
# This is an autogenerated file. It serves as a starting point
# for a more precise manual annotation of this module.
# Feel free to edit the source below, but remove this header when you do.
from typing import Any
def _get_object_traceback(*args, **kwargs) -> Any: ...
def _get_traces() -> Any:
raise MemoryError()
def clear_traces() -> None: ...
def get_traceback_limit() -> int: ...
def get_traced_memory() -> tuple: ...
def get_tracemalloc_memory() -> Any: ...
def is_tracing() -> bool: ...
def start(*args, **kwargs) -> None:
raise ValueError()
def stop() -> None: ...

65
stdlib/3/enum.pyi Normal file
View File

@@ -0,0 +1,65 @@
# NB: third_party/3/enum.pyi and stdlib/3.4/enum.pyi must remain consistent!
import sys
from typing import Any, Iterator, List, Mapping, Type, TypeVar, Union
from abc import ABCMeta
_T = TypeVar('_T')
_S = TypeVar('_S', bound=Type[Enum])
# Note: EnumMeta actually subclasses type directly, not ABCMeta.
# This is a temporary workaround to allow multiple creation of enums with builtins
# such as str as mixins, which due to the handling of ABCs of builtin types, cause
# spurious inconsistent metaclass structure. See #1595.
# Structurally: Iterable[T], Reversible[T], Container[T] where T is the enum itself
class EnumMeta(ABCMeta):
def __iter__(self: Type[_T]) -> Iterator[_T]: ...
def __reversed__(self: Type[_T]) -> Iterator[_T]: ...
def __contains__(self: Type[_T], member: Any) -> bool: ...
def __getitem__(self: Type[_T], name: str) -> _T: ...
@property
def __members__(self: Type[_T]) -> Mapping[str, _T]: ...
def __len__(self) -> int: ...
class Enum(metaclass=EnumMeta):
def __new__(cls: Type[_T], value: Any) -> _T: ...
def __repr__(self) -> str: ...
def __str__(self) -> str: ...
def __dir__(self) -> List[str]: ...
def __format__(self, format_spec: str) -> str: ...
def __hash__(self) -> Any: ...
def __reduce_ex__(self, proto: Any) -> Any: ...
name = ... # type: str
value = ... # type: Any
class IntEnum(int, Enum):
value = ... # type: int
def unique(enumeration: _S) -> _S: ...
if sys.version_info >= (3, 6):
_auto_null = ... # type: Any
# subclassing IntFlag so it picks up all implemented base functions, best modeling behavior of enum.auto()
class auto(IntFlag):
value = ... # type: Any
class Flag(Enum):
def __contains__(self: _T, other: _T) -> bool: ...
def __repr__(self) -> str: ...
def __str__(self) -> str: ...
def __bool__(self) -> bool: ...
def __or__(self: _T, other: _T) -> _T: ...
def __and__(self: _T, other: _T) -> _T: ...
def __xor__(self: _T, other: _T) -> _T: ...
def __invert__(self: _T) -> _T: ...
# The `type: ignore` comment is needed because mypy considers the type
# signatures of several methods defined in int and Flag to be incompatible.
class IntFlag(int, Flag): # type: ignore
def __or__(self: _T, other: Union[int, _T]) -> _T: ...
def __and__(self: _T, other: Union[int, _T]) -> _T: ...
def __xor__(self: _T, other: Union[int, _T]) -> _T: ...
__ror__ = __or__
__rand__ = __and__
__rxor__ = __xor__

122
stdlib/3/pathlib.pyi Normal file
View File

@@ -0,0 +1,122 @@
# Stubs for pathlib (Python 3.4)
from typing import Any, Generator, IO, Optional, Sequence, Tuple, Type, TypeVar, Union, List
from types import TracebackType
import os
import sys
_P = TypeVar('_P', bound='PurePath')
if sys.version_info >= (3, 6):
_PurePathBase = os.PathLike[str]
else:
_PurePathBase = object
class PurePath(_PurePathBase):
parts = ... # type: Tuple[str, ...]
drive = ... # type: str
root = ... # type: str
anchor = ... # type: str
name = ... # type: str
suffix = ... # type: str
suffixes = ... # type: List[str]
stem = ... # type: str
if sys.version_info < (3, 5):
def __init__(self, *pathsegments: str) -> None: ...
elif sys.version_info < (3, 6):
def __new__(cls: Type[_P], *args: Union[str, PurePath]) -> _P: ...
else:
def __new__(cls: Type[_P], *args: Union[str, os.PathLike[str]]) -> _P: ...
def __hash__(self) -> int: ...
def __lt__(self, other: PurePath) -> bool: ...
def __le__(self, other: PurePath) -> bool: ...
def __gt__(self, other: PurePath) -> bool: ...
def __ge__(self, other: PurePath) -> bool: ...
def __truediv__(self: _P, key: Union[str, PurePath]) -> _P: ...
def __bytes__(self) -> bytes: ...
def as_posix(self) -> str: ...
def as_uri(self) -> str: ...
def is_absolute(self) -> bool: ...
def is_reserved(self) -> bool: ...
def match(self, path_pattern: str) -> bool: ...
def relative_to(self: _P, *other: Union[str, PurePath]) -> _P: ...
def with_name(self: _P, name: str) -> _P: ...
def with_suffix(self: _P, suffix: str) -> _P: ...
def joinpath(self: _P, *other: Union[str, PurePath]) -> _P: ...
@property
def parents(self: _P) -> Sequence[_P]: ...
@property
def parent(self: _P) -> _P: ...
class PurePosixPath(PurePath): ...
class PureWindowsPath(PurePath): ...
class Path(PurePath):
def __enter__(self) -> Path: ...
def __exit__(self, exc_type: Optional[Type[BaseException]],
exc_value: Optional[BaseException],
traceback: Optional[TracebackType]) -> Optional[bool]: ...
@classmethod
def cwd(cls: Type[_P]) -> _P: ...
def stat(self) -> os.stat_result: ...
def chmod(self, mode: int) -> None: ...
def exists(self) -> bool: ...
def glob(self, pattern: str) -> Generator[Path, None, None]: ...
def group(self) -> str: ...
def is_dir(self) -> bool: ...
def is_file(self) -> bool: ...
def is_symlink(self) -> bool: ...
def is_socket(self) -> bool: ...
def is_fifo(self) -> bool: ...
def is_block_device(self) -> bool: ...
def is_char_device(self) -> bool: ...
def iterdir(self) -> Generator[Path, None, None]: ...
def lchmod(self, mode: int) -> None: ...
def lstat(self) -> os.stat_result: ...
if sys.version_info < (3, 5):
def mkdir(self, mode: int = ...,
parents: bool = ...) -> None: ...
else:
def mkdir(self, mode: int = ..., parents: bool = ...,
exist_ok: bool = ...) -> None: ...
def open(self, mode: str = ..., buffering: int = ...,
encoding: Optional[str] = ..., errors: Optional[str] = ...,
newline: Optional[str] = ...) -> IO[Any]: ...
def owner(self) -> str: ...
def rename(self, target: Union[str, PurePath]) -> None: ...
def replace(self, target: Union[str, PurePath]) -> None: ...
if sys.version_info < (3, 6):
def resolve(self: _P) -> _P: ...
else:
def resolve(self: _P, strict: bool = ...) -> _P: ...
def rglob(self, pattern: str) -> Generator[Path, None, None]: ...
def rmdir(self) -> None: ...
def symlink_to(self, target: Union[str, Path],
target_is_directory: bool = ...) -> None: ...
def touch(self, mode: int = ..., exist_ok: bool = ...) -> None: ...
def unlink(self) -> None: ...
if sys.version_info >= (3, 5):
@classmethod
def home(cls: Type[_P]) -> _P: ...
if sys.version_info < (3, 6):
def __new__(cls: Type[_P], *args: Union[str, PurePath],
**kwargs: Any) -> _P: ...
else:
def __new__(cls: Type[_P], *args: Union[str, os.PathLike[str]],
**kwargs: Any) -> _P: ...
def absolute(self: _P) -> _P: ...
def expanduser(self: _P) -> _P: ...
def read_bytes(self) -> bytes: ...
def read_text(self, encoding: Optional[str] = ...,
errors: Optional[str] = ...) -> str: ...
def samefile(self, other_path: Union[str, bytes, int, Path]) -> bool: ...
def write_bytes(self, data: bytes) -> int: ...
def write_text(self, data: str, encoding: Optional[str] = ...,
errors: Optional[str] = ...) -> int: ...
class PosixPath(Path, PurePosixPath): ...
class WindowsPath(Path, PureWindowsPath): ...

90
stdlib/3/selectors.pyi Normal file
View File

@@ -0,0 +1,90 @@
# Stubs for selector
# See https://docs.python.org/3/library/selectors.html
from typing import Any, List, NamedTuple, Mapping, Tuple, Optional, Union
from abc import ABCMeta, abstractmethod
import socket
# Type aliases added mainly to preserve some context
#
# See https://github.com/python/typeshed/issues/482
# for details regarding how _FileObject is typed.
_FileObject = Union[int, socket.socket]
_FileDescriptor = int
_EventMask = int
EVENT_READ = ... # type: _EventMask
EVENT_WRITE = ... # type: _EventMask
SelectorKey = NamedTuple('SelectorKey', [
('fileobj', _FileObject),
('fd', _FileDescriptor),
('events', _EventMask),
('data', Any)
])
class BaseSelector(metaclass=ABCMeta):
@abstractmethod
def register(self, fileobj: _FileObject, events: _EventMask, data: Any = ...) -> SelectorKey: ...
@abstractmethod
def unregister(self, fileobj: _FileObject) -> SelectorKey: ...
def modify(self, fileobj: _FileObject, events: _EventMask, data: Any = ...) -> SelectorKey: ...
@abstractmethod
def select(self, timeout: Optional[float] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ...
def close(self) -> None: ...
def get_key(self, fileobj: _FileObject) -> SelectorKey: ...
@abstractmethod
def get_map(self) -> Mapping[_FileObject, SelectorKey]: ...
def __enter__(self) -> BaseSelector: ...
def __exit__(self, *args: Any) -> None: ...
class SelectSelector(BaseSelector):
def register(self, fileobj: _FileObject, events: _EventMask, data: Any = ...) -> SelectorKey: ...
def unregister(self, fileobj: _FileObject) -> SelectorKey: ...
def select(self, timeout: Optional[float] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ...
def get_map(self) -> Mapping[_FileObject, SelectorKey]: ...
class PollSelector(BaseSelector):
def register(self, fileobj: _FileObject, events: _EventMask, data: Any = ...) -> SelectorKey: ...
def unregister(self, fileobj: _FileObject) -> SelectorKey: ...
def select(self, timeout: Optional[float] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ...
def get_map(self) -> Mapping[_FileObject, SelectorKey]: ...
class EpollSelector(BaseSelector):
def fileno(self) -> int: ...
def register(self, fileobj: _FileObject, events: _EventMask, data: Any = ...) -> SelectorKey: ...
def unregister(self, fileobj: _FileObject) -> SelectorKey: ...
def select(self, timeout: Optional[float] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ...
def get_map(self) -> Mapping[_FileObject, SelectorKey]: ...
class DevpollSelector(BaseSelector):
def fileno(self) -> int: ...
def register(self, fileobj: _FileObject, events: _EventMask, data: Any = ...) -> SelectorKey: ...
def unregister(self, fileobj: _FileObject) -> SelectorKey: ...
def select(self, timeout: Optional[float] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ...
def get_map(self) -> Mapping[_FileObject, SelectorKey]: ...
class KqueueSelector(BaseSelector):
def fileno(self) -> int: ...
def register(self, fileobj: _FileObject, events: _EventMask, data: Any = ...) -> SelectorKey: ...
def unregister(self, fileobj: _FileObject) -> SelectorKey: ...
def select(self, timeout: Optional[float] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ...
def get_map(self) -> Mapping[_FileObject, SelectorKey]: ...
class DefaultSelector(BaseSelector):
def register(self, fileobj: _FileObject, events: _EventMask, data: Any = ...) -> SelectorKey: ...
def unregister(self, fileobj: _FileObject) -> SelectorKey: ...
def select(self, timeout: Optional[float] = ...) -> List[Tuple[SelectorKey, _EventMask]]: ...
def get_map(self) -> Mapping[_FileObject, SelectorKey]: ...

24
stdlib/3/statistics.pyi Normal file
View File

@@ -0,0 +1,24 @@
# Stubs for statistics
from decimal import Decimal
from fractions import Fraction
import sys
from typing import Iterable, Optional, TypeVar
# Most functions in this module accept homogeneous collections of one of these types
_Number = TypeVar('_Number', float, Decimal, Fraction)
class StatisticsError(ValueError): ...
def mean(data: Iterable[_Number]) -> _Number: ...
if sys.version_info >= (3, 6):
def harmonic_mean(data: Iterable[_Number]) -> _Number: ...
def median(data: Iterable[_Number]) -> _Number: ...
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: ...
def pstdev(data: Iterable[_Number], mu: Optional[_Number] = ...) -> _Number: ...
def pvariance(data: Iterable[_Number], mu: Optional[_Number] = ...) -> _Number: ...
def stdev(data: Iterable[_Number], xbar: Optional[_Number] = ...) -> _Number: ...
def variance(data: Iterable[_Number], xbar: Optional[_Number] = ...) -> _Number: ...

70
stdlib/3/tracemalloc.pyi Normal file
View File

@@ -0,0 +1,70 @@
# Stubs for tracemalloc (Python 3.4+)
import sys
from typing import List, Optional, Sequence, Tuple, Union, overload
def clear_traces() -> None: ...
def get_object_traceback(obj: object) -> Optional[Traceback]: ...
def get_traceback_limit() -> int: ...
def get_traced_memory() -> Tuple[int, int]: ...
def get_tracemalloc_memory() -> int: ...
def is_tracing() -> bool: ...
def start(nframe: int = ...) -> None: ...
def stop() -> None: ...
def take_snapshot() -> Snapshot: ...
if sys.version_info >= (3, 6):
class DomainFilter:
inclusive = ... # type: bool
domain = ... # type: int
def __init__(self, inclusive: bool, domain: int) -> None: ...
class Filter:
if sys.version_info >= (3, 6):
domain = ... # type: Optional[int]
inclusive = ... # type: bool
lineno = ... # type: Optional[int]
filename_pattern = ... # type: str
all_frames = ... # type: bool
def __init__(self, inclusive: bool, filename_pattern: str, lineno: Optional[int] = ..., all_frames: bool = ..., domain: Optional[int] = ...) -> None: ...
class Frame:
filename = ... # type: str
lineno = ... # type: int
class Snapshot:
def compare_to(self, old_snapshot: Snapshot, key_type: str, cumulative: bool = ...) -> List[StatisticDiff]: ...
def dump(self, filename: str) -> None: ...
if sys.version_info >= (3, 6):
def filter_traces(self, filters: Sequence[Union[DomainFilter, Filter]]) -> Snapshot: ...
else:
def filter_traces(self, filters: Sequence[Filter]) -> Snapshot: ...
@classmethod
def load(cls, filename: str) -> Snapshot: ...
def statistics(self, key_type: str, cumulative: bool = ...) -> List[Statistic]: ...
traceback_limit = ... # type: int
traces = ... # type: Sequence[Trace]
class Statistic:
count = ... # type: int
size = ... # type: int
traceback = ... # type: Traceback
class StatisticDiff:
count = ... # type: int
count_diff = ... # type: int
size = ... # type: int
size_diff = ... # type: int
traceback = ... # type: Traceback
class Trace:
size = ... # type: int
traceback = ... # type: Traceback
class Traceback(Sequence[Frame]):
def format(self, limit: Optional[int] = ...) -> List[str]: ...
@overload
def __getitem__(self, i: int) -> Frame: ...
@overload
def __getitem__(self, s: slice) -> Sequence[Frame]: ...
def __len__(self) -> int: ...