From ad8e5a1d5009ce76cfcaaefc8c56b5a659b69179 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 (cherry picked from commit 12aa2913baa4e004d2198f0a5fd3ad9ccfeb302d) --- 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 5335ee7dcb..c36342ae64 100644 --- a/manila/exception.py +++ b/manila/exception.py @@ -574,6 +574,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 19df4f6257..e51f67e28d 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 26fc8d3647..2c2c164735 100644 --- a/manila/share/manager.py +++ b/manila/share/manager.py @@ -5876,7 +5876,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 503c1b1cb2..57e478bdc8 100644 --- a/tox.ini +++ b/tox.ini @@ -115,7 +115,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}