diff --git a/stdlib/2.7/__builtin__.pyi b/stdlib/2.7/__builtin__.pyi index 3944416fb..e09ebd9eb 100644 --- a/stdlib/2.7/__builtin__.pyi +++ b/stdlib/2.7/__builtin__.pyi @@ -849,7 +849,7 @@ class UnicodeWarning(Warning): ... class BytesWarning(Warning): ... class ResourceWarning(Warning): ... -def eval(s: str) -> Any: ... +def eval(s: str, globals: Dict[str, Any] = ..., locals: Dict[str, Any] = ...) -> Any: ... def cmp(x: Any, y: Any) -> int: ... diff --git a/stdlib/2.7/_weakref.pyi b/stdlib/2.7/_weakref.pyi index cf676344e..9ed024ede 100644 --- a/stdlib/2.7/_weakref.pyi +++ b/stdlib/2.7/_weakref.pyi @@ -10,11 +10,11 @@ class ProxyType(object): # "weakproxy" class ReferenceType(Generic[_T]): # TODO rest of members - def __call__(self) -> Optional[_T]: - ... + def __init__(self, o: _T, callback: Callable[[ReferenceType[_T]], + Any] = ...) -> None: ... + def __call__(self) -> Optional[_T]: ... -def ref(o: _T, callback: Callable[[ReferenceType[_T]], - Any] = ...) -> ReferenceType[_T]: ... +ref = ReferenceType def getweakrefcount(object: Any) -> int: ... def getweakrefs(object: Any) -> int: ... diff --git a/stdlib/2.7/copy.pyi b/stdlib/2.7/copy.pyi index 237f4203a..0661cb7d4 100644 --- a/stdlib/2.7/copy.pyi +++ b/stdlib/2.7/copy.pyi @@ -2,9 +2,9 @@ # NOTE: These are incomplete! -from typing import TypeVar +from typing import TypeVar, Dict, Any _T = TypeVar('_T') -def deepcopy(x: _T) -> _T: ... +def deepcopy(x: _T, memo: Dict[Any, Any] = ...) -> _T: ... def copy(x: _T) -> _T: ... diff --git a/stdlib/2.7/os/__init__.pyi b/stdlib/2.7/os/__init__.pyi index 5c10abd5e..55145c893 100644 --- a/stdlib/2.7/os/__init__.pyi +++ b/stdlib/2.7/os/__init__.pyi @@ -191,7 +191,7 @@ def nice(increment: int) -> int: ... # TODO: plock, popen*, spawn*, P_* -def startfile(path: unicode, operation: str) -> None: ... +def startfile(path: unicode, operation: str = ...) -> None: ... # Windows only def system(command: unicode) -> int: ... def times() -> Tuple[float, float, float, float, float]: ... def wait() -> Tuple[int, int]: ... # Unix only diff --git a/stdlib/2.7/pipes.pyi b/stdlib/2.7/pipes.pyi index 6cfb94ed2..d5f5291e3 100644 --- a/stdlib/2.7/pipes.pyi +++ b/stdlib/2.7/pipes.pyi @@ -4,10 +4,10 @@ class Template: def __init__(self) -> None: ... def reset(self) -> None: ... def clone(self) -> Template: ... - def debug(flag: bool) -> None: ... - def append(cmd: str, kind: str) -> None: ... - def prepend(cmd: str, kind: str) -> None: ... - def open(file: str, mode: str) -> IO[Any]: ... - def copy(infile: str, outfile: str) -> None: ... + def debug(self, flag: bool) -> None: ... + def append(self, cmd: str, kind: str) -> None: ... + def prepend(self, cmd: str, kind: str) -> None: ... + def open(self, file: str, mode: str) -> IO[Any]: ... + def copy(self, infile: str, outfile: str) -> None: ... def quote(s: str) -> str: ... diff --git a/stdlib/2.7/time.pyi b/stdlib/2.7/time.pyi index 8a564c889..79f252637 100644 --- a/stdlib/2.7/time.pyi +++ b/stdlib/2.7/time.pyi @@ -1,19 +1,22 @@ """Stub file for the 'time' module.""" # See https://docs.python.org/2/library/time.html -from typing import NamedTuple, Tuple, Union +from typing import NamedTuple, Tuple, Union, Any # ----- variables and constants ----- -accept2dyear = False +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)]) +class 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)])): + def __init__(self, o: Tuple[int, int, int, + int, int, int, + int, int, int], _arg: Any = ...) -> None: ... _TIME_TUPLE = Tuple[int, int, int, int, int, int, int, int, int] diff --git a/stdlib/2.7/weakref.pyi b/stdlib/2.7/weakref.pyi index 4318b3eb9..93fd9e8e4 100644 --- a/stdlib/2.7/weakref.pyi +++ b/stdlib/2.7/weakref.pyi @@ -4,7 +4,15 @@ from typing import Any import UserDict -from _weakref import getweakrefcount as getweakrefcount, getweakrefs as getweakrefs, ref as ref, proxy as proxy, CallableProxyType as CallableProxyType, ProxyType as ProxyType, ReferenceType as ReferenceType +from _weakref import ( + getweakrefcount as getweakrefcount, + getweakrefs as getweakrefs, + ref as ref, + proxy as proxy, + CallableProxyType as CallableProxyType, + ProxyType as ProxyType, + ReferenceType as ReferenceType +) from _weakrefset import WeakSet as WeakSet from exceptions import ReferenceError as ReferenceError diff --git a/stdlib/2and3/operator.pyi b/stdlib/2and3/operator.pyi index ae5c4ba2d..125ec67c8 100644 --- a/stdlib/2and3/operator.pyi +++ b/stdlib/2and3/operator.pyi @@ -1,6 +1,6 @@ # Stubs for operator -from typing import Any, Callable +from typing import Any, Callable, overload, Tuple def __abs__(a: Any) -> Any: ... def __add__(a: Any, b: Any) -> Any: ... @@ -114,14 +114,22 @@ def truediv(a: Any, b: Any) -> Any: ... def truth(x: Any) -> bool: ... def xor(a: Any, b: Any) -> Any: ... -# Unsupported feature: "If more than one attribute is requested, -# returns a tuple of attributes." +# Unsupported: more than 3 attributes. # Unsupported: on Python 2 the parameter type should be `basestring`. -def attrgetter(attr: str) -> Callable[[Any], Any]: ... +@overload +def attrgetter(attr1: str) -> Callable[[Any], Any]: ... +@overload +def attrgetter(attr1: str, attr2: str) -> Callable[[Any], Tuple[Any, Any]]: ... +@overload +def attrgetter(attr1: str, attr2: str, attr3: str) -> Callable[[Any], Tuple[Any, Any, Any]]: ... -# Unsupported feature: "If multiple items are specified, returns a -# tuple of lookup values." -def itemgetter(item: Any) -> Callable[[Any], Any]: ... +# Unsupported: more than 3 items. +@overload +def itemgetter(item1: Any) -> Callable[[Any], Any]: ... +@overload +def itemgetter(item1: Any, item2: Any) -> Callable[[Any], Tuple[Any, Any]]: ... +@overload +def itemgetter(item1: Any, item2: Any, item3: Any) -> Callable[[Any], Tuple[Any, Any, Any]]: ... # Unsupported: on Python 2 the parameter type should be `basestring`. def methodcaller(name: str, *args, **kwargs) -> Callable[[Any], Any]: ... diff --git a/stdlib/3/copy.pyi b/stdlib/3/copy.pyi index 237f4203a..0661cb7d4 100644 --- a/stdlib/3/copy.pyi +++ b/stdlib/3/copy.pyi @@ -2,9 +2,9 @@ # NOTE: These are incomplete! -from typing import TypeVar +from typing import TypeVar, Dict, Any _T = TypeVar('_T') -def deepcopy(x: _T) -> _T: ... +def deepcopy(x: _T, memo: Dict[Any, Any] = ...) -> _T: ... def copy(x: _T) -> _T: ... diff --git a/stdlib/3/weakref.pyi b/stdlib/3/weakref.pyi index 17f78544d..6e62f0b03 100644 --- a/stdlib/3/weakref.pyi +++ b/stdlib/3/weakref.pyi @@ -13,11 +13,11 @@ _VT = TypeVar('_VT') class ReferenceType(Generic[_T]): # TODO rest of members - def __call__(self) -> Optional[_T]: - ... + def __init__(o: _T, callback: Callable[[ReferenceType[_T]], + Any] = ...) -> None: ... + def __call__(self) -> Optional[_T]: ... -def ref(o: _T, callback: Callable[[ReferenceType[_T]], - Any] = ...) -> ReferenceType[_T]: ... +ref = ReferenceType # TODO callback def proxy(object: _T) -> _T: ...