]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr: use annotation style without comment 49058/head
authorKefu Chai <tchaikov@gmail.com>
Thu, 24 Nov 2022 06:01:13 +0000 (14:01 +0800)
committerIlya Dryomov <idryomov@gmail.com>
Fri, 25 Nov 2022 14:03:44 +0000 (15:03 +0100)
* use annotation style without comment
* add noqa to import statement to prevent flake8 from complaining
  those which import typing modules

to silence the warnings like:

```
flake8 run-test: commands[0] | flake8 --config=tox.ini alerts balancer cephadm cli_api crash devicehealth diskprediction_local hello iostat localpool nfs orchestrator prometheus selftest
cephadm/schedule.py:5:1: F401 'typing.Callable' imported but unused
cephadm/schedule.py:8:1: F401 'ceph.deployment.service_spec.ServiceSpec' imported but unused
cephadm/tests/fixtures.py:17:1: F401 'orchestrator.OrchResult' imported but unused
orchestrator/module.py:4:1: F401 'typing.Set' imported but unused
orchestrator/module.py:17:1: F401 'ceph.deployment.inventory.Device' imported but unused
prometheus/module.py:17:1: F401 'typing.DefaultDict' imported but unused
6     F401 'typing.Callable' imported but unused
ERROR: InvocationError for command /home/jenkins-build/build/workspace/ceph-pull-requests/src/pybind/mgr/.tox/flake8/bin/flake8 --config=tox.ini alerts
```

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
(cherry picked from commit 7894e7bdd1c25d86a71e3dcdc88c46062cb31101)

Conflicts:
src/pybind/mgr/orchestrator/module.py [ commit 28314cebef32
  ("mgr/cephadm: Adding support for natural sorting") not in
  pacific ]
src/pybind/mgr/cephadm/services/exporter.py [ additional
  pacific-only change, this file doesn't exist in main ]

src/pybind/mgr/cephadm/schedule.py
src/pybind/mgr/cephadm/services/exporter.py
src/pybind/mgr/cephadm/tests/fixtures.py
src/pybind/mgr/orchestrator/module.py
src/pybind/mgr/prometheus/module.py

index 5002ec6e5060e66f71c378f8e574bb8639384ec1..a727f50491f509718c11593f264ba2b5191cac07 100644 (file)
@@ -140,12 +140,12 @@ class DaemonPlacement(NamedTuple):
 class HostAssignment(object):
 
     def __init__(self,
-                 spec,  # type: ServiceSpec
+                 spec: ServiceSpec,
                  hosts: List[orchestrator.HostSpec],
                  unreachable_hosts: List[orchestrator.HostSpec],
                  daemons: List[orchestrator.DaemonDescription],
                  networks: Dict[str, Dict[str, Dict[str, List[str]]]] = {},
-                 filter_new_host=None,  # type: Optional[Callable[[str],bool]]
+                 filter_new_host: Optional[Callable[[str], bool]] = None,
                  allow_colo: bool = False,
                  primary_daemon_type: Optional[str] = None,
                  per_host_daemon_type: Optional[str] = None,
index d6bef885bc2fea214da6a2697195bbbac42dbded..b9c7d85e6256aba59b2a15378d447ee80b59f80a 100644 (file)
@@ -17,8 +17,8 @@ class CephadmExporterConfig:
     required_keys = ['crt', 'key', 'token', 'port']
     DEFAULT_PORT = '9443'
 
-    def __init__(self, mgr, crt="", key="", token="", port=""):
-        # type: (CephadmOrchestrator, str, str, str, str) -> None
+    def __init__(self, mgr: "CephadmOrchestrator", crt: str = "", key: str = "",
+                 token: str = "", port: str = "") -> None:
         self.mgr = mgr
         self.crt = crt
         self.key = key
index eef15e83056870cb9fe59e8eb5f4d1ebc714fafd..8c2e1cfbfbb621b734e87606474237445e5e336a 100644 (file)
@@ -80,8 +80,7 @@ def with_cephadm_module(module_options=None, store=None):
         yield m
 
 
-def wait(m, c):
-    # type: (CephadmOrchestrator, OrchResult) -> Any
+def wait(m: CephadmOrchestrator, c: OrchResult) -> Any:
     return raise_if_exception(c)
 
 
index 4e7ddf247ef3d6e01c281888467b1eddc2cc5063..2288cfeef35c6aff418d065d2b977cbc6bccca05 100644 (file)
@@ -8,7 +8,7 @@ import datetime
 import yaml
 from prettytable import PrettyTable
 
-from ceph.deployment.inventory import Device
+from ceph.deployment.inventory import Device  # noqa: F401; pylint: disable=unused-variable
 from ceph.deployment.drive_group import DriveGroupSpec, DeviceSelection, OSDMethod
 from ceph.deployment.service_spec import PlacementSpec, ServiceSpec, service_spec_allow_invalid_from_json
 from ceph.deployment.hostspec import SpecValidationError
@@ -216,8 +216,8 @@ class OrchestratorCli(OrchestratorClientMixin, MgrModule,
 
     def __init__(self, *args: Any, **kwargs: Any) -> None:
         super(OrchestratorCli, self).__init__(*args, **kwargs)
-        self.ident = set()  # type: Set[str]
-        self.fault = set()  # type: Set[str]
+        self.ident: Set[str] = set()
+        self.fault: Set[str] = set()
         self._load()
         self._refresh_health()
 
index 0d073eb6b03300fc70a38dd8184cfb237ea5a085..dd225ad03bb5640814501af3372ce5473ff36609 100644 (file)
@@ -1031,7 +1031,7 @@ class Module(MgrModule):
         pg_summary = self.get('pg_summary')
 
         for pool in pg_summary['by_pool']:
-            num_by_state = defaultdict(int)  # type: DefaultDict[str, int]
+            num_by_state: DefaultDict[str, int] = defaultdict(int)
 
             for state_name, count in pg_summary['by_pool'][pool].items():
                 for state in state_name.split('+'):