Skip to content

Commit 74b35be

Browse files
authored
stubtest: revert to allow mixed stubs and inline types, add test (#12896)
Reverts #12889 Co-authored-by: hauntsaninja <>
1 parent f08c57e commit 74b35be

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

mypy/stubtest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,8 +1301,7 @@ def build_stubs(modules: List[str], options: Options, find_submodules: bool = Fa
13011301

13021302
def get_stub(module: str) -> Optional[nodes.MypyFile]:
13031303
"""Returns a stub object for the given module, if we've built one."""
1304-
stub = _all_stubs.get(module)
1305-
return stub if stub and stub.is_stub else None
1304+
return _all_stubs.get(module)
13061305

13071306

13081307
def get_typeshed_stdlib_modules(

mypy/test/teststubtest.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,17 +1201,17 @@ def test_missing_stubs(self) -> None:
12011201
"Found 1 error (checked 1 module)\n"
12021202
)
12031203

1204-
def test_missing_only_stubs(self) -> None:
1204+
def test_only_py(self) -> None:
1205+
# in this case, stubtest will check the py against itself
1206+
# this is useful to support packages with a mix of stubs and inline types
12051207
with use_tmp_dir(TEST_MODULE_NAME):
12061208
with open(f"{TEST_MODULE_NAME}.py", "w") as f:
12071209
f.write("a = 1")
12081210
output = io.StringIO()
12091211
with contextlib.redirect_stdout(output):
12101212
test_stubs(parse_options([TEST_MODULE_NAME]))
1211-
assert (
1212-
f"error: {TEST_MODULE_NAME} failed to find stubs"
1213-
in remove_color_code(output.getvalue())
1214-
)
1213+
output_str = remove_color_code(output.getvalue())
1214+
assert output_str == 'Success: no issues found in 1 module\n'
12151215

12161216
def test_get_typeshed_stdlib_modules(self) -> None:
12171217
stdlib = mypy.stubtest.get_typeshed_stdlib_modules(None, (3, 6))

0 commit comments

Comments
 (0)