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

Enable --fast-exit by default to speed up mypy #11541

Merged
merged 2 commits into from
Nov 14, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion mypy/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def run(args: List[str]) -> Tuple[str, str, int]:
# Lazy import to avoid needing to import all of mypy to call run_dmypy
from mypy.main import main
return _run(lambda stdout, stderr: main(None, args=args,
stdout=stdout, stderr=stderr))
stdout=stdout, stderr=stderr, clean_exit=True))


def run_dmypy(args: List[str]) -> Tuple[str, str, int]:
Expand Down
9 changes: 7 additions & 2 deletions mypy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,16 @@ def main(script_path: Optional[str],
stdout: TextIO,
stderr: TextIO,
args: Optional[List[str]] = None,
clean_exit: bool = False,
) -> None:
"""Main entry point to the type checker.

Args:
script_path: Path to the 'mypy' script (used for finding data files).
args: Custom command-line arguments. If not given, sys.argv[1:] will
be used.
be used.
clean_exit: Don't hard kill the process on exit. This allows catching
SystemExit.
"""
util.check_python_version('mypy')
t0 = time.time()
Expand All @@ -66,6 +69,8 @@ def main(script_path: Optional[str],
fscache = FileSystemCache()
sources, options = process_options(args, stdout=stdout, stderr=stderr,
fscache=fscache)
if clean_exit:
options.fast_exit = False

formatter = util.FancyFormatter(stdout, stderr, options.show_error_codes)

Expand Down Expand Up @@ -769,7 +774,7 @@ def add_invertible_flag(flag: str,
dest='shadow_file', action='append',
help="When encountering SOURCE_FILE, read and type check "
"the contents of SHADOW_FILE instead.")
add_invertible_flag('--fast-exit', default=False, help=argparse.SUPPRESS,
add_invertible_flag('--fast-exit', default=True, help=argparse.SUPPRESS,
group=internals_group)

report_group = parser.add_argument_group(
Expand Down
2 changes: 1 addition & 1 deletion mypy/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def __init__(self) -> None:
self.package_root: List[str] = []
self.cache_map: Dict[str, Tuple[str, str]] = {}
# Don't properly free objects on exit, just kill the current process.
self.fast_exit = False
self.fast_exit = True
# Used to transform source code before parsing if not None
# TODO: Make the type precise (AnyStr -> AnyStr)
self.transform_source: Optional[Callable[[Any], Any]] = None
Expand Down