summaryrefslogtreecommitdiff
path: root/run_mypy.py
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2023-08-16 13:03:44 -0400
committerEli Schwartz <eschwartz@archlinux.org>2023-08-18 15:38:13 -0400
commit1ed619d1965e0fa4aa6dadae88843e923ff0d198 (patch)
treecf4ad5731d14f8608fcd4e95de98e78e1d007b4a /run_mypy.py
parent3ebd570bd538732437ee83c2fe9ac97aef6a03db (diff)
downloadmeson-1ed619d1965e0fa4aa6dadae88843e923ff0d198.tar.gz
run_mypy: add option to run once for each supported version of python
This allows verifying that meson is type-safe under older versions of Python, which it currently is. Different versions of Python sometimes have different supported types for an API. Verify this in CI. (We flush output to ensure CI prints lines in the right order.)
Diffstat (limited to 'run_mypy.py')
-rwxr-xr-xrun_mypy.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/run_mypy.py b/run_mypy.py
index 15dd5a628..cf0e0e3de 100755
--- a/run_mypy.py
+++ b/run_mypy.py
@@ -104,6 +104,7 @@ def main() -> int:
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')
+ parser.add_argument('--allver', action='store_true', help='Check all supported versions of python')
opts, args = parser.parse_known_args()
if opts.pretty:
@@ -129,8 +130,15 @@ def main() -> int:
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(command + args + to_check, cwd=root)
- return p.returncode
+ retcode = subprocess.run(command + args + to_check, cwd=root).returncode
+ if opts.allver and retcode == 0:
+ for minor in range(7, sys.version_info[1]):
+ if not opts.quiet:
+ print(f'Checking mypy with python version: 3.{minor}')
+ p = subprocess.run(command + args + to_check + [f'--python-version=3.{minor}'], cwd=root)
+ if p.returncode != 0:
+ retcode = p.returncode
+ return retcode
else:
if not opts.quiet:
print('nothing to do...')