From: Sebastian Wagner Date: Tue, 23 Feb 2021 15:05:22 +0000 (+0100) Subject: qa/tasks: some type annotations X-Git-Tag: v17.1.0~2660^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=340281fe76dc1d9170815f68a0553c50fb0b157f;p=ceph.git qa/tasks: some type annotations Mostly for making my IDE aware of things Signed-off-by: Sebastian Wagner --- diff --git a/qa/tasks/ceph_manager.py b/qa/tasks/ceph_manager.py index fbdf0da8e887..41841fb1ce8d 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 23cf4839f63f..0f207c6409bd 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 ecd0124bd548..118cf0c387f2 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 b64910a18e7e..b8e25a48bd18 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 f5fed7c00ce3..d7295b5db116 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