8000 Run build a second time when using --install-types --non-interactive by JukkaL · Pull Request #10669 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Run build a second time when using --install-types --non-interactive #10669

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

Merged
merged 8 commits into from
Jun 18, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix exit code and trim output when nothing installed
  • Loading branch information
JukkaL committed Jun 18, 2021
commit 8fcaf9100013f0a45d8683e3fa3764f5ed816705
16 changes: 9 additions & 7 deletions mypy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,12 @@ def main(script_path: Optional[str],
stdout.flush()

if options.install_types and not options.non_interactive:
install_types(options.cache_dir, formatter, after_run=True,
non_interactive=options.non_interactive)
print()
print("Hint: Run mypy again for up-to-date results with installed types")
return
result = install_types(options.cache_dir, formatter, after_run=True,
non_interactive=options.non_interactive)
if result:
print()
print("Hint: Run mypy again for up-to-date results with installed types")
return

if options.fast_exit:
# Exit without freeing objects -- it's faster.
Expand Down Expand Up @@ -1144,12 +1145,12 @@ def install_types(cache_dir: str,
formatter: util.FancyFormatter,
*,
after_run: bool = False,
non_interactive: bool = False) -> None:
non_interactive: bool = False) -> bool:
"""Install stub packages using pip if some missing stubs were detected."""
packages = read_types_packages_to_install(cache_dir, after_run)
if not packages:
# If there are no missing stubs, generate no output.
return
return False
if after_run and not non_interactive:
print()
print('Installing missing stub packages:')
Expand All @@ -1163,3 +1164,4 @@ def install_types(cache_dir: str,
sys.exit(2)
print()
subprocess.run(cmd)
return True
7 changes: 7 additions & 0 deletions test-data/unit/cmdline.test
Original file line number Diff line number Diff line change
Expand Up @@ -1295,3 +1295,10 @@ pkg.py:1: error: "int" not callable
[file pkg.py]
1 + 2
[out]

[case testCmdlineInteractiveInstallTypesNothingToDo]
# cmd: mypy --install-types -m pkg
[file pkg.py]
1()
[out]
pkg.py:1: error: "int" not callable
0