8000 Added two tests, in build the extension is not a parameter anymore, c… · python/mypy@8cddea6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8cddea6

Browse files
committed
Added two tests, in build the extension is not a parameter anymore, checkout travis.sh
1 parent fa0c7bb commit 8cddea6

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

mypy/build.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def default_lib_path(data_dir: str, target: int, pyversion: int,
228228

229229
def lookup_program(module: str, lib_path: List[str]) -> str:
230230
# Modules are .py and not .pyi
231-
path = find_module(module, lib_path, ['.py'])
231+
path = find_module(module, lib_path)
232232
if path:
233233
return path
234234
else:
@@ -470,7 +470,7 @@ def all_imported_modules_in_file(self,
470470

471471
def is_module(self, id: str) -> bool:
472472
"""Is there a file in the file system corresponding to module id?"""
473-
return find_module(id, self.lib_path, ['.pyi', '.py']) is not None
473+
return find_module(id, self.lib_path) is not None
474474

475475
def final_passes(self, files: List[MypyFile],
476476
types: Dict[Node, Type]) -> None:
@@ -838,7 +838,7 @@ def read_module_source_from_file(id: str,
838838
id: module name, a string of form 'foo' or 'foo.bar'
839839
lib_path: library search path
840840
"""
841-
path = find_module(id, lib_path, ['.pyi', '.py'])
841+
path = find_module(id, lib_path)
842842
if path is not None:
843843
text = ''
844844
try:
@@ -854,8 +854,9 @@ def read_module_source_from_file(id: str,
854854
return None, None 10000
855855

856856

857-
def find_module(id: str, lib_path: List[str], extensions: List[str]) -> str:
857+
def find_module(id: str, lib_path: List[str]) -> str:
858858
"""Return the path of the module source file, or None if not found."""
859+
extensions = ['.pyi', '.py']
859860
for pathitem in lib_path:
860861
for extension in extensions:
861862
comp = id.split('.')

mypy/test/data/check-modules.test

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
-- Test cases for the type checker.
23

34
[case testAccessImportedDefinitions]
@@ -137,6 +138,24 @@ def f() -> None: pass
137138
[out]
138139
main: In class "C":
139140

141+
[case testImportWithStub]
142+
import _m
143+
_m.f("hola")
144+
[file _m.pyi]
145+
def f(c:str) -> None: pass
146+
[out]
147+
148+
149+
[case testImportWithStubIncompatibleType]
150+
import _m
151+
_m.f("hola")
152+
_m.f(12) # E: Argument 1 to "f" has incompatible type "int"; expected "str"
153+
[file _m.py]
154+
def f(c):
155+
print(c)
156+
[file _m.pyi]
157+
def f(c:str) -> None: pass
158+
140159
[case testInvalidOperationsOnModules]
141160
import m
142161
import typing

travis.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ done
3232
STUBTEST=_test_stubs.py
3333
echo "import typing" > $STUBTEST
3434
cd stubs/3.2
35-
ls *.pyi | sed s/\\.pyi//g | sed "s/^/import /g" >> ../../$STUBTEST
35+
ls *.py | sed s/\\.py//g | sed "s/^/import /g" >> ../../$STUBTEST
3636
for m in os os.path; do
3737
echo "import $m" >> ../../$STUBTEST
3838
done

0 commit comments

Comments
 (0)
0