fix bugs in builtins/2.7/*.pyi

This commit is contained in:
Matthias Kramm
2015-10-01 08:02:44 -07:00
parent 3f713101a5
commit a2f5703041
22 changed files with 77 additions and 58 deletions

View File

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

View File

@@ -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]

View File

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

View File

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

View File

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

View File

@@ -1,3 +1,5 @@
from typing import Optional
class sha224(object):
name = ... # type: str
block_size = ... # type: int

View File

@@ -1,3 +1,5 @@
from typing import Optional
class sha384(object):
name = ... # type: str
block_size = ... # type: int

View File

@@ -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

View File

@@ -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

View File

@@ -1,5 +1,7 @@
"""Stub file for the '_struct' module."""
from typing import Any, AnyStr, Tuple
class error(Exception): ...
class Struct(object):

View File

@@ -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

View File

@@ -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()

View File

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

View File

@@ -1,4 +1,4 @@
from typing import Any, List
from typing import Any, List, Optional
class StandardError(Exception): ...
class ArithmeticError(StandardError): ...

View File

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

View File

@@ -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]: ...

View File

@@ -1,8 +1,6 @@
def getpwall() -> list<struct_passwd>
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: ...

View File

@@ -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

View File

@@ -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

View File

@@ -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]: ...

View File

@@ -1,6 +1,6 @@
"""Stub file for the 'zipimport' module."""
from typing import Dict
from typing import Dict, Optional
class ZipImportError(ImportError):
pass

View File

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