]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
src,qa: Upgrade to mypy 0.790 38490/head
authorSebastian Wagner <sebastian.wagner@suse.com>
Tue, 8 Dec 2020 14:36:11 +0000 (15:36 +0100)
committerSebastian Wagner <sebastian.wagner@suse.com>
Wed, 9 Dec 2020 08:18:16 +0000 (09:18 +0100)
dashboard/tools: Make sure {begin,end}_time are set.

Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
qa/tox.ini
src/cephadm/tox.ini
src/pybind/mgr/dashboard/tools.py
src/pybind/mgr/tox.ini
src/python-common/requirements.txt

index e1583649f8ccbdd956e14203536151af1d8bef21..eac9e53701d3f2f1ac7b2e6faba15a6a864e724a 100644 (file)
@@ -10,7 +10,7 @@ commands=flake8 --select=F,E9 --exclude=venv,.tox
 
 [testenv:mypy]
 basepython = python3
-deps = mypy==0.782
+deps = mypy==0.790
 commands = mypy {posargs:.}
 
 [testenv:import-tasks]
index d8cd7c322a99d4482767f0379a0253c1853f8023..17371260e9aaaf091952b7dd7d48ee29d677500b 100644 (file)
@@ -12,5 +12,5 @@ commands=pytest {posargs}
 
 [testenv:mypy]
 basepython = python3
-deps = mypy==0.782
+deps = mypy==0.790
 commands = mypy --config-file ../mypy.ini {posargs:cephadm}
index c4819ef30263a7fb404fa3d401d147a3a17ded82..b428efe7ab5324fb0eeed714c72a608387069212 100644 (file)
@@ -21,7 +21,8 @@ from .services.auth import JwtManager
 from .settings import Settings
 
 try:
-    from typing import Any, AnyStr, Callable, DefaultDict, Deque, Dict, List, Set, Tuple, Union
+    from typing import Any, AnyStr, Callable, DefaultDict, Deque, Dict, List, \
+        Optional, Set, Tuple, Union
 except ImportError:
     pass  # For typing only
 
@@ -569,9 +570,9 @@ class Task(object):
         self.event = threading.Event()
         self.progress = None
         self.ret_value = None
-        self.begin_time = None
-        self.end_time = None
-        self.duration = 0
+        self._begin_time: Optional[float] = None
+        self._end_time: Optional[float] = None
+        self.duration = 0.0
         self.exception = None
         self.logger = logging.getLogger('task')
         self.lock = threading.Lock()
@@ -595,7 +596,7 @@ class Task(object):
             assert not self.running
             self.executor.init(self)
             self.set_progress(0, in_lock=True)
-            self.begin_time = time.time()
+            self._begin_time = time.time()
             self.running = True
         self.executor.start()
 
@@ -609,10 +610,10 @@ class Task(object):
                 exception = ex
         with self.lock:
             assert self.running, "_complete cannot be called before _run"
-            self.end_time = now
+            self._end_time = now
             self.ret_value = ret_value
             self.exception = exception
-            self.duration = now - self.begin_time  # type: ignore
+            self.duration = now - self.begin_time
             if not self.exception:
                 self.set_progress(100, True)
         NotificationQueue.new_notification('cd_task_finished', self)
@@ -661,6 +662,16 @@ class Task(object):
         if not in_lock:
             self.lock.release()
 
+    @property
+    def end_time(self) -> float:
+        assert self._end_time is not None
+        return self._end_time
+
+    @property
+    def begin_time(self) -> float:
+        assert self._begin_time is not None
+        return self._begin_time
+
 
 def build_url(host, scheme=None, port=None):
     """
index 77c7559a75cf6e103d4747dd306cd150dd9cd96f..bb9c62e88006405f30cd2483615bac1f12f647cf 100644 (file)
@@ -47,7 +47,7 @@ basepython = python3
 deps =
     cython
     -rrequirements.txt
-    mypy==0.782
+    mypy==0.790
 commands =
     mypy --config-file=../../mypy.ini \
            cephadm/module.py \
index d472610f624214d6b34a90f1dce4f66e522f77b7..987dd0d2892d1b9bf3a9940e3f64941917da52f8 100644 (file)
@@ -1,6 +1,6 @@
 pytest >=2.1.3,<5; python_version < '3.5'
 mock; python_version < '3.3'
-mypy==0.782; python_version >= '3'
+mypy==0.790; python_version >= '3'
 pytest-mypy; python_version >= '3'
 pytest >= 2.1.3; python_version >= '3'
 pyyaml