From 703e40669edc188a8d6714656ec4ecc37efc214f Mon Sep 17 00:00:00 2001 From: Miroslav Vadkerti Date: Tue, 27 Apr 2021 09:06:25 +0200 Subject: [PATCH] typing: update to latest mypy We need latest mypy to bring in coloring support to tox Related to https://gitlab.com/testing-farm/gluetool-modules/-/merge_requests/28 Signed-off-by: Miroslav Vadkerti --- gluetool/glue.py | 3 ++- gluetool/log.py | 4 +++- gluetool/utils.py | 2 +- tox.ini | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gluetool/glue.py b/gluetool/glue.py index fad5c5f4..53162b30 100644 --- a/gluetool/glue.py +++ b/gluetool/glue.py @@ -947,7 +947,8 @@ def _for_each_option(callback, options): # Sort options by their names - no code has a strong option on their order, so force # one to all users of this helper. - option_names = sorted(iterkeys(options), key=lambda x: x[1] if isinstance(x, tuple) else x) + # Mypy is not happy about lambda function: https://github.com/python/mypy/issues/9656#issuecomment-718284938 + option_names = sorted(iterkeys(options), key=lambda x: x[1] if isinstance(x, tuple) else x) # type: ignore for names in option_names: params = options[names] diff --git a/gluetool/log.py b/gluetool/log.py index e4c69d88..be7b210c 100644 --- a/gluetool/log.py +++ b/gluetool/log.py @@ -897,9 +897,11 @@ def format(self, record): # # Regular sort would yield contexts by their priorities from lower to higher ones, therefore reversed flag. # That way we'd start inserting higher priority contexts sooner than lower priority ones. + + # Mypy is not happy about lambda function: https://github.com/python/mypy/issues/9656#issuecomment-718284938 sorted_contexts = sorted( iterkeys(contexts), - key=lambda ctx_name: contexts[ctx_name][0], + key=lambda ctx_name: contexts[ctx_name][0], # type: ignore reverse=True ) diff --git a/gluetool/utils.py b/gluetool/utils.py index 1144819b..6673d174 100644 --- a/gluetool/utils.py +++ b/gluetool/utils.py @@ -489,7 +489,7 @@ def __init__(self, executable, options=None, logger=None): self._command = None # type: Optional[List[str]] self._popen_kwargs = None # type: Optional[Dict[str, Any]] - self._process = None # type: Optional[subprocess.Popen] + self._process = None # type: Optional[subprocess.Popen[str]] self._exit_code = None # type: Optional[int] self._stdout = None # type: Optional[str] diff --git a/tox.ini b/tox.ini index b63f09f9..244794bc 100644 --- a/tox.ini +++ b/tox.ini @@ -52,8 +52,8 @@ envdir = {toxinidir}/.tox/type-check basepython = python3.6 skip_install = True deps = - mypy==0.720 - mypy-extensions==0.4.1 + mypy==0.812 + mypy-extensions==0.4.3 setenv = MYPATH = {toxinidir}