##// END OF EJS Templates
validators: don't catch all Exceptions as invalid clone URIs, be specific...
validators: don't catch all Exceptions as invalid clone URIs, be specific When adding a new repository with a remote clone URI, the URI will be validated in some way. Several exceptions could occur during that validation. Previously, the code would catch based on 'Exception', which means that _any_ exception would cause the URI to be found invalid. This means that errors in the code (e.g. related to Python 3 conversion) were also categorized as 'invalid clone URI'. And thus, the tests that test an actually invalid URI would pass, even though there was a bug. Now, things have been refactored so it only is relevant to catch InvalidCloneUriException. Any other exception will now yield a 500 Internal Server Error, as expected.

File last commit:

r8109:51af7c12 default
r8155:4aa6a17a default
Show More
pyflakes
37 lines | 1.2 KiB | text/plain | TextLexer
#!/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)