Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stubtest: revert to allow mixed stubs and inline types, add test #12896

Merged
merged 1 commit into from
May 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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