From 467d21a7104ddbdbe793dbb1493e2237b8b8e905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Behrmann?= Date: Sun, 13 Oct 2024 15:20:44 +0200 Subject: [PATCH] ukify: Add more mypy options This achieves parity with the mypy config used in mkosi. The import of builtins is needed because otherwise type is attempted to be resolved to the variable in the scope. --- src/ukify/mypy.ini | 3 ++- src/ukify/ukify.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ukify/mypy.ini b/src/ukify/mypy.ini index bae4e70f44e..c9836169c10 100644 --- a/src/ukify/mypy.ini +++ b/src/ukify/mypy.ini @@ -1,8 +1,9 @@ [mypy] python_version = 3.9 -allow_redefinition = True # belonging to --strict warn_unused_configs = true +disallow_any_generics = true +disallow_subclassing_any = true disallow_untyped_calls = true disallow_untyped_defs = true disallow_untyped_decorators = true diff --git a/src/ukify/ukify.py b/src/ukify/ukify.py index ebb4985cfcb..f0d7ee60b78 100755 --- a/src/ukify/ukify.py +++ b/src/ukify/ukify.py @@ -20,6 +20,7 @@ # pylint: disable=unnecessary-lambda-assignment import argparse +import builtins import collections import configparser import contextlib @@ -1386,9 +1387,9 @@ class ConfigItem: name: Union[str, tuple[str, str]] dest: Optional[str] = None metavar: Optional[str] = None - type: Optional[Callable] = None + type: Optional[Callable[[str], Any]] = None nargs: Optional[str] = None - action: Optional[Union[str, Callable]] = None + action: Optional[Union[str, Callable[[str], Any], builtins.type[argparse.Action]]] = None default: Any = None version: Optional[str] = None choices: Optional[tuple[str, ...]] = None