Update hacking for Python3

The repo is Python 3 now, so update hacking to version 3.0 which
supports Python 3.

Fix:
F601 dictionary key 'cr_to_rp' repeated with different values
F841 local variable 'excep' is assigned to but never used
F821 undefined name 'excep'
E305 expected 2 blank lines after class or function definition, found 1
E731 do not assign a lambda expression, use a def

Blacklist:
W504 line break after binary operator

Update hacking extension for newer flake8 version.

Change-Id: I9f0d7b166e285091111c42fe978d29d7dd3bf5db
This commit is contained in:
Andreas Jaeger 2020-03-27 19:45:11 +01:00 committed by Andreas Jaeger
parent a7fd12bb19
commit 724f36bd3e
7 changed files with 15 additions and 15 deletions

View File

@ -51,7 +51,8 @@ class VMwareDriverException(Exception):
"""
msg_fmt = _("An unknown exception occurred.")
__str__ = lambda self: self.description
def __str__(self):
return self.description
def __init__(self, message=None, details=None, **kwargs):

View File

@ -14,6 +14,8 @@
import re
from hacking import core
_all_log_levels = {'critical', 'error', 'exception', 'info',
'warning', 'debug'}
@ -28,6 +30,7 @@ _log_translation_hint = re.compile(
})
@core.flake8ext
def no_translate_logs(logical_line, filename):
"""N537 - Don't translate logs.
@ -46,7 +49,3 @@ def no_translate_logs(logical_line, filename):
"""
if _log_translation_hint.match(logical_line):
yield (0, "N537: Log messages should not be translated!")
def factory(register):
register(no_translate_logs)

View File

@ -445,8 +445,8 @@ class DatastoreURL(object):
httplib.CannotSendHeader) as excep:
excep_msg = _("Error occurred while creating HTTP connection "
"to write to file with URL = %s.") % str(self)
LOG.exception(excep_msg)
raise exceptions.VimConnectionException(excep_msg, excep)
LOG.exception(excep_msg)
raise exceptions.VimConnectionException(excep_msg, excep)
def get_transfer_ticket(self, session, method):
client_factory = session.vim.client.factory

View File

@ -459,5 +459,6 @@ class SudsLogFilter(logging.Filter):
return True
# Set log filter to mask/truncate vCenter credentials in suds logs.
suds.client.log.addFilter(SudsLogFilter())

View File

@ -102,11 +102,6 @@ class VimUtilTest(base.TestCase):
'skip': False,
'selectSet': [rp_to_rp_sel_spec,
rp_to_vm_sel_spec]},
'cr_to_rp': {'type': 'ComputeResource',
'path': 'resourcePool',
'skip': False,
'selectSet': [rp_to_rp_sel_spec,
rp_to_vm_sel_spec]},
'ccr_to_h': {'type': 'ClusterComputeResource',
'path': 'host',
'skip': False,

View File

@ -3,7 +3,7 @@
# process, which may cause wedges in the gate later.
# Hacking already pins down pep8, pyflakes and flake8
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
hacking>=3.0,<3.1.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD
mock>=2.0.0 # BSD

View File

@ -44,14 +44,18 @@ commands = {posargs}
[flake8]
show-source = True
ignore = H405
ignore = H405,W504
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,__init__.py
[hacking]
import_exceptions =
oslo_vmware.tests.base
tests.base
local-check-factory = oslo_vmware.hacking.checks.factory
[flake8:local-plugins]
extension =
N537 = checks:no_translate_logs
paths = ./oslo_vmware/hacking
[testenv:releasenotes]
whitelist_externals = rm