flake8: Add flake8-pep3101 plugin.

Checks for old string formatting.
https://pypi.python.org/pypi/flake8-pep3101/
This commit is contained in:
Florian Bruhin 2016-01-22 19:40:10 +01:00
parent a4a8c00e0f
commit 7fa0dc68bf
8 changed files with 11 additions and 7 deletions

View File

@ -84,7 +84,7 @@ def dirbrowser_html(path):
except OSError as e:
html = jinja.env.get_template('error.html').render(
title="Error while reading directory",
url='file://%s' % path,
url='file://{}'.format(path),
error=str(e),
icon='')
return html.encode('UTF-8', errors='xmlcharrefreplace')

View File

@ -49,7 +49,7 @@ attr_chars = string.ascii_letters + string.digits + attr_chars_nonalnum
# RFC 5987 gives this alternative construction of the token character class
token_chars = attr_chars + "*'%"
token_chars = attr_chars + "*'%" # flake8: disable=S001
# Definitions from https://tools.ietf.org/html/rfc2616#section-2.2

View File

@ -100,7 +100,7 @@ def _get_environment_vars():
for key, value in os.environ.items():
for m in masks:
if fnmatch.fnmatch(key, m):
info.append('%s = %s' % (key, value))
info.append('{} = {}'.format(key, value))
return '\n'.join(sorted(info))

View File

@ -41,7 +41,8 @@ class ConfigChecker(checkers.BaseChecker):
__implements__ = interfaces.IAstroidChecker
name = 'config'
msgs = {
'E0000': ('"%s -> %s" is no valid config option.', 'bad-config-call',
'E0000': ('"%s -> %s" is no valid config option.', # flake8: disable=S001
'bad-config-call',
None),
}
priority = -1

View File

@ -128,8 +128,8 @@ def report(items):
for item in sorted(items, key=lambda e: (e.file.lower(), e.lineno)):
relpath = os.path.relpath(item.file)
path = relpath if not relpath.startswith('..') else item.file
output.append("%s:%d: Unused %s '%s'" % (path, item.lineno, item.typ,
item))
output.append("{}:{}: Unused {} '{}'".format(path, item.lineno,
item.typ, item))
return output

View File

@ -72,7 +72,8 @@ class UsageFormatter(argparse.HelpFormatter):
result = "'{}'".format(action.metavar)
elif action.choices is not None:
choice_strs = [str(choice) for choice in action.choices]
result = '{%s}' % ','.join('*{}*'.format(e) for e in choice_strs)
result = ('{' + ','.join('*{}*'.format(e) for e in choice_strs) +
'}')
else:
result = "'{}'".format(default_metavar)

View File

@ -38,6 +38,7 @@ putty-ignore =
/# flake8: disable=N803/ : +N803
/# flake8: disable=T002/ : +T002
/# flake8: disable=F841/ : +F841
/# flake8: disable=S001/ : +S001
copyright-check = True
copyright-regexp = # Copyright [\d-]+ .*
copyright-min-file-size = 110

View File

@ -164,6 +164,7 @@ deps =
flake8-string-format==0.2.1
flake8-deprecated==0.2
flake8-mock==0.2
flake8-pep3101==0.2
commands =
{envpython} -m flake8