mirror of https://github.com/zulip/zulip.git
run-mypy: Deindent a bit of logic by moving an exit path up.
This commit is contained in:
parent
103178ffb2
commit
704e94c85c
|
@ -83,6 +83,9 @@ files_dict = cast(Dict[str, List[str]],
|
||||||
pyi_files = set(files_dict['pyi'])
|
pyi_files = set(files_dict['pyi'])
|
||||||
python_files = [fpath for fpath in files_dict['py']
|
python_files = [fpath for fpath in files_dict['py']
|
||||||
if not fpath.endswith('.py') or fpath + 'i' not in pyi_files]
|
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",
|
extra_args = ["--check-untyped-defs",
|
||||||
"--follow-imports=silent",
|
"--follow-imports=silent",
|
||||||
|
@ -102,17 +105,14 @@ if args.ignore_missing_imports:
|
||||||
if args.quick:
|
if args.quick:
|
||||||
extra_args.append("--quick")
|
extra_args.append("--quick")
|
||||||
|
|
||||||
|
rc = subprocess.call([mypy_command] + extra_args + python_files)
|
||||||
|
|
||||||
# run mypy
|
if args.linecoverage_report:
|
||||||
if python_files:
|
# Move the coverage report to where codecov will look for it.
|
||||||
rc = subprocess.call([mypy_command] + extra_args + python_files)
|
try:
|
||||||
if args.linecoverage_report:
|
os.rename('var/linecoverage-report/coverage.txt', 'var/.coverage')
|
||||||
# Move the coverage report to where codecov will look for it.
|
except OSError:
|
||||||
try:
|
# maybe mypy crashed; exit with its error code
|
||||||
os.rename('var/linecoverage-report/coverage.txt', 'var/.coverage')
|
pass
|
||||||
except OSError:
|
|
||||||
# maybe mypy crashed; exit with its error code
|
sys.exit(rc)
|
||||||
pass
|
|
||||||
sys.exit(rc)
|
|
||||||
else:
|
|
||||||
print("There are no files to run mypy on.")
|
|
||||||
|
|
Loading…
Reference in New Issue