Merge pull request #38490 from sebastian-philipp/mypy-0.790

src,qa,dashboard: Upgrade to mypy 0.790

Reviewed-by: Juan Miguel Olmo Martínez <jolmomar@redhat.com>
Reviewed-by: Laura Paduano <lpaduano@suse.com>
Reviewed-by: Tatjana Dehler <tdehler@suse.com>
This commit is contained in:
Sebastian Wagner 2020-12-10 22:41:47 +01:00 committed by GitHub
commit 84a110744c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 11 deletions

View 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]

View 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}

View 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):
"""

View 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 \

View 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