1
0
Fork 0

generate: container: Fix maybe_or()

isinstance() sadly can not get the type itself, so type() needs to be
called on _or first.

Signed-off-by: Enno Tensing <tenno@suij.in>
This commit is contained in:
Enno Tensing 2025-07-30 10:32:15 +02:00
parent 93245d5bc6
commit 1cd43e0c95
Signed by: tenno
GPG key ID: 95265603BD36E66C

View file

@ -40,7 +40,7 @@ def maybe(json: dict, key: str) -> ConfigValue:
def maybe_or(json: dict, key: str, _or: ConfigValue) -> ConfigValue: def maybe_or(json: dict, key: str, _or: ConfigValue) -> ConfigValue:
"""Maybe get a value, but return _or if it is None.""" """Maybe get a value, but return _or if it is None."""
val = maybe(json, key) val = maybe(json, key)
if val is None or not isinstance(val, _or): if val is None or not isinstance(val, type(_or)):
return _or return _or
return val return val