From 12aa2913baa4e004d2198f0a5fd3ad9ccfeb302d Mon Sep 17 00:00:00 2001 From: silvacarloss Date: Wed, 13 Mar 2024 10:59:18 -0300 Subject: [PATCH] Bump pylint version and fix pylint issues Bumps pylint to version 3.0.2 and fixes some issues in the code by either ignoring or changing the way we are approaching them. Signed-off-by: silvacarloss Change-Id: Ifdc9ae9326f2b3d63d4b2e9ce14854f391d504a9 --- manila/exception.py | 4 ++++ manila/scheduler/evaluator/evaluator.py | 2 +- manila/share/api.py | 15 ++++++++++----- manila/share/manager.py | 2 +- tox.ini | 2 +- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/manila/exception.py b/manila/exception.py index 7b6a2155c6..e4f00133b1 100644 --- a/manila/exception.py +++ b/manila/exception.py @@ -578,6 +578,10 @@ class ShareBackendException(ManilaException): message = _("Share backend error: %(msg)s.") +class OperationNotSupportedByDriverMode(ManilaException): + message = _("The share driver mode does not support this operation.") + + class RequirementMissing(ManilaException): message = _("Requirement %(req)s is not installed.") diff --git a/manila/scheduler/evaluator/evaluator.py b/manila/scheduler/evaluator/evaluator.py index ae41554ecc..34ccd3eae3 100644 --- a/manila/scheduler/evaluator/evaluator.py +++ b/manila/scheduler/evaluator/evaluator.py @@ -227,7 +227,7 @@ _vars = {} def _def_parser(): # Enabling packrat parsing greatly speeds up the parsing. - pyparsing.ParserElement.enablePackrat() + pyparsing.ParserElement.enablePackrat() # pylint: disable = no-value-for-parameter # noqa:E501 alphas = pyparsing.alphas Combine = pyparsing.Combine diff --git a/manila/share/api.py b/manila/share/api.py index f76858a33f..3a89a2f771 100644 --- a/manila/share/api.py +++ b/manila/share/api.py @@ -137,6 +137,7 @@ class API(base.Base): self.access_helper = access.ShareInstanceAccess(self.db, None) coordination.LOCK_COORDINATOR.start() + # pylint: disable = no-self-argument def prevent_locked_action_on_share(arg): """Decorator for preventing a locked method from executing on a share. @@ -471,6 +472,7 @@ class API(base.Base): az_request_multiple_subnet_support_map = ( compatible_azs_multiple) + share = None try: share = self.db.share_create(context, options, create_share_instance=False) @@ -478,7 +480,8 @@ class API(base.Base): except Exception: with excutils.save_and_reraise_exception(): try: - self.db.share_delete(context, share['id']) + if share: + self.db.share_delete(context, share['id']) finally: QUOTAS.rollback( context, reservations, share_type_id=share_type_id) @@ -844,6 +847,7 @@ class API(base.Base): else: cast_rules_to_readonly = False + share_replica = None try: request_spec, share_replica = ( self.create_share_instance_and_get_request_spec( @@ -862,9 +866,10 @@ class API(base.Base): except Exception: with excutils.save_and_reraise_exception(): try: - self.db.share_replica_delete( - context, share_replica['id'], - need_to_update_usages=False) + if share_replica: + self.db.share_replica_delete( + context, share_replica['id'], + need_to_update_usages=False) finally: QUOTAS.rollback( context, reservations, share_type_id=share_type['id']) @@ -1639,8 +1644,8 @@ class API(base.Base): if metadata: options.update({"metadata": metadata}) + snapshot = None try: - snapshot = None snapshot = self.db.share_snapshot_create(context, options) QUOTAS.commit( context, reservations, diff --git a/manila/share/manager.py b/manila/share/manager.py index 08c2389cd4..6bef6a4bed 100644 --- a/manila/share/manager.py +++ b/manila/share/manager.py @@ -5883,7 +5883,7 @@ class ShareManager(manager.SchedulerDependentManager): if not self.driver.driver_handles_share_servers: LOG.error('This operation is supported only on backends that ' 'handle share servers.') - raise + raise exception.OperationNotSupportedByDriverMode() self._share_server_migration_start_driver( context, share_server, dest_host, writable, nondisruptive, diff --git a/tox.ini b/tox.ini index 522ea66668..dc82ed9aae 100644 --- a/tox.ini +++ b/tox.ini @@ -122,7 +122,7 @@ commands = [testenv:pylint] deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt - pylint==2.3.1 + pylint==3.0.2 allowlist_externals = bash commands = bash ./tools/coding-checks.sh --pylint {posargs}