##// END OF EJS Templates
cleanup: run pyflakes as a part of scripts/run-all-cleanup...
Mads Kiilerich -
r8109:51af7c12 default
parent child Browse files
Show More
@@ -0,0 +1,37 b''
1 #!/usr/bin/env python3
2 """
3 pyflakes with filter configuration for Kallithea.
4 Inspired by pyflakes/api.py and flake8/plugins/pyflakes.py .
5 """
6
7 import sys
8 import pyflakes.api
9 import pyflakes.messages
10
11 class Reporter:
12
13 warned = False
14
15 def flake(self, warning):
16 # ignore known warnings
17 if isinstance(warning, pyflakes.messages.UnusedVariable):
18 return
19 if warning.filename == 'kallithea/bin/kallithea_cli_ishell.py':
20 if isinstance(warning, pyflakes.messages.ImportStarUsed) and warning.message_args == ('kallithea.model.db',):
21 return
22 if isinstance(warning, pyflakes.messages.UnusedImport) and warning.message_args == ('kallithea.model.db.*',):
23 return
24
25 print('%s:%s %s [%s %s]' % (warning.filename, warning.lineno, warning.message % warning.message_args, type(warning).__name__, warning.message_args))
26 self.warned = True
27
28 def unexpectedError(self, filename, msg):
29 print('Unexpected error for %s: %s' % (filename, msg))
30
31
32 reporter = Reporter()
33
34 for filename in sorted(set(sys.argv[1:])):
35 pyflakes.api.checkPath(filename, reporter=reporter)
36 if reporter.warned:
37 raise SystemExit(1)
@@ -6,3 +6,4 b' mock >= 3.0.0, < 4.1'
6 Sphinx >= 1.8.0, < 2.4
6 Sphinx >= 1.8.0, < 2.4
7 WebTest >= 2.0.6, < 2.1
7 WebTest >= 2.0.6, < 2.1
8 isort == 4.3.21
8 isort == 4.3.21
9 pyflakes == 2.1.1
@@ -8,3 +8,5 b' set -x'
8 scripts/docs-headings.py
8 scripts/docs-headings.py
9 scripts/generate-ini.py
9 scripts/generate-ini.py
10 scripts/whitespacecleanup.sh
10 scripts/whitespacecleanup.sh
11
12 hg loc 'set:!binary()&grep("^#!.*python")' '*.py' | xargs scripts/pyflakes
General Comments 0
You need to be logged in to leave comments. Login now