]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ukify: Add more mypy options 34738/head
authorJörg Behrmann <behrmann@physik.fu-berlin.de>
Sun, 13 Oct 2024 13:20:44 +0000 (15:20 +0200)
committerJörg Behrmann <behrmann@physik.fu-berlin.de>
Mon, 14 Oct 2024 07:59:25 +0000 (09:59 +0200)
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
src/ukify/ukify.py

index bae4e70f44e832d4ac6343418af3cc21c19b61d8..c9836169c104cf37f8773abae4edae11bed7952b 100644 (file)
@@ -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
index ebb4985cfcb4408eba55053965646b92e99db852..f0d7ee60b781ad97f450a1851fb924501a90cdcd 100755 (executable)
@@ -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