From dd042b3255291dce0a8b7c43cdf8ecc18a76bc44 Mon Sep 17 00:00:00 2001 From: Matthias Kramm Date: Tue, 15 Sep 2015 13:51:11 -0700 Subject: [PATCH] Improve several stubs. (math, _random, time, etc.) Some of these are derived from mypy/stubs/. --- 2.7/_random.pyi | 26 ++-- 2.7/cStringIO.pyi | 72 +++++----- 2.7/datetime.pyi | 287 +++++++++++++++++++++++++++++---------- 2.7/gc.pyi | 48 +++---- 2.7/math.pyi | 132 +++++++----------- 2.7/operator.pyi | 334 +++++++++++++++------------------------------- 2.7/signal.pyi | 57 ++++---- 2.7/thread.pyi | 63 +++------ 2.7/time.pyi | 38 ++++-- 2.7/zlib.pyi | 57 ++++---- 10 files changed, 538 insertions(+), 576 deletions(-) diff --git a/2.7/_random.pyi b/2.7/_random.pyi index 7cb63a1e8..fca2ccba6 100644 --- a/2.7/_random.pyi +++ b/2.7/_random.pyi @@ -1,20 +1,12 @@ -"""Stub file for the '_random' module.""" -# This is an autogenerated file. It serves as a starting point -# for a more precise manual annotation of this module. -# Feel free to edit the source below, but remove this header when you do. +# Stubs for _random -from typing import Any, List, Tuple, Dict, GenericType +from typing import Optional, Any class Random(object): - def getrandbits(a: int) -> Any: - raise MemoryError() - raise ValueError() - def getstate() -> tuple: ... - def jumpahead(*args, **kwargs) -> None: - raise TypeError() - def random() -> float: ... - def seed(*args, **kwargs) -> None: - raise MemoryError() - def setstate(*args, **kwargs) -> None: - raise TypeError() - raise ValueError() + def __init__(self, seed: x: object = None) -> None: ... + def seed(self, x: object = None) -> None: ... + def getstate(self) -> tuple: ... + def setstate(self, state: tuple) -> None: ... + def random(self) -> float: ... + def getrandbits(self, k: int) -> int: ... + def jumpahead(self, i: int) -> None: ... diff --git a/2.7/cStringIO.pyi b/2.7/cStringIO.pyi index aa0c95a98..2b80621de 100644 --- a/2.7/cStringIO.pyi +++ b/2.7/cStringIO.pyi @@ -1,43 +1,39 @@ -"""Stub file for the 'cStringIO' module.""" -# This is an autogenerated file. It serves as a starting point -# for a more precise manual annotation of this module. -# Feel free to edit the source below, but remove this header when you do. +# Stubs for cStringIO (Python 2.7) +# See https://docs.python.org/2/library/stringio.html -from typing import Any, List, Tuple, Dict, GenericType +from typing import IO, List, Iterable, Iterator, Any, Union -InputType = ... # type: StringI -OutputType = ... # type: StringO -cStringIO_CAPI = ... # type: object +class StringIO(IO[str]): + softspace = ... # type: int -def StringIO(*args, **kwargs) -> Any: ... - - -class StringI(object): - def close() -> None: ... - def flush() -> None: ... - def getvalue(*args, **kwargs) -> str: ... - def isatty() -> bool: ... - def read(*args, **kwargs) -> str: ... - def readline(*args, **kwargs) -> str: ... - def readlines(*args, **kwargs) -> List[str]: ... - def reset() -> None: ... - def seek(a: int, *args, **kwargs) -> None: ... - def tell() -> int: ... - def truncate(*args, **kwargs) -> None: + def __init__(self, s: str = None) -> None: ... + 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() - -class StringO(object): - def close() -> None: ... - def flush() -> None: ... - def getvalue(*args, **kwargs) -> str: ... - def isatty() -> bool: ... - def read(*args, **kwargs) -> str: ... - def readline(*args, **kwargs) -> str: ... - def readlines(*args, **kwargs) -> List[str]: ... + def writable(self) -> bool: ... + def writelines(self, lines: Iterable[str]) -> None: ... + def next(self) -> str: ... + def __iter__(self) -> StringI: ... + def __enter__(self) -> Any: ... + def __exit__(self, exc_type: type, exc_val: Any, exc_tb: Any) -> Any: ... + # only StringO: def reset() -> None: ... - def seek(a: int, *args, **kwargs) -> None: ... - def tell() -> int: ... - def truncate(*args, **kwargs) -> None: - raise IOError() - def write(a) -> None: ... - def writelines(*args, **kwargs) -> None: ... + def write(self, b: Union[str, unicode]) -> None: ... + def writelines(self, lines: Iterable[Union[str, unicode]]) -> None: ... + +InputType = StringIO +OutputType = StringIO + diff --git a/2.7/datetime.pyi b/2.7/datetime.pyi index 54d81cf37..28ee105d7 100644 --- a/2.7/datetime.pyi +++ b/2.7/datetime.pyi @@ -1,76 +1,221 @@ -"""Stub file for the 'datetime' module.""" -# This is an autogenerated file. It serves as a starting point -# for a more precise manual annotation of this module. -# Feel free to edit the source below, but remove this header when you do. +# Stubs for datetime -from typing import Any, List, Tuple, Dict, GenericType +# NOTE: These are incomplete! -max = ... # type: object -min = ... # type: object -resolution = ... # type: object +from typing import Optional, SupportsAbs, Tuple, Union, overload -class date(object): - def __format__(a) -> unicode: - raise ValueError() - def __reduce__() -> tuple: ... - def ctime() -> str: ... - def fromordinal(a: int) -> Any: - raise ValueError() - def fromtimestamp(a: float) -> Any: ... - def isocalendar() -> tuple: ... - def isoformat() -> str: ... - def isoweekday() -> int: ... - def replace(*args, **kwargs) -> Any: ... - def strftime(format) -> Any: ... - def timetuple() -> Any: ... - def today() -> Any: ... - def toordinal() -> int: ... - def weekday() -> int: ... - -class datetime(object): - def __reduce__() -> tuple: ... - def astimezone(tz) -> Any: - raise ValueError() - def combine(date, time) -> Any: ... - def ctime() -> str: ... - def date() -> Any: ... - def dst() -> Any: ... - def fromtimestamp(timestamp: float, *args, **kwargs) -> Any: ... - def isoformat(*args, **kwargs) -> str: ... - def now(*args, **kwargs) -> Any: ... - def replace(*args, **kwargs) -> Any: ... - def strptime(a: str, b: str) -> Any: - raise ValueError() - def time() -> Any: ... - def timetuple() -> Any: ... - def timetz() -> Any: ... - def tzname() -> Any: ... - def utcfromtimestamp(a: float) -> Any: ... - def utcnow() -> Any: ... - def utcoffset() -> Any: ... - def utctimetuple() -> Any: - raise OverflowError() - -class time(object): - def __format__(a) -> unicode: - raise ValueError() - def __reduce__() -> tuple: ... - def dst() -> Any: ... - def isoformat() -> str: ... - def replace(*args, **kwargs) -> Any: ... - def strftime(format) -> Any: ... - def tzname() -> Any: ... - def utcoffset() -> Any: ... - -class timedelta(object): - def __reduce__() -> tuple: ... - def total_seconds() -> int: ... +MINYEAR = 0 +MAXYEAR = 0 class tzinfo(object): - def __reduce__() -> tuple: ... - def dst(*args, **kwargs) -> Any: ... - def fromutc(*args, **kwargs) -> Any: - raise TypeError() - raise ValueError() - def tzname(*args, **kwargs) -> Any: ... - def utcoffset(*args, **kwargs) -> Any: ... + def tzname(self, dt: Optional[datetime]) -> str: ... + def utcoffset(self, dt: Optional[datetime]) -> int: ... + def dst(self, dt: Optional[datetime]) -> int: ... + def fromutc(self, dt: datetime) -> datetime: ... + +class timezone(tzinfo): + utc = ... # type: tzinfo + min = ... # type: tzinfo + max = ... # type: tzinfo + + def __init__(self, offset: timedelta, name: str = '') -> None: ... + def __hash__(self) -> int: ... + +_tzinfo = tzinfo +_timezone = timezone + +class date(object): + min = ... # type: date + max = ... # type: date + resolution = ... # type: timedelta + + def __init__(self, year: int, month: int = None, day: int = None) -> None: ... + + @classmethod + def fromtimestamp(cls, t: float) -> date: ... + @classmethod + def today(cls) -> date: ... + @classmethod + def fromordinal(cls, n: int) -> date: ... + + @property + def year(self) -> int: ... + @property + def month(self) -> int: ... + @property + def day(self) -> int: ... + + def ctime(self) -> str: ... + def strftime(self, fmt: str) -> str: ... + def __format__(self, fmt: Union[str, unicode]) -> str: ... + def isoformat(self) -> str: ... + def timetuple(self) -> tuple: ... # TODO return type + def toordinal(self) -> int: ... + def replace(self, year: int = None, month: int = None, day: int = None) -> date: ... + def __le__(self, other: date) -> bool: ... + def __lt__(self, other: date) -> bool: ... + def __ge__(self, other: date) -> bool: ... + def __gt__(self, other: date) -> bool: ... + def __add__(self, other: timedelta) -> date: ... + @overload + def __sub__(self, other: timedelta) -> date: ... + @overload + def __sub__(self, other: date) -> timedelta: ... + def __hash__(self) -> int: ... + def weekday(self) -> int: ... + def isoweekday(self) -> int: ... + def isocalendar(self) -> Tuple[int, int, int]: ... + +class time: + min = ... # type: time + max = ... # type: time + resolution = ... # type: timedelta + + def __init__(self, hour: int = 0, minute: int = 0, second: int = 0, microsecond: int = 0, + tzinfo: tzinfo = None) -> None: ... + + @property + def hour(self) -> int: ... + @property + def minute(self) -> int: ... + @property + def second(self) -> int: ... + @property + def microsecond(self) -> int: ... + @property + def tzinfo(self) -> _tzinfo: ... + + def __le__(self, other: time) -> bool: ... + def __lt__(self, other: time) -> bool: ... + def __ge__(self, other: time) -> bool: ... + def __gt__(self, other: time) -> bool: ... + def __hash__(self) -> int: ... + def isoformat(self) -> str: ... + def strftime(self, fmt: str) -> str: ... + def __format__(self, fmt: str) -> str: ... + def utcoffset(self) -> Optional[int]: ... + def tzname(self) -> Optional[str]: ... + def dst(self) -> Optional[int]: ... + def replace(self, hour: int = None, minute: int = None, second: int = None, + microsecond: int = None, tzinfo: Union[_tzinfo, bool] = True) -> time: ... + +_date = date +_time = time + +class timedelta(SupportsAbs[timedelta]): + min = ... # type: timedelta + max = ... # type: timedelta + resolution = ... # type: timedelta + + def __init__(self, days: int = 0, seconds: int = 0, microseconds: int = 0, + milliseconds: int = 0, minutes: int = 0, hours: int = 0, + weeks: int = 0) -> None: ... + + @property + def days(self) -> int: ... + @property + def seconds(self) -> int: ... + @property + def microseconds(self) -> int: ... + + def total_seconds(self) -> float: ... + def __add__(self, other: timedelta) -> timedelta: ... + def __radd__(self, other: timedelta) -> timedelta: ... + def __sub__(self, other: timedelta) -> timedelta: ... + def __rsub(self, other: timedelta) -> timedelta: ... + def __neg__(self) -> timedelta: ... + def __pos__(self) -> timedelta: ... + def __abs__(self) -> timedelta: ... + def __mul__(self, other: float) -> timedelta: ... + def __rmul__(self, other: float) -> timedelta: ... + @overload + def __floordiv__(self, other: timedelta) -> int: ... + @overload + def __floordiv__(self, other: int) -> timedelta: ... + @overload + def __truediv__(self, other: timedelta) -> float: ... + @overload + def __truediv__(self, other: float) -> timedelta: ... + def __mod__(self, other: timedelta) -> timedelta: ... + def __divmod__(self, other: timedelta) -> Tuple[int, timedelta]: ... + def __le__(self, other: timedelta) -> bool: ... + def __lt__(self, other: timedelta) -> bool: ... + def __ge__(self, other: timedelta) -> bool: ... + def __gt__(self, other: timedelta) -> bool: ... + def __hash__(self) -> int: ... + +class datetime(object): + # TODO: is actually subclass of date, but __le__, __lt__, __ge__, __gt__ don't work with date. + min = ... # type: datetime + max = ... # type: datetime + resolution = ... # type: timedelta + + def __init__(self, year: int, month: int = None, day: int = None, hour: int = None, + minute: int = None, second: int = None, microseconds: int = None, + tzinfo: tzinfo = None) -> None: ... + + @property + def year(self) -> int: ... + @property + def month(self) -> int: ... + @property + def day(self) -> int: ... + @property + def hour(self) -> int: ... + @property + def minute(self) -> int: ... + @property + def second(self) -> int: ... + @property + def microsecond(self) -> int: ... + @property + def tzinfo(self) -> _tzinfo: ... + + @classmethod + def fromtimestamp(cls, t: float, tz: timezone = None) -> datetime: ... + @classmethod + def utcfromtimestamp(cls, t: float) -> datetime: ... + @classmethod + def today(cls) -> datetime: ... + @classmethod + def fromordinal(cls, n: int) -> datetime: ... + @classmethod + def now(cls, tz: timezone = None) -> datetime: ... + @classmethod + def utcnow(cls) -> datetime: ... + @classmethod + def combine(cls, date: date, time: time) -> datetime: ... + def strftime(self, fmt: str) -> str: ... + def __format__(self, fmt: str) -> str: ... + def toordinal(self) -> int: ... + def timetuple(self) -> tuple: ... # TODO return type + def timestamp(self) -> float: ... + def utctimetuple(self) -> tuple: # TODO return type + raise OverflowError() + def date(self) -> _date: ... + def time(self) -> _time: ... + def timetz(self) -> _time: ... + def replace(self, year: int = None, month: int = None, day: int = None, hour: int = None, + minute: int = None, second: int = None, microsecond: int = None, tzinfo: + Union[_tzinfo, bool] = True) -> datetime: ... + def astimezone(self, tz: timezone = None) -> datetime: ... + def ctime(self) -> str: ... + def isoformat(self, sep: str = 'T') -> str: ... + @classmethod + def strptime(cls, date_string: str, format: str) -> datetime: ... + def utcoffset(self) -> Optional[int]: ... + def tzname(self) -> Optional[str]: ... + def dst(self) -> Optional[int]: ... + def __le__(self, other: datetime) -> bool: ... + def __lt__(self, other: datetime) -> bool: ... + def __ge__(self, other: datetime) -> bool: ... + def __gt__(self, other: datetime) -> bool: ... + def __add__(self, other: timedelta) -> datetime: ... + @overload + def __sub__(self, other: datetime) -> timedelta: ... + @overload + def __sub__(self, other: timedelta) -> datetime: ... + def __hash__(self) -> int: ... + def weekday(self) -> int: ... + def isoweekday(self) -> int: ... + def isocalendar(self) -> Tuple[int, int, int]: ... diff --git a/2.7/gc.pyi b/2.7/gc.pyi index 1204781ff..3b8a43bac 100644 --- a/2.7/gc.pyi +++ b/2.7/gc.pyi @@ -1,33 +1,27 @@ -"""Stub file for the 'gc' module.""" -# This is an autogenerated file. It serves as a starting point -# for a more precise manual annotation of this module. -# Feel free to edit the source below, but remove this header when you do. +# Stubs for gc (Python 2) -from typing import Any, List, Tuple, Dict, GenericType - -def collect(*args, **kwargs) -> int: - raise ValueError() - -def disable() -> None: ... +from typing import List, Any, Tuple def enable() -> None: ... - -def get_count() -> tuple: ... - -def get_debug() -> int: ... - -def get_objects() -> list: ... - -def get_referents(*args, **kwargs) -> list: ... - -def get_referrers(*args, **kwargs) -> list: ... - -def get_threshold() -> tuple: ... - -def is_tracked(*args, **kwargs) -> bool: ... - +def disable() -> None: ... def isenabled() -> bool: ... +def collect(generation: int = None) -> int: ... +def set_debug(flags: int) -> None: ... +def get_debug() -> int: ... +def get_objects() -> List[Any]: ... +def set_threshold(threshold0: int, threshold1: int = None, threshold2: int = None) -> None: ... +def get_count() -> Tuple[int, int, int]: ... +def get_threshold() -> Tuple[int, int, int]: ... +def get_referrers(*objs: Any) -> List[Any]: ... +def get_referents(*objs: Any) -> List[Any]: ... +def is_tracked(obj: Any) -> bool: ... -def set_debug(a: int) -> None: ... +garbage = ... # type: List[Any] -def set_threshold(a: int, *args, **kwargs) -> None: ... +DEBUG_STATS = ... # type: Any +DEBUG_COLLECTABLE = ... # type: Any +DEBUG_UNCOLLECTABLE = ... # type: Any +DEBUG_INSTANCES = ... # type: Any +DEBUG_OBJECTS = ... # type: Any +DEBUG_SAVEALL = ... # type: Any +DEBUG_LEAK = ... # type: Any diff --git a/2.7/math.pyi b/2.7/math.pyi index 4c096d67a..19a101a01 100644 --- a/2.7/math.pyi +++ b/2.7/math.pyi @@ -1,90 +1,48 @@ -"""Stub file for the 'math' module.""" -# This is an autogenerated file. It serves as a starting point -# for a more precise manual annotation of this module. -# Feel free to edit the source below, but remove this header when you do. +# Stubs for math +# See: http://docs.python.org/2/library/math.html -from typing import Any, List, Tuple, Dict, GenericType +from typing import Tuple, Iterable, Optional -def acos(*args, **kwargs) -> float: ... +e = ... # type: float +pi = ... # type: float -def acosh(*args, **kwargs) -> float: ... - -def asin(*args, **kwargs) -> float: ... - -def asinh(*args, **kwargs) -> float: ... - -def atan(*args, **kwargs) -> float: ... - -def atan2(*args, **kwargs) -> float: ... - -def atanh(*args, **kwargs) -> float: ... - -def ceil(*args, **kwargs) -> float: ... - -def copysign(*args, **kwargs) -> float: ... - -def cos(*args, **kwargs) -> float: ... - -def cosh(*args, **kwargs) -> float: ... - -def degrees(*args, **kwargs) -> float: ... - -def erf(*args, **kwargs) -> float: ... - -def erfc(*args, **kwargs) -> float: ... - -def exp(*args, **kwargs) -> float: ... - -def expm1(*args, **kwargs) -> float: ... - -def fabs(*args, **kwargs) -> float: ... - -def factorial(*args, **kwargs) -> int: - raise ValueError() - -def floor(*args, **kwargs) -> float: ... - -def fmod(*args, **kwargs) -> float: ... - -def frexp(*args, **kwargs) -> tuple: ... - -def fsum(*args, **kwargs) -> float: - raise OverflowError() - raise ValueError() - -def gamma(*args, **kwargs) -> float: ... - -def hypot(*args, **kwargs) -> float: ... - -def isinf(*args, **kwargs) -> bool: ... - -def isnan(*args, **kwargs) -> bool: ... - -def ldexp(a: float, b) -> float: - raise TypeError() - -def lgamma(*args, **kwargs) -> float: ... - -def log(*args, **kwargs) -> float: ... - -def log10(*args, **kwargs) -> float: ... - -def log1p(*args, **kwargs) -> float: ... - -def modf(*args, **kwargs) -> tuple: ... - -def pow(*args, **kwargs) -> float: ... - -def radians(*args, **kwargs) -> float: ... - -def sin(*args, **kwargs) -> float: ... - -def sinh(*args, **kwargs) -> float: ... - -def sqrt(*args, **kwargs) -> float: ... - -def tan(*args, **kwargs) -> float: ... - -def tanh(*args, **kwargs) -> float: ... - -def trunc(*args, **kwargs) -> Any: ... +def acos(x: float) -> float: ... +def acosh(x: float) -> float: ... +def asin(x: float) -> float: ... +def asinh(x: float) -> float: ... +def atan(x: float) -> float: ... +def atan2(y: float, x: float) -> float: ... +def atanh(x: float) -> float: ... +def ceil(x: float) -> int: ... +def copysign(x: float, y: float) -> float: ... +def cos(x: float) -> float: ... +def cosh(x: float) -> float: ... +def degrees(x: float) -> float: ... +def erf(x: float) -> float: ... +def erfc(x: float) -> float: ... +def exp(x: float) -> float: ... +def expm1(x: float) -> float: ... +def fabs(x: float) -> float: ... +def factorial(x: int) -> int: ... +def floor(x: float) -> float: ... +def fmod(x: float, y: float) -> float: ... +def frexp(x: float) -> Tuple[float, int]: ... +def fsum(iterable: Iterable) -> float: ... +def gamma(x: float) -> float: ... +def hypot(x: float, y: float) -> float: ... +def isinf(x: float) -> bool: ... +def isnan(x: float) -> bool: ... +def ldexp(x: float, i: int) -> float: ... +def lgamma(x: float) -> float: ... +def log(x: float, base: Optional[float]) -> float: ... +def log10(x: float) -> float: ... +def log1p(x: float) -> float: ... +def modf(x: float) -> Tuple[float, float]: ... +def pow(x: float, y: float) -> float: ... +def radians(x: float) -> float: ... +def sin(x: float) -> float: ... +def sinh(x: float) -> float: ... +def sqrt(x: float) -> float: ... +def tan(x: float) -> float: ... +def tanh(x: float) -> float: ... +def trunc(x: float) -> int: ... diff --git a/2.7/operator.pyi b/2.7/operator.pyi index e27bd1cb7..91ea86f84 100644 --- a/2.7/operator.pyi +++ b/2.7/operator.pyi @@ -1,236 +1,124 @@ -"""Stub file for the 'operator' module.""" -# This is an autogenerated file. It serves as a starting point -# for a more precise manual annotation of this module. -# Feel free to edit the source below, but remove this header when you do. +# Stubs for operator -from typing import Any, List, Tuple, Dict, GenericType - -def __abs__(*args, **kwargs) -> Any: ... - -def __add__(*args, **kwargs) -> Any: ... - -def __and__(*args, **kwargs) -> Any: ... - -def __concat__(*args, **kwargs) -> Any: ... - -def __contains__(*args, **kwargs) -> bool: ... - -def __delitem__(*args, **kwargs) -> None: ... - -def __delslice__(a, b: int, c: int) -> None: ... - -def __div__(*args, **kwargs) -> Any: ... - -def __eq__(*args, **kwargs) -> Any: ... - -def __floordiv__(*args, **kwargs) -> Any: ... - -def __ge__(*args, **kwargs) -> Any: ... - -def __getitem__(*args, **kwargs) -> Any: ... - -def __getslice__(a, b: int, c: int) -> Any: ... - -def __gt__(*args, **kwargs) -> Any: ... - -def __iadd__(*args, **kwargs) -> Any: ... - -def __iand__(*args, **kwargs) -> Any: ... - -def __iconcat__(*args, **kwargs) -> Any: ... - -def __idiv__(*args, **kwargs) -> Any: ... - -def __ifloordiv__(*args, **kwargs) -> Any: ... - -def __ilshift__(*args, **kwargs) -> Any: ... - -def __imod__(*args, **kwargs) -> Any: ... - -def __imul__(*args, **kwargs) -> Any: ... - -def __index__(*args, **kwargs) -> Any: ... - -def __inv__(*args, **kwargs) -> Any: ... - -def __invert__(*args, **kwargs) -> Any: ... - -def __ior__(*args, **kwargs) -> Any: ... - -def __ipow__(*args, **kwargs) -> Any: ... - -def __irepeat__(a, b: int) -> Any: ... - -def __irshift__(*args, **kwargs) -> Any: ... - -def __isub__(*args, **kwargs) -> Any: ... - -def __itruediv__(*args, **kwargs) -> Any: ... - -def __ixor__(*args, **kwargs) -> Any: ... - -def __le__(*args, **kwargs) -> Any: ... - -def __lshift__(*args, **kwargs) -> Any: ... - -def __lt__(*args, **kwargs) -> Any: ... - -def __mod__(*args, **kwargs) -> Any: ... - -def __mul__(*args, **kwargs) -> Any: ... - -def __ne__(*args, **kwargs) -> Any: ... - -def __neg__(*args, **kwargs) -> Any: ... - -def __not__(*args, **kwargs) -> bool: ... - -def __or__(*args, **kwargs) -> Any: ... - -def __pos__(*args, **kwargs) -> Any: ... - -def __pow__(*args, **kwargs) -> Any: ... +from typing import Any +def __abs__(a: Any) -> Any: ... +def __add__(a: Any, b: Any) -> Any: ... +def __and__(a: Any, b: Any) -> Any: ... +def __concat__(a: Any, b: Any) -> Any: ... +def __contains__(container: Any, item: Any) -> bool: ... +def __delitem__(container: Any, item: Any) -> None: ... +def __delslice__(container: Any, b: int, c: int) -> None: ... +def __div__(a: Any, b: Any) -> Any: ... +def __eq__(a: Any, b: Any) -> Any: ... +def __floordiv__(a: Any, b: Any) -> Any: ... +def __ge__(a: Any, b: Any) -> Any: ... +def __getitem__(container: Any, key: Any) -> Any: ... +def __getslice__(container, b: int, c: int) -> Any: ... +def __gt__(a: Any, b: Any) -> Any: ... +def __iadd__(a: Any, b: Any) -> Any: ... +def __iand__(a: Any, b: Any) -> Any: ... +def __iconcat__(a: Any, b: Any) -> Any: ... +def __idiv__(a: Any, b: Any) -> Any: ... +def __ifloordiv__(a: Any, b: Any) -> Any: ... +def __ilshift__(a: Any, b: Any) -> Any: ... +def __imod__(a: Any, b: Any) -> Any: ... +def __imul__(a: Any, b: Any) -> Any: ... +def __index__(x: Any) -> Any: ... +def __inv__(x: Any) -> Any: ... +def __invert__(x: Any) -> Any: ... +def __ior__(a: Any, b: Any) -> Any: ... +def __ipow__(a: Any, b: Any) -> Any: ... +def __irepeat__(a: Any, b: int) -> Any: ... +def __irshift__(a: Any, b: Any) -> Any: ... +def __isub__(a: Any, b: Any) -> Any: ... +def __itruediv__(a: Any, b: Any) -> Any: ... +def __ixor__(a: Any, b: Any) -> Any: ... +def __le__(a: Any, b: Any) -> Any: ... +def __lshift__(a: Any, b: Any) -> Any: ... +def __lt__(a: Any, b: Any) -> Any: ... +def __mod__(a: Any, b: Any) -> Any: ... +def __mul__(a: Any, b: Any) -> Any: ... +def __ne__(a: Any, b: Any) -> Any: ... +def __neg__(x: Any) -> Any: ... +def __not__(x: Any) -> bool: ... +def __or__(a: Any, b: Any) -> Any: ... +def __pos__(x: Any) -> Any: ... +def __pow__(a: Any, b: Any) -> Any: ... def __repeat__(a, b: int) -> Any: ... - -def __rshift__(*args, **kwargs) -> Any: ... - -def __setitem__(*args, **kwargs) -> None: ... - -def __setslice__(a, b: int, c: int, d) -> None: ... - -def __sub__(*args, **kwargs) -> Any: ... - -def __truediv__(*args, **kwargs) -> Any: ... - -def __xor__(*args, **kwargs) -> Any: ... +def __rshift__(a: Any, b: Any) -> Any: ... +def __setitem__(container: Any, b: Any) -> None: ... +def __setslice__(container: Any, b: int, c: int, item: Any) -> None: ... +def __sub__(a: Any, b: Any) -> Any: ... +def __truediv__(a: Any, b: Any) -> Any: ... +def __xor__(a: Any, b: Any) -> Any: ... def abs(*args, **kwargs) -> Any: ... - -def add(*args, **kwargs) -> Any: ... - -def and_(*args, **kwargs) -> Any: ... - -def concat(*args, **kwargs) -> Any: ... - -def contains(*args, **kwargs) -> bool: ... - -def countOf(*args, **kwargs) -> int: ... - -def delitem(*args, **kwargs) -> None: ... - -def delslice(a, b: int, c: int) -> None: ... - -def div(*args, **kwargs) -> Any: ... - -def eq(*args, **kwargs) -> Any: ... - -def floordiv(*args, **kwargs) -> Any: ... - -def ge(*args, **kwargs) -> Any: ... - -def getitem(*args, **kwargs) -> Any: ... - -def getslice(a, b: int, c: int) -> Any: ... - -def gt(*args, **kwargs) -> Any: ... - -def iadd(*args, **kwargs) -> Any: ... - -def iand(*args, **kwargs) -> Any: ... - -def iconcat(*args, **kwargs) -> Any: ... - -def idiv(*args, **kwargs) -> Any: ... - -def ifloordiv(*args, **kwargs) -> Any: ... - -def ilshift(*args, **kwargs) -> Any: ... - -def imod(*args, **kwargs) -> Any: ... - -def imul(*args, **kwargs) -> Any: ... - -def index(*args, **kwargs) -> Any: ... - -def indexOf(*args, **kwargs) -> int: ... - -def inv(*args, **kwargs) -> Any: ... - -def invert(*args, **kwargs) -> Any: ... - -def ior(*args, **kwargs) -> Any: ... - -def ipow(*args, **kwargs) -> Any: ... - +def add(a: Any, b: Any) -> Any: ... +def and_(a: Any, b: Any) -> Any: ... +def concat(a: Any, b: Any) -> Any: ... +def contains(container: Any, item: Any) -> bool: ... +def countOf(container: Any, item: Any) -> int: ... +def delitem(container: Any, item: Any) -> None: ... +def delslice(container: Any, b: int, c: int) -> None: ... +def div(a: Any, b: Any) -> Any: ... +def eq(a: Any, b: Any) -> Any: ... +def floordiv(a: Any, b: Any) -> Any: ... +def ge(a: Any, b: Any) -> Any: ... +def getitem(a: Any, b: Any) -> Any: ... +def getslice(container: Any, b: int, c: int) -> Any: ... +def gt(a: Any, b: Any) -> Any: ... +def iadd(a: Any, b: Any) -> Any: ... +def iand(a: Any, b: Any) -> Any: ... +def iconcat(a: Any, b: Any) -> Any: ... +def idiv(a: Any, b: Any) -> Any: ... +def ifloordiv(a: Any, b: Any) -> Any: ... +def ilshift(a: Any, b: Any) -> Any: ... +def imod(a: Any, b: Any) -> Any: ... +def imul(a: Any, b: Any) -> Any: ... +def index(x: Any) -> Any: ... +def indexOf(container: Any, item: Any) -> int: ... +def inv(x: Any) -> Any: ... +def invert(x: Any) -> Any: ... +def ior(a: Any, b: Any) -> Any: ... +def ipow(a: Any, b: Any) -> Any: ... def irepeat(a, b: int) -> Any: ... - -def irshift(*args, **kwargs) -> Any: ... - -def isCallable(*args, **kwargs) -> bool: ... - -def isMappingType(*args, **kwargs) -> bool: ... - -def isNumberType(*args, **kwargs) -> bool: ... - -def isSequenceType(*args, **kwargs) -> bool: ... - -def is_(*args, **kwargs) -> bool: ... - -def is_not(*args, **kwargs) -> bool: ... - -def isub(*args, **kwargs) -> Any: ... - -def itruediv(*args, **kwargs) -> Any: ... - -def ixor(*args, **kwargs) -> Any: ... - -def le(*args, **kwargs) -> Any: ... - -def lshift(*args, **kwargs) -> Any: ... - -def lt(*args, **kwargs) -> Any: ... - -def mod(*args, **kwargs) -> Any: ... - -def mul(*args, **kwargs) -> Any: ... - -def ne(*args, **kwargs) -> Any: ... - -def neg(*args, **kwargs) -> Any: ... - -def not_(*args, **kwargs) -> bool: ... - -def or_(*args, **kwargs) -> Any: ... - -def pos(*args, **kwargs) -> Any: ... - -def pow(*args, **kwargs) -> Any: ... - +def irshift(a: Any, b: Any) -> Any: ... +def isCallable(x: Any) -> bool: ... +def isMappingType(x: Any) -> bool: ... +def isNumberType(x: Any) -> bool: ... +def isSequenceType(x: Any) -> bool: ... +def is_(a: Any, b: Any) -> bool: ... +def is_not(a: Any, b: Any) -> bool: ... +def isub(a: Any, b: Any) -> Any: ... +def itruediv(a: Any, b: Any) -> Any: ... +def ixor(a: Any, b: Any) -> Any: ... +def le(a: Any, b: Any) -> Any: ... +def lshift(a: Any, b: Any) -> Any: ... +def lt(a: Any, b: Any) -> Any: ... +def mod(a: Any, b: Any) -> Any: ... +def mul(a: Any, b: Any) -> Any: ... +def ne(a: Any, b: Any) -> Any: ... +def neg(x: Any) -> Any: ... +def not_(x: Any) -> bool: ... +def or_(a: Any, b: Any) -> Any: ... +def pos(x: Any) -> Any: ... +def pow(a: Any, b: Any) -> Any: ... def repeat(a, b: int) -> Any: ... - -def rshift(*args, **kwargs) -> Any: ... - -def sequenceIncludes(*args, **kwargs) -> bool: ... - -def setitem(*args, **kwargs) -> None: ... - -def setslice(a, b: int, c: int, d) -> None: ... - -def sub(*args, **kwargs) -> Any: ... - -def truediv(*args, **kwargs) -> Any: ... - -def truth(*args, **kwargs) -> bool: ... - -def xor(*args, **kwargs) -> Any: ... - +def rshift(a: Any, b: Any) -> Any: ... +def sequenceIncludes(seq1: Any, seq2: Any) -> bool: ... +def setitem(container: Any, key: Any, item: Any) -> None: ... +def setslice(container: Any, b: int, c: int, slice: Any) -> None: ... +def sub(a: Any, b: Any) -> Any: ... +def truediv(a: Any, b: Any) -> Any: ... +def truth(x: Any) -> bool: ... +def xor(a: Any, b: Any) -> Any: ... class attrgetter(object): - pass + def __init__(self, name: Any): ... class itemgetter(object): - pass + def __init__(self, key: Any): ... class methodcaller(object): - pass + def __init__(self, method_name: str, *args, **kwargs): ... diff --git a/2.7/signal.pyi b/2.7/signal.pyi index 335c0675a..3f9cdc23a 100644 --- a/2.7/signal.pyi +++ b/2.7/signal.pyi @@ -1,15 +1,11 @@ -"""Stub file for the 'signal' module.""" -# This is an autogenerated file. It serves as a starting point -# for a more precise manual annotation of this module. -# Feel free to edit the source below, but remove this header when you do. +from typing import Callable, Any, Tuple, Union -from typing import Any, List, Tuple, Dict, GenericType - -ITIMER_PROF = ... # type: long +SIG_DFL = ... # type: long +SIG_IGN = ... # type: long ITIMER_REAL = ... # type: long ITIMER_VIRTUAL = ... # type: long -ItimerError = ... # type: object -NSIG = ... # type: int +ITIMER_PROF = ... # type: long + SIGABRT = ... # type: int SIGALRM = ... # type: int SIGBUS = ... # type: int @@ -45,31 +41,26 @@ SIGVTALRM = ... # type: int SIGWINCH = ... # type: int SIGXCPU = ... # type: int SIGXFSZ = ... # type: int -SIG_DFL = ... # type: long -SIG_IGN = ... # type: long +NSIG = ... # type: int -def alarm(a: int) -> 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] + +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 siginterrupt(signalnum: int, flag: bool) -> None: + raise RuntimeError() +def signal(signalnum: int, handler: _HANDLER) -> None: + raise RuntimeError() def default_int_handler(*args, **kwargs) -> Any: raise KeyboardInterrupt() - -def getitimer(a: int) -> tuple: ... - -def getsignal(a: int) -> None: - raise ValueError() - -def pause() -> None: ... - -def set_wakeup_fd(a: int) -> long: - raise ValueError() - -def setitimer(a: int, b: float, *args, **kwargs) -> tuple: ... - -def siginterrupt(a: int, b: int) -> None: - raise RuntimeError() - raise ValueError() - -def signal(a: int, b) -> None: - raise RuntimeError() - raise TypeError() - raise ValueError() diff --git a/2.7/thread.pyi b/2.7/thread.pyi index bddfbc1b9..7688ad921 100644 --- a/2.7/thread.pyi +++ b/2.7/thread.pyi @@ -1,40 +1,18 @@ -"""Stub file for the 'thread' module.""" -# This is an autogenerated file. It serves as a starting point -# for a more precise manual annotation of this module. -# Feel free to edit the source below, but remove this header when you do. - -from typing import Any, List, Tuple, Dict, GenericType - -LockType = ... # type: lock -error = ... # type: object +from typing import Callable, Any def _count() -> int: ... -def allocate() -> lock: ... - -def allocate_lock() -> lock: ... - -def exit() -> Any: - raise SystemExit() - -def exit_thread() -> Any: - raise SystemExit() - -def get_ident() -> int: ... - -def interrupt_main() -> None: ... - -def stack_size(*args, **kwargs) -> int: - raise ValueError() - -def start_new(*args, **kwargs) -> int: - raise MemoryError() - raise TypeError() - -def start_new_thread(*args, **kwargs) -> int: - raise MemoryError() - raise TypeError() +class error(Exception): ... +class LockType: + def acquire(self, waitflag: int = None) -> bool: ... + def acquire_lock(self, waitflag: int = None) -> bool: ... + def release(self) -> None: ... + def release_lock(self) -> None: ... + def locked(self) -> bool: ... + def locked_lock(self) -> bool: ... + def __enter__(self) -> LockType: ... + def __exit__(self, value: Any, traceback: Any) -> None: ... class _local(object): pass @@ -42,12 +20,13 @@ class _local(object): class _localdummy(object): pass -class lock(object): - def __enter__(*args, **kwargs) -> bool: ... - def __exit__(*args, **kwargs) -> None: ... - def acquire(*args, **kwargs) -> bool: ... - def acquire_lock(*args, **kwargs) -> bool: ... - def locked() -> bool: ... - def locked_lock() -> bool: ... - def release() -> None: ... - def release_lock() -> None: ... +def start_new(function: Callable[..., Any], args: Any, kwargs: Any = None) -> int: ... +def start_new_thread(function: Callable[..., Any], args: Any, kwargs: Any = None) -> int: ... +def interrupt_main() -> None: ... +def exit() -> None: ... + raise SystemExit() +def exit_thread() -> Any: + raise SystemExit() +def allocate_lock() -> LockType: ... +def get_ident() -> int: ... +def stack_size(size: int = None) -> int: ... diff --git a/2.7/time.pyi b/2.7/time.pyi index d414961be..265dc0612 100644 --- a/2.7/time.pyi +++ b/2.7/time.pyi @@ -1,32 +1,46 @@ """Stub file for the 'time' module.""" -# This is an autogenerated file. It serves as a starting point -# for a more precise manual annotation of this module. -# Feel free to edit the source below, but remove this header when you do. +# See https://docs.python.org/2/library/time.html -from typing import Any, List, Tuple, Dict, GenericType +from typing import NamedTuple, Tuple, Union -def asctime(*args, **kwargs) -> str: +# ----- variables and constants ----- +accept2dyear = False +altzone = 0 +daylight = 0 +timezone = 0 +tzname = ... # type: Tuple[str, str] + +struct_time = NamedTuple('struct_time', + [('tm_year', int), ('tm_mon', int), ('tm_mday', int), + ('tm_hour', int), ('tm_min', int), ('tm_sec', int), + ('tm_wday', int), ('tm_yday', int), ('tm_isdst', int)]) + +_TIME_TUPLE = Tuple[int, int, int, int, int, int, int, int, int] + +def asctime(t: struct_time = None) -> str: raise ValueError() def clock() -> float: ... -def ctime(*args, **kwargs) -> str: +def ctime(secs: float = None) -> str: raise ValueError() -def gmtime(*args, **kwargs) -> tuple: ... +def gmtime(secs: float = None) -> struct_time: ... -def localtime(*args, **kwargs) -> tuple: ... +def localtime(secs: float = None) -> struct_time: ... -def mktime(*args, **kwargs) -> float: +def mktime(t: struct_time) -> float: raise OverflowError() + raise ValueError() -def sleep(a: float) -> None: ... +def sleep(secs: float) -> None: ... -def strftime(a: str, *args, **kwargs) -> str: +def strftime(format: str, t: struct_time = None) -> str: raise MemoryError() raise ValueError() -def strptime(*args, **kwargs) -> Any: ... +def strptime(string: str, format: str = "%a %b %d %H:%M:%S %Y") -> struct_time: + raise ValueError() def time() -> float: raise IOError() diff --git a/2.7/zlib.pyi b/2.7/zlib.pyi index 832654824..d431f3bd5 100644 --- a/2.7/zlib.pyi +++ b/2.7/zlib.pyi @@ -1,31 +1,36 @@ -"""Stub file for the 'zlib' module.""" -# This is an autogenerated file. It serves as a starting point -# for a more precise manual annotation of this module. -# Feel free to edit the source below, but remove this header when you do. +# Stubs for zlib (Python 2.7) -from typing import Any, List, Tuple, Dict, GenericType +class error(Exception): ... -def adler32(a, *args, **kwargs) -> int: ... +DEFLATED = ... # type: int +DEF_MEM_LEVEL = ... # type: int +MAX_WBITS = ... # type: int +ZLIB_VERSION = ... # type: str +Z_BEST_COMPRESSION = ... # type: int +Z_BEST_SPEED = ... # type: int +Z_DEFAULT_COMPRESSION = ... # type: int +Z_DEFAULT_STRATEGY = ... # type: int +Z_FILTERED = ... # type: int +Z_FINISH = ... # type: int +Z_FULL_FLUSH = ... # type: int +Z_HUFFMAN_ONLY = ... # type: int +Z_NO_FLUSH = ... # type: int +Z_SYNC_FLUSH = ... # type: int -def compress(a, *args, **kwargs) -> str: - raise MemoryError() +def adler32(data: str, value: int = ...) -> int: ... +def compress(data: str, level: int = ...) -> str: ... +def crc32(data: str, value: int = ...) -> int: ... +def decompress(data: str, wbits: int = ..., bufsize: int = ...) -> str: ... -def compressobj(*args, **kwargs) -> Any: - raise MemoryError() - raise ValueError() +class compressobj: + def __init__(level: int = ..., method: int = ..., wbits: int = ..., memlevel: int = ..., + strategy: int = ...): ... + def compress(self, data: str) -> str + def copy(self) -> _Compress + def flush(self) -> NoneType -def crc32(a, *args, **kwargs) -> int: ... - -def decompress(a, *args, **kwargs) -> str: - raise MemoryError() - -def decompressobj(*args, **kwargs) -> Any: - raise MemoryError() - raise ValueError() - - -class Compress(object): - pass - -class Decompress(object): - pass +class decompressobj: + def __init__(wbits: int = ...): ... + def copy(self) -> _Compress + def decompress(self, data: str) -> str + def flush(self) -> NoneType