Enable flake8-pyi plugin to automatically include *.pyi files

This simplifies running flake8 tests and reduces the amount of F821 errors
reported (flake8-pyi enables support for forward references in *.pyi files).
The error code is left disabled until I clean up the remaining issues.
This commit is contained in:
Lukasz Langa
2016-12-21 00:44:17 -08:00
parent 52d9f815dd
commit 8c5c788a4d
7 changed files with 14 additions and 55 deletions

View File

@@ -1,47 +0,0 @@
#!/usr/bin/env python3
import pathlib
import subprocess
import sys
PY2_ONLY_KEYWORDS = [
'StandardError',
'apply',
'basestring',
'buffer',
'cmp',
'coerce',
'execfile',
'file',
'intern',
'long',
'raw_input',
'reduce',
'reload',
'unichr',
'unicode',
'xrange',
]
root = pathlib.Path(__file__).parent.parent
paths = list(sorted(str(p) for p in root.glob('**/*.pyi')))
window = 0
size = 100
returncode = 0
print('Running flake8 on {} .pyi files...'.format(len(paths)))
while True:
chunk = paths[window:window + size]
if not chunk:
break
proc = subprocess.run(
['flake8', '--builtins=' + ','.join(PY2_ONLY_KEYWORDS)] + chunk,
)
if proc.returncode:
print('flake8 run failed!')
sys.exit(1)
window += size
print('flake8 run clean.')

View File

@@ -126,7 +126,7 @@ def main():
flags.append('--strict-optional')
if (major, minor) >= (3, 6):
flags.append('--fast-parser')
##flags.append('--warn-unused-ignores') # Fast parser and regular parser disagree.
# flags.append('--warn-unused-ignores') # Fast parser and regular parser disagree.
sys.argv = ['mypy'] + flags + files
if args.verbose:
print("running", ' '.join(sys.argv))