Skip to content

Commit

Permalink
stubtest: revert to allow mixed stubs and inline types, add test (#12896
Browse files Browse the repository at this point in the history
)

Reverts #12889

Co-authored-by: hauntsaninja <>
  • Loading branch information
hauntsaninja authored May 28, 2022
1 parent f08c57e commit 74b35be
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions mypy/stubtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1301,8 +1301,7 @@ def build_stubs(modules: List[str], options: Options, find_submodules: bool = Fa

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


def get_typeshed_stdlib_modules(
Expand Down
10 changes: 5 additions & 5 deletions mypy/test/teststubtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1201,17 +1201,17 @@ def test_missing_stubs(self) -> None:
"Found 1 error (checked 1 module)\n"
)

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

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

0 comments on commit 74b35be

Please sign in to comment.