From e6d7fb67282dfd8d1f614980821f9cb7ff4fdf51 Mon Sep 17 00:00:00 2001 From: Michael Fritch Date: Mon, 4 May 2020 14:54:54 -0600 Subject: [PATCH] mgr/orch: fix mypy errors orchestrator/module.py: note: In member "_daemon_add_misc" of class "OrchestratorCli": orchestrator/module.py:655: error: Incompatible types in assignment (expression has type "PlacementSpec", variable has type "Optional[str]") orchestrator/module.py:656: error: Argument 1 to "ServiceSpec" has incompatible type "Optional[str]"; expected "str" orchestrator/module.py:656: error: Argument "placement" to "ServiceSpec" has incompatible type "Optional[str]"; expected "Optional[PlacementSpec]" orchestrator/module.py: note: In member "_apply_misc" of class "OrchestratorCli": orchestrator/module.py:881: error: Incompatible types in assignment (expression has type "PlacementSpec", variable has type "Optional[str]") orchestrator/module.py:882: error: Argument 1 to "ServiceSpec" has incompatible type "Optional[str]"; expected "str" orchestrator/module.py:882: error: Argument "placement" to "ServiceSpec" has incompatible type "Optional[str]"; expected "Optional[PlacementSpec Signed-off-by: Michael Fritch --- src/pybind/mgr/orchestrator/module.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pybind/mgr/orchestrator/module.py b/src/pybind/mgr/orchestrator/module.py index 9f33874d9b0..95800522148 100644 --- a/src/pybind/mgr/orchestrator/module.py +++ b/src/pybind/mgr/orchestrator/module.py @@ -652,8 +652,9 @@ Usage: raise OrchestratorValidationError(usage) spec = ServiceSpec.from_json(yaml.safe_load(inbuf)) else: - placement = PlacementSpec.from_string(placement) # type: ignore - spec = ServiceSpec(daemon_type, placement=placement) # type: ignore + spec = PlacementSpec.from_string(placement) + assert daemon_type + spec = ServiceSpec(daemon_type, placement=spec) daemon_type = spec.service_type @@ -875,8 +876,9 @@ Usage: content: Iterator = yaml.load_all(inbuf) specs = [ServiceSpec.from_json(s) for s in content] else: - placement = PlacementSpec.from_string(placement) # type: ignore - specs = [ServiceSpec(service_type, placement=placement, unmanaged=unmanaged)] # type: ignore + spec = PlacementSpec.from_string(placement) + assert service_type + specs = [ServiceSpec(service_type, placement=spec, unmanaged=unmanaged)] completion = self.apply(specs) self._orchestrator_wait([completion]) -- 2.39.5