Skip to content

Run tests on win32 for mypy #3425

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 27 additions & 19 deletions tests/mypy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@
import sys
import argparse

PLATFORMS = ["win32", "linux"]

parser = argparse.ArgumentParser(description="Test runner for typeshed. "
"Patterns are unanchored regexps on the full path.")
parser.add_argument('-v', '--verbose', action='count', default=0, help="More output")
parser.add_argument('-n', '--dry-run', action='store_true', help="Don't actually run mypy")
parser.add_argument('-x', '--exclude', type=str, nargs='*', help="Exclude pattern")
parser.add_argument('-p', '--python-version', type=str, nargs='*',
help="These versions only (major[.minor])")
parser.add_argument('--platforms', type=str, nargs='*',
help="These platforms only")
parser.add_argument('--warn-unused-ignores', action='store_true',
help="Run mypy with --warn-unused-ignores "
"(hint: only get rid of warnings that are "
Expand Down Expand Up @@ -96,6 +100,8 @@ def main():
print("--- no versions selected ---")
sys.exit(1)

platforms = args.platforms or PLATFORMS

code = 0
runs = 0
for major, minor in versions:
Expand Down Expand Up @@ -126,25 +132,27 @@ def main():
seen.add(mod)
files.append(fn)
if files:
runs += 1
flags = ['--python-version', '%d.%d' % (major, minor)]
flags.append('--strict-optional')
flags.append('--no-site-packages')
flags.append('--show-traceback')
flags.append('--no-implicit-optional')
flags.append('--disallow-any-generics')
if args.warn_unused_ignores:
flags.append('--warn-unused-ignores')
sys.argv = ['mypy'] + flags + files
if args.verbose:
print("running", ' '.join(sys.argv))
else:
print("running mypy", ' '.join(flags), "# with", len(files), "files")
try:
if not args.dry_run:
mypy_main('', sys.stdout, sys.stderr)
except SystemExit as err:
code = max(code, err.code)
for platform in platforms:
runs += 1
flags = ['--python-version', '%d.%d' % (major, minor)]
flags.append('--strict-optional')
flags.append('--no-site-packages')
flags.append('--show-traceback')
flags.append('--no-implicit-optional')
flags.append('--disallow-any-generics')
if args.warn_unused_ignores:
flags.append('--warn-unused-ignores')
flags += ['--platform', platform]
sys.argv = ['mypy'] + flags + files
if args.verbose:
print("running", ' '.join(sys.argv))
else:
print("running mypy", ' '.join(flags), "# with", len(files), "files")
try:
if not args.dry_run:
mypy_main('', sys.stdout, sys.stderr)
except SystemExit as err:
code = max(code, err.code)
if code:
print("--- exit status", code, "---")
sys.exit(code)
Expand Down