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) |
General Comments 0
You need to be logged in to leave comments.
Login now