@@ -153,17 +153,18 @@ def f(c:str) -> None: pass
153
153
[case testInvalidOperationsOnModules]
154
154
import m
155
155
import typing
156
+
156
157
class A: pass
157
- m() # E: "module " not callable
158
- a = m # type: A # E: Incompatible types in assignment (expression has type "module ", variable has type "A")
159
- m + None # E: Unsupported left operand type for + ("module ")
158
+ m() # E: "ModuleType " not callable
159
+ a = m # type: A # E: Incompatible types in assignment (expression has type "ModuleType ", variable has type "A")
160
+ m + None # E: Unsupported left operand type for + ("ModuleType ")
160
161
[file m.py]
161
162
[builtins fixtures/module.pyi]
162
163
163
164
[case testNameDefinedInDifferentModule]
164
165
import m, n
165
166
import typing
166
- m.x # E: "module " has no attribute "x"
167
+ m.x # E: "ModuleType " has no attribute "x"
167
168
[file m.py]
168
169
y = object()
169
170
[file n.py]
@@ -329,7 +330,7 @@ import nonexistent
329
330
[out]
330
331
tmp/x.py:1: error: Cannot find module named 'nonexistent'
331
332
tmp/x.py:1: note: (Perhaps setting MYPYPATH or using the "--ignore-missing-imports" flag would help)
332
- main:3: error: "module " has no attribute "z"
333
+ main:3: error: "ModuleType " has no attribute "z"
333
334
334
335
[case testUnknownModuleImportedWithinFunction]
335
336
def f():
@@ -647,7 +648,7 @@ def f(x: str) -> None: pass
647
648
if object():
648
649
import m
649
650
else:
650
- m = 1 # E: Incompatible types in assignment (expression has type "int", variable has type "module ")
651
+ m = 1 # E: Incompatible types in assignment (expression has type "int", variable has type "ModuleType ")
651
652
[file m.py]
652
653
[builtins fixtures/module.pyi]
653
654
[out]
@@ -751,7 +752,7 @@ value = 3.2
751
752
[case testSubmoduleImportFromDoesNotAddParents]
752
753
from a import b
753
754
reveal_type(b.value) # E: Revealed type is 'builtins.str'
754
- b.c.value # E: "module " has no attribute "c"
755
+ b.c.value # E: "ModuleType " has no attribute "c"
755
756
a.value # E: Name 'a' is not defined
756
757
757
758
[file a/__init__.py]
@@ -852,7 +853,7 @@ bar = parent.unrelated.ShouldNotLoad()
852
853
[builtins fixtures/module.pyi]
853
854
[out]
854
855
tmp/parent/child.py:8: error: Revealed type is 'parent.common.SomeClass'
855
- tmp/parent/child.py:9: error: "module " has no attribute "unrelated"
856
+ tmp/parent/child.py:9: error: "ModuleType " has no attribute "unrelated"
856
857
857
858
[case testSubmoduleMixingImportFromAndImport2]
858
859
import parent.child
@@ -1406,3 +1407,12 @@ reveal_type(cb) # E: Revealed type is 'def (*Any, **Any) -> Any'
1406
1407
from typing import Callable, Any
1407
1408
AnyCallable = Callable[..., Any]
1408
1409
[out]
1410
+
1411
+ [case testRevealType]
1412
+ import types
1413
+ def f() -> types.ModuleType:
1414
+ return types
1415
+ reveal_type(f()) # E: Revealed type is 'types.ModuleType'
1416
+ reveal_type(types) # E: Revealed type is 'types.ModuleType'
1417
+
1418
+ [builtins fixtures/module.pyi]
0 commit comments