]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
json: fix typos and add missing raise 1953/head
authorJoerg Behrmann <behrmann@physik.fu-berlin.de>
Thu, 5 Oct 2023 10:45:03 +0000 (12:45 +0200)
committerJoerg Behrmann <behrmann@physik.fu-berlin.de>
Thu, 5 Oct 2023 10:50:27 +0000 (12:50 +0200)
mkosi/config.py

index 577a8b7653df88f6bdd63be843b8d86cf59819d4..a6f493a557e11de7f725457a7913f6e82310ddb4 100644 (file)
@@ -684,7 +684,7 @@ class MkosiArgs:
         })
 
     def to_json(self, *, indent: Optional[int] = 4, sort_keys: bool = True) -> str:
-        """Dump MKosiArgs as JSON string."""
+        """Dump MkosiArgs as JSON string."""
         def key_transformer(k: str) -> str:
             return "".join(p.capitalize() for p in k.split("_"))
 
@@ -943,7 +943,7 @@ class MkosiConfig:
         }
 
     def to_json(self, *, indent: Optional[int] = 4, sort_keys: bool = True) -> str:
-        """Dump MKosiConfig as JSON string."""
+        """Dump MkosiConfig as JSON string."""
         def key_transformer(k: str) -> str:
             if (s := SETTINGS_LOOKUP_BY_DEST.get(k)) is not None:
                 return s.name
@@ -2823,10 +2823,8 @@ def json_type_transformer(refcls: Union[type[MkosiArgs], type[MkosiConfig]]) ->
         # It is unlikely that the type of a field will be None only, so let's not bother with a different sentinel
         # value
         if fieldtype is None:
-            ValueError(f"{refcls} has no field {key}")
+            raise ValueError(f"{refcls} has no field {key}")
 
-        # TODO: exchange for TypeGuard once on 3.10
-        assert fieldtype is not None
         transformer = cast(Optional[Callable[[str, type], Any]], transformers.get(fieldtype.type))
         if transformer is not None:
             try: