From 704e94c85c04a9edbe54f85da74e4a1b95d08bb7 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Tue, 26 Sep 2017 14:43:34 -0700 Subject: [PATCH] run-mypy: Deindent a bit of logic by moving an exit path up. --- tools/run-mypy | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tools/run-mypy b/tools/run-mypy index d3f67060fe..c9fc2238cf 100755 --- a/tools/run-mypy +++ b/tools/run-mypy @@ -83,6 +83,9 @@ files_dict = cast(Dict[str, List[str]], pyi_files = set(files_dict['pyi']) python_files = [fpath for fpath in files_dict['py'] if not fpath.endswith('.py') or fpath + 'i' not in pyi_files] +if not python_files: + print("There are no files to run mypy on.") + sys.exit(0) extra_args = ["--check-untyped-defs", "--follow-imports=silent", @@ -102,17 +105,14 @@ if args.ignore_missing_imports: if args.quick: extra_args.append("--quick") +rc = subprocess.call([mypy_command] + extra_args + python_files) -# run mypy -if python_files: - rc = subprocess.call([mypy_command] + extra_args + python_files) - if args.linecoverage_report: - # Move the coverage report to where codecov will look for it. - try: - os.rename('var/linecoverage-report/coverage.txt', 'var/.coverage') - except OSError: - # maybe mypy crashed; exit with its error code - pass - sys.exit(rc) -else: - print("There are no files to run mypy on.") +if args.linecoverage_report: + # Move the coverage report to where codecov will look for it. + try: + os.rename('var/linecoverage-report/coverage.txt', 'var/.coverage') + except OSError: + # maybe mypy crashed; exit with its error code + pass + +sys.exit(rc)