Fix Flake8 3.6.0 errors
Flake8 3.6.0 now warns about both line break after and *before* binary operator, you have to choose whether you use W503 or W504. Disable the newer W504. Fix "F841 local variable 'e' is assigned to but never used". Handle warnings about invalid escape sequence in regex. Handle invalid escape sequence in string. Change-Id: I68efbde4e9dd2e6e9455d91313eb45c9c79d35ce
This commit is contained in:
parent
b170daeea7
commit
cb737354f0
|
@ -52,11 +52,11 @@ def _enforce_policy(action, target, credentials, do_raise=True):
|
||||||
try:
|
try:
|
||||||
_ENFORCER.authorize(action, target, credentials.to_policy_view(),
|
_ENFORCER.authorize(action, target, credentials.to_policy_view(),
|
||||||
**extras)
|
**extras)
|
||||||
except policy.PolicyNotRegistered as e:
|
except policy.PolicyNotRegistered:
|
||||||
LOG.exception('Policy not registered for %(action)s',
|
LOG.exception('Policy not registered for %(action)s',
|
||||||
{'action': action})
|
{'action': action})
|
||||||
raise exc.ActionForbidden()
|
raise exc.ActionForbidden()
|
||||||
except Exception as e:
|
except Exception:
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception():
|
||||||
LOG.debug(
|
LOG.debug(
|
||||||
'Policy check for %(action)s failed with credentials '
|
'Policy check for %(action)s failed with credentials '
|
||||||
|
|
|
@ -120,7 +120,7 @@ class ReferenceResolver(object):
|
||||||
reference
|
reference
|
||||||
"""
|
"""
|
||||||
ks_sess = ks_utils.get_keystone_session()
|
ks_sess = ks_utils.get_keystone_session()
|
||||||
(new_scheme, foo) = re.subn('^[^+]+\+', '', design_uri.scheme)
|
(new_scheme, foo) = re.subn('^[^+]+\+', '', design_uri.scheme) # noqa
|
||||||
url = urllib.parse.urlunparse(
|
url = urllib.parse.urlunparse(
|
||||||
(new_scheme, design_uri.netloc, design_uri.path, design_uri.params,
|
(new_scheme, design_uri.netloc, design_uri.path, design_uri.params,
|
||||||
design_uri.query, design_uri.fragment))
|
design_uri.query, design_uri.fragment))
|
||||||
|
|
|
@ -115,7 +115,7 @@ class ChartWait():
|
||||||
return DaemonSetWait(resource_type, self, labels, **kwargs)
|
return DaemonSetWait(resource_type, self, labels, **kwargs)
|
||||||
elif resource_type == 'statefulset':
|
elif resource_type == 'statefulset':
|
||||||
return StatefulSetWait(resource_type, self, labels, **kwargs)
|
return StatefulSetWait(resource_type, self, labels, **kwargs)
|
||||||
except TypeError as e:
|
except TypeError:
|
||||||
raise manifest_exceptions.ManifestException(
|
raise manifest_exceptions.ManifestException(
|
||||||
'invalid config for item in `wait.resources`: {}'.format(
|
'invalid config for item in `wait.resources`: {}'.format(
|
||||||
resource_config))
|
resource_config))
|
||||||
|
|
|
@ -461,8 +461,9 @@ class ChartBuilderNegativeTestCase(BaseChartBuilderTestCase):
|
||||||
chartbuilder = ChartBuilder(test_chart)
|
chartbuilder = ChartBuilder(test_chart)
|
||||||
|
|
||||||
# Confirm it failed for both encodings.
|
# Confirm it failed for both encodings.
|
||||||
error_re = (r'.*A str exception occurred while trying to read file:'
|
error_re = (
|
||||||
'.*Details:\n.*\(encoding=utf-8\).*\n\(encoding=latin1\)')
|
r'.*A str exception occurred while trying to read file:' # noqa
|
||||||
|
'.*Details:\n.*\(encoding=utf-8\).*\n\(encoding=latin1\)')
|
||||||
with mock.patch("builtins.open", mock.mock_open(read_data="")) \
|
with mock.patch("builtins.open", mock.mock_open(read_data="")) \
|
||||||
as mock_file:
|
as mock_file:
|
||||||
mock_file.return_value.read.side_effect = self.exc_to_raise
|
mock_file.return_value.read.side_effect = self.exc_to_raise
|
||||||
|
|
|
@ -322,7 +322,8 @@ class OverrideNegativeTestCase(testtools.TestCase):
|
||||||
with open(self.base_manifest) as f:
|
with open(self.base_manifest) as f:
|
||||||
original_documents = list(yaml.safe_load_all(f.read()))
|
original_documents = list(yaml.safe_load_all(f.read()))
|
||||||
|
|
||||||
override = ('manifest:simple-armada:release_prefix=' '\overridden', )
|
# Provide invalid JSON to compel the error to get thrown.
|
||||||
|
override = ('manifest:simple-armada:release_prefix=\\overridden', )
|
||||||
ovr = Override(original_documents, override)
|
ovr = Override(original_documents, override)
|
||||||
self.assertRaises(json.decoder.JSONDecodeError, ovr.update_manifests)
|
self.assertRaises(json.decoder.JSONDecodeError, ovr.update_manifests)
|
||||||
|
|
||||||
|
|
5
tox.ini
5
tox.ini
|
@ -102,5 +102,8 @@ commands =
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
filename = *.py
|
filename = *.py
|
||||||
ignore =
|
# These are ignored intentionally:
|
||||||
|
# W504 - line break after binary operator, we cannot have both
|
||||||
|
# W503 and W504 enabled
|
||||||
|
ignore = W504
|
||||||
exclude = .git,.tox,dist,*lib/python*,*egg,build,releasenotes,doc/*,hapi,venv
|
exclude = .git,.tox,dist,*lib/python*,*egg,build,releasenotes,doc/*,hapi,venv
|
||||||
|
|
Loading…
Reference in New Issue