]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/orchestrator: ignore Liskov substitution principle violation
authorSebastian Wagner <sebastian.wagner@suse.com>
Mon, 18 Jan 2021 15:27:18 +0000 (16:27 +0100)
committerJuan Miguel Olmo Martínez <jolmomar@redhat.com>
Mon, 25 Jan 2021 16:56:49 +0000 (17:56 +0100)
Right now, we're violating the Liskov substitution principle by deriving from `Orchestrator` but `process` takes a sub class of `Completion`:
See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides

The idea is to make Orchestrator a type constructor with `CompletionT` as argument, but this is not supported by mypy: https://github.com/python/typing/issues/548

Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
(cherry picked from commit 9923d2a1193c374b9c2e00b5ee69023cb72a9f00)

src/pybind/mgr/cephadm/module.py
src/pybind/mgr/rook/module.py
src/pybind/mgr/test_orchestrator/module.py

index 1eb73bf837d370cef4f9a134adac519976c2f07b..f788f5ee623d277d3983339ad3e7ad76e92f5b54 100644 (file)
@@ -685,7 +685,7 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule,
             return False, 'SSH keys not set. Use `ceph cephadm set-priv-key` and `ceph cephadm set-pub-key` or `ceph cephadm generate-key`'
         return True, ''
 
-    def process(self, completions: List[CephadmCompletion]) -> None:
+    def process(self, completions: List[CephadmCompletion]) -> None:  # type: ignore
         """
         Does nothing, as completions are processed in another thread.
         """
index cef24e5c27c57f802cce9f732d0daec2960d16bb..101b97a7a2690a3601a53d22942281f203118f8d 100644 (file)
@@ -102,9 +102,7 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator):
         # TODO: configure k8s API addr instead of assuming local
     ]
 
-    def process(self, completions):
-        # type: (List[RookCompletion]) -> None
-
+    def process(self, completions: List[RookCompletion]) -> None:  # type: ignore
         if completions:
             self.log.info("process: completions={0}".format(orchestrator.pretty_print(completions)))
 
index 56f13388443c98057868f533fd55d11b77daf88e..85f67e8d7db94546a1f7e67148c0ff6cab0a6129 100644 (file)
@@ -67,8 +67,7 @@ class TestOrchestrator(MgrModule, orchestrator.Orchestrator):
     The implementation is similar to the Rook orchestrator, but simpler.
     """
 
-    def process(self, completions):
-        # type: (List[TestCompletion]) -> None
+    def process(self, completions: List[TestCompletion]) -> None:  # type: ignore
         if completions:
             self.log.info("process: completions={0}".format(orchestrator.pretty_print(completions)))