diff --git a/builtins/2.7/_ast.pyi b/builtins/2.7/_ast.pyi index a82350bfd..961c2e64d 100644 --- a/builtins/2.7/_ast.pyi +++ b/builtins/2.7/_ast.pyi @@ -1,10 +1,11 @@ -from typing import Any, Tuple +from typing import Any +from typing import Tuple as TypingTuple PyCF_ONLY_AST = ... # type: int class AST(object): - _attributes = ... # type: Tuple[str] - _fields = ... # type: Tuple[str] + _attributes = ... # type: TypingTuple[str] + _fields = ... # type: TypingTuple[str] def __init__(self, *args, **kwargs) -> None: pass class alias(AST): diff --git a/builtins/2.7/_collections.pyi b/builtins/2.7/_collections.pyi index 35d668ae9..5855277dc 100644 --- a/builtins/2.7/_collections.pyi +++ b/builtins/2.7/_collections.pyi @@ -1,6 +1,6 @@ """Stub file for the '_collections' module.""" -from typing import Any, Generic, Iterator, TypeVar +from typing import Any, Generic, Iterator, TypeVar, Optional, Union class defaultdict(dict): default_factory = ... # type: None @@ -10,8 +10,8 @@ class defaultdict(dict): def __copy__(self) -> "defaultdict": ... def copy(self) -> "defaultdict": ... -_T = TypeVar('T') -_T2 = TypeVar('T2') +_T = TypeVar('_T') +_T2 = TypeVar('_T2') class deque(Generic[_T]): maxlen = ... # type: Optional[int] diff --git a/builtins/2.7/_functools.pyi b/builtins/2.7/_functools.pyi index ceb3870d0..ef59af088 100644 --- a/builtins/2.7/_functools.pyi +++ b/builtins/2.7/_functools.pyi @@ -1,8 +1,8 @@ """Stub file for the '_functools' module.""" -from typing import Any, Callable, Iterator, Optional, TypeVar +from typing import Any, Callable, Iterator, Optional, TypeVar, Tuple -_T = TypeVar("T") +_T = TypeVar("_T") def reduce(function: Callable[[_T, _T], _T], sequence: Iterator[_T], initial=Optional[_T]) -> _T: ... diff --git a/builtins/2.7/_io.pyi b/builtins/2.7/_io.pyi index f776cf1fc..a8119a877 100644 --- a/builtins/2.7/_io.pyi +++ b/builtins/2.7/_io.pyi @@ -1,4 +1,4 @@ -from typing import Any, Iterable, Tuple, List, Union +from typing import Any, Optional, Iterable, Tuple, List, Union DEFAULT_BUFFER_SIZE = ... # type: int @@ -10,7 +10,7 @@ class UnsupportedOperation(ValueError, IOError): ... class _IOBase(object): - closed = ... # type: getset_descriptor + closed = ... # type: bool def __enter__(self) -> "_IOBase": ... def __exit__(self, type, value, traceback) -> bool: ... def __iter__(self) -> "_IOBase": ... @@ -76,16 +76,16 @@ class FileIO(_RawIOBase): def write(self, pbuf: str) -> int: ... class IncrementalNewlineDecoder(object): - newlines = ... # type: AnyStr + newlines = ... # type: Union[str, unicode] def decode(self, input, final) -> Any: ... def getstate(self) -> Tuple[Any, int]: ... def setstate(self, state: Tuple[Any, int]) -> None: ... def reset(self) -> None: ... class _TextIOBase(_IOBase): - errors = ... # type: Optional[] - newlines = ... # type: AnyStr - encoding = ... # type: Optional[] + errors = ... # type: Optional[str] + newlines = ... # type: Union[str, unicode] + encoding = ... # type: Optional[str] def read(self, n: int = ...) -> str: ... def write(self): ... def detach(self): ... diff --git a/builtins/2.7/_random.pyi b/builtins/2.7/_random.pyi index 7b5cba32e..b8cef226e 100644 --- a/builtins/2.7/_random.pyi +++ b/builtins/2.7/_random.pyi @@ -1,7 +1,7 @@ -from typing import Optional, Any +from typing import Optional, Union, Any class Random(object): - def __init__(self, seed: x, object = None) -> None: ... + def __init__(self, seed: Optional[Union[int, Any]] = ..., object = ...) -> None: ... def getstate(self) -> tuple: ... def setstate(self, state: tuple) -> None: ... def random(self) -> float: ... diff --git a/builtins/2.7/_sha256.pyi b/builtins/2.7/_sha256.pyi index a429ec7e0..4cf40c1f3 100644 --- a/builtins/2.7/_sha256.pyi +++ b/builtins/2.7/_sha256.pyi @@ -1,3 +1,5 @@ +from typing import Optional + class sha224(object): name = ... # type: str block_size = ... # type: int diff --git a/builtins/2.7/_sha512.pyi b/builtins/2.7/_sha512.pyi index 5da79aabb..f9e4928af 100644 --- a/builtins/2.7/_sha512.pyi +++ b/builtins/2.7/_sha512.pyi @@ -1,3 +1,5 @@ +from typing import Optional + class sha384(object): name = ... # type: str block_size = ... # type: int diff --git a/builtins/2.7/_socket.pyi b/builtins/2.7/_socket.pyi index cb87cce1f..6f72ba9df 100644 --- a/builtins/2.7/_socket.pyi +++ b/builtins/2.7/_socket.pyi @@ -1,4 +1,4 @@ -from typing import Tuple, Union, IO, Any, overload +from typing import Tuple, Union, IO, Any, Optional, overload AF_APPLETALK = ... # type: int AF_ASH = ... # type: int @@ -42,7 +42,6 @@ BTPROTO_HCI = ... # type: int BTPROTO_L2CAP = ... # type: int BTPROTO_RFCOMM = ... # type: int BTPROTO_SCO = ... # type: int -CAPI = ... # type: PyCapsule EAI_ADDRFAMILY = ... # type: int EAI_AGAIN = ... # type: int EAI_BADFLAGS = ... # type: int @@ -238,9 +237,14 @@ TIPC_WAIT_FOREVER = ... # type: int TIPC_WITHDRAWN = ... # type: int TIPC_ZONE_SCOPE = ... # type: int +# PyCapsule +CAPI = ... # type: Any + has_ipv6 = ... # type: bool class error(IOError): ... +class gaierror(error): ... +class timeout(error): ... class SocketType(object): family = ... # type: int diff --git a/builtins/2.7/_sre.pyi b/builtins/2.7/_sre.pyi index 01561576c..2f1500f66 100644 --- a/builtins/2.7/_sre.pyi +++ b/builtins/2.7/_sre.pyi @@ -1,6 +1,6 @@ """Stub file for the '_sre' module.""" -from typing import Any, Optional, Mapping, Sequence, Dict, List, Tuple, overload +from typing import Any, Union, Iterable, Optional, Mapping, Sequence, Dict, List, Tuple, overload CODESIZE = ... # type: int MAGIC = ... # type: int diff --git a/builtins/2.7/_struct.pyi b/builtins/2.7/_struct.pyi index a0700f203..a9048b7f5 100644 --- a/builtins/2.7/_struct.pyi +++ b/builtins/2.7/_struct.pyi @@ -1,5 +1,7 @@ """Stub file for the '_struct' module.""" +from typing import Any, AnyStr, Tuple + class error(Exception): ... class Struct(object): diff --git a/builtins/2.7/_symtable.pyi b/builtins/2.7/_symtable.pyi index bd2a677de..b2c92902b 100644 --- a/builtins/2.7/_symtable.pyi +++ b/builtins/2.7/_symtable.pyi @@ -22,6 +22,9 @@ TYPE_FUNCTION = ... # type: int TYPE_MODULE = ... # type: int USE = ... # type: int +class _symtable_entry(object): + ... + class symtable(object): children = ... # type: List[_symtable_entry] id = ... # type: int diff --git a/builtins/2.7/array.pyi b/builtins/2.7/array.pyi index e0ea9a83a..baaa50e13 100644 --- a/builtins/2.7/array.pyi +++ b/builtins/2.7/array.pyi @@ -1,6 +1,7 @@ """Stub file for the 'array' module.""" -from typing import Any, Generic, IO, Iterable, Sequence, TypeVar, Union, overload +from typing import (Any, Generic, IO, Iterable, Sequence, TypeVar, + Union, overload, Iterator, Tuple, BinaryIO) T = TypeVar('T') @@ -42,7 +43,7 @@ class array(Generic[T]): def index(self, x: T) -> int: ... def insert(self, i: int, x: T) -> None: ... def pop(self, i: int = ...) -> T: ... - def read(self, f: file, n: int) -> None: + def read(self, f: IO[str], n: int) -> None: raise DeprecationWarning() def remove(self, x: T) -> None: ... def reverse(self) -> None: ... @@ -51,5 +52,5 @@ class array(Generic[T]): def tolist(self) -> List[T]: ... def tostring(self) -> str: ... def tounicode(self) -> unicode: ... - def write(self, f: file) -> None: + def write(self, f: IO[str]) -> None: raise DeprecationWarning() diff --git a/builtins/2.7/cStringIO.pyi b/builtins/2.7/cStringIO.pyi index bb49c9bd4..418b3fd2e 100644 --- a/builtins/2.7/cStringIO.pyi +++ b/builtins/2.7/cStringIO.pyi @@ -24,10 +24,11 @@ class StringIO(IO[str]): def truncate(self, size: int = None) -> int: raise IOError() def writable(self) -> bool: ... - def next(self) -> str: ... - def __iter__(self) -> "InputType": ... + def __next__(self) -> str: ... def __enter__(self) -> Any: ... def __exit__(self, exc_type: type, exc_val: Any, exc_tb: Any) -> Any: ... + # The C extension actually returns an "InputType". + def __iter__(self) -> Iterator[str]: ... # only StringO: def reset(self) -> None: ... def write(self, b: Union[str, unicode]) -> None: ... diff --git a/builtins/2.7/exceptions.pyi b/builtins/2.7/exceptions.pyi index 27021b791..1f29e909a 100644 --- a/builtins/2.7/exceptions.pyi +++ b/builtins/2.7/exceptions.pyi @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any, List, Optional class StandardError(Exception): ... class ArithmeticError(StandardError): ... diff --git a/builtins/2.7/operator.pyi b/builtins/2.7/operator.pyi index f06724345..4f12ab197 100644 --- a/builtins/2.7/operator.pyi +++ b/builtins/2.7/operator.pyi @@ -115,10 +115,10 @@ def truth(x: Any) -> bool: ... def xor(a: Any, b: Any) -> Any: ... class attrgetter(object): - def __init__(self, name: Any): ... + def __init__(self, name: Any) -> None: ... class itemgetter(object): - def __init__(self, key: Any): ... + def __init__(self, key: Any) -> None: ... class methodcaller(object): - def __init__(self, method_name: str, *args, **kwargs): ... + def __init__(self, method_name: str, *args, **kwargs) -> None: ... diff --git a/builtins/2.7/posix.pyi b/builtins/2.7/posix.pyi index 3847880cb..2257c8c84 100644 --- a/builtins/2.7/posix.pyi +++ b/builtins/2.7/posix.pyi @@ -1,4 +1,4 @@ -from typing import List, Mapping, Tuple, Union, Sequence, IO, Any, Optional +from typing import List, Mapping, Tuple, Union, Sequence, IO, Optional, TypeVar error = OSError @@ -110,7 +110,7 @@ def fchdir(fd: int) -> None: ... def fchmod(fd: int, mode: int) -> None: ... def fchown(fd: int, uid: int, gid: int) -> None: ... def fdatasync(fd: int) -> None: ... -def fdopen(fd: int, mode: str = ..., bufsize: int = ...) -> file: ... +def fdopen(fd: int, mode: str = ..., bufsize: int = ...) -> IO[str]: ... def fork() -> int: raise OSError() def forkpty() -> Tuple[int, int]: @@ -143,8 +143,8 @@ def kill(pid: int, sig: int) -> None: ... def killpg(pgid: int, sig: int) -> None: ... def lchown(path: unicode, uid: int, gid: int) -> None: ... def link(source: unicode, link_name: str) -> None: ... -_t = TypeVar -def listdir(path: _t) -> List[_t]: ... +_T = TypeVar("_T") +def listdir(path: _T) -> List[_T]: ... def lseek(fd: int, pos: int, how: int) -> None: ... def lstat(path: unicode) -> stat_result: ... def major(device: int) -> int: ... @@ -158,10 +158,10 @@ def open(file: unicode, flags: int, mode: int = ...) -> int: ... def openpty() -> Tuple[int, int]: ... def pathconf(path: unicode, name: str) -> str: ... def pipe() -> Tuple[int, int]: ... -def popen(command: str, mode: str = ..., bufsize: int = ...) -> file: ... +def popen(command: str, mode: str = ..., bufsize: int = ...) -> IO[str]: ... def putenv(varname: str, value: str) -> None: ... def read(fd: int, n: int) -> str: ... -def readlink(path: _t) -> _t: ... +def readlink(path: _T) -> _T: ... def remove(path: unicode) -> None: ... def rename(src: unicode, dst: unicode) -> None: ... def rmdir(path: unicode) -> None: ... @@ -179,7 +179,7 @@ def setsid() -> None: ... def setuid(pid: int) -> None: ... def stat(path: unicode) -> stat_result: ... def statvfs(path: unicode) -> statvfs_result: ... -def stat_float_times(fd: int) -> NoneType: ... +def stat_float_times(fd: int) -> None: ... def strerror(code: int) -> str: ... def symlink(source: unicode, link_name: unicode) -> None: ... def sysconf(name: Union[str, int]) -> int: ... @@ -187,7 +187,7 @@ def system(command: unicode) -> int: ... def tcgetpgrp(fd: int) -> int: ... def tcsetpgrp(fd: int, pg: int) -> None: ... def times() -> Tuple[float, float, float, float, float]: ... -def tmpfile() -> file: ... +def tmpfile() -> IO[str]: ... def ttyname(fd: int) -> str: ... def umask(mask: int) -> int: ... def uname() -> Tuple[str, str, str, str, str]: ... diff --git a/builtins/2.7/pwd.pyi b/builtins/2.7/pwd.pyi index 71013c51d..facd9dbea 100644 --- a/builtins/2.7/pwd.pyi +++ b/builtins/2.7/pwd.pyi @@ -1,8 +1,6 @@ -def getpwall() -> list -def getpwnam(name:str) -> struct_passwd -def getpwuid(uid:int) -> struct_passwd +from typing import List -class struct_passwd(tuple): ... +class struct_passwd(tuple): n_fields = ... # type: int n_sequence_fields = ... # type: int n_unnamed_fields = ... # type: int @@ -13,3 +11,8 @@ class struct_passwd(tuple): ... pw_gecos = ... # type: str pw_gid = ... # type: int pw_uid = ... # type: int + +def getpwall() -> List[struct_passwd]: ... +def getpwnam(name:str) -> struct_passwd: ... +def getpwuid(uid:int) -> struct_passwd: ... + diff --git a/builtins/2.7/select.pyi b/builtins/2.7/select.pyi index 872564d82..ba6e9afbb 100644 --- a/builtins/2.7/select.pyi +++ b/builtins/2.7/select.pyi @@ -1,6 +1,6 @@ """Stubs for the 'select' module.""" -from typing import Any, Optional +from typing import Any, Optional, Tuple, Iterable EPOLLERR = ... # type: int EPOLLET = ... # type: int diff --git a/builtins/2.7/sys.pyi b/builtins/2.7/sys.pyi index 52fffa7e5..1e955a80a 100644 --- a/builtins/2.7/sys.pyi +++ b/builtins/2.7/sys.pyi @@ -1,7 +1,7 @@ """Stubs for the 'sys' module.""" from typing import ( - List, Sequence, Any, Dict, Tuple, BinaryIO, overload + IO, Union, List, Sequence, Any, Dict, Tuple, BinaryIO, overload ) class _flags: @@ -63,12 +63,11 @@ path = ... # type: List[str] platform = ... # type: str prefix = ... # type: str py3kwarning = ... # type: bool -stderr = ... # type: file -stdin = ... # type: file -stdout = ... # type: file +stderr = ... # type: IO[str] +stdin = ... # type: IO[str] +stdout = ... # type: IO[str] subversion = ... # type: tuple version = ... # type: str -version_info = ... # type: Tuple[int] warnoptions = ... # type: object float_info = ... # type: _float_info version_info = ... # type: _version_info diff --git a/builtins/2.7/unicodedata.pyi b/builtins/2.7/unicodedata.pyi index 9e3be51be..ab233af39 100644 --- a/builtins/2.7/unicodedata.pyi +++ b/builtins/2.7/unicodedata.pyi @@ -1,12 +1,13 @@ """Stubs for the 'unicodedata' module.""" -from typing import Any, TypeVar +from typing import Any, TypeVar, Union, Optional ucd_3_2_0 = ... # type: UCD -ucnhash_CAPI = ... # type: Any (PyCapsule) unidata_version = ... # type: str +# PyCapsule +ucnhash_CAPI = ... # type: Any -_default = TypeVar("default") +_default = TypeVar("_default") def bidirectional(unichr: unicode) -> str: ... def category(unichr: unicode) -> str: ... @@ -19,7 +20,7 @@ def lookup(name: str): unicode def mirrored(unichr: unicode): int def name(chr: unicode, default=_default) -> Union[str, _default]: ... def normalize(form: str, unistr: unicode) -> unicode: ... -def numeric(chr, default=_default): Union[float, _default]: ... +def numeric(chr, default=_default) -> Union[float, _default]: ... class UCD(object): unidata_version = ... # type: str @@ -36,4 +37,4 @@ class UCD(object): def mirrored(unichr: unicode): int def name(chr: unicode, default=_default) -> Union[str, _default]: ... def normalize(form: str, unistr: unicode) -> unicode: ... - def numeric(chr, default=_default): Union[float, _default]: ... + def numeric(chr, default=_default) -> Union[float, _default]: ... diff --git a/builtins/2.7/zipimport.pyi b/builtins/2.7/zipimport.pyi index b794f7d7b..e13bc10cc 100644 --- a/builtins/2.7/zipimport.pyi +++ b/builtins/2.7/zipimport.pyi @@ -1,6 +1,6 @@ """Stub file for the 'zipimport' module.""" -from typing import Dict +from typing import Dict, Optional class ZipImportError(ImportError): pass diff --git a/builtins/2.7/zlib.pyi b/builtins/2.7/zlib.pyi index 74eeed33e..72bfc88c1 100644 --- a/builtins/2.7/zlib.pyi +++ b/builtins/2.7/zlib.pyi @@ -24,13 +24,13 @@ def decompress(data: str, wbits: int = ..., bufsize: int = ...) -> str: ... class compressobj: def __init__(level: int = ..., method: int = ..., wbits: int = ..., memlevel: int = ..., - strategy: int = ...): ... + strategy: int = ...) -> None: ... + def copy(self) -> "compressobj": ... def compress(self, data: str) -> str: ... - def copy(self) -> _Compress: ... - def flush(self) -> NoneType: ... + def flush(self) -> None: ... class decompressobj: - def __init__(wbits: int = ...): ... - def copy(self) -> _Compress: ... + def __init__(wbits: int = ...) -> None: ... + def copy(self) -> "decompressobj": ... def decompress(self, data: str) -> str: ... - def flush(self) -> NoneType: ... + def flush(self) -> None: ...