From 0764f5dab12034efdc41d35ccd627f2a6618c459 Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Thu, 16 Apr 2020 10:41:24 +0200 Subject: [PATCH] Update hacking for Python3 The repo is Python 3 now, so update hacking to version 3.0.1 which supports Python 3. Fix problems found. Remove hacking and friends from lower-constraints, they are not needed for installation. Change-Id: I6691687f0cd2fe4c9e7f2a76d333ca9eacb0cbf3 --- karbor/api/common.py | 2 +- karbor/api/openstack/__init__.py | 2 +- karbor/api/v1/triggers.py | 2 +- karbor/cmd/api.py | 16 ++++++++-------- karbor/cmd/manage.py | 19 ++++++++----------- karbor/cmd/operationengine.py | 14 +++++++------- karbor/cmd/protection.py | 14 +++++++------- karbor/db/sqlalchemy/api.py | 1 + karbor/quota.py | 4 ++-- karbor/services/protection/bank_plugin.py | 8 ++++---- karbor/services/protection/flows/copy.py | 6 +++--- .../image/image_protection_plugin.py | 2 +- .../network/neutron_protection_plugin.py | 10 +++++----- .../volume/cinder_protection_plugin.py | 2 +- .../volume/volume_glance_plugin.py | 2 +- .../test_network_protectable_plugin.py | 4 ++-- .../plugins/test_pod_protectable_plugin.py | 2 +- .../test_cinder_protection_plugin.py | 8 ++++---- .../test_cinder_snapshot_protection_plugin.py | 2 +- .../test_glance_protection_plugin.py | 2 +- karbor/tests/unit/protection/test_graph.py | 14 +++++++------- .../test_neutron_protection_plugin.py | 18 +++++++++--------- .../protection/test_nova_protection_plugin.py | 3 +-- .../protection/test_pod_protection_plugin.py | 2 +- karbor/wsgi/wsgi.py | 12 ++++++------ lower-constraints.txt | 5 ----- test-requirements.txt | 2 +- tools/install_venv.py | 1 + tox.ini | 4 +++- 29 files changed, 89 insertions(+), 94 deletions(-) diff --git a/karbor/api/common.py b/karbor/api/common.py index 4c1aa2b4..5f4ed6a2 100644 --- a/karbor/api/common.py +++ b/karbor/api/common.py @@ -188,7 +188,7 @@ def get_request_url(request): forwarded = headers.get('X-Forwarded-Host') if forwarded: url_parts = list(urllib.parse.urlsplit(url)) - url_parts[1] = re.split(',\s?', forwarded)[-1] + url_parts[1] = re.split(r',\s?', forwarded)[-1] url = urllib.parse.urlunsplit(url_parts).rstrip('/') return url diff --git a/karbor/api/openstack/__init__.py b/karbor/api/openstack/__init__.py index fd7d1792..60cb2bf0 100644 --- a/karbor/api/openstack/__init__.py +++ b/karbor/api/openstack/__init__.py @@ -23,7 +23,7 @@ import routes class APIMapper(routes.Mapper): def routematch(self, url=None, environ=None): - if url is "": + if url == "": result = self._match("", environ) return result[0], result[1] return routes.Mapper.routematch(self, url, environ) diff --git a/karbor/api/v1/triggers.py b/karbor/api/v1/triggers.py index d27b7c72..2ea6eb96 100644 --- a/karbor/api/v1/triggers.py +++ b/karbor/api/v1/triggers.py @@ -146,7 +146,7 @@ class TriggersController(wsgi.Controller): try: with StartNotification(context, id=id): self.operationengine_api.delete_trigger(context, id) - except exception.TriggerNotFound as ex: + except exception.TriggerNotFound: pass except (exception.DeleteTriggerNotAllowed, Exception) as ex: diff --git a/karbor/cmd/api.py b/karbor/cmd/api.py index 76cf213b..13e5bccd 100644 --- a/karbor/cmd/api.py +++ b/karbor/cmd/api.py @@ -16,19 +16,19 @@ import eventlet eventlet.monkey_patch() -import sys +import sys # noqa: E402 -from oslo_config import cfg -from oslo_log import log as logging +from oslo_config import cfg # noqa: E402 +from oslo_log import log as logging # noqa: E402 # Need to register global_opts from karbor.common import config # noqa -from karbor import i18n +from karbor import i18n # noqa: E402 i18n.enable_lazy() -from karbor import objects -from karbor import rpc -from karbor import service -from karbor import version +from karbor import objects # noqa: E402 +from karbor import rpc # noqa: E402 +from karbor import service # noqa: E402 +from karbor import version # noqa: E402 CONF = cfg.CONF diff --git a/karbor/cmd/manage.py b/karbor/cmd/manage.py index 6d11b3dc..50d2c8ca 100644 --- a/karbor/cmd/manage.py +++ b/karbor/cmd/manage.py @@ -15,9 +15,6 @@ CLI interface for karbor management. """ -from __future__ import print_function - - import os import sys @@ -31,14 +28,14 @@ i18n.enable_lazy() # Need to register global_opts from karbor.common import config # noqa -from karbor import context -from karbor import db -from karbor.db import migration as db_migration -from karbor.db.sqlalchemy import api as db_api -from karbor.i18n import _ -from karbor import objects -from karbor import utils -from karbor import version +from karbor import context # noqa: E402 +from karbor import db # noqa: E402 +from karbor.db import migration as db_migration # noqa: E402 +from karbor.db.sqlalchemy import api as db_api # noqa: E402 +from karbor.i18n import _ # noqa: E402 +from karbor import objects # noqa: E402 +from karbor import utils # noqa: E402 +from karbor import version # noqa: E402 CONF = cfg.CONF diff --git a/karbor/cmd/operationengine.py b/karbor/cmd/operationengine.py index b873c96b..b0986a4c 100644 --- a/karbor/cmd/operationengine.py +++ b/karbor/cmd/operationengine.py @@ -16,19 +16,19 @@ import eventlet eventlet.monkey_patch() -import sys +import sys # noqa: E402 -from oslo_config import cfg -from oslo_log import log as logging +from oslo_config import cfg # noqa: E402 +from oslo_log import log as logging # noqa: E402 -from karbor import i18n +from karbor import i18n # noqa: E402 i18n.enable_lazy() -from karbor import objects +from karbor import objects # noqa: E402 # Need to register global_opts from karbor.common import config # noqa -from karbor import service -from karbor import version +from karbor import service # noqa: E402 +from karbor import version # noqa: E402 CONF = cfg.CONF diff --git a/karbor/cmd/protection.py b/karbor/cmd/protection.py index e8b5fa22..2082b76a 100644 --- a/karbor/cmd/protection.py +++ b/karbor/cmd/protection.py @@ -16,19 +16,19 @@ import eventlet eventlet.monkey_patch() -import sys +import sys # noqa: E402 -from oslo_config import cfg -from oslo_log import log as logging +from oslo_config import cfg # noqa: E402 +from oslo_log import log as logging # noqa: E402 -from karbor import i18n +from karbor import i18n # noqa: E402 i18n.enable_lazy() -from karbor import objects +from karbor import objects # noqa: E402 # Need to register global_opts from karbor.common import config # noqa -from karbor import service -from karbor import version +from karbor import service # noqa: E402 +from karbor import version # noqa: E402 CONF = cfg.CONF diff --git a/karbor/db/sqlalchemy/api.py b/karbor/db/sqlalchemy/api.py index 82966286..8c198cac 100644 --- a/karbor/db/sqlalchemy/api.py +++ b/karbor/db/sqlalchemy/api.py @@ -78,6 +78,7 @@ def get_session(**kwargs): def dispose_engine(): get_engine().dispose() + _DEFAULT_QUOTA_NAME = 'default' diff --git a/karbor/quota.py b/karbor/quota.py index d18c6950..a88614d8 100644 --- a/karbor/quota.py +++ b/karbor/quota.py @@ -187,9 +187,9 @@ class DbQuotaDriver(object): # Filter resources if has_sync: - sync_filt = lambda x: hasattr(x, 'sync') + sync_filt = lambda x: hasattr(x, 'sync') # noqa: E731 else: - sync_filt = lambda x: not hasattr(x, 'sync') + sync_filt = lambda x: not hasattr(x, 'sync') # noqa: E731 desired = set(keys) sub_resources = dict((k, v) for k, v in resources.items() if k in desired and sync_filt(v)) diff --git a/karbor/services/protection/bank_plugin.py b/karbor/services/protection/bank_plugin.py index 9abfb1e4..82b0a5ba 100644 --- a/karbor/services/protection/bank_plugin.py +++ b/karbor/services/protection/bank_plugin.py @@ -71,8 +71,8 @@ def validate_dir(key): class Bank(object): - _KEY_VALIDATION = re.compile('^[A-Za-z0-9/_.\-@]+(?=0.12.0 # Apache-2.0 +hacking!=3.0.1,<3.1.0 # Apache-2.0 botocore>=1.5.1 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0 croniter>=0.3.4 # MIT License diff --git a/tools/install_venv.py b/tools/install_venv.py index 4648058d..bced3431 100644 --- a/tools/install_venv.py +++ b/tools/install_venv.py @@ -67,5 +67,6 @@ def main(argv): install.install_dependencies() print_help() + if __name__ == '__main__': main(sys.argv) diff --git a/tox.ini b/tox.ini index 09918722..d5897618 100644 --- a/tox.ini +++ b/tox.ini @@ -75,7 +75,9 @@ commands = oslopolicy-sample-generator --config-file=etc/karbor-policy-generator [flake8] show-source = True -ignore = +# W503 line break before binary operator +# W504 line break after binary operator +ignore = W503,W504 builtins = _ exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,releasenotes