From: Michael Fritch Date: Mon, 4 May 2020 20:54:54 +0000 (-0600) Subject: mgr/orch: fix mypy errors X-Git-Tag: wip-pdonnell-testing-20200918.022351~1331^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=e6d7fb67282dfd8d1f614980821f9cb7ff4fdf51;p=ceph-ci.git 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 --- 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])