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

Improve error reporting when --install-types has no cache #10667

Merged
merged 1 commit into from Jun 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 13 additions & 2 deletions mypy/main.py
Expand Up @@ -77,6 +77,10 @@ def main(script_path: Optional[str],
if options.non_interactive and not options.install_types:
fail("Error: --non-interactive is only supported with --install-types", stderr, options)

if options.install_types and not options.incremental:
fail("Error: --install-types not supported with incremental mode disabled",
stderr, options)

if options.install_types and not sources:
install_types(options.cache_dir, formatter, non_interactive=options.non_interactive)
return
Expand Down Expand Up @@ -1090,8 +1094,15 @@ def install_types(cache_dir: str,
non_interactive: bool = False) -> None:
"""Install stub packages using pip if some missing stubs were detected."""
if not os.path.isdir(cache_dir):
sys.stderr.write(
"Error: no mypy cache directory (you must enable incremental mode)\n")
if not after_run:
sys.stderr.write(
"Error: Can't determine which types to install with no files to check " +
"(and no cache from previous mypy run)\n"
)
else:
sys.stderr.write(
"Error: --install-types failed (no mypy cache directory)\n"
)
sys.exit(2)
fnam = build.missing_stubs_file(cache_dir)
if not os.path.isfile(fnam):
Expand Down