Changeset - 51af7c12ffb1
[Not reviewed]
default
0 2 1
Mads Kiilerich (mads) - 6 years ago 2020-02-11 05:17:03
mads@kiilerich.com
cleanup: run pyflakes as a part of scripts/run-all-cleanup

pyflakes has no usable configuration options, so create a small wrapper script.
Instead of having two wrapper scripts (with one being almost nothing and the
other containing configuration), just keep it simple and use one combined.
3 files changed with 40 insertions and 0 deletions:
0 comments (0 inline, 0 general)
dev_requirements.txt
Show inline comments
 
@@ -3,6 +3,7 @@ pytest-sugar >= 0.9.2, < 0.10
 
pytest-benchmark >= 3.2.2, < 3.3
 
pytest-localserver >= 0.5.0, < 0.6
 
mock >= 3.0.0, < 4.1
 
Sphinx >= 1.8.0, < 2.4
 
WebTest >= 2.0.6, < 2.1
 
isort == 4.3.21
 
pyflakes == 2.1.1
scripts/pyflakes
Show inline comments
 
new file 100755
 
#!/usr/bin/env python3
 
"""
 
pyflakes with filter configuration for Kallithea.
 
Inspired by pyflakes/api.py and flake8/plugins/pyflakes.py .
 
"""
 

	
 
import sys
 
import pyflakes.api
 
import pyflakes.messages
 

	
 
class Reporter:
 

	
 
    warned = False
 

	
 
    def flake(self, warning):
 
        # ignore known warnings
 
        if isinstance(warning, pyflakes.messages.UnusedVariable):
 
            return
 
        if warning.filename == 'kallithea/bin/kallithea_cli_ishell.py':
 
            if isinstance(warning, pyflakes.messages.ImportStarUsed) and warning.message_args == ('kallithea.model.db',):
 
                return
 
            if isinstance(warning, pyflakes.messages.UnusedImport) and warning.message_args == ('kallithea.model.db.*',):
 
                return
 

	
 
        print('%s:%s %s   [%s %s]' % (warning.filename, warning.lineno, warning.message % warning.message_args, type(warning).__name__, warning.message_args))
 
        self.warned = True
 

	
 
    def unexpectedError(self, filename, msg):
 
        print('Unexpected error for %s: %s' % (filename, msg))
 

	
 

	
 
reporter = Reporter()
 

	
 
for filename in sorted(set(sys.argv[1:])):
 
    pyflakes.api.checkPath(filename, reporter=reporter)
 
if reporter.warned:
 
    raise SystemExit(1)
scripts/run-all-cleanup
Show inline comments
 
@@ -5,6 +5,8 @@
 
set -e
 
set -x
 

	
 
scripts/docs-headings.py
 
scripts/generate-ini.py
 
scripts/whitespacecleanup.sh
 

	
 
hg loc 'set:!binary()&grep("^#!.*python")' '*.py' | xargs scripts/pyflakes
0 comments (0 inline, 0 general)