filterpyflakes.py
37 lines
| 890 B
| text/x-python
|
PythonLexer
/ tests / filterpyflakes.py
timeless
|
r14140 | #!/usr/bin/env python | ||
# Filter output by pyflakes to control which warnings we check | ||||
Robert Stanca
|
r28724 | from __future__ import absolute_import, print_function | ||
Gregory Szorc
|
r27285 | |||
import re | ||||
import sys | ||||
timeless
|
r14140 | |||
timeless
|
r14173 | lines = [] | ||
timeless
|
r14140 | for line in sys.stdin: | ||
Augie Fackler
|
r30421 | # We blacklist tests that are too noisy for us | ||
timeless
|
r14175 | pats = [ | ||
Gregory Szorc
|
r32277 | r"undefined name 'WindowsError'", | ||
Augie Fackler
|
r30421 | r"redefinition of unused '[^']+' from line", | ||
Yuya Nishihara
|
r32510 | # for cffi, allow re-exports from pure.* | ||
r"cffi/[^:]*:.*\bimport \*' used", | ||||
r"cffi/[^:]*:.*\*' imported but unused", | ||||
Augie Fackler
|
r30421 | ] | ||
Matt Mackall
|
r21293 | |||
Augie Fackler
|
r30421 | keep = True | ||
for pat in pats: | ||||
if re.search(pat, line): | ||||
keep = False | ||||
Simon Heimberg
|
r19335 | break # pattern matches | ||
Augie Fackler
|
r30421 | if keep: | ||
fn = line.split(':', 1)[0] | ||||
f = open(fn) | ||||
data = f.read() | ||||
f.close() | ||||
if 'no-' 'check-code' in data: | ||||
continue | ||||
lines.append(line) | ||||
timeless
|
r14173 | |||
Augie Fackler
|
r30421 | for line in lines: | ||
timeless
|
r14140 | sys.stdout.write(line) | ||
Robert Stanca
|
r28724 | print() | ||