]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
config: annotate json object before assignment 4177/head
authorJörg Behrmann <behrmann@physik.fu-berlin.de>
Mon, 16 Feb 2026 12:17:26 +0000 (13:17 +0100)
committerJörg Behrmann <behrmann@physik.fu-berlin.de>
Mon, 16 Feb 2026 12:17:26 +0000 (13:17 +0100)
This makes comments from type checkers clearer in this case, since the type is
clear before it is first assignment, but what is assigned to the object comes
from different functions.

mkosi/config.py

index 93c06166e3584cd473bad274abe2e6dc6043086a..ed0f9d25cd5f203eb8f7e7806e652ed66353e4bc 100644 (file)
@@ -1903,6 +1903,7 @@ class Args:
     def from_json(cls, s: Union[str, dict[str, Any], SupportsRead[str], SupportsRead[bytes]]) -> "Args":
         """Instantiate a Args object from a (partial) JSON dump."""
 
+        j: dict[str, Any]
         if isinstance(s, str):
             j = json.loads(s)
         elif isinstance(s, dict):
@@ -2477,6 +2478,8 @@ class Config:
         s: Union[str, dict[str, Any], SupportsRead[str], SupportsRead[bytes]],
     ) -> dict[str, Any]:
         """Instantiate a Config object from a (partial) JSON dump."""
+
+        j: dict[str, Any]
         if isinstance(s, str):
             j = json.loads(s)
         elif isinstance(s, dict):