From: Daan De Meyer Date: Tue, 26 Mar 2024 09:34:07 +0000 (+0100) Subject: Fix bug in optional_enum_transformer() X-Git-Tag: v23~62^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=538397d36496251badadbfb227bde8da370d63d2;p=thirdparty%2Fmkosi.git Fix bug in optional_enum_transformer() We need to instantiate the nested type, not the optional itself. --- diff --git a/mkosi/config.py b/mkosi/config.py index c008084b6..588058d57 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -24,6 +24,7 @@ import subprocess import sys import tempfile import textwrap +import typing import uuid from collections.abc import Collection, Iterable, Iterator, Sequence from pathlib import Path @@ -3901,7 +3902,7 @@ def json_type_transformer(refcls: Union[type[Args], type[Config]]) -> Callable[[ return fieldtype(enumval) def optional_enum_transformer(enumval: Optional[str], fieldtype: type[Optional[E]]) -> Optional[E]: - return fieldtype(enumval) if enumval is not None else None # type: ignore + return typing.get_args(fieldtype)[0] if enumval is not None else None def enum_list_transformer(enumlist: list[str], fieldtype: type[list[E]]) -> list[E]: enumtype = fieldtype.__args__[0] # type: ignore