Add flags to pass on --warn-unused-ignores and --no-implicit-optional to mypy (#1421)

* Add flags to pass on --warn-unused-ignores and --no-implicit-optional to mypy
* Make implicit Optional explicit in arg types (2and3 part)
* Convert {stdlib,third_party}/2 to explicit Optional
This commit is contained in:
Guido van Rossum
2017-06-20 22:18:49 -07:00
committed by Jelle Zijlstra
parent 30256097ea
commit 04fe184dcf
23 changed files with 257 additions and 237 deletions

View File

@@ -24,6 +24,13 @@ parser.add_argument('-n', '--dry-run', action='store_true', help="Don't actually
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('--no-implicit-optional', action='store_true',
help="Run mypy with --no-implicit-optional (causes lots of errors)")
parser.add_argument('--warn-unused-ignores', action='store_true',
help="Run mypy with --warn-unused-ignores "
"(hint: only git rid of warnings that are "
"unused for all platforms and Python versions)")
parser.add_argument('filter', type=str, nargs='*', help="Include pattern (default all)")
@@ -124,7 +131,10 @@ def main():
runs += 1
flags = ['--python-version', '%d.%d' % (major, minor)]
flags.append('--strict-optional')
# flags.append('--warn-unused-ignores') # Fast parser and regular parser disagree.
if args.no_implicit_optional:
flags.append('--no-implicit-optional')
if args.warn_unused_ignores:
flags.append('--warn-unused-ignores')
sys.argv = ['mypy'] + flags + files
if args.verbose:
print("running", ' '.join(sys.argv))