]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/volumes: add `Dict` type
authorMichael Fritch <mfritch@suse.com>
Tue, 3 Mar 2020 15:15:43 +0000 (08:15 -0700)
committerMichael Fritch <mfritch@suse.com>
Thu, 5 Mar 2020 20:19:31 +0000 (13:19 -0700)
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 <mfritch@suse.com>
src/pybind/mgr/volumes/fs/operations/lock.py
src/pybind/mgr/volumes/fs/operations/op_sm.py

index f9c44dc4f67989c22608ab761a456cbd15dbd9f2..f5c022935e8faf0b5dccf0a0f8d1bd78738ee974 100644 (file)
@@ -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']:
index 9915005a8f35ae720e747a0386aeb642f4d1ae18..459d904617d2ef79df2402af848e7c338217a841 100644 (file)
@@ -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):