From 340281fe76dc1d9170815f68a0553c50fb0b157f Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Tue, 23 Feb 2021 16:05:22 +0100 Subject: [PATCH] qa/tasks: some type annotations Mostly for making my IDE aware of things Signed-off-by: Sebastian Wagner --- qa/tasks/ceph_manager.py | 4 ++-- qa/tasks/ceph_test_case.py | 6 +++++- qa/tasks/cephadm_cases/test_cli.py | 5 +++-- qa/tasks/cephfs/filesystem.py | 2 +- qa/tasks/vstart_runner.py | 2 +- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/qa/tasks/ceph_manager.py b/qa/tasks/ceph_manager.py index fbdf0da8e887e..41841fb1ce8d0 100644 --- a/qa/tasks/ceph_manager.py +++ b/qa/tasks/ceph_manager.py @@ -1356,7 +1356,7 @@ class CephManager: """ def __init__(self, controller, ctx=None, config=None, logger=None, - cluster='ceph', cephadm=False): + cluster='ceph', cephadm=False) -> None: self.lock = threading.RLock() self.ctx = ctx self.config = config @@ -1418,7 +1418,7 @@ class CephManager: kwargs['args'] = prefix + list(kwargs['args']) return self.controller.run(**kwargs) - def raw_cluster_cmd(self, *args, **kwargs): + def raw_cluster_cmd(self, *args, **kwargs) -> str: """ Start ceph on a raw cluster. Return count """ diff --git a/qa/tasks/ceph_test_case.py b/qa/tasks/ceph_test_case.py index 23cf4839f63f4..0f207c6409bd0 100644 --- a/qa/tasks/ceph_test_case.py +++ b/qa/tasks/ceph_test_case.py @@ -1,9 +1,13 @@ +from typing import Optional, TYPE_CHECKING import unittest import time import logging from teuthology.orchestra.run import CommandFailedError +if TYPE_CHECKING: + from tasks.mgr.mgr_test_case import MgrCluster + log = logging.getLogger(__name__) class TestTimeoutError(RuntimeError): @@ -23,7 +27,7 @@ class CephTestCase(unittest.TestCase): backup_fs = None ceph_cluster = None mds_cluster = None - mgr_cluster = None + mgr_cluster: Optional['MgrCluster'] = None ctx = None mon_manager = None diff --git a/qa/tasks/cephadm_cases/test_cli.py b/qa/tasks/cephadm_cases/test_cli.py index ecd0124bd5487..118cf0c387f2d 100644 --- a/qa/tasks/cephadm_cases/test_cli.py +++ b/qa/tasks/cephadm_cases/test_cli.py @@ -6,10 +6,11 @@ log = logging.getLogger(__name__) class TestCephadmCLI(MgrTestCase): - def _cmd(self, *args): + def _cmd(self, *args) -> str: + assert self.mgr_cluster is not None return self.mgr_cluster.mon_manager.raw_cluster_cmd(*args) - def _orch_cmd(self, *args): + def _orch_cmd(self, *args) -> str: return self._cmd("orch", *args) def setUp(self): diff --git a/qa/tasks/cephfs/filesystem.py b/qa/tasks/cephfs/filesystem.py index b64910a18e7e0..b8e25a48bd189 100644 --- a/qa/tasks/cephfs/filesystem.py +++ b/qa/tasks/cephfs/filesystem.py @@ -215,7 +215,7 @@ class CephCluster(object): (result,) = self._ctx.cluster.only(first_mon).remotes.keys() return result - def __init__(self, ctx): + def __init__(self, ctx) -> None: self._ctx = ctx self.mon_manager = ceph_manager.CephManager(self.admin_remote, ctx=ctx, logger=log.getChild('ceph_manager')) diff --git a/qa/tasks/vstart_runner.py b/qa/tasks/vstart_runner.py index f5fed7c00ce33..d7295b5db116c 100644 --- a/qa/tasks/vstart_runner.py +++ b/qa/tasks/vstart_runner.py @@ -809,7 +809,7 @@ class LocalCephManager(CephManager): kwargs['args'] = [CEPH_CMD] + list(kwargs['args']) return self.controller.run(**kwargs) - def raw_cluster_cmd(self, *args, **kwargs): + def raw_cluster_cmd(self, *args, **kwargs) -> str: """ args like ["osd", "dump"} return stdout string -- 2.39.5