refactor: replace if isinstance with match case (#37412)

This commit is contained in:
jashwanth_reddy_gummula
2026-06-14 13:00:01 +00:00
committed by GitHub
parent 09b6f25fb9
commit 0ca39c96db
2 changed files with 14 additions and 13 deletions
+8 -7
View File
@@ -132,13 +132,14 @@ def cast_parameter_value(typ: StrEnum, value: Any, /):
return value if isinstance(value, bool) else bool(value)
case PluginParameterType.NUMBER:
if isinstance(value, int | float):
return value
elif isinstance(value, str) and value:
if "." in value:
return float(value)
else:
return int(value)
match value:
case int() | float():
return value
case str() if value:
if "." in value:
return float(value)
else:
return int(value)
case PluginParameterType.SYSTEM_FILES | PluginParameterType.FILES:
if not isinstance(value, list):
return [value]