]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Work around pyright errors 2827/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 3 Jul 2024 10:51:34 +0000 (12:51 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 3 Jul 2024 10:59:48 +0000 (12:59 +0200)
mkosi/config.py

index 429c7554405c8246088e847ea535bbdf5b5bcbf5..cf06577a89a66203584151e8c176709c1584b6e7 100644 (file)
@@ -4251,10 +4251,23 @@ def json_type_transformer(refcls: Union[type[Args], type[Config]]) -> Callable[[
         if fieldtype is None:
             raise ValueError(f"{refcls} has no field {key}")
 
-        transformer = cast(Optional[Callable[[str, type], Any]], transformers.get(fieldtype.type))
+        # TODO: Remove type: ignore once we figure out the following pyright error:
+        # /home/runner/work/mkosi/mkosi/mkosi/config.py:4255:83 - error: Argument of type "Any | str" cannot be
+        #       assigned to parameter "key" of type "type[Path] | type[None] | type[list[Path]] | type[UUID] |
+        #       type[tuple[str, bool]] | type[list[ConfigTree]] | type[tuple[str, ...]] | type[Architecture] |
+        #       type[BiosBootloader] | type[ShimBootloader] | type[Bootloader] | type[Compression] |
+        #       type[ConfigFeature] | type[Distribution] | type[OutputFormat] | type[QemuFirmware] |
+        #       type[SecureBootSignTool] | type[list[ManifestFormat]] | type[Verb] | type[DocFormat] |
+        #       type[list[QemuDrive]] | type[GenericVersion] | type[Cacheonly] | type[Network] |
+        #       type[KeySource] | type[Vmm]" in function "get" (reportArgumentType)
+        #     /home/runner/work/mkosi/mkosi/mkosi/config.py:4258:41 - error: Argument of type "Any | str" cannot be
+        #        assigned to parameter of type "type"
+        #         Type "Any | str" is incompatible with type "type"
+        #         "str" is incompatible with "type" (reportArgumentType)
+        transformer = cast(Optional[Callable[[str, type], Any]], transformers.get(fieldtype.type)) # type: ignore
         if transformer is not None:
             try:
-                return transformer(val, fieldtype.type)
+                return transformer(val, fieldtype.type) # type: ignore
             except (ValueError, IndexError, AssertionError) as e:
                 raise ValueError(f"Unable to parse {val:r} for attribute {key:r} for {refcls.__name__}") from e