Enable pathlib, io, itertools, ssl stubs (PY-30450, PY-29863, PY-27972, PY-28155, PY-15949, PY-22845)

This commit is contained in:
Semyon Proshev
2018-06-18 18:46:59 +03:00
parent c942325636
commit 5571702b32
13 changed files with 1226 additions and 1032 deletions

View File

@@ -1,622 +0,0 @@
"""Skeleton for 'io' stdlib module."""
from __future__ import unicode_literals
import sys
import io
def open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None,
closefd=True, opener=None):
"""This is an alias for the builtin open() function.
:type file: string
:type mode: string
:type buffering: numbers.Integral
:type encoding: string | None
:type errors: string | None
:type newline: string | None
:type closefd: bool
:type opener: ((string, int) -> int) | None
:rtype: io.FileIO[bytes] | io.TextIOWrapper[unicode]
"""
pass
class IOBase(object):
"""The abstract base class for all I/O classes, acting on streams of
bytes.
:type closed: bool
"""
def __init__(self, *args, **kwargs):
"""Private constructor of IOBase.
:rtype: io.IOBase[T <= bytes | unicode]
"""
self.closed = False
def __iter__(self):
"""Iterate over lines.
:rtype: collections.Iterator[T]
"""
return []
def close(self):
"""Flush and close this stream.
:rtype: None
"""
pass
def fileno(self):
"""Return the underlying file descriptor (an integer) of the stream if
it exists.
:rtype: int
"""
return 0
def flush(self):
"""Flush the write buffers of the stream if applicable.
:rtype: None
"""
pass
def isatty(self):
"""Return True if the stream is interactive (i.e., connected to a
terminal/tty device).
:rtype: bool
"""
return False
def readable(self):
"""Return True if the stream can be read from.
:rtype: bool
"""
return False
def readline(self, limit=-1):
"""Read and return one line from the stream.
:type limit: numbers.Integral
:rtype: T
"""
pass
def readlines(self, hint=-1):
"""Read and return a list of lines from the stream.
:type hint: numbers.Integral
:rtype: list[T]
"""
return []
def seek(self, offset, whence=io.SEEK_SET):
"""Change the stream position to the given byte offset.
:type offset: numbers.Integral
:type whence: numbers.Integral
:rtype: None
"""
pass
def seekable(self):
"""Return True if the stream supports random access.
:rtype: bool
"""
return False
def tell(self):
"""Return the current stream position.
:rtype: int
"""
return 0
def truncate(self, size=None):
"""Resize the stream to the given size in bytes (or the current
position if size is not specified).
:type size: numbers.Integral | None
:rtype: None
"""
pass
def writable(self):
"""Return True if the stream supports writing.
:rtype: bool
"""
return False
def writelines(self, lines):
"""Write a list of lines to the stream.
:type lines: collections.Iterable[T]
:rtype: None
"""
pass
class RawIOBase(io.IOBase):
"""Base class for raw binary I/O."""
def __init__(self, *args, **kwargs):
"""Private constructor of RawIOBase.
:rtype: io.RawIOBase[bytes]
"""
pass
def read(self, n=1):
"""Read up to n bytes from the object and return them.
:type n: numbers.Integral
:rtype: bytes
"""
return b''
def readall(self):
"""Read and return all the bytes from the stream until EOF, using
multiple calls to the stream if necessary.
:rtype: bytes
"""
return b''
def readinto(self, b):
"""Read up to len(b) bytes into bytearray b and return the number of
bytes read.
:type b: bytearray
:rtype: int
"""
return 0
def write(self, b):
"""Write the given bytes or bytearray object, b, to the underlying raw
stream and return the number of bytes written.
:type b: bytes | bytearray
:rtype: int
"""
return 0
class BufferedIOBase(io.IOBase):
"""Base class for binary streams that support some kind of buffering."""
def __init__(self, *args, **kwargs):
"""Private constructor of BufferedIOBase.
:rtype: io.BufferedIOBase[bytes]
"""
pass
if sys.version_info >= (2, 7):
def detach(self):
"""Separate the underlying raw stream from the buffer and return
it.
:rtype: None
"""
pass
def read1(self, n=-1):
"""Read and return up to n bytes, with at most one call to the
underlying raw stream's read() method.
:type n: numbers.Integral
:rtype: bytes
"""
return b''
class FileIO(io.RawIOBase):
"""FileIO represents an OS-level file containing bytes data.
:type name: string
:type mode: string
:type closefd: bool
:type closed: bool
"""
def __init__(self, name, mode='r', closefd=True):
"""Create a FileIO object.
:type name: string
:type mode: string
:type closefd: bool
:rtype: io.FileIO[bytes]
"""
self.name = name
self.mode = mode
self.closefd = closefd
self.closed = False
pass
def __iter__(self):
"""Iterate over lines.
:rtype: collections.Iterator[bytes]
"""
return []
def close(self):
"""Flush and close this stream.
:rtype: None
"""
pass
def fileno(self):
"""Return the underlying file descriptor (an integer) of the stream if
it exists.
:rtype: int
"""
return 0
def flush(self):
"""Flush the write buffers of the stream if applicable.
:rtype: None
"""
pass
def isatty(self):
"""Return True if the stream is interactive (i.e., connected to a
terminal/tty device).
:rtype: bool
"""
return False
def readable(self):
"""Return True if the stream can be read from.
:rtype: bool
"""
return False
def readline(self, limit=-1):
"""Read and return one line from the stream.
:type limit: numbers.Integral
:rtype: bytes
"""
return b''
def readlines(self, hint=-1):
"""Read and return a list of lines from the stream.
:type hint: numbers.Integral
:rtype: list[bytes]
"""
return []
def seek(self, offset, whence=io.SEEK_SET):
"""Change the stream position to the given byte offset.
:type offset: numbers.Integral
:type whence: numbers.Integral
:rtype: None
"""
pass
def seekable(self):
"""Return True if the stream supports random access.
:rtype: bool
"""
return False
def tell(self):
"""Return the current stream position.
:rtype: int
"""
return 0
def truncate(self, size=None):
"""Resize the stream to the given size in bytes (or the current
position if size is not specified).
:type size: numbers.Integral | None
:rtype: None
"""
pass
def writable(self):
"""Return True if the stream supports writing.
:rtype: bool
"""
return False
def writelines(self, lines):
"""Write a list of lines to the stream.
:type lines: collections.Iterable[bytes]
:rtype: None
"""
pass
def read(self, n=1):
"""Read up to n bytes from the object and return them.
:type n: numbers.Integral
:rtype: bytes
"""
return b''
def readall(self):
"""Read and return all the bytes from the stream until EOF, using
multiple calls to the stream if necessary.
:rtype: bytes
"""
return b''
def readinto(self, b):
"""Read up to len(b) bytes into bytearray b and return the number of
bytes read.
:type b: bytearray
:rtype: int
"""
return 0
def write(self, b):
"""Write the given bytes or bytearray object, b, to the underlying raw
stream and return the number of bytes written.
:type b: bytes | bytearray
:rtype: int
"""
return 0
class BytesIO(io.BufferedIOBase):
"""A stream implementation using an in-memory bytes buffer."""
def __init__(self, initial_bytes=None):
"""Create a BytesIO object.
:rtype: io.BytesIO[bytes]
"""
pass
if sys.version_info >= (3, 2):
def getbuffer(self):
"""Return a readable and writable view over the contents of the
buffer without copying them.
:rtype: bytearray
"""
return bytearray()
def getvalue(self):
"""Return bytes containing the entire contents of the buffer.
:rtype: bytes
"""
return b''
class TextIOBase(io.IOBase):
"""Base class for text streams.
:type encoding: string
:type errors: string
:type newlines: string | tuple | None
:type buffer: BufferedIOBase
"""
def __init__(self, *args, **kwargs):
"""Private constructor of TextIOBase.
:rtype: TextIOBase[unicode]
"""
self.encoding = str()
self.errors = str()
self.newlines = None
self.buffer = BufferedIOBase()
if sys.version_info >= (2, 7):
def detach(self):
"""Separate the underlying raw stream from the buffer and return
it.
:rtype: None
"""
pass
def read(self, n=None):
"""Read and return at most n characters from the stream as a single
unicode.
:type n: numbers.Integral | None
:rtype: unicode
"""
return ''
def write(self, s):
"""Write the unicode string s to the stream and return the number of
characters written.
:type b: unicode
:rtype: int
"""
return 0
class TextIOWrapper(io.TextIOBase):
"""A buffered text stream over a BufferedIOBase binary stream.
:type buffer: io.BufferedIOBase
:type encoding: string
:type errors: string
:type newlines: string
:type line_buffering: bool
:type name: string
"""
def __init__(self, buffer, encoding=None, errors=None, newline=None,
line_buffering=False):
"""Creat a TextIOWrapper object.
:type buffer: io.BufferedIOBase
:type encoding: string | None
:type errors: string | None
:type newline: string | None
:type line_buffering: bool
:rtype: io.TextIOWrapper[unicode]
"""
self.name = ''
self.buffer = buffer
self.encoding = encoding
self.errors = errors
self.newlines = newline
self.line_buffering = line_buffering
def __iter__(self):
"""Iterate over lines.
:rtype: collections.Iterator[unicode]
"""
return []
def close(self):
"""Flush and close this stream.
:rtype: None
"""
pass
def fileno(self):
"""Return the underlying file descriptor (an integer) of the stream if
it exists.
:rtype: int
"""
return 0
def flush(self):
"""Flush the write buffers of the stream if applicable.
:rtype: None
"""
pass
def isatty(self):
"""Return True if the stream is interactive (i.e., connected to a
terminal/tty device).
:rtype: bool
"""
return False
def readable(self):
"""Return True if the stream can be read from.
:rtype: bool
"""
return False
def readline(self, limit=-1):
"""Read and return one line from the stream.
:type limit: numbers.Integral
:rtype: unicode
"""
pass
def readlines(self, hint=-1):
"""Read and return a list of lines from the stream.
:type hint: numbers.Integral
:rtype: list[unicode]
"""
return []
def seek(self, offset, whence=io.SEEK_SET):
"""Change the stream position to the given byte offset.
:type offset: numbers.Integral
:type whence: numbers.Integral
:rtype: None
"""
pass
def seekable(self):
"""Return True if the stream supports random access.
:rtype: bool
"""
return False
def tell(self):
"""Return the current stream position.
:rtype: int
"""
return 0
def truncate(self, size=None):
"""Resize the stream to the given size in bytes (or the current
position if size is not specified).
:type size: numbers.Integral | None
:rtype: None
"""
pass
def writable(self):
"""Return True if the stream supports writing.
:rtype: bool
"""
return False
def writelines(self, lines):
"""Write a list of lines to the stream.
:type lines: collections.Iterable[unicode]
:rtype: None
"""
pass
if sys.version_info >= (2, 7):
def detach(self):
"""Separate the underlying raw stream from the buffer and return
it.
:rtype: None
"""
pass
def read(self, n=None):
"""Read and return at most n characters from the stream as a single
unicode.
:type n: numbers.Integral | None
:rtype: unicode
"""
return ''
def write(self, s):
"""Write the unicode string s to the stream and return the number of
characters written.
:type b: unicode
:rtype: int
"""
return 0

View File

@@ -1,12 +0,0 @@
"""Skeleton for 'itertools' stdlib module."""
class islice(object):
def __init__(self, iterable, start, stop=None, step=None):
"""
:type iterable: collections.Iterable[T]
:type start: numbers.Integral
:type stop: numbers.Integral | None
:type step: numbers.Integral | None
:rtype: itertools.islice[T]
"""
pass

View File

@@ -1,383 +0,0 @@
"""Skeleton for 'pathlib' stdlib module."""
import pathlib
import os
class PurePath(object):
def __new__(cls, *pathsegments):
"""
:type pathsegments: str | bytes | os.PathLike
:rtype: pathlib.PurePath
"""
return cls.__new__(*pathsegments)
def __truediv__(self, key):
"""
:type key: string | pathlib.PurePath
:rtype: pathlib.PurePath
"""
return pathlib.PurePath()
def __rtruediv__(self, key):
"""
:type key: string | pathlib.PurePath
:rtype: pathlib.PurePath
"""
return pathlib.PurePath()
@property
def parts(self):
"""
:rtype: tuple[str]
"""
return ()
@property
def drive(self):
"""
:rtype: str
"""
return ''
@property
def root(self):
"""
:rtype: str
"""
return ''
@property
def anchor(self):
"""
:rtype: str
"""
return ''
@property
def parent(self):
"""
:rtype: pathlib.PurePath | unknown
"""
return pathlib.PurePath()
@property
def name(self):
"""
:rtype: str
"""
return ''
@property
def suffix(self):
"""
:rtype: str
"""
return ''
@property
def suffixes(self):
"""
:rtype: list[str]
"""
return []
@property
def stem(self):
"""
:rtype: str
"""
return ''
def as_posix(self):
"""
:rtype: str
"""
return ''
def as_uri(self):
"""
:rtype: str
"""
return ''
def is_absolute(self):
"""
:rtype: bool
"""
return False
def is_reserved(self):
"""
:rtype: bool
"""
return False
def joinpath(self, *other):
"""
:rtype: pathlib.PurePath
"""
return pathlib.PurePath()
def match(self, pattern):
"""
:type pattern: string
:rtype: bool
"""
return False
def relative_to(self, *other):
"""
:rtype: pathlib.PurePath
"""
return pathlib.PurePath()
def __fspath__(self):
"""
:rtype: str
"""
pass
class PurePosixPath(pathlib.PurePath):
pass
class PureWindowsPath(pathlib.PurePath):
pass
class Path(pathlib.PurePath):
def __new__(cls, *pathsegments):
"""
:type pathsegments: str | bytes | os.PathLike
:rtype: pathlib.Path
"""
return cls.__new__(*pathsegments)
def __truediv__(self, key):
"""
:type key: string | pathlib.Path
:rtype: pathlib.Path
"""
return pathlib.Path()
def __rtruediv__(self, key):
"""
:type key: string | pathlib.Path
:rtype: pathlib.Path
"""
return pathlib.Path()
@property
def parents(self):
"""
:rtype: collections.Sequence[pathlib.Path]
"""
return []
@property
def parent(self):
"""
:rtype: pathlib.Path
"""
return pathlib.Path()
def joinpath(self, *other):
"""
:rtype: pathlib.Path
"""
return pathlib.Path()
def relative_to(self, *other):
"""
:rtype: pathlib.Path
"""
return pathlib.Path()
@classmethod
def cwd(cls):
"""
:rtype: pathlib.Path
"""
return pathlib.Path()
def stat(self):
"""
:rtype: os.stat_result
"""
pass
def chmod(self, mode):
"""
:rtype mode: int
:rtype: None
"""
pass
def exists(self):
"""
:rtype: bool
"""
return False
def glob(self, pattern):
"""
:type pattern: string
:rtype: collections.Iterable[pathlib.Path]
"""
return []
def group(self):
"""
:rtype: str
"""
return ''
def is_dir(self):
"""
:rtype: bool
"""
return False
def is_file(self):
"""
:rtype: bool
"""
return False
def is_file(self):
"""
:rtype: bool
"""
return False
def is_symlink(self):
"""
:rtype: bool
"""
return False
def is_socket(self):
"""
:rtype: bool
"""
return False
def is_fifo(self):
"""
:rtype: bool
"""
return False
def is_block_device(self):
"""
:rtype: bool
"""
return False
def is_char_device(self):
"""
:rtype: bool
"""
return False
def iterdir(self):
"""
:rtype: collections.Iterable[pathlib.Path]
"""
return []
def lchmod(self, mode):
"""
:rtype mode: int
:rtype: None
"""
pass
def lstat(self):
"""
:rtype: os.stat_result
"""
pass
def mkdir(self, mode=0o777, parents=False, exist_ok=False):
"""
:type mode: int
:type parents: bool
:type exist_ok: bool
:rtype: None
"""
pass
def open(self, mode='r', buffering=-1, encoding=None, errors=None,
newline=None):
"""
:type mode: string
:type buffering: numbers.Integral
:type encoding: string | None
:type errors: string | None
:type newline: string | None
:rtype: io.FileIO[bytes] | io.TextIOWrapper[unicode]
"""
pass
def owner(self):
"""
:rtype: str
"""
return ''
def rename(self, target):
"""
:type target: string | pathlib.Path
:rtype: None
"""
pass
def replace(self, target):
"""
:type target: string | pathlib.Path
:rtype: None
"""
pass
def resolve(self):
"""
:rtype: pathlib.Path
"""
return pathlib.Path()
def rglob(self, pattern):
"""
:type pattern: string
:rtype: collections.Iterable[pathlib.Path]
"""
return []
def rmdir(self):
"""
:rtype: None
"""
pass
def symlink_to(self, target, target_is_directory=False):
"""
:type target: string | pathlib.Path
:type target_is_directory: bool
:rtype: None
"""
pass
def touch(self, mode=0o777, exist_ok=True):
"""
:type mode: int
:type exist_ok: bool
:rtype: None
"""
pass
def unlink(self):
"""
:rtype: None
"""
pass

View File

@@ -0,0 +1,45 @@
# Stubs for io
# Based on https://docs.python.org/2/library/io.html
# Only a subset of functionality is included.
from typing import List, BinaryIO, TextIO, IO, overload, Iterator, Iterable, Any, Union, Optional
import _io
from _io import BlockingIOError as BlockingIOError
from _io import BufferedRWPair as BufferedRWPair
from _io import BufferedRandom as BufferedRandom
from _io import BufferedReader as BufferedReader
from _io import BufferedWriter as BufferedWriter
from _io import BytesIO as BytesIO
from _io import DEFAULT_BUFFER_SIZE as DEFAULT_BUFFER_SIZE
from _io import FileIO as FileIO
from _io import IncrementalNewlineDecoder as IncrementalNewlineDecoder
from _io import StringIO as StringIO
from _io import TextIOWrapper as TextIOWrapper
from _io import UnsupportedOperation as UnsupportedOperation
from _io import open as open
def _OpenWrapper(file: Union[str, unicode, int],
mode: unicode = ..., buffering: int = ..., encoding: unicode = ...,
errors: unicode = ..., newline: unicode = ...,
closefd: bool = ...) -> IO[Any]: ...
SEEK_SET = ... # type: int
SEEK_CUR = ... # type: int
SEEK_END = ... # type: int
class IOBase(_io._IOBase): ...
class RawIOBase(_io._RawIOBase, IOBase):
pass
class BufferedIOBase(_io._BufferedIOBase, IOBase):
pass
# Note: In the actual io.py, TextIOBase subclasses IOBase.
# (Which we don't do here because we don't want to subclass both TextIO and BinaryIO.)
class TextIOBase(_io._TextIOBase):
pass

View File

@@ -0,0 +1,165 @@
# Stubs for itertools
# Based on https://docs.python.org/2/library/itertools.html
from typing import (Iterator, TypeVar, Iterable, overload, Any, Callable, Tuple,
Union, Sequence, Generic, Optional)
_T = TypeVar('_T')
_S = TypeVar('_S')
def count(start: int = ...,
step: int = ...) -> Iterator[int]: ... # more general types?
def cycle(iterable: Iterable[_T]) -> Iterator[_T]: ...
def repeat(object: _T, times: int = ...) -> Iterator[_T]: ...
def accumulate(iterable: Iterable[_T]) -> Iterator[_T]: ...
class chain(Iterator[_T], Generic[_T]):
def __init__(self, *iterables: Iterable[_T]) -> None: ...
def next(self) -> _T: ...
def __iter__(self) -> Iterator[_T]: ...
@staticmethod
def from_iterable(iterable: Iterable[Iterable[_S]]) -> Iterator[_S]: ...
def compress(data: Iterable[_T], selectors: Iterable[Any]) -> Iterator[_T]: ...
def dropwhile(predicate: Callable[[_T], Any],
iterable: Iterable[_T]) -> Iterator[_T]: ...
def ifilter(predicate: Optional[Callable[[_T], Any]],
iterable: Iterable[_T]) -> Iterator[_T]: ...
def ifilterfalse(predicate: Optional[Callable[[_T], Any]],
iterable: Iterable[_T]) -> Iterator[_T]: ...
@overload
def groupby(iterable: Iterable[_T]) -> Iterator[Tuple[_T, Iterator[_T]]]: ...
@overload
def groupby(iterable: Iterable[_T],
key: Callable[[_T], _S]) -> Iterator[Tuple[_S, Iterator[_T]]]: ...
@overload
def islice(iterable: Iterable[_T], stop: Optional[int]) -> Iterator[_T]: ...
@overload
def islice(iterable: Iterable[_T], start: Optional[int], stop: Optional[int],
step: Optional[int] = ...) -> Iterator[_T]: ...
_T1 = TypeVar('_T1')
_T2 = TypeVar('_T2')
_T3 = TypeVar('_T3')
_T4 = TypeVar('_T4')
_T5 = TypeVar('_T5')
_T6 = TypeVar('_T6')
@overload
def imap(func: Callable[[_T1], _S], iter1: Iterable[_T1]) -> Iterator[_S]: ...
@overload
def imap(func: Callable[[_T1, _T2], _S],
iter1: Iterable[_T1],
iter2: Iterable[_T2]) -> Iterator[_S]: ...
@overload
def imap(func: Callable[[_T1, _T2, _T3], _S],
iter1: Iterable[_T1], iter2: Iterable[_T2],
iter3: Iterable[_T3]) -> Iterator[_S]: ...
@overload
def imap(func: Callable[[_T1, _T2, _T3, _T4], _S],
iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3],
iter4: Iterable[_T4]) -> Iterator[_S]: ...
@overload
def imap(func: Callable[[_T1, _T2, _T3, _T4, _T5], _S],
iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3],
iter4: Iterable[_T4], iter5: Iterable[_T5]) -> Iterator[_S]: ...
@overload
def imap(func: Callable[[_T1, _T2, _T3, _T4, _T5, _T6], _S],
iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3],
iter4: Iterable[_T4], iter5: Iterable[_T5],
iter6: Iterable[_T6]) -> Iterator[_S]: ...
@overload
def imap(func: Callable[..., _S],
iter1: Iterable[Any], iter2: Iterable[Any], iter3: Iterable[Any],
iter4: Iterable[Any], iter5: Iterable[Any], iter6: Iterable[Any],
iter7: Iterable[Any], *iterables: Iterable[Any]) -> Iterator[_S]: ...
def starmap(func: Any, iterable: Iterable[Any]) -> Iterator[Any]: ...
def takewhile(predicate: Callable[[_T], Any],
iterable: Iterable[_T]) -> Iterator[_T]: ...
def tee(iterable: Iterable[_T], n: int = ...) -> Tuple[Iterator[_T], ...]: ...
@overload
def izip(iter1: Iterable[_T1]) -> Iterator[Tuple[_T1]]: ...
@overload
def izip(iter1: Iterable[_T1],
iter2: Iterable[_T2]) -> Iterator[Tuple[_T1, _T2]]: ...
@overload
def izip(iter1: Iterable[_T1], iter2: Iterable[_T2],
iter3: Iterable[_T3]) -> Iterator[Tuple[_T1, _T2, _T3]]: ...
@overload
def izip(iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3],
iter4: Iterable[_T4]) -> Iterator[Tuple[_T1, _T2,
_T3, _T4]]: ...
@overload
def izip(iter1: Iterable[_T1], iter2: Iterable[_T2],
iter3: Iterable[_T3], iter4: Iterable[_T4],
iter5: Iterable[_T5]) -> Iterator[Tuple[_T1, _T2,
_T3, _T4, _T5]]: ...
@overload
def izip(iter1: Iterable[_T1], iter2: Iterable[_T2],
iter3: Iterable[_T3], iter4: Iterable[_T4],
iter5: Iterable[_T5], iter6: Iterable[_T6]) -> Iterator[Tuple[_T1, _T2, _T3,
_T4, _T5, _T6]]: ...
@overload
def izip(iter1: Iterable[Any], iter2: Iterable[Any],
iter3: Iterable[Any], iter4: Iterable[Any],
iter5: Iterable[Any], iter6: Iterable[Any],
iter7: Iterable[Any], *iterables: Iterable[Any]) -> Iterator[Tuple[Any, ...]]: ...
def izip_longest(*p: Iterable[Any],
fillvalue: Any = ...) -> Iterator[Any]: ...
@overload
def product(iter1: Iterable[_T1]) -> Iterator[Tuple[_T1]]: ...
@overload
def product(iter1: Iterable[_T1],
iter2: Iterable[_T2]) -> Iterator[Tuple[_T1, _T2]]: ...
@overload
def product(iter1: Iterable[_T1],
iter2: Iterable[_T2],
iter3: Iterable[_T3]) -> Iterator[Tuple[_T1, _T2, _T3]]: ...
@overload
def product(iter1: Iterable[_T1],
iter2: Iterable[_T2],
iter3: Iterable[_T3],
iter4: Iterable[_T4]) -> Iterator[Tuple[_T1, _T2, _T3, _T4]]: ...
@overload
def product(iter1: Iterable[_T1],
iter2: Iterable[_T2],
iter3: Iterable[_T3],
iter4: Iterable[_T4],
iter5: Iterable[_T5]) -> Iterator[Tuple[_T1, _T2, _T3, _T4, _T5]]: ...
@overload
def product(iter1: Iterable[_T1],
iter2: Iterable[_T2],
iter3: Iterable[_T3],
iter4: Iterable[_T4],
iter5: Iterable[_T5],
iter6: Iterable[_T6]) -> Iterator[Tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ...
@overload
def product(iter1: Iterable[Any],
iter2: Iterable[Any],
iter3: Iterable[Any],
iter4: Iterable[Any],
iter5: Iterable[Any],
iter6: Iterable[Any],
iter7: Iterable[Any], *iterables: Iterable) -> Iterator[Tuple]: ...
@overload
def product(*iter: Iterable[_T], repeat: int) -> Iterator[Tuple[_T, ...]]: ...
def permutations(iterable: Iterable[_T],
r: int = ...) -> Iterator[Sequence[_T]]: ...
def combinations(iterable: Iterable[_T],
r: int) -> Iterator[Sequence[_T]]: ...
def combinations_with_replacement(iterable: Iterable[_T],
r: int) -> Iterator[Sequence[_T]]: ...

View File

@@ -0,0 +1,208 @@
# Stubs for ssl
from typing import (
Any, Dict, Callable, List, NamedTuple, Optional, Set, Tuple, Union,
)
import socket
import sys
_PCTRTT = Tuple[Tuple[str, str], ...]
_PCTRTTT = Tuple[_PCTRTT, ...]
_PeerCertRetDictType = Dict[str, Union[str, _PCTRTTT, _PCTRTT]]
_PeerCertRetType = Union[_PeerCertRetDictType, bytes, None]
_EnumRetType = List[Tuple[bytes, str, Union[Set[str], bool]]]
_PasswordType = Union[Callable[[], Union[str, bytes]], str, bytes]
_SrvnmeCbType = Callable[['SSLSocket', Optional[str], 'SSLSocket'], Optional[int]]
class SSLError(OSError):
library = ... # type: str
reason = ... # type: str
class SSLZeroReturnError(SSLError): ...
class SSLWantReadError(SSLError): ...
class SSLWantWriteError(SSLError): ...
class SSLSyscallError(SSLError): ...
class SSLEOFError(SSLError): ...
class CertificateError(Exception): ...
def wrap_socket(sock: socket.socket, keyfile: Optional[str] = ...,
certfile: Optional[str] = ..., server_side: bool = ...,
cert_reqs: int = ..., ssl_version: int = ...,
ca_certs: Optional[str] = ...,
do_handshake_on_connect: bool = ...,
suppress_ragged_eofs: bool = ...,
ciphers: Optional[str] = ...) -> 'SSLSocket': ...
def create_default_context(purpose: Any = ..., *,
cafile: Optional[str] = ...,
capath: Optional[str] = ...,
cadata: Optional[str] = ...) -> 'SSLContext': ...
def RAND_status() -> bool: ...
def RAND_egd(path: str) -> None: ...
def RAND_add(bytes: bytes, entropy: float) -> None: ...
def match_hostname(cert: _PeerCertRetType, hostname: str) -> None: ...
def cert_time_to_seconds(cert_time: str) -> int: ...
def get_server_certificate(addr: Tuple[str, int], ssl_version: int = ...,
ca_certs: Optional[str] = ...) -> str: ...
def DER_cert_to_PEM_cert(der_cert_bytes: bytes) -> str: ...
def PEM_cert_to_DER_cert(pem_cert_string: str) -> bytes: ...
DefaultVerifyPaths = NamedTuple('DefaultVerifyPaths',
[('cafile', str), ('capath', str),
('openssl_cafile_env', str),
('openssl_cafile', str),
('openssl_capath_env', str),
('openssl_capath', str)])
def get_default_verify_paths() -> DefaultVerifyPaths: ...
if sys.platform == 'win32':
def enum_certificates(store_name: str) -> _EnumRetType: ...
def enum_crls(store_name: str) -> _EnumRetType: ...
CERT_NONE = ... # type: int
CERT_OPTIONAL = ... # type: int
CERT_REQUIRED = ... # type: int
VERIFY_DEFAULT = ... # type: int
VERIFY_CRL_CHECK_LEAF = ... # type: int
VERIFY_CRL_CHECK_CHAIN = ... # type: int
VERIFY_X509_STRICT = ... # type: int
VERIFY_X509_TRUSTED_FIRST = ... # type: int
PROTOCOL_SSLv23 = ... # type: int
PROTOCOL_SSLv2 = ... # type: int
PROTOCOL_SSLv3 = ... # type: int
PROTOCOL_TLSv1 = ... # type: int
PROTOCOL_TLSv1_1 = ... # type: int
PROTOCOL_TLSv1_2 = ... # type: int
OP_ALL = ... # type: int
OP_NO_SSLv2 = ... # type: int
OP_NO_SSLv3 = ... # type: int
OP_NO_TLSv1 = ... # type: int
OP_NO_TLSv1_1 = ... # type: int
OP_NO_TLSv1_2 = ... # type: int
OP_CIPHER_SERVER_PREFERENCE = ... # type: int
OP_SINGLE_DH_USE = ... # type: int
OP_SINGLE_ECDH_USE = ... # type: int
OP_NO_COMPRESSION = ... # type: int
HAS_ALPN = ... # type: int
HAS_ECDH = ... # type: bool
HAS_SNI = ... # type: bool
HAS_NPN = ... # type: bool
CHANNEL_BINDING_TYPES = ... # type: List[str]
OPENSSL_VERSION = ... # type: str
OPENSSL_VERSION_INFO = ... # type: Tuple[int, int, int, int, int]
OPENSSL_VERSION_NUMBER = ... # type: int
ALERT_DESCRIPTION_HANDSHAKE_FAILURE = ... # type: int
ALERT_DESCRIPTION_INTERNAL_ERROR = ... # type: int
ALERT_DESCRIPTION_ACCESS_DENIED = ... # type: int
ALERT_DESCRIPTION_BAD_CERTIFICATE = ... # type: int
ALERT_DESCRIPTION_BAD_CERTIFICATE_HASH_VALUE = ... # type: int
ALERT_DESCRIPTION_BAD_CERTIFICATE_STATUS_RESPONSE = ... # type: int
ALERT_DESCRIPTION_BAD_RECORD_MAC = ... # type: int
ALERT_DESCRIPTION_CERTIFICATE_EXPIRED = ... # type: int
ALERT_DESCRIPTION_CERTIFICATE_REVOKED = ... # type: int
ALERT_DESCRIPTION_CERTIFICATE_UNKNOWN = ... # type: int
ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE = ... # type: int
ALERT_DESCRIPTION_CLOSE_NOTIFY = ... # type: int
ALERT_DESCRIPTION_DECODE_ERROR = ... # type: int
ALERT_DESCRIPTION_DECOMPRESSION_FAILURE = ... # type: int
ALERT_DESCRIPTION_DECRYPT_ERROR = ... # type: int
ALERT_DESCRIPTION_ILLEGAL_PARAMETER = ... # type: int
ALERT_DESCRIPTION_INSUFFICIENT_SECURITY = ... # type: int
ALERT_DESCRIPTION_NO_RENEGOTIATION = ... # type: int
ALERT_DESCRIPTION_PROTOCOL_VERSION = ... # type: int
ALERT_DESCRIPTION_RECORD_OVERFLOW = ... # type: int
ALERT_DESCRIPTION_UNEXPECTED_MESSAGE = ... # type: int
ALERT_DESCRIPTION_UNKNOWN_CA = ... # type: int
ALERT_DESCRIPTION_UNKNOWN_PSK_IDENTITY = ... # type: int
ALERT_DESCRIPTION_UNRECOGNIZED_NAME = ... # type: int
ALERT_DESCRIPTION_UNSUPPORTED_CERTIFICATE = ... # type: int
ALERT_DESCRIPTION_UNSUPPORTED_EXTENSION = ... # type: int
ALERT_DESCRIPTION_USER_CANCELLED = ... # type: int
_PurposeType = NamedTuple('_PurposeType',
[('nid', int), ('shortname', str),
('longname', str), ('oid', str)])
class Purpose:
SERVER_AUTH = ... # type: _PurposeType
CLIENT_AUTH = ... # type: _PurposeType
class SSLSocket(socket.socket):
def do_handshake(self) -> None: ...
def getpeercert(self, binary_form: bool = ...) -> _PeerCertRetType: ...
def cipher(self) -> Tuple[str, int, int]: ...
def compression(self) -> Optional[str]: ...
def get_channel_binding(self, cb_type: str = ...) -> Optional[bytes]: ...
def selected_alpn_protocol(self) -> Optional[str]: ...
def selected_npn_protocol(self) -> Optional[str]: ...
def unwrap(self) -> socket.socket: ...
def version(self) -> Optional[str]: ...
def read(self, len: int = ...,
buffer: Optional[bytearray] = ...) -> str: ...
def write(self, buf: str) -> int: ...
def pending(self) -> int: ...
class SSLContext:
check_hostname = ... # type: bool
options = ... # type: int
@property
def protocol(self) -> int: ...
verify_flags = ... # type: int
verify_mode = ... # type: int
def __init__(self, protocol: int) -> None: ...
def cert_store_stats(self) -> Dict[str, int]: ...
def load_cert_chain(self, certfile: str, keyfile: Optional[str] = ...,
password: _PasswordType = ...) -> None: ...
def load_default_certs(self, purpose: _PurposeType = ...) -> None: ...
def load_verify_locations(self, cafile: Optional[str] = ...,
capath: Optional[str] = ...,
cadata: Union[str, bytes, None] = ...) -> None: ...
def get_ca_certs(self,
binary_form: bool = ...) -> Union[List[_PeerCertRetDictType], List[bytes]]: ...
def set_default_verify_paths(self) -> None: ...
def set_ciphers(self, ciphers: str) -> None: ...
def set_alpn_protocols(self, protocols: List[str]) -> None: ...
def set_npn_protocols(self, protocols: List[str]) -> None: ...
def set_servername_callback(self,
server_name_callback: Optional[_SrvnmeCbType]) -> None: ...
def load_dh_params(self, dhfile: str) -> None: ...
def set_ecdh_curve(self, curve_name: str) -> None: ...
def wrap_socket(self, sock: socket.socket, server_side: bool = ...,
do_handshake_on_connect: bool = ...,
suppress_ragged_eofs: bool = ...,
server_hostname: Optional[str] = ...) -> SSLSocket: ...
def session_stats(self) -> Dict[str, int]: ...
# TODO below documented in cpython but not in docs.python.org
# taken from python 3.4
SSL_ERROR_EOF = ... # type: int
SSL_ERROR_INVALID_ERROR_CODE = ... # type: int
SSL_ERROR_SSL = ... # type: int
SSL_ERROR_SYSCALL = ... # type: int
SSL_ERROR_WANT_CONNECT = ... # type: int
SSL_ERROR_WANT_READ = ... # type: int
SSL_ERROR_WANT_WRITE = ... # type: int
SSL_ERROR_WANT_X509_LOOKUP = ... # type: int
SSL_ERROR_ZERO_RETURN = ... # type: int
def get_protocol_name(protocol_code: int) -> str: ...
AF_INET = ... # type: int
PEM_FOOTER = ... # type: str
PEM_HEADER = ... # type: str
SOCK_STREAM = ... # type: int
SOL_SOCKET = ... # type: int
SO_TYPE = ... # type: int

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): ...

View File

@@ -0,0 +1,266 @@
from typing import (
List, BinaryIO, TextIO, Iterator, Union, Optional, Callable, Tuple, Type, Any, IO, Iterable
)
import builtins
import codecs
from mmap import mmap
import sys
from types import TracebackType
from typing import TypeVar
_bytearray_like = Union[bytearray, mmap]
DEFAULT_BUFFER_SIZE = ... # type: int
SEEK_SET = ... # type: int
SEEK_CUR = ... # type: int
SEEK_END = ... # type: int
_T = TypeVar('_T', bound='IOBase')
open = builtins.open
if sys.version_info >= (3, 3):
BlockingIOError = builtins.BlockingIOError
class UnsupportedOperation(OSError, ValueError): ...
else:
class BlockingIOError(IOError):
characters_written: int
class UnsupportedOperation(IOError, ValueError): ...
class IOBase:
def __iter__(self) -> Iterator[bytes]: ...
def __next__(self) -> bytes: ...
def __enter__(self: _T) -> _T: ...
def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException],
exc_tb: Optional[TracebackType]) -> bool: ...
def close(self) -> None: ...
def fileno(self) -> int: ...
def flush(self) -> None: ...
def isatty(self) -> bool: ...
def readable(self) -> bool: ...
def readlines(self, hint: int = ...) -> List[bytes]: ...
def seek(self, offset: int, whence: int = ...) -> int: ...
def seekable(self) -> bool: ...
def tell(self) -> int: ...
def truncate(self, size: Optional[int] = ...) -> int: ...
def writable(self) -> bool: ...
def writelines(self, lines: Iterable[Union[bytes, bytearray]]) -> None: ...
if sys.version_info >= (3, 4):
def readline(self, size: int = ...) -> bytes: ...
def __del__(self) -> None: ...
else:
def readline(self, limit: int = ...) -> bytes: ...
if sys.version_info >= (3, 2):
@property
def closed(self) -> bool: ...
else:
def closed(self) -> bool: ...
class RawIOBase(IOBase):
def readall(self) -> bytes: ...
def readinto(self, b: bytearray) -> Optional[int]: ...
def write(self, b: Union[bytes, bytearray]) -> Optional[int]: ...
if sys.version_info >= (3, 4):
def read(self, size: int = ...) -> Optional[bytes]: ...
else:
def read(self, n: int = ...) -> Optional[bytes]: ...
class BufferedIOBase(IOBase):
def detach(self) -> RawIOBase: ...
def readinto(self, b: _bytearray_like) -> int: ...
def write(self, b: Union[bytes, bytearray]) -> int: ...
if sys.version_info >= (3, 5):
def readinto1(self, b: _bytearray_like) -> int: ...
if sys.version_info >= (3, 4):
def read(self, size: Optional[int] = ...) -> bytes: ...
def read1(self, size: int = ...) -> bytes: ...
else:
def read(self, n: Optional[int] = ...) -> bytes: ...
def read1(self, n: int = ...) -> bytes: ...
class FileIO(RawIOBase):
mode = ... # type: str
name = ... # type: Union[int, str]
if sys.version_info >= (3, 3):
def __init__(
self,
name: Union[str, bytes, int],
mode: str = ...,
closefd: bool = ...,
opener: Optional[Callable[[Union[int, str], str], int]] = ...
) -> None: ...
else:
def __init__(self, name: Union[str, bytes, int],
mode: str = ..., closefd: bool = ...) -> None: ...
# TODO should extend from BufferedIOBase
class BytesIO(BinaryIO):
def __init__(self, initial_bytes: bytes = ...) -> None: ...
# BytesIO does not contain a "name" field. This workaround is necessary
# to allow BytesIO sub-classes to add this field, as it is defined
# as a read-only property on IO[].
name: Any
def getvalue(self) -> bytes: ...
if sys.version_info >= (3, 2):
def getbuffer(self) -> memoryview: ...
# copied from IOBase
def __iter__(self) -> Iterator[bytes]: ...
def __next__(self) -> bytes: ...
def __enter__(self) -> 'BytesIO': ...
def __exit__(self, t: Optional[Type[BaseException]] = ..., value: Optional[BaseException] = ...,
traceback: Optional[TracebackType] = ...) -> bool: ...
def close(self) -> None: ...
def fileno(self) -> int: ...
def flush(self) -> None: ...
def isatty(self) -> bool: ...
def readable(self) -> bool: ...
def readlines(self, hint: int = ...) -> List[bytes]: ...
def seek(self, offset: int, whence: int = ...) -> int: ...
def seekable(self) -> bool: ...
def tell(self) -> int: ...
def truncate(self, size: Optional[int] = ...) -> int: ...
def writable(self) -> bool: ...
# TODO should be the next line instead
# def writelines(self, lines: List[Union[bytes, bytearray]]) -> None: ...
def writelines(self, lines: Any) -> None: ...
if sys.version_info >= (3, 4):
def readline(self, size: int = ...) -> bytes: ...
def __del__(self) -> None: ...
else:
def readline(self, limit: int = ...): ...
if sys.version_info >= (3, 2):
closed = ... # type: bool
else:
def closed(self) -> bool: ...
# copied from BufferedIOBase
def detach(self) -> RawIOBase: ...
def readinto(self, b: _bytearray_like) -> int: ...
def write(self, b: Union[bytes, bytearray]) -> int: ...
if sys.version_info >= (3, 5):
def readinto1(self, b: _bytearray_like) -> int: ...
if sys.version_info >= (3, 4):
def read(self, size: Optional[int] = ...) -> bytes: ...
def read1(self, size: int = ...) -> bytes: ...
else:
def read(self, n: Optional[int] = ...) -> bytes: ...
def read1(self, n: int = ...) -> bytes: ...
class BufferedReader(BufferedIOBase):
def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...
if sys.version_info >= (3, 4):
def peek(self, size: int = ...) -> bytes: ...
else:
def peek(self, n: int = ...) -> bytes: ...
class BufferedWriter(BufferedIOBase):
def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...
def flush(self) -> None: ...
def write(self, b: Union[bytes, bytearray]) -> int: ...
class BufferedRandom(BufferedReader, BufferedWriter):
def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...
def seek(self, offset: int, whence: int = ...) -> int: ...
def tell(self) -> int: ...
class BufferedRWPair(BufferedIOBase):
def __init__(self, reader: RawIOBase, writer: RawIOBase,
buffer_size: int = ...) -> None: ...
class TextIOBase(IOBase):
encoding = ... # type: str
errors = ... # type: Optional[str]
newlines = ... # type: Union[str, Tuple[str, ...], None]
def __iter__(self) -> Iterator[str]: ... # type: ignore
def __next__(self) -> str: ... # type: ignore
def detach(self) -> IOBase: ...
def write(self, s: str) -> int: ...
if sys.version_info >= (3, 4):
def readline(self, size: int = ...) -> str: ... # type: ignore
def read(self, size: Optional[int] = ...) -> str: ...
elif sys.version_info >= (3, 2):
def readline(self, limit: int = ...) -> str: ... # type: ignore
else:
def readline(self) -> str: ...
if sys.version_info >= (3, 2):
def seek(self, offset: int, whence: int = ...) -> int: ...
def tell(self) -> int: ...
# TODO should extend from TextIOBase
class TextIOWrapper(TextIO):
line_buffering = ... # type: bool
# TODO uncomment after fixing mypy about using write_through
# if sys.version_info >= (3, 3):
# def __init__(self, buffer: IO[bytes], encoding: str = ...,
# errors: Optional[str] = ..., newline: Optional[str] = ...,
# line_buffering: bool = ..., write_through: bool = ...) \
# -> None: ...
# else:
# def __init__(self, buffer: IO[bytes],
# encoding: str = ..., errors: Optional[str] = ...,
# newline: Optional[str] = ..., line_buffering: bool = ...) \
# -> None: ...
def __init__(
self,
buffer: IO[bytes],
encoding: str = ...,
errors: Optional[str] = ...,
newline: Optional[str] = ...,
line_buffering: bool = ...,
write_through: bool = ...
) -> None: ...
# copied from IOBase
def __exit__(self, t: Optional[Type[BaseException]] = ..., value: Optional[BaseException] = ...,
traceback: Optional[TracebackType] = ...) -> bool: ...
def close(self) -> None: ...
def fileno(self) -> int: ...
def flush(self) -> None: ...
def isatty(self) -> bool: ...
def readable(self) -> bool: ...
def readlines(self, hint: int = ...) -> List[str]: ...
def seekable(self) -> bool: ...
def truncate(self, size: Optional[int] = ...) -> int: ...
def writable(self) -> bool: ...
# TODO should be the next line instead
# def writelines(self, lines: List[str]) -> None: ...
def writelines(self, lines: Any) -> None: ...
if sys.version_info >= (3, 4):
def __del__(self) -> None: ...
if sys.version_info >= (3, 2):
closed = ... # type: bool
else:
def closed(self) -> bool: ...
# copied from TextIOBase
encoding = ... # type: str
errors = ... # type: Optional[str]
newlines = ... # type: Union[str, Tuple[str, ...], None]
def __iter__(self) -> Iterator[str]: ...
def __next__(self) -> str: ...
def __enter__(self) -> 'TextIO': ...
def detach(self) -> IOBase: ...
def write(self, s: str) -> int: ...
if sys.version_info >= (3, 4):
def readline(self, size: int = ...) -> str: ...
def read(self, size: Optional[int] = ...) -> str: ...
elif sys.version_info >= (3, 2):
def readline(self, limit: int = ...) -> str: ...
else:
def readline(self) -> str: ...
if sys.version_info >= (3, 2):
def seek(self, offset: int, whence: int = ...) -> int: ...
def tell(self) -> int: ...
class StringIO(TextIOWrapper):
def __init__(self, initial_value: str = ...,
newline: Optional[str] = ...) -> None: ...
# StringIO does not contain a "name" field. This workaround is necessary
# to allow StringIO sub-classes to add this field, as it is defined
# as a read-only property on IO[].
name: Any
def getvalue(self) -> str: ...
def __enter__(self) -> 'StringIO': ...
class IncrementalNewlineDecoder(codecs.IncrementalDecoder):
def decode(self, input: codecs._encoded, final: bool = ...) -> codecs._decoded: ...

View File

@@ -0,0 +1,110 @@
# Stubs for itertools
# Based on http://docs.python.org/3.2/library/itertools.html
from typing import (Iterator, TypeVar, Iterable, overload, Any, Callable, Tuple,
Generic, Optional)
_T = TypeVar('_T')
_S = TypeVar('_S')
_N = TypeVar('_N', int, float)
def count(start: _N = ...,
step: _N = ...) -> Iterator[_N]: ... # more general types?
def cycle(iterable: Iterable[_T]) -> Iterator[_T]: ...
@overload
def repeat(object: _T) -> Iterator[_T]: ...
@overload
def repeat(object: _T, times: int) -> Iterator[_T]: ...
def accumulate(iterable: Iterable[_T], func: Callable[[_T, _T], _T] = ...) -> Iterator[_T]: ...
class chain(Iterator[_T], Generic[_T]):
def __init__(self, *iterables: Iterable[_T]) -> None: ...
def __next__(self) -> _T: ...
def __iter__(self) -> Iterator[_T]: ...
@staticmethod
def from_iterable(iterable: Iterable[Iterable[_S]]) -> Iterator[_S]: ...
def compress(data: Iterable[_T], selectors: Iterable[Any]) -> Iterator[_T]: ...
def dropwhile(predicate: Callable[[_T], Any],
iterable: Iterable[_T]) -> Iterator[_T]: ...
def filterfalse(predicate: Optional[Callable[[_T], Any]],
iterable: Iterable[_T]) -> Iterator[_T]: ...
@overload
def groupby(iterable: Iterable[_T]) -> Iterator[Tuple[_T, Iterator[_T]]]: ...
@overload
def groupby(iterable: Iterable[_T],
key: Callable[[_T], _S]) -> Iterator[Tuple[_S, Iterator[_T]]]: ...
@overload
def islice(iterable: Iterable[_T], stop: Optional[int]) -> Iterator[_T]: ...
@overload
def islice(iterable: Iterable[_T], start: Optional[int], stop: Optional[int],
step: Optional[int] = ...) -> Iterator[_T]: ...
def starmap(func: Callable[..., _S], iterable: Iterable[Iterable[Any]]) -> Iterator[_S]: ...
def takewhile(predicate: Callable[[_T], Any],
iterable: Iterable[_T]) -> Iterator[_T]: ...
def tee(iterable: Iterable[_T], n: int = ...) -> Tuple[Iterator[_T], ...]: ...
def zip_longest(*p: Iterable[Any],
fillvalue: Any = ...) -> Iterator[Any]: ...
_T1 = TypeVar('_T1')
_T2 = TypeVar('_T2')
_T3 = TypeVar('_T3')
_T4 = TypeVar('_T4')
_T5 = TypeVar('_T5')
_T6 = TypeVar('_T6')
@overload
def product(iter1: Iterable[_T1], *,
repeat: int = ...) -> Iterator[Tuple[_T1]]: ...
@overload
def product(iter1: Iterable[_T1],
iter2: Iterable[_T2], *,
repeat: int = ...) -> Iterator[Tuple[_T1, _T2]]: ...
@overload
def product(iter1: Iterable[_T1],
iter2: Iterable[_T2],
iter3: Iterable[_T3], *,
repeat: int = ...) -> Iterator[Tuple[_T1, _T2, _T3]]: ...
@overload
def product(iter1: Iterable[_T1],
iter2: Iterable[_T2],
iter3: Iterable[_T3],
iter4: Iterable[_T4], *,
repeat: int = ...) -> Iterator[Tuple[_T1, _T2, _T3, _T4]]: ...
@overload
def product(iter1: Iterable[_T1],
iter2: Iterable[_T2],
iter3: Iterable[_T3],
iter4: Iterable[_T4],
iter5: Iterable[_T5], *,
repeat: int = ...) -> Iterator[Tuple[_T1, _T2, _T3, _T4, _T5]]: ...
@overload
def product(iter1: Iterable[_T1],
iter2: Iterable[_T2],
iter3: Iterable[_T3],
iter4: Iterable[_T4],
iter5: Iterable[_T5],
iter6: Iterable[_T6], *,
repeat: int = ...) -> Iterator[Tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ...
@overload
def product(iter1: Iterable[Any],
iter2: Iterable[Any],
iter3: Iterable[Any],
iter4: Iterable[Any],
iter5: Iterable[Any],
iter6: Iterable[Any],
iter7: Iterable[Any], *iterables: Iterable,
repeat: int = ...) -> Iterator[Tuple]: ...
def permutations(iterable: Iterable[_T],
r: Optional[int] = ...) -> Iterator[Tuple[_T, ...]]: ...
def combinations(iterable: Iterable[_T],
r: int) -> Iterable[Tuple[_T, ...]]: ...
def combinations_with_replacement(iterable: Iterable[_T],
r: int) -> Iterable[Tuple[_T, ...]]: ...

View File

@@ -0,0 +1,305 @@
# Stubs for ssl (Python 3.4)
from typing import (
Any, Dict, Callable, List, NamedTuple, Optional, Set, Tuple, Union,
)
import socket
import sys
_PCTRTT = Tuple[Tuple[str, str], ...]
_PCTRTTT = Tuple[_PCTRTT, ...]
_PeerCertRetDictType = Dict[str, Union[str, _PCTRTTT, _PCTRTT]]
_PeerCertRetType = Union[_PeerCertRetDictType, bytes, None]
_EnumRetType = List[Tuple[bytes, str, Union[Set[str], bool]]]
_PasswordType = Union[Callable[[], Union[str, bytes]], str, bytes]
if sys.version_info >= (3, 5):
_SC1ArgT = Union[SSLSocket, SSLObject]
else:
_SC1ArgT = SSLSocket
_SrvnmeCbType = Callable[[_SC1ArgT, Optional[str], 'SSLSocket'], Optional[int]]
class SSLError(OSError):
library = ... # type: str
reason = ... # type: str
class SSLZeroReturnError(SSLError): ...
class SSLWantReadError(SSLError): ...
class SSLWantWriteError(SSLError): ...
class SSLSyscallError(SSLError): ...
class SSLEOFError(SSLError): ...
class CertificateError(Exception): ...
def wrap_socket(sock: socket.socket, keyfile: Optional[str] = ...,
certfile: Optional[str] = ..., server_side: bool = ...,
cert_reqs: int = ..., ssl_version: int = ...,
ca_certs: Optional[str] = ...,
do_handshake_on_connect: bool = ...,
suppress_ragged_eofs: bool = ...,
ciphers: Optional[str] = ...) -> 'SSLSocket': ...
if sys.version_info >= (3, 4):
def create_default_context(purpose: Any = ..., *,
cafile: Optional[str] = ...,
capath: Optional[str] = ...,
cadata: Optional[str] = ...) -> 'SSLContext': ...
def _create_unverified_context(protocol: int = ..., *,
cert_reqs: int = ...,
check_hostname: bool = ...,
purpose: Any = ...,
certfile: Optional[str] = ...,
keyfile: Optional[str] = ...,
cafile: Optional[str] = ...,
capath: Optional[str] = ...,
cadata: Optional[str] = ...) -> 'SSLContext': ...
_create_default_https_context = ... # type: Callable[..., 'SSLContext']
def RAND_bytes(num: int) -> bytes: ...
def RAND_pseudo_bytes(num: int) -> Tuple[bytes, bool]: ...
def RAND_status() -> bool: ...
def RAND_egd(path: str) -> None: ...
def RAND_add(bytes: bytes, entropy: float) -> None: ...
def match_hostname(cert: _PeerCertRetType, hostname: str) -> None: ...
def cert_time_to_seconds(cert_time: str) -> int: ...
def get_server_certificate(addr: Tuple[str, int], ssl_version: int = ...,
ca_certs: Optional[str] = ...) -> str: ...
def DER_cert_to_PEM_cert(der_cert_bytes: bytes) -> str: ...
def PEM_cert_to_DER_cert(pem_cert_string: str) -> bytes: ...
if sys.version_info >= (3, 4):
DefaultVerifyPaths = NamedTuple('DefaultVerifyPaths',
[('cafile', str), ('capath', str),
('openssl_cafile_env', str),
('openssl_cafile', str),
('openssl_capath_env', str),
('openssl_capath', str)])
def get_default_verify_paths() -> DefaultVerifyPaths: ...
if sys.version_info >= (3, 4) and sys.platform == 'win32':
def enum_certificates(store_name: str) -> _EnumRetType: ...
def enum_crls(store_name: str) -> _EnumRetType: ...
CERT_NONE = ... # type: int
CERT_OPTIONAL = ... # type: int
CERT_REQUIRED = ... # type: int
if sys.version_info >= (3, 4):
VERIFY_DEFAULT = ... # type: int
VERIFY_CRL_CHECK_LEAF = ... # type: int
VERIFY_CRL_CHECK_CHAIN = ... # type: int
VERIFY_X509_STRICT = ... # type: int
VERIFY_X509_TRUSTED_FIRST = ... # type: int
PROTOCOL_SSLv23 = ... # type: int
PROTOCOL_SSLv2 = ... # type: int
PROTOCOL_SSLv3 = ... # type: int
PROTOCOL_TLSv1 = ... # type: int
if sys.version_info >= (3, 4):
PROTOCOL_TLSv1_1 = ... # type: int
PROTOCOL_TLSv1_2 = ... # type: int
if sys.version_info >= (3, 5):
PROTOCOL_TLS = ... # type: int
if sys.version_info >= (3, 6):
PROTOCOL_TLS_CLIENT = ... # type: int
PROTOCOL_TLS_SERVER = ... # type: int
OP_ALL = ... # type: int
OP_NO_SSLv2 = ... # type: int
OP_NO_SSLv3 = ... # type: int
OP_NO_TLSv1 = ... # type: int
if sys.version_info >= (3, 4):
OP_NO_TLSv1_1 = ... # type: int
OP_NO_TLSv1_2 = ... # type: int
OP_CIPHER_SERVER_PREFERENCE = ... # type: int
OP_SINGLE_DH_USE = ... # type: int
OP_SINGLE_ECDH_USE = ... # type: int
OP_NO_COMPRESSION = ... # type: int
if sys.version_info >= (3, 6):
OP_NO_TICKET = ... # type: int
if sys.version_info >= (3, 5):
HAS_ALPN = ... # type: int
HAS_ECDH = ... # type: bool
HAS_SNI = ... # type: bool
HAS_NPN = ... # type: bool
CHANNEL_BINDING_TYPES = ... # type: List[str]
OPENSSL_VERSION = ... # type: str
OPENSSL_VERSION_INFO = ... # type: Tuple[int, int, int, int, int]
OPENSSL_VERSION_NUMBER = ... # type: int
if sys.version_info >= (3, 4):
ALERT_DESCRIPTION_HANDSHAKE_FAILURE = ... # type: int
ALERT_DESCRIPTION_INTERNAL_ERROR = ... # type: int
ALERT_DESCRIPTION_ACCESS_DENIED = ... # type: int
ALERT_DESCRIPTION_BAD_CERTIFICATE = ... # type: int
ALERT_DESCRIPTION_BAD_CERTIFICATE_HASH_VALUE = ... # type: int
ALERT_DESCRIPTION_BAD_CERTIFICATE_STATUS_RESPONSE = ... # type: int
ALERT_DESCRIPTION_BAD_RECORD_MAC = ... # type: int
ALERT_DESCRIPTION_CERTIFICATE_EXPIRED = ... # type: int
ALERT_DESCRIPTION_CERTIFICATE_REVOKED = ... # type: int
ALERT_DESCRIPTION_CERTIFICATE_UNKNOWN = ... # type: int
ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE = ... # type: int
ALERT_DESCRIPTION_CLOSE_NOTIFY = ... # type: int
ALERT_DESCRIPTION_DECODE_ERROR = ... # type: int
ALERT_DESCRIPTION_DECOMPRESSION_FAILURE = ... # type: int
ALERT_DESCRIPTION_DECRYPT_ERROR = ... # type: int
ALERT_DESCRIPTION_ILLEGAL_PARAMETER = ... # type: int
ALERT_DESCRIPTION_INSUFFICIENT_SECURITY = ... # type: int
ALERT_DESCRIPTION_NO_RENEGOTIATION = ... # type: int
ALERT_DESCRIPTION_PROTOCOL_VERSION = ... # type: int
ALERT_DESCRIPTION_RECORD_OVERFLOW = ... # type: int
ALERT_DESCRIPTION_UNEXPECTED_MESSAGE = ... # type: int
ALERT_DESCRIPTION_UNKNOWN_CA = ... # type: int
ALERT_DESCRIPTION_UNKNOWN_PSK_IDENTITY = ... # type: int
ALERT_DESCRIPTION_UNRECOGNIZED_NAME = ... # type: int
ALERT_DESCRIPTION_UNSUPPORTED_CERTIFICATE = ... # type: int
ALERT_DESCRIPTION_UNSUPPORTED_EXTENSION = ... # type: int
ALERT_DESCRIPTION_USER_CANCELLED = ... # type: int
if sys.version_info >= (3, 4):
_PurposeType = NamedTuple('_PurposeType',
[('nid', int), ('shortname', str),
('longname', str), ('oid', str)])
class Purpose:
SERVER_AUTH = ... # type: _PurposeType
CLIENT_AUTH = ... # type: _PurposeType
class SSLSocket(socket.socket):
context = ... # type: SSLContext
server_side = ... # type: bool
server_hostname = ... # type: Optional[str]
if sys.version_info >= (3, 6):
session = ... # type: Optional[SSLSession]
session_reused = ... # type: Optional[bool]
def read(self, len: int = ...,
buffer: Optional[bytearray] = ...) -> bytes: ...
def write(self, buf: bytes) -> int: ...
def do_handshake(self) -> None: ...
def getpeercert(self, binary_form: bool = ...) -> _PeerCertRetType: ...
def cipher(self) -> Tuple[str, int, int]: ...
if sys.version_info >= (3, 5):
def shared_cipher(self) -> Optional[List[Tuple[str, int, int]]]: ...
def compression(self) -> Optional[str]: ...
def get_channel_binding(self, cb_type: str = ...) -> Optional[bytes]: ...
if sys.version_info >= (3, 5):
def selected_alpn_protocol(self) -> Optional[str]: ...
def selected_npn_protocol(self) -> Optional[str]: ...
def unwrap(self) -> socket.socket: ...
if sys.version_info >= (3, 5):
def version(self) -> Optional[str]: ...
def pending(self) -> int: ...
class SSLContext:
if sys.version_info >= (3, 4):
check_hostname = ... # type: bool
options = ... # type: int
@property
def protocol(self) -> int: ...
if sys.version_info >= (3, 4):
verify_flags = ... # type: int
verify_mode = ... # type: int
if sys.version_info >= (3, 5):
def __init__(self, protocol: int = ...) -> None: ...
else:
def __init__(self, protocol: int) -> None: ...
if sys.version_info >= (3, 4):
def cert_store_stats(self) -> Dict[str, int]: ...
def load_cert_chain(self, certfile: str, keyfile: Optional[str] = ...,
password: _PasswordType = ...) -> None: ...
if sys.version_info >= (3, 4):
def load_default_certs(self, purpose: _PurposeType = ...) -> None: ...
def load_verify_locations(self, cafile: Optional[str] = ...,
capath: Optional[str] = ...,
cadata: Union[str, bytes, None] = ...) -> None: ...
def get_ca_certs(self,
binary_form: bool = ...) -> Union[List[_PeerCertRetDictType], List[bytes]]: ...
else:
def load_verify_locations(self,
cafile: Optional[str] = ...,
capath: Optional[str] = ...) -> None: ...
def set_default_verify_paths(self) -> None: ...
def set_ciphers(self, ciphers: str) -> None: ...
if sys.version_info >= (3, 5):
def set_alpn_protocols(self, protocols: List[str]) -> None: ...
def set_npn_protocols(self, protocols: List[str]) -> None: ...
def set_servername_callback(self,
server_name_callback: Optional[_SrvnmeCbType]) -> None: ...
def load_dh_params(self, dhfile: str) -> None: ...
def set_ecdh_curve(self, curve_name: str) -> None: ...
def wrap_socket(self, sock: socket.socket, server_side: bool = ...,
do_handshake_on_connect: bool = ...,
suppress_ragged_eofs: bool = ...,
server_hostname: Optional[str] = ...) -> SSLSocket: ...
if sys.version_info >= (3, 5):
def wrap_bio(self, incoming: 'MemoryBIO', outgoing: 'MemoryBIO',
server_side: bool = ...,
server_hostname: Optional[str] = ...) -> 'SSLObject': ...
def session_stats(self) -> Dict[str, int]: ...
if sys.version_info >= (3, 5):
class SSLObject:
context = ... # type: SSLContext
server_side = ... # type: bool
server_hostname = ... # type: Optional[str]
if sys.version_info >= (3, 6):
session = ... # type: Optional[SSLSession]
session_reused = ... # type: bool
def read(self, len: int = ...,
buffer: Optional[bytearray] = ...) -> bytes: ...
def write(self, buf: bytes) -> int: ...
def getpeercert(self, binary_form: bool = ...) -> _PeerCertRetType: ...
def selected_npn_protocol(self) -> Optional[str]: ...
def cipher(self) -> Tuple[str, int, int]: ...
def shared_cipher(self) -> Optional[List[Tuple[str, int, int]]]: ...
def compression(self) -> Optional[str]: ...
def pending(self) -> int: ...
def do_handshake(self) -> None: ...
def unwrap(self) -> None: ...
def get_channel_binding(self, cb_type: str = ...) -> Optional[bytes]: ...
class MemoryBIO:
pending = ... # type: int
eof = ... # type: bool
def read(self, n: int = ...) -> bytes: ...
def write(self, buf: bytes) -> int: ...
def write_eof(self) -> None: ...
if sys.version_info >= (3, 6):
class SSLSession:
id = ... # type: bytes
time = ... # type: int
timeout = ... # type: int
ticket_lifetime_hint = ... # type: int
has_ticket = ... # type: bool
# TODO below documented in cpython but not in docs.python.org
# taken from python 3.4
SSL_ERROR_EOF = ... # type: int
SSL_ERROR_INVALID_ERROR_CODE = ... # type: int
SSL_ERROR_SSL = ... # type: int
SSL_ERROR_SYSCALL = ... # type: int
SSL_ERROR_WANT_CONNECT = ... # type: int
SSL_ERROR_WANT_READ = ... # type: int
SSL_ERROR_WANT_WRITE = ... # type: int
SSL_ERROR_WANT_X509_LOOKUP = ... # type: int
SSL_ERROR_ZERO_RETURN = ... # type: int
def get_protocol_name(protocol_code: int) -> str: ...
AF_INET = ... # type: int
PEM_FOOTER = ... # type: str
PEM_HEADER = ... # type: str
SOCK_STREAM = ... # type: int
SOL_SOCKET = ... # type: int
SO_TYPE = ... # type: int

View File

@@ -17,7 +17,7 @@ os.fsencode(a)
os.fsdecode(a)
Path(a)
PurePath(a)
PurePath(<warning descr="Expected type 'str', got 'A' instead">a</warning>) # TODO ok after supporting versioning in pyi-stubs
os.path.abspath(a)
@@ -34,8 +34,8 @@ os.fspath(b) # TODO fail after enabling pyi-stubs for `os` module
os.fsencode(b) # TODO fail after enabling pyi-stubs for `os` module
os.fsdecode(b) # TODO fail after enabling pyi-stubs for `os` module
Path(<warning descr="Expected type 'Union[str, bytes, PathLike]', got 'B' instead">b</warning>)
PurePath(<warning descr="Expected type 'Union[str, bytes, PathLike]', got 'B' instead">b</warning>)
Path(<warning descr="Unexpected type(s):(B)Possible types:(Union[str, PurePath])(Union[str, PathLike[str]])">b</warning>)
PurePath(<warning descr="Expected type 'str', got 'B' instead">b</warning>) # TODO update after supporting versioning in pyi-stubs
os.path.abspath(<warning descr="Expected type 'Union[bytes, str, PathLike]', got 'B' instead">b</warning>)

View File

@@ -1,11 +0,0 @@
class PurePath(object):
def __new__(cls, *pathsegments):
pass
def __fspath__(self):
pass
class Path(PurePath):
def __new__(cls, *pathsegments):
pass

View File

@@ -21,7 +21,8 @@ println("Bundled: ${bundled.abs()}")
sync(repo, bundled)
val whiteList = setOf("typing", "six", "__builtin__", "builtins", "exceptions", "types", "datetime", "functools", "shutil", "re", "time",
"argparse", "uuid", "threading", "signal", "collections", "subprocess", "math", "queue", "socket", "sqlite3", "attr")
"argparse", "uuid", "threading", "signal", "collections", "subprocess", "math", "queue", "socket", "sqlite3", "attr",
"pathlib", "io", "itertools", "ssl")
clean(topLevelPackages(bundled), whiteList)