From 2d26c272c3225f99c945d2c510c61910c34a9377 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Thu, 2 Mar 2023 15:46:38 -0500 Subject: [PATCH] run_mypy: accept the path to an alternative mypy executable mypy might be installed with a different python than the one run_mypy.py is using. --- run_mypy.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/run_mypy.py b/run_mypy.py index 9ad43b880..338968d49 100755 --- a/run_mypy.py +++ b/run_mypy.py @@ -96,6 +96,7 @@ def main() -> int: parser = argparse.ArgumentParser(description='Process some integers.') parser.add_argument('files', nargs='*') + parser.add_argument('--mypy', help='path to mypy executable') parser.add_argument('-q', '--quiet', action='store_true', help='do not print informational messages') parser.add_argument('-p', '--pretty', action='store_true', help='pretty print mypy errors') parser.add_argument('-C', '--clear', action='store_true', help='clear the terminal before running mypy') @@ -121,12 +122,10 @@ def main() -> int: to_check.extend(modules) if to_check: + command = [opts.mypy] if opts.mypy else [sys.executable, '-m', 'mypy'] if not opts.quiet: print('Running mypy (this can take some time) ...') - p = subprocess.run( - [sys.executable, '-m', 'mypy'] + args + to_check, - cwd=root, - ) + p = subprocess.run(command + args + to_check, cwd=root) return p.returncode else: if not opts.quiet: