From: Michael Fritch Date: Tue, 3 Mar 2020 15:15:43 +0000 (-0700) Subject: mgr/volumes: add `Dict` type X-Git-Tag: v15.1.1~93^2~20 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=322019beef0098f44621ce377bc988ac250a472f;p=ceph.git mgr/volumes: add `Dict` type fixes mypy errors: volumes/fs/operations/op_sm.py:39: error: "object" has no attribute "get" volumes/fs/operations/op_sm.py:49: error: "object" has no attribute "get" volumes/fs/operations/lock.py: note: In member "__init__" of class "GlobalLock": volumes/fs/operations/lock.py:27: error: "object" has no attribute "__enter__" volumes/fs/operations/lock.py:27: error: "object" has no attribute "__exit__" volumes/fs/operations/lock.py: note: In member "lock_op" of class "GlobalLock": volumes/fs/operations/lock.py:35: error: "object" has no attribute "__enter__" volumes/fs/operations/lock.py:35: error: "object" has no attribute "__exit__" Fixes: https://tracker.ceph.com/issues/44393 Signed-off-by: Michael Fritch --- diff --git a/src/pybind/mgr/volumes/fs/operations/lock.py b/src/pybind/mgr/volumes/fs/operations/lock.py index f9c44dc4f67..f5c022935e8 100644 --- a/src/pybind/mgr/volumes/fs/operations/lock.py +++ b/src/pybind/mgr/volumes/fs/operations/lock.py @@ -1,5 +1,6 @@ from contextlib import contextmanager from threading import Lock +from typing import Dict # singleton design pattern taken from http://www.aleax.it/5ep.html @@ -21,7 +22,7 @@ class GlobalLock(object): _shared_state = { 'lock' : Lock(), 'init' : False - } + } # type: Dict def __init__(self): with self._shared_state['lock']: diff --git a/src/pybind/mgr/volumes/fs/operations/op_sm.py b/src/pybind/mgr/volumes/fs/operations/op_sm.py index 9915005a8f3..459d904617d 100644 --- a/src/pybind/mgr/volumes/fs/operations/op_sm.py +++ b/src/pybind/mgr/volumes/fs/operations/op_sm.py @@ -1,5 +1,7 @@ import errno +from typing import Dict + from ..exception import OpSmException class OpSm(object): @@ -16,12 +18,12 @@ class OpSm(object): INIT_STATE_KEY : 'pending', 'pending' : ('in-progress', FAILED_STATE), 'in-progress' : (FINAL_STATE, FAILED_STATE), - } + } # type: Dict STATE_MACHINES_TYPES = { "subvolume" : OP_SM_SUBVOLUME, "clone" : OP_SM_CLONE, - } + } # type: Dict @staticmethod def is_final_state(state):