From d23b504ad39e43cb276355d2149ecfc5f341e304 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Wed, 12 Apr 2017 13:29:44 -0700 Subject: [PATCH 1/2] Remove all mention of 'module' from typeshed. This depends on python/mypy#3107. --- stdlib/2/__builtin__.pyi | 5 ----- stdlib/2/abc.pyi | 9 +-------- stdlib/2/tokenize.pyi | 9 +++++---- stdlib/2/types.pyi | 1 + stdlib/2/unittest.pyi | 3 ++- stdlib/3/_importlib_modulespec.pyi | 3 ++- stdlib/3/builtins.pyi | 6 ------ 7 files changed, 11 insertions(+), 25 deletions(-) diff --git a/stdlib/2/__builtin__.pyi b/stdlib/2/__builtin__.pyi index fc680ca78dc7..541122b27bc3 100644 --- a/stdlib/2/__builtin__.pyi +++ b/stdlib/2/__builtin__.pyi @@ -675,11 +675,6 @@ class xrange(Sized, Iterable[int], Reversible[int]): def __getitem__(self, i: int) -> int: ... def __reversed__(self) -> Iterator[int]: ... -class module: - __name__ = ... # type: str - __file__ = ... # type: str - __dict__ = ... # type: Dict[unicode, Any] - class property(object): def __init__(self, fget: Callable[[Any], Any] = None, fset: Callable[[Any, Any], None] = None, diff --git a/stdlib/2/abc.pyi b/stdlib/2/abc.pyi index a2d270f76f08..e21065e5c1db 100644 --- a/stdlib/2/abc.pyi +++ b/stdlib/2/abc.pyi @@ -1,11 +1,7 @@ from typing import Any, Dict, Set, Tuple, Type import _weakrefset -# mypy has special processing for ABCMeta and abstractmethod. - -WeakSet = ... # type: _weakrefset.WeakSet -_InstanceType = ... # type: type -types = ... # type: module +# NOTE: mypy has special processing for ABCMeta and abstractmethod. def abstractmethod(funcobj: Any) -> Any: ... @@ -23,9 +19,6 @@ class ABCMeta(type): def _dump_registry(cls: "ABCMeta", *args: Any, **kwargs: Any) -> None: ... def register(cls: "ABCMeta", subclass: Type[Any]) -> None: ... -class _C: - pass - # TODO: The real abc.abstractproperty inherits from "property". class abstractproperty(object): def __new__(cls, func: Any) -> Any: ... diff --git a/stdlib/2/tokenize.pyi b/stdlib/2/tokenize.pyi index 159adf96d5f5..565a0ed53fa1 100644 --- a/stdlib/2/tokenize.pyi +++ b/stdlib/2/tokenize.pyi @@ -1,6 +1,7 @@ # Automatically generated by pytype, manually fixed up. May still contain errors. from typing import Any, Callable, Dict, Generator, Iterator, List, Tuple, Union, Iterable +import types __all__ = ... # type: List[str] __author__ = ... # type: str @@ -102,15 +103,15 @@ chain = ... # type: type double3prog = ... # type: type endprogs = ... # type: Dict[str, Any] pseudoprog = ... # type: type -re = ... # type: module +re = ... # type: types.ModuleType single3prog = ... # type: type single_quoted = ... # type: Dict[str, str] -string = ... # type: module -sys = ... # type: module +string = ... # type: types.ModuleType +sys = ... # type: types.ModuleType t = ... # type: str tabsize = ... # type: int tok_name = ... # type: Dict[int, str] -token = ... # type: module +token = ... # type: types.ModuleType tokenprog = ... # type: type triple_quoted = ... # type: Dict[str, str] x = ... # type: str diff --git a/stdlib/2/types.pyi b/stdlib/2/types.pyi index 54e8b78998de..5054f4100ea8 100644 --- a/stdlib/2/types.pyi +++ b/stdlib/2/types.pyi @@ -103,6 +103,7 @@ class ModuleType: __name__ = ... # type: str __package__ = ... # type: Optional[str] __path__ = ... # type: Optional[Iterable[str]] + __dict__ = ... # type: Dict[str, Any] def __init__(self, name: str, doc: Optional[str] = ...) -> None: ... FileType = file XRangeType = xrange diff --git a/stdlib/2/unittest.pyi b/stdlib/2/unittest.pyi index 9f3f7d600288..52decfedd49a 100644 --- a/stdlib/2/unittest.pyi +++ b/stdlib/2/unittest.pyi @@ -9,6 +9,7 @@ from typing import ( overload, Set, FrozenSet, TypeVar, Union, Pattern, Type ) from abc import abstractmethod, ABCMeta +import types _T = TypeVar('_T') _FT = TypeVar('_FT') @@ -173,4 +174,4 @@ def main(module: str = ..., defaultTest: str = ..., testLoader: Any = ...) -> None: ... # TODO types # private but occasionally used -util = ... # type: module +util = ... # type: types.ModuleType diff --git a/stdlib/3/_importlib_modulespec.pyi b/stdlib/3/_importlib_modulespec.pyi index 6b80ab68c207..bfd27ad2b456 100644 --- a/stdlib/3/_importlib_modulespec.pyi +++ b/stdlib/3/_importlib_modulespec.pyi @@ -7,7 +7,7 @@ from abc import ABCMeta import sys -from typing import Any, Optional +from typing import Dict, Any, Optional if sys.version_info >= (3, 4): class ModuleSpec: @@ -26,6 +26,7 @@ if sys.version_info >= (3, 4): class ModuleType: __name__ = ... # type: str __file__ = ... # type: str + __dict__ = ... # type: Dict[str, Any] if sys.version_info >= (3, 4): __loader__ = ... # type: Optional[Loader] __package__ = ... # type: Optional[str] diff --git a/stdlib/3/builtins.pyi b/stdlib/3/builtins.pyi index 490c7f31a0ae..5264f22c44d5 100644 --- a/stdlib/3/builtins.pyi +++ b/stdlib/3/builtins.pyi @@ -731,12 +731,6 @@ class range(Sequence[int]): def __repr__(self) -> str: ... def __reversed__(self) -> Iterator[int]: ... -class module: - # TODO not defined in builtins! - __name__ = ... # type: str - __file__ = ... # type: str - __dict__ = ... # type: Dict[str, Any] - class property: def __init__(self, fget: Callable[[Any], Any] = None, fset: Callable[[Any, Any], None] = None, From afa97fe41ec523972bee33c43d9d5bf6c6eddea8 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 13 Apr 2017 08:33:10 -0700 Subject: [PATCH 2/2] remove imported modules from tokenize Mostly to re-trigger tests --- stdlib/2/tokenize.pyi | 5 ----- 1 file changed, 5 deletions(-) diff --git a/stdlib/2/tokenize.pyi b/stdlib/2/tokenize.pyi index 565a0ed53fa1..834e2197d064 100644 --- a/stdlib/2/tokenize.pyi +++ b/stdlib/2/tokenize.pyi @@ -1,7 +1,6 @@ # Automatically generated by pytype, manually fixed up. May still contain errors. from typing import Any, Callable, Dict, Generator, Iterator, List, Tuple, Union, Iterable -import types __all__ = ... # type: List[str] __author__ = ... # type: str @@ -103,15 +102,11 @@ chain = ... # type: type double3prog = ... # type: type endprogs = ... # type: Dict[str, Any] pseudoprog = ... # type: type -re = ... # type: types.ModuleType single3prog = ... # type: type single_quoted = ... # type: Dict[str, str] -string = ... # type: types.ModuleType -sys = ... # type: types.ModuleType t = ... # type: str tabsize = ... # type: int tok_name = ... # type: Dict[int, str] -token = ... # type: types.ModuleType tokenprog = ... # type: type triple_quoted = ... # type: Dict[str, str] x = ... # type: str