]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr: use annotation style without comment 49040/head
authorKefu Chai <tchaikov@gmail.com>
Thu, 24 Nov 2022 06:01:13 +0000 (14:01 +0800)
committerKefu Chai <tchaikov@gmail.com>
Thu, 24 Nov 2022 06:47:00 +0000 (14:47 +0800)
* 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>
src/pybind/mgr/cephadm/schedule.py
src/pybind/mgr/cephadm/tests/fixtures.py
src/pybind/mgr/orchestrator/module.py
src/pybind/mgr/prometheus/module.py

index 692b4282e860e6ab196e771f14c22fd391f82dad..09c8c4e43cdcd6e4241eea0a710f51e1bed11ef6 100644 (file)
@@ -141,13 +141,13 @@ class DaemonPlacement(NamedTuple):
 class HostAssignment(object):
 
     def __init__(self,
-                 spec,  # type: ServiceSpec
+                 spec: ServiceSpec,
                  hosts: List[orchestrator.HostSpec],
                  unreachable_hosts: List[orchestrator.HostSpec],
                  draining_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 2ca027a37d525edcd8cf067608c3898bfb3414ae..7b5cc459fbcf5ae13a6a67c4c573fdf6b009dd7c 100644 (file)
@@ -134,8 +134,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 91ce66b49bda66604d3090bb8d291b65906abb91..c54da23c24d39b08bab3eb7c4edaa455add819ec 100644 (file)
@@ -14,7 +14,7 @@ except ImportError:
     # fallback to normal sort
     natsorted = sorted  # type: ignore
 
-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, TracingSpec
 from ceph.deployment.hostspec import SpecValidationError
@@ -227,8 +227,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 8e930bb304ed31e3780da373b82501ada1416345..f776813bfc16f96530386f675654b2a85002000d 100644 (file)
@@ -1043,7 +1043,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('+'):