Debian Codegraph @

tests/filterpyflakes.py

raw
1 #!/usr/bin/env python3
2
3 # Filter output by pyflakes to control which warnings we check
4
5
6 import re
7 import sys
8
9 lines = []
10 for line in sys.stdin:
11 # We blacklist tests that are too noisy for us
12 pats = [
13 r"undefined name 'WindowsError'",
14 r"redefinition of unused '[^']+' from line",
15 # for cffi, allow re-exports from pure.*
16 r"cffi/[^:]*:.*\bimport \*' used",
17 r"cffi/[^:]*:.*\*' imported but unused",
18 r"mercurial/interfaces/types.py:.+' imported but unused",
19 r"mercurial/hgweb/hgweb_mod.py:.+ 'from \.hgweb_mod_inner import \*' used.+",
20 r"mercurial/hgweb/hgweb_mod.py:.+ '\.hgweb_mod_inner\.\*' imported but unused",
21 r"mercurial/hgweb/hgwebdir_mod.py:.+ 'from \.hgwebdir_mod_inner import \*' used.+",
22 r"mercurial/hgweb/hgwebdir_mod.py:.+ '\.hgwebdir_mod_inner.\*' imported but unused",
23 r"mercurial/hgweb/wsgicgi.py:.+ 'from \.wsgicgi_inner import \*' used.+",
24 r"mercurial/hgweb/wsgicgi.py:.+ '\.wsgicgi_inner\.\*' imported but unused",
25 ]
26
27 keep = True
28 for pat in pats:
29 if re.search(pat, line):
30 keep = False
31 break # pattern matches
32 if keep:
33 fn = line.split(':', 1)[0]
34 with open(fn, 'rb') as f:
35 data = f.read()
36 if b'no-' b'check-code' in data:
37 continue
38 lines.append(line)
39
40 for line in lines:
41 sys.stdout.write(line)
42 print()