Make sys.modules a Dict[str, Any] (#1266)

* Add __getattr__ to ModuleType.

Modules can contain anything, so give them a generic "__getattr__(name) -> Any".
This makes code like the following type-check, in pytype:
    sys.modules.get("random").randint

* undo Python 3 change

* Revert "undo Python 3 change"

This reverts commit 96cf2d529e374a754f1ba681f0fc81aab25f81ef.

* Revert "Add __getattr__ to ModuleType."

This reverts commit 3ac1cf8a3b25dabfe386fbf34aef680fb1acd112.

* In stdlib/2/, make sys.modules a Dict[str, Any].

(Instead of Dict[str, ModuleType])
Same as stdlib/3/.
This commit is contained in:
Matthias Kramm
2017-05-20 11:08:25 -07:00
committed by Jelle Zijlstra
parent d68d0c5c00
commit 8d8708594e

View File

@@ -61,7 +61,7 @@ long_info = ... # type: object
maxint = ... # type: int
maxsize = ... # type: int
maxunicode = ... # type: int
modules = ... # type: Dict[str, ModuleType]
modules = ... # type: Dict[str, Any]
path = ... # type: List[str]
platform = ... # type: str
prefix = ... # type: str