From: Jörg Behrmann Date: Mon, 16 Feb 2026 12:17:26 +0000 (+0100) Subject: config: annotate json object before assignment X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F4177%2Fhead;p=thirdparty%2Fmkosi.git config: annotate json object before assignment 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. --- diff --git a/mkosi/config.py b/mkosi/config.py index 93c06166e..ed0f9d25c 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -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):