]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: update pylint to 2.6.0
authorVolker Theile <vtheile@suse.com>
Fri, 25 Sep 2020 11:17:19 +0000 (13:17 +0200)
committerKefu Chai <kchai@redhat.com>
Tue, 30 Mar 2021 10:19:01 +0000 (18:19 +0800)
* Update pylint to 2.6.0.
* Fix pylint issues.

Fixes: https://tracker.ceph.com/issues/47647
Signed-off-by: Volker Theile <vtheile@suse.com>
s

(cherry picked from commit 298c91958a41674a928d53f010b20f174f16d68f)

Conflicts:
src/pybind/mgr/dashboard/requirements-lint.txt
src/pybind/mgr/dashboard/services/ceph_service.py
src/pybind/mgr/dashboard/services/ganesha.py
src/pybind/mgr/dashboard/services/rgw_client.py
src/pybind/mgr/dashboard/tests/test_access_control.py
src/pybind/mgr/dashboard/tests/test_ganesha.py
src/pybind/mgr/dashboard/tests/test_iscsi.py
src/pybind/mgr/dashboard/tests/test_rgw.py
src/pybind/mgr/dashboard/tests/test_settings.py

38 files changed:
src/pybind/mgr/dashboard/.pylintrc
src/pybind/mgr/dashboard/controllers/nfsganesha.py
src/pybind/mgr/dashboard/controllers/osd.py
src/pybind/mgr/dashboard/plugins/__init__.py
src/pybind/mgr/dashboard/requirements-lint.txt
src/pybind/mgr/dashboard/services/auth.py
src/pybind/mgr/dashboard/services/cephx.py
src/pybind/mgr/dashboard/services/ganesha.py
src/pybind/mgr/dashboard/services/iscsi_client.py
src/pybind/mgr/dashboard/services/iscsi_config.py
src/pybind/mgr/dashboard/services/progress.py
src/pybind/mgr/dashboard/services/rgw_client.py
src/pybind/mgr/dashboard/tests/__init__.py
src/pybind/mgr/dashboard/tests/helper.py
src/pybind/mgr/dashboard/tests/test_access_control.py
src/pybind/mgr/dashboard/tests/test_api_auditing.py
src/pybind/mgr/dashboard/tests/test_cephfs.py
src/pybind/mgr/dashboard/tests/test_controllers.py
src/pybind/mgr/dashboard/tests/test_docs.py
src/pybind/mgr/dashboard/tests/test_erasure_code_profile.py
src/pybind/mgr/dashboard/tests/test_exceptions.py
src/pybind/mgr/dashboard/tests/test_feature_toggles.py
src/pybind/mgr/dashboard/tests/test_grafana.py
src/pybind/mgr/dashboard/tests/test_home.py
src/pybind/mgr/dashboard/tests/test_host.py
src/pybind/mgr/dashboard/tests/test_iscsi.py
src/pybind/mgr/dashboard/tests/test_orchestrator.py
src/pybind/mgr/dashboard/tests/test_osd.py
src/pybind/mgr/dashboard/tests/test_plugin_debug.py
src/pybind/mgr/dashboard/tests/test_pool.py
src/pybind/mgr/dashboard/tests/test_prometheus.py
src/pybind/mgr/dashboard/tests/test_rbd_mirroring.py
src/pybind/mgr/dashboard/tests/test_rest_tasks.py
src/pybind/mgr/dashboard/tests/test_rgw_client.py
src/pybind/mgr/dashboard/tests/test_settings.py
src/pybind/mgr/dashboard/tests/test_sso.py
src/pybind/mgr/dashboard/tests/test_tools.py
src/pybind/mgr/dashboard/tools.py

index 404a16a2e6fa9a269ad2e869527c93f69158c77e..c4bf033cdae65ba1906408801fed8789359f7c9a 100644 (file)
@@ -15,7 +15,7 @@ ignore-patterns=
 
 # Python code to execute, usually for sys.path manipulation such as
 # pygtk.require().
-#init-hook=
+init-hook='import sys; sys.path.append("./")'
 
 # Use multiple processes to speed up Pylint.
 jobs=1
@@ -118,7 +118,11 @@ disable=import-star-module-level,
         too-many-arguments,
         too-many-locals,
         too-many-statements,
-        useless-object-inheritance
+        useless-object-inheritance,
+        relative-beyond-top-level,
+        raise-missing-from,
+        super-with-arguments,
+        import-outside-toplevel
 
 
 # Enable the message, report, category or checker with the given id(s). You can
index f00a277da4f12dfabf3280c88b6564d73926fb04..1630657a7fc224ce16d172a02dcccc1d65217161 100644 (file)
@@ -258,7 +258,7 @@ class NFSGaneshaUi(BaseController):
     @Endpoint('GET', '/cephx/clients')
     @ReadPermission
     def cephx_clients(self):
-        return [client for client in CephX.list_clients()]
+        return list(CephX.list_clients())
 
     @Endpoint('GET', '/fsals')
     @ReadPermission
index accccd7703b47d2f317a3d86d5ccd5c57653ee12..bb8cf55859d2f02bf58478c48bc99ce835f23dac 100644 (file)
@@ -295,7 +295,7 @@ class Osd(RESTController):
 
     @CreatePermission
     @osd_task('create', {'tracking_id': '{tracking_id}'})
-    def create(self, method, data, tracking_id):  # pylint: disable=W0622
+    def create(self, method, data, tracking_id):  # pylint: disable=unused-argument
         if method == 'bare':
             return self._create_bare(data)
         if method == 'drive_groups':
index 8973654770278f8bcd1296a6f1e6853c6461f141..3e3aca400175383000002abd2c76ac774ef48278 100644 (file)
@@ -71,4 +71,4 @@ class DashboardPluginManager(object):
 PLUGIN_MANAGER = DashboardPluginManager("ceph-mgr.dashboard")
 
 # Load all interfaces and their hooks
-from . import interfaces  # noqa: F401 pylint: disable=wrong-import-position,cyclic-import
+from . import interfaces  # noqa pylint: disable=C0413,W0406
index 19a6fa5bc2f037ba57051fd0487f5567c1851cc7..cc646e97979deee1875bbbabdc1e54a14e075561 100644 (file)
@@ -1,4 +1,4 @@
-pylint==2.3.1; python_version >= '3'
+pylint==2.6.0; python_version >= '3'
 flake8==3.9.0; python_version >= '3'
 flake8-colors==0.1.6; python_version >= '3'
 #TODO: Fix docstring issues: https://tracker.ceph.com/issues/41224
index e9bf1bbd419ca4863dd7d84edd36017f76a0173b..916afca99a1f77e9685cdabf32988dad51a78e63 100644 (file)
@@ -192,7 +192,6 @@ class AuthManagerTool(cherrypy.Tool):
 
     def _check_authorization(self, username):
         self.logger.debug("checking authorization...")
-        username = username
         handler = cherrypy.request.handler.callable
         controller = handler.__self__
         sec_scope = getattr(controller, '_security_scope', None)
index ccda38796119f2a69e7683c1b1608c33f43170fb..60303ad85fd68d835e7bb4337326264ac6b153cf 100644 (file)
@@ -22,7 +22,7 @@ class CephX(object):
 
     @classmethod
     def list_clients(cls):
-        return [client for client in cls._clients_map()]
+        return list(cls._clients_map())
 
     @classmethod
     def get_client_key(cls, client_id):
index 2c963e25f4b3bf190bb9471174388c60ff5b38a7..b51ab38f75789b601e021e5f96abaebb4ec151a5 100644 (file)
@@ -109,7 +109,7 @@ class Ganesha(object):
 
     @classmethod
     def get_ganesha_clusters(cls):
-        return [cluster_id for cluster_id in cls._get_clusters_locations()]
+        return list(cls._get_clusters_locations())
 
     @staticmethod
     def _get_orch_nfs_services() -> List[ServiceDescription]:
@@ -322,7 +322,7 @@ class GaneshaConfParser(object):
         for key, val in block.items():
             if key == 'block_name':
                 continue
-            elif key == '_blocks_':
+            if key == '_blocks_':
                 for blo in val:
                     conf_str += GaneshaConfParser.write_block(blo, depth)
             elif val:
@@ -687,21 +687,21 @@ class Export(object):
             result['attr_expiration_time'] = self.attr_expiration_time
             result['security_label'] = self.security_label
         if 'protocols' not in defaults:
-            result['protocols'] = [p for p in self.protocols]
+            result['protocols'] = list(self.protocols)
         else:
             def_proto = defaults['protocols']
             if not isinstance(def_proto, list):
                 def_proto = set([def_proto])
             if self.protocols != def_proto:
-                result['protocols'] = [p for p in self.protocols]
+                result['protocols'] = list(self.protocols)
         if 'transports' not in defaults:
-            result['transports'] = [t for t in self.transports]
+            result['transports'] = list(self.transports)
         else:
             def_transp = defaults['transports']
             if not isinstance(def_transp, list):
                 def_transp = set([def_transp])
             if self.transports != def_transp:
-                result['transports'] = [t for t in self.transports]
+                result['transports'] = list(self.transports)
 
         result['_blocks_'] = [self.fsal.to_fsal_block()]
         result['_blocks_'].extend([client.to_client_block()
@@ -731,14 +731,14 @@ class Export(object):
             'path': self.path,
             'fsal': self.fsal.to_dict(),
             'cluster_id': self.cluster_id,
-            'daemons': sorted([d for d in self.daemons]),
+            'daemons': sorted(list(self.daemons)),
             'pseudo': self.pseudo,
             'tag': self.tag,
             'access_type': self.access_type,
             'squash': self.squash,
             'security_label': self.security_label,
-            'protocols': sorted([p for p in self.protocols]),
-            'transports': sorted([t for t in self.transports]),
+            'protocols': sorted(list(self.protocols)),
+            'transports': sorted(list(self.transports)),
             'clients': [client.to_dict() for client in self.clients]
         }
 
index cde4f7a6b73e375cd04e7202ecdb19a75a389137..b5ab88629aebfb5fdd86a746207b9d348d4667c7 100644 (file)
@@ -12,7 +12,7 @@ try:
 except ImportError:
     from urllib.parse import urlparse
 
-from .iscsi_config import IscsiGatewaysConfig  # pylint: disable=cyclic-import
+from .iscsi_config import IscsiGatewaysConfig
 from ..settings import Settings
 from ..rest_client import RestClient
 
index ab900485001b0a33796f7bcfcd565692b297ba83..86bdfc770d27dc597087e09b092a6e675e9abf87 100644 (file)
@@ -57,7 +57,7 @@ class IscsiGatewaysConfig(object):
         """
         for gateway_name, gateway_config in config['gateways'].items():
             if '.' not in gateway_name:
-                from .iscsi_client import IscsiClient
+                from .iscsi_client import IscsiClient  # pylint: disable=cyclic-import
                 from ..rest_client import RequestException
                 try:
                     service_url = gateway_config['service_url']
index d8cf7521fae3bc755e92ddc0bffaa95a25b22e95..d7b9ed973b560ba3640e5003b4240864a4b1168e 100644 (file)
@@ -12,7 +12,7 @@ from __future__ import absolute_import
 from datetime import datetime
 import logging
 
-from . import rbd
+from . import rbd  # pylint: disable=no-name-in-module
 from .. import mgr
 
 
index 69093acf599b4a6d4a3739b0a72f16c14d244aac..bb1bf2a92181928c8abab2e0ba5764b8504a3a65 100644 (file)
@@ -314,6 +314,7 @@ class RgwClient(RestClient):
         if self.userid != RgwClient._SYSTEM_USERID:
             logger.info("Fetching new keys for user: %s", self.userid)
             keys = RgwClient.admin_instance().get_user_keys(self.userid)
+            # pylint: disable=attribute-defined-outside-init
             self.auth = S3Auth(keys['access_key'], keys['secret_key'],
                                service_url=self.service_url)
         else:
index ca049c088bed2a2d2ea7f44605845657e5cb63a6..00bfcda3eabf0b49edd8ef12ce5496a646d0a478 100644 (file)
@@ -21,7 +21,7 @@ from ..services.auth import AuthManagerTool
 from ..services.exception import dashboard_exception_handler
 
 from ..plugins import PLUGIN_MANAGER
-from ..plugins import feature_toggles, debug  # noqa # pylint: disable=unused-import
+from ..plugins import feature_toggles, debug  # noqa
 
 
 PLUGIN_MANAGER.hook.init()
index 9ec043d6bec6924d5edfae57a8a067967153da11..06b83d42a82cf4ef935f746701ebc4d82497c4f8 100644 (file)
@@ -2,7 +2,7 @@
 from __future__ import absolute_import
 
 try:
-    from typing import Dict, Any  # pylint: disable=unused-import
+    from typing import Dict, Any
 except ImportError:
     pass
 
index c3c1b29f48c1f888669c71a7c55a6092710d8469..ffe2f05b8e72fca5bcbc9d74e20694f566dc9ed2 100644 (file)
@@ -11,7 +11,7 @@ from datetime import datetime, timedelta
 
 from mgr_module import ERROR_MSG_EMPTY_INPUT_FILE
 
-from . import CmdException, CLICommandTestMixin
+from . import CmdException, CLICommandTestMixin  # pylint: disable=no-name-in-module
 from .. import mgr
 from ..security import Scope, Permission
 from ..services.access_control import load_access_control_db, \
index 0416c0363857968be7ad87fe8199126e16042b62..023ea7992a1f7a1b2f9b124f842ee63dea1faf2f 100644 (file)
@@ -9,7 +9,7 @@ try:
 except ImportError:
     import unittest.mock as mock
 
-from . import ControllerTestCase, KVStoreMockMixin
+from . import ControllerTestCase, KVStoreMockMixin  # pylint: disable=no-name-in-module
 from ..controllers import RESTController, Controller
 from ..tools import RequestLoggingTool
 from .. import mgr
index e9abda538090852197e61a1b9d6762d9608a6a71..778b0aa2750b9af6ec4d2a9806ae8916cc6f1fea 100644 (file)
@@ -6,7 +6,7 @@ except ImportError:
     from unittest.mock import Mock
 
 from .. import mgr
-from . import ControllerTestCase
+from . import ControllerTestCase  # pylint: disable=no-name-in-module
 from ..controllers.cephfs import CephFS
 
 
index 0e880470615e19d0d05d6ba57f2c3268a0a6dcfa..b14878ff2e44a54b5fcc79b6b24081b39fb57b2e 100644 (file)
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 from __future__ import absolute_import
 
-from . import ControllerTestCase
+from . import ControllerTestCase  # pylint: disable=no-name-in-module
 from ..controllers import BaseController, RESTController, Controller, \
                           ApiController, Endpoint
 
index a6e03b526711ea85442a3f71961bb9961e5674f8..ccb777aca5f2a5df74d2d976e8e91f7974765668 100644 (file)
@@ -1,7 +1,7 @@
 # # -*- coding: utf-8 -*-
 from __future__ import absolute_import
 
-from . import ControllerTestCase
+from . import ControllerTestCase  # pylint: disable=no-name-in-module
 from ..controllers import RESTController, ApiController, Endpoint, EndpointDoc, ControllerDoc
 from ..controllers.docs import Docs
 
index 557b7c1061b166c245be08582d28cfe3a7e4b1cb..d266735e8f5c2268771cac7dee2affba4d22c17d 100644 (file)
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 
 from .. import mgr
-from . import ControllerTestCase
+from . import ControllerTestCase  # pylint: disable=no-name-in-module
 from ..controllers.erasure_code_profile import ErasureCodeProfile
 
 
index 2bb25da1bf3d0f21b29ceca4549929ee8e9512ed..b42c3564799b3004cb988f81d4599ae393754acf 100644 (file)
@@ -5,7 +5,7 @@ import time
 
 import rados
 
-from . import ControllerTestCase
+from . import ControllerTestCase  # pylint: disable=no-name-in-module
 from ..services.ceph_service import SendCommandError
 from ..controllers import RESTController, Controller, Task, Endpoint
 from ..services.exception import handle_rados_error, handle_send_command_error, \
index 031d0ef8394448fe178b6c7c06b0096a797f6b58..23068c5eda75c5c932d9b2bc1eea4e7067e6accb 100644 (file)
@@ -7,7 +7,7 @@ try:
 except ImportError:
     from unittest.mock import Mock, patch
 
-from . import KVStoreMockMixin
+from . import KVStoreMockMixin  # pylint: disable=no-name-in-module
 from ..plugins.feature_toggles import FeatureToggles, Features
 
 
index 0eb46bf0f00061dafc48bf6d64151d5aac0a764c..a5456905f20279d0e149e2246082278c2e950a16 100644 (file)
@@ -8,7 +8,7 @@ except ImportError:
 
 from requests import RequestException
 
-from . import ControllerTestCase, KVStoreMockMixin
+from . import ControllerTestCase, KVStoreMockMixin  # pylint: disable=no-name-in-module
 from ..controllers.grafana import Grafana
 from ..grafana import GrafanaRestClient
 from ..settings import Settings
index c3088b7a6506ff57d986f482f2deaca335beeed1..c942eed9be816e46ec9b59291eb902b97e6ecf46 100644 (file)
@@ -8,7 +8,7 @@ try:
 except ImportError:
     import unittest.mock as mock
 
-from . import ControllerTestCase, FakeFsMixin
+from . import ControllerTestCase, FakeFsMixin  # pylint: disable=no-name-in-module
 from .. import mgr
 
 from ..controllers.home import HomeController, LanguageMixin
index ab7286074b7386b53adb88a99756a2ffdc8e3c31..191c3f1245f4be194b50641e932556e9dc3c8436 100644 (file)
@@ -7,7 +7,7 @@ except ImportError:
 
 from orchestrator import HostSpec
 
-from . import ControllerTestCase
+from . import ControllerTestCase  # pylint: disable=no-name-in-module
 from ..controllers.host import get_hosts, Host, HostUi
 from .. import mgr
 
index 5115d849d09a5d63f85322eb612a3c3e828d25ae..0a6f4a72b9793f24e69b9c2d040a86c6786672c3 100644 (file)
@@ -12,7 +12,8 @@ except ImportError:
 
 from mgr_module import ERROR_MSG_NO_INPUT_FILE
 
-from . import CmdException, ControllerTestCase, CLICommandTestMixin, KVStoreMockMixin
+from . import CmdException, ControllerTestCase, CLICommandTestMixin, \
+    KVStoreMockMixin  # pylint: disable=no-name-in-module
 from .. import mgr
 from ..controllers.iscsi import Iscsi, IscsiTarget
 from ..services.iscsi_client import IscsiClient
index 714d59c08565fb98fdd3f7bbd940003067c53893..9a9d179bbc9e7d4530f88af68dc6498904cf91fd 100644 (file)
@@ -6,7 +6,7 @@ except ImportError:
 
 from orchestrator import InventoryHost
 
-from . import ControllerTestCase
+from . import ControllerTestCase  # pylint: disable=no-name-in-module
 from .. import mgr
 from ..controllers.orchestrator import get_device_osd_map
 from ..controllers.orchestrator import Orchestrator
index aeb32ed576452503c1eb4c5f5743bf4d1684a912..063705ddbb08018a63bc8a19f0c98cd645a50071 100644 (file)
@@ -11,11 +11,11 @@ except ImportError:
 from ceph.deployment.drive_group import DeviceSelection, DriveGroupSpec
 from ceph.deployment.service_spec import PlacementSpec
 
-from . import ControllerTestCase
+from . import ControllerTestCase  # pylint: disable=no-name-in-module
 from ..controllers.osd import Osd
 from ..tools import NotificationQueue, TaskManager
 from .. import mgr
-from .helper import update_dict
+from .helper import update_dict  # pylint: disable=import-error
 
 try:
     from typing import List, Dict, Any  # pylint: disable=unused-import
index 4985540046ca9cd2db05329cbb645529bc05200e..cb4d1afc21844f53c1c80d081bdba5b3250779b7 100644 (file)
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 from __future__ import absolute_import
 
-from . import CLICommandTestMixin, ControllerTestCase
+from . import CLICommandTestMixin, ControllerTestCase  # pylint: disable=no-name-in-module
 
 
 class TestPluginDebug(ControllerTestCase, CLICommandTestMixin):
index e33e4365405378b91dcac431640daa1c242b6b06..179a8feeed80030c442b3afac97bec240a5d65d7 100644 (file)
@@ -6,7 +6,7 @@ try:
 except ImportError:
     import unittest.mock as mock
 
-from . import ControllerTestCase
+from . import ControllerTestCase  # pylint: disable=no-name-in-module
 from ..controllers.pool import Pool
 from ..controllers.task import Task
 from ..tools import NotificationQueue, TaskManager
index c9d6ff0dd79b609095d5a0d8315e9b1682555005..fcaad811b704ce14b6f67b3b112dc81db70ffcdd 100644 (file)
@@ -5,7 +5,7 @@ try:
 except ImportError:
     from unittest.mock import patch
 
-from . import ControllerTestCase
+from . import ControllerTestCase  # pylint: disable=no-name-in-module
 from .. import mgr
 from ..controllers.prometheus import Prometheus, PrometheusReceiver, PrometheusNotifications
 
index ecb4856dc193fbc7f38e65d5a18536762cc1211b..d7e0c7dd1e87966df7b5e86875e57484a5b811ab 100644 (file)
@@ -6,7 +6,7 @@ try:
 except ImportError:
     import unittest.mock as mock
 
-from . import ControllerTestCase
+from . import ControllerTestCase  # pylint: disable=no-name-in-module
 from .. import mgr
 from ..controllers.summary import Summary
 from ..controllers.rbd_mirroring import RbdMirroring, RbdMirroringSummary, \
index e9d7907f0524bdc246bd8392908fe761398652df..aa158cd288ce1b2e3c3949f4219d624a33d920a5 100644 (file)
@@ -8,7 +8,7 @@ try:
 except ImportError:
     import unittest.mock as mock
 
-from . import ControllerTestCase
+from . import ControllerTestCase  # pylint: disable=no-name-in-module
 from ..controllers import Controller, RESTController, Task
 from ..controllers.task import Task as TaskController
 from ..services import progress
index 3f742d45f7ff14c7827edca133ae462ecbfb36c3..7cde2d4c3ff421341b435523aeb8b911fe1f5723 100644 (file)
@@ -9,7 +9,7 @@ except ImportError:
 
 from ..services.rgw_client import RgwClient, _parse_frontend_config
 from ..settings import Settings
-from . import KVStoreMockMixin
+from . import KVStoreMockMixin  # pylint: disable=no-name-in-module
 
 
 def _dummy_daemon_info():
index 39c0aaaa6ce269dc7f78569a8cc6571e89437c15..abe2558cd0cc0e5db96d3afde5a4f72207e10e98 100644 (file)
@@ -6,7 +6,7 @@ import unittest
 
 from mgr_module import ERROR_MSG_EMPTY_INPUT_FILE
 
-from . import KVStoreMockMixin, ControllerTestCase
+from . import KVStoreMockMixin, ControllerTestCase  # pylint: disable=no-name-in-module
 from .. import settings
 from ..controllers.settings import Settings as SettingsController
 from ..settings import Settings, handle_option_command
index f8681b89ede8d8784b89bfa61aeb011c3f1a2cd5..e8141a09cc360817ddf045121b1e6f2bc4bae373 100644 (file)
@@ -5,7 +5,8 @@ from __future__ import absolute_import
 import errno
 import unittest
 
-from . import CmdException, exec_dashboard_cmd, KVStoreMockMixin
+from . import CmdException, exec_dashboard_cmd, \
+    KVStoreMockMixin  # pylint: disable=no-name-in-module
 from ..services.sso import handle_sso_command, load_sso_db
 
 
index 0f27ec8e634670b849819589f8c0187f28a880a9..340ff8c41d5e43ec45cfc79c005aae33260b2537 100644 (file)
@@ -10,7 +10,7 @@ try:
 except ImportError:
     from unittest.mock import patch
 
-from . import ControllerTestCase
+from . import ControllerTestCase  # pylint: disable=no-name-in-module
 from ..services.exception import handle_rados_error
 from ..controllers import RESTController, ApiController, Controller, \
                           BaseController, Proxy
index ec88cbbff74c6165a2f069f4dab1c37517214bbd..1a630b832c29df9c5951c241addb5380362c5ade 100644 (file)
@@ -30,7 +30,7 @@ from .services.auth import JwtManager
 
 try:
     from typing import Any, AnyStr, Callable, DefaultDict, Deque,\
-        Dict, List, Set, Tuple, Union  # noqa pylint: disable=unused-import
+        Dict, List, Set, Tuple, Union  # noqa
 except ImportError:
     pass  # For typing only