Skip to content

Lots of stub fixes #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions builtins/2.7/_functools.pyi
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
"""Stub file for the '_functools' module."""

from typing import Any, Callable, Iterator, Optional, TypeVar, Tuple
from typing import Any, Callable, Dict, Iterator, Optional, TypeVar, Tuple, overload

_T = TypeVar("_T")

@overload
def reduce(function: Callable[[_T, _T], _T],
sequence: Iterator[_T]) -> _T: ...
@overload
def reduce(function: Callable[[_T, _T], _T],
sequence: Iterator[_T], initial=Optional[_T]) -> _T: ...
sequence: Iterator[_T], initial: _T) -> _T: ...

class partial(object):
func = ... # type: Callable[..., Any]
args = ... # type: Tuple[Any]
args = ... # type: Tuple[Any, ...]
keywords = ... # type: Dict[str, Any]
def __init__(self, func: Callable[..., Any], *args, **kwargs) -> None: ...
def __call__(self, *args, **kwargs) -> Any: ...
def __init__(self, func: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
12 changes: 8 additions & 4 deletions builtins/2.7/_random.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
from typing import Optional, Union, Any
from typing import Tuple

# Actually Tuple[(int,) * 625]
_State = Tuple[int, ...]

class Random(object):
def __init__(self, seed: Optional[Union[int, Any]] = ..., object = ...) -> None: ...
def getstate(self) -> tuple: ...
def setstate(self, state: tuple) -> None: ...
def __init__(self, seed: object = None) -> None: ...
def seed(self, x: object = None) -> None: ...
def getstate(self) -> _State: ...
def setstate(self, state: _State) -> None: ...
def random(self) -> float: ...
def getrandbits(self, k: int) -> int: ...
def jumpahead(self, i: int) -> None: ...
2 changes: 1 addition & 1 deletion builtins/2.7/_warnings.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any
from typing import Any, List

default_action = ... # type: str
filters = ... # type: List[tuple]
Expand Down
2 changes: 1 addition & 1 deletion builtins/2.7/array.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Stub file for the 'array' module."""

from typing import (Any, Generic, IO, Iterable, Sequence, TypeVar,
Union, overload, Iterator, Tuple, BinaryIO)
Union, overload, Iterator, Tuple, BinaryIO, List)

T = TypeVar('T')

Expand Down
3 changes: 2 additions & 1 deletion builtins/2.7/builtins.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Stubs for builtins (Python 2.7)

from typing import (
Optional, TypeVar, Iterator, Iterable, overload,
TypeVar, Iterator, Iterable, overload,
Sequence, Mapping, Tuple, List, Any, Dict, Callable, Generic, Set,
AbstractSet, Sized, Reversible, SupportsInt, SupportsFloat, SupportsAbs,
SupportsRound, IO, BinaryIO, Union, AnyStr, MutableSequence, MutableMapping,
Expand Down Expand Up @@ -496,6 +496,7 @@ class list(MutableSequence[_T], Reversible[_T], Generic[_T]):
def __delitem__(self, i: Union[int, slice]) -> None: ...
def __delslice(self, start: int, stop: int) -> None: ...
def __add__(self, x: List[_T]) -> List[_T]: ...
def __iadd__(self, x: Iterable[_T]) -> List[_T]: ...
def __mul__(self, n: int) -> List[_T]: ...
def __rmul__(self, n: int) -> List[_T]: ...
def __contains__(self, o: object) -> bool: ...
Expand Down
2 changes: 1 addition & 1 deletion builtins/2.7/cPickle.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, IO
from typing import Any, IO, List

HIGHEST_PROTOCOL = ... # type: int
compatible_formats = ... # type: List[str]
Expand Down
48 changes: 30 additions & 18 deletions builtins/2.7/cStringIO.pyi
Original file line number Diff line number Diff line change
@@ -1,38 +1,50 @@
# Stubs for cStringIO (Python 2.7)
# See https://docs.python.org/2/library/stringio.html

from typing import IO, List, Iterable, Iterator, Any, Union
from typing import overload, IO, List, Iterable, Iterator, Optional, Union
from types import TracebackType

class StringIO(IO[str]):
softspace = ... # type: int
# TODO the typing.IO[] generics should be split into input and output.

def __init__(self, s: str = None) -> None: ...
class InputType(IO[str], Iterator[str]):
def getvalue(self) -> str: ...
def close(self) -> None: ...
@property
def closed(self) -> bool: ...
def fileno(self) -> int: ...
def flush(self) -> None: ...
def isatty(self) -> bool: ...
def read(self, size: int = -1) -> str: ...
def readable(self) -> bool: ...
def readline(self, size: int = -1) -> str: ...
def readlines(self, hint: int = -1) -> List[str]: ...
def seek(self, offset: int, whence: int = ...) -> None: ...
def seekable(self) -> bool: ...
def tell(self) -> int: ...
def truncate(self, size: int = None) -> int:
raise IOError()
def writable(self) -> bool: ...
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 truncate(self, size: int = ...) -> Optional[int]: ...
def __iter__(self) -> 'InputType': ...
def next(self) -> str: ...
def reset(self) -> None: ...

class OutputType(IO[str], Iterator[str]):
@property
def softspace(self) -> int: ...
def getvalue(self) -> str: ...
def close(self) -> None: ...
@property
def closed(self) -> bool: ...
def flush(self) -> None: ...
def isatty(self) -> bool: ...
def read(self, size: int = -1) -> str: ...
def readline(self, size: int = -1) -> str: ...
def readlines(self, hint: int = -1) -> List[str]: ...
def seek(self, offset: int, whence: int = ...) -> None: ...
def tell(self) -> int: ...
def truncate(self, size: int = ...) -> Optional[int]: ...
def __iter__(self) -> 'OutputType': ...
def next(self) -> str: ...
def reset(self) -> None: ...
def write(self, b: Union[str, unicode]) -> None: ...
def writelines(self, lines: Iterable[Union[str, unicode]]) -> None: ...

InputType = StringIO
OutputType = StringIO
@overload
def StringIO() -> OutputType: ...
@overload
def StringIO(s: str) -> InputType: ...
2 changes: 1 addition & 1 deletion builtins/2.7/select.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Stubs for the 'select' module."""

from typing import Any, Optional, Tuple, Iterable
from typing import Any, Optional, Tuple, Iterable, List

EPOLLERR = ... # type: int
EPOLLET = ... # type: int
Expand Down
24 changes: 10 additions & 14 deletions builtins/2.7/signal.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from typing import Callable, Any, Tuple, Union
from types import FrameType

SIG_DFL = ... # type: long
SIG_IGN = ... # type: long
ITIMER_REAL = ... # type: long
ITIMER_VIRTUAL = ... # type: long
ITIMER_PROF = ... # type: long
SIG_DFL = ... # type: int
SIG_IGN = ... # type: int
ITIMER_REAL = ... # type: int
ITIMER_VIRTUAL = ... # type: int
ITIMER_PROF = ... # type: int

SIGABRT = ... # type: int
SIGALRM = ... # type: int
Expand Down Expand Up @@ -43,24 +44,19 @@ SIGXCPU = ... # type: int
SIGXFSZ = ... # type: int
NSIG = ... # type: int

# Python 3 only:
CTRL_C_EVENT = 0
CTRL_BREAK_EVENT = 0
GSIG = 0

class ItimerError(IOError): ...

_HANDLER = Union[Callable[[int, Any], Any], int, None]
_HANDLER = Union[Callable[[int, FrameType], None], int, None]

def alarm(time: int) -> int: ...
def getsignal(signalnum: int) -> _HANDLER: ...
def pause() -> None: ...
def setitimer(which: int, seconds: float, interval: float = None) -> Tuple[float, float]: ...
def getitimer(which: int) -> Tuple[float, float]: ...
def set_wakeup_fd(fd: int) -> long: ...
def set_wakeup_fd(fd: int) -> int: ...
def siginterrupt(signalnum: int, flag: bool) -> None:
raise RuntimeError()
def signal(signalnum: int, handler: _HANDLER) -> None:
def signal(signalnum: int, handler: _HANDLER) -> _HANDLER:
raise RuntimeError()
def default_int_handler(*args, **kwargs) -> Any:
def default_int_handler(signum: int, frame: FrameType) -> None:
raise KeyboardInterrupt()
37 changes: 26 additions & 11 deletions builtins/2.7/sys.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Stubs for the 'sys' module."""

from typing import (
IO, Union, List, Sequence, Any, Dict, Tuple, BinaryIO, overload
IO, Union, List, Sequence, Any, Dict, Tuple, BinaryIO, Optional, Callable, overload
)
from types import FrameType, ModuleType, TracebackType

class _flags:
bytes_warning = ... # type: int
Expand Down Expand Up @@ -42,10 +43,10 @@ class _version_info(Tuple[int, int, int, str, int]):
releaselevel = ''
serial = 0

_mercurial = ... # type: tuple
_mercurial = ... # type: Tuple[str, str, str]
api_version = ... # type: int
argv = ... # type: List[str]
builtin_module_names = ... # type: List[str]
builtin_module_names = ... # type: Tuple[str, ...]
byteorder = ... # type: str
copyright = ... # type: str
dont_write_bytecode = ... # type: bool
Expand All @@ -58,19 +59,33 @@ long_info = ... # type: object
maxint = ... # type: int
maxsize = ... # type: int
maxunicode = ... # type: int
modules = ... # type: Dict[str, module]
modules = ... # type: Dict[str, ModuleType]
path = ... # type: List[str]
platform = ... # type: str
prefix = ... # type: str
py3kwarning = ... # type: bool
__stderr__ = ... # type: IO[str]
__stdin__ = ... # type: IO[str]
__stdout__ = ... # type: IO[str]
stderr = ... # type: IO[str]
stdin = ... # type: IO[str]
stdout = ... # type: IO[str]
subversion = ... # type: tuple
subversion = ... # type: Tuple[str, str, str]
version = ... # type: str
warnoptions = ... # type: object
float_info = ... # type: _float_info
version_info = ... # type: _version_info
ps1 = ''
ps2 = ''
last_type = ... # type: type
last_value = ... # type: BaseException
last_traceback = ... # type: TracebackType
# TODO precise types
meta_path = ... # type: List[Any]
path_hooks = ... # type: List[Any]
path_importer_cache = ... # type: Dict[str, Any]
displayhook = ... # type: Optional[Callable[[int], None]]
excepthook = ... # type: Optional[Callable[[type, BaseException, TracebackType], None]]

class _WindowsVersionType:
major = ... # type: Any
Expand All @@ -83,17 +98,17 @@ class _WindowsVersionType:
suite_mask = ... # type: Any
product_type = ... # type: Any

def getwindowsversion() -> _WindowsVersionType: ... # TODO return type
def getwindowsversion() -> _WindowsVersionType: ...

def _clear_type_cache() -> None: ...
def _current_frames() -> Dict[int, Any]: ...
def _getframe(depth: int = ...) -> Any: ... # TODO: Return FrameObject
def _current_frames() -> Dict[int, FrameType]: ...
def _getframe(depth: int = ...) -> FrameType: ...
def call_tracing(fn: Any, args: Any) -> Any: ...
def displayhook(value: int) -> None: ... # value might be None
def excepthook(type_: type, value: BaseException, traceback: Any) -> None: ... # TODO traceback type
def __displayhook__(value: int) -> None: ...
def __excepthook__(type_: type, value: BaseException, traceback: TracebackType) -> None: ...
def exc_clear() -> None:
raise DeprecationWarning()
def exc_info() -> Tuple[type, Any, Any]: ... # TODO traceback type
def exc_info() -> Tuple[type, BaseException, TracebackType]: ...
def exit(arg: int = ...) -> None:
raise SystemExit()
def getcheckinterval() -> int: ... # deprecated
Expand Down
34 changes: 17 additions & 17 deletions builtins/2.7/unicodedata.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Stubs for the 'unicodedata' module."""

from typing import Any, TypeVar, Union, Optional
from typing import Any, TypeVar, Union

ucd_3_2_0 = ... # type: UCD
unidata_version = ... # type: str
Expand All @@ -12,29 +12,29 @@ _default = TypeVar("_default")
def bidirectional(unichr: unicode) -> str: ...
def category(unichr: unicode) -> str: ...
def combining(unichr: unicode) -> int: ...
def decimal(chr: unicode, default=_default) -> Union[int, _default]: ...
def decimal(chr: unicode, default: _default = ...) -> Union[int, _default]: ...
def decomposition(unichr: unicode) -> str: ...
def digit(chr: unicode, default=_default) -> Union[int, _default]: ...
def digit(chr: unicode, default: _default = ...) -> Union[int, _default]: ...
def east_asian_width(unichr: unicode): str
def lookup(name: str): unicode
def mirrored(unichr: unicode): int
def name(chr: unicode, default=_default) -> Union[str, _default]: ...
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
# The methods below are constructed from the same array in C
# (unicodedata_functions) and hence identical to the methods above.
def bidirectional(unichr: unicode) -> str: ...
def category(unichr: unicode) -> str: ...
def combining(unichr: unicode) -> int: ...
def decimal(chr: unicode, default=_default) -> Union[int, _default]: ...
def decomposition(unichr: unicode) -> str: ...
def digit(chr: unicode, default=_default) -> Union[int, _default]: ...
def east_asian_width(unichr: unicode): str
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 bidirectional(self, unichr: unicode) -> str: ...
def category(self, unichr: unicode) -> str: ...
def combining(self, unichr: unicode) -> int: ...
def decimal(self, chr: unicode, default: _default = ...) -> Union[int, _default]: ...
def decomposition(self, unichr: unicode) -> str: ...
def digit(self, chr: unicode, default: _default = ...) -> Union[int, _default]: ...
def east_asian_width(self, unichr: unicode): str
def lookup(self, name: str): unicode
def mirrored(self, unichr: unicode): int
def name(self, chr: unicode, default: _default = ...) -> Union[str, _default]: ...
def normalize(self, form: str, unistr: unicode) -> unicode: ...
def numeric(self, chr: unicode, default: _default = ...) -> Union[float, _default]: ...
8 changes: 4 additions & 4 deletions builtins/2.7/zipimport.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Stub file for the 'zipimport' module."""

from typing import Dict, Optional
from types import CodeType
from types import CodeType, ModuleType

class ZipImportError(ImportError):
pass
Expand All @@ -14,12 +14,12 @@ class zipimporter(object):
_files = ... # type: Dict[str, tuple]
def __init__(self, path: str) -> None:
raise ZipImportError
def find_module(self, fullname: str, path: str = ...) -> Optional[zipimporter]: ...
def get_code(self, fullname: str) -> types.CodeType: ...
def find_module(self, fullname: str, path: str = ...) -> Optional['zipimporter']: ...
def get_code(self, fullname: str) -> CodeType: ...
def get_data(self, fullname: str) -> str:
raise IOError
def get_filename(self, fullname: str) -> str: ...
def get_source(self, fullname: str) -> str: ...
def is_package(self, fullname: str) -> bool: ...
def load_module(self, fullname: str) -> module: ...
def load_module(self, fullname: str) -> ModuleType: ...

5 changes: 4 additions & 1 deletion builtins/2and3/math.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

from typing import Tuple, Iterable, Optional

import sys

e = ... # type: float
pi = ... # type: float

Expand Down Expand Up @@ -31,7 +33,8 @@ def fsum(iterable: Iterable) -> float: ...
def gamma(x: float) -> float: ...
def hypot(x: float, y: float) -> float: ...
def isinf(x: float) -> bool: ...
def isfinite(x: float) -> bool: ...
if sys.version_info[0] >= 3:
def isfinite(x: float) -> bool: ...
def isnan(x: float) -> bool: ...
def ldexp(x: float, i: int) -> float: ...
def lgamma(x: float) -> float: ...
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion builtins/3/_codecs.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Stub file for the '_codecs' module."""

from typing import Any, AnyStr, Callable, Tuple, Optional
from typing import Any, AnyStr, Callable, Tuple, Optional, Dict

import codecs

Expand Down
2 changes: 1 addition & 1 deletion builtins/3/_warnings.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any
from typing import Any, List

_defaultaction = ... # type: str
_onceregistry = ... # type: dict
Expand Down
File renamed without changes.
Loading