Refactor check of BasicType

The intention is either a BasicType or a list where each element is only a BasicType (and not a list).
This commit is contained in:
j-t-1
2024-12-21 06:15:35 +00:00
committed by GitHub
parent 0b2f4fdeb7
commit bed03dfbc7
+9 -5
View File
@@ -554,11 +554,15 @@ class Volshell(interfaces.plugins.PluginInterface):
del kwargs[argname]
for keyword, val in kwargs.items():
if not isinstance(val, (interfaces.configuration.BasicTypes, list)):
if all(isinstance(x, interfaces.configuration.BasicTypes) for x in val):
raise TypeError(
"Configurable values must be simple types (int, bool, str, bytes)"
)
BasicType_or_list_of_BasicType = False # excludes list of lists
if isinstance(val, interfaces.configuration.BasicTypes):
BasicType_or_list_of_BasicType = True
if all(isinstance(x, interfaces.configuration.BasicTypes) for x in val):
BasicType_or_list_of_BasicType = True
if not BasicType_or_list_of_BasicType:
raise TypeError(
"Configurable values must be simple types (int, bool, str, bytes)"
)
self.context.config[config_path + "." + keyword] = val
constructed = clazz(self.context, config_path, **constructor_args)