From 9923d2a1193c374b9c2e00b5ee69023cb72a9f00 Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Mon, 18 Jan 2021 16:27:18 +0100 Subject: [PATCH] mgr/orchestrator: ignore Liskov substitution principle violation 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 --- src/pybind/mgr/cephadm/module.py | 2 +- src/pybind/mgr/rook/module.py | 4 +--- src/pybind/mgr/test_orchestrator/module.py | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 2885b1875aa..a3613e1a936 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -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. """ diff --git a/src/pybind/mgr/rook/module.py b/src/pybind/mgr/rook/module.py index cef24e5c27c..101b97a7a26 100644 --- a/src/pybind/mgr/rook/module.py +++ b/src/pybind/mgr/rook/module.py @@ -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))) diff --git a/src/pybind/mgr/test_orchestrator/module.py b/src/pybind/mgr/test_orchestrator/module.py index 56f13388443..85f67e8d7db 100644 --- a/src/pybind/mgr/test_orchestrator/module.py +++ b/src/pybind/mgr/test_orchestrator/module.py @@ -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))) -- 2.39.5