From 8fa350c52796ab105084cba4369713c9b9ab9a60 Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Fri, 13 Dec 2019 12:01:57 +0100 Subject: [PATCH] pybind/mgr: add_tox_test: Add mypy to TOX_ENVS Signed-off-by: Sebastian Wagner --- src/pybind/mgr/CMakeLists.txt | 2 +- src/pybind/mgr/cephadm/module.py | 19 ++++++++++--------- src/pybind/mgr/orchestrator.py | 4 ++-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/pybind/mgr/CMakeLists.txt b/src/pybind/mgr/CMakeLists.txt index e8fc630d2cd..f7e200b1f88 100644 --- a/src/pybind/mgr/CMakeLists.txt +++ b/src/pybind/mgr/CMakeLists.txt @@ -6,7 +6,7 @@ add_subdirectory(ansible) if(WITH_TESTS) include(AddCephTest) - add_tox_test(mgr ${CMAKE_CURRENT_SOURCE_DIR}) + add_tox_test(mgr ${CMAKE_CURRENT_SOURCE_DIR} TOX_ENVS mypy) endif() # Location needs to match default setting for mgr_module_path, currently: diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 07f2d24d0cd..660d666c1fe 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -1119,7 +1119,7 @@ class CephadmOrchestrator(MgrModule, orchestrator.Orchestrator): extra_args=extra_args) def update_mons(self, spec): - # type: (List[orchestrator.HostSpec]) -> orchestrator.Completion + # type: (orchestrator.StatefulServiceSpec) -> orchestrator.Completion """ Adjust the number of cluster managers. """ @@ -1488,7 +1488,8 @@ class BaseScheduler(object): # type: (orchestrator.PlacementSpec) -> None self.placement_spec = placement_spec - def place(self): + def place(self, host_pool, count=None): + # type: (List, Optional[int]) -> List[HostSpec] raise NotImplementedError @@ -1502,7 +1503,7 @@ class SimpleScheduler(BaseScheduler): super(SimpleScheduler, self).__init__(placement_spec) def place(self, host_pool, count=None): - # type: (List, Optional(int)) -> List + # type: (List, Optional[int]) -> List[HostSpec] if not host_pool: raise Exception('List of host candidates is empty') host_pool = [HostSpec(x, '', '') for x in host_pool] @@ -1523,10 +1524,10 @@ class NodeAssignment(object): """ def __init__(self, - spec=None, # type: orchestrator.PlacementSpec - scheduler=None, # type: BaseScheduler - get_hosts_func=None, # type: Callable - service_type=None, # type: str + spec=None, # type: Optional[orchestrator.StatefulServiceSpec] + scheduler=None, # type: Optional[BaseScheduler] + get_hosts_func=None, # type: Optional[Callable] + service_type=None, # type: Optional[str] ): assert spec and get_hosts_func and service_type self.spec = spec @@ -1535,7 +1536,7 @@ class NodeAssignment(object): self.service_type = service_type def load(self): - # type: () -> orchestrator.PlacementSpec + # type: () -> orchestrator.StatefulServiceSpec """ Load nodes into the spec.placement.nodes container. """ @@ -1565,7 +1566,7 @@ class NodeAssignment(object): # If no imperative or declarative host assignments, use the scheduler to pick from the # host pool (assuming `count` is set) if not self.spec.placement.label and not self.spec.placement.nodes and self.spec.placement.count: - logger.info("Found num spec. Looking for labeled nodes.".format(self.scheduler)) + logger.info("Found num spec. Looking for labeled nodes.") # TODO: actually query for labels (self.service_type) candidates = self.scheduler.place([x[0] for x in self.get_hosts_func()], count=self.spec.placement.count) diff --git a/src/pybind/mgr/orchestrator.py b/src/pybind/mgr/orchestrator.py index 30ca32f8f8d..27d3b8f3d35 100644 --- a/src/pybind/mgr/orchestrator.py +++ b/src/pybind/mgr/orchestrator.py @@ -1219,8 +1219,8 @@ class StatelessServiceSpec(object): class NFSServiceSpec(StatelessServiceSpec): - def __init__(self, name, pool=None, namespace=None, count=1, placement=None): - super(NFSServiceSpec, self).__init__(name, placement, count) + def __init__(self, name, pool=None, namespace=None, placement=None): + super(NFSServiceSpec, self).__init__(name, placement) #: RADOS pool where NFS client recovery data is stored. self.pool = pool -- 2.39.5