Selaa lähdekoodia

fix: Refines None checks in result transformation

Simplifies the code by replacing type checks for None with
direct comparisons, improving readability and consistency in
handling None values during output validation.

Signed-off-by: -LAN- <laipz8200@outlook.com>
tags/0.15.7^0
-LAN- 6 kuukautta sitten
vanhempi
commit
5f7f851b17
No account linked to committer's email address
1 muutettua tiedostoa jossa 4 lisäystä ja 4 poistoa
  1. 4
    4
      api/core/workflow/nodes/code/code_node.py

+ 4
- 4
api/core/workflow/nodes/code/code_node.py Näytä tiedosto

if output_config.type == "object": if output_config.type == "object":
# check if output is object # check if output is object
if not isinstance(result.get(output_name), dict): if not isinstance(result.get(output_name), dict):
if isinstance(result.get(output_name), type(None)):
if result.get(output_name) is None:
transformed_result[output_name] = None transformed_result[output_name] = None
else: else:
raise OutputValidationError( raise OutputValidationError(
elif output_config.type == "array[number]": elif output_config.type == "array[number]":
# check if array of number available # check if array of number available
if not isinstance(result[output_name], list): if not isinstance(result[output_name], list):
if isinstance(result[output_name], type(None)):
if result[output_name] is None:
transformed_result[output_name] = None transformed_result[output_name] = None
else: else:
raise OutputValidationError( raise OutputValidationError(
elif output_config.type == "array[string]": elif output_config.type == "array[string]":
# check if array of string available # check if array of string available
if not isinstance(result[output_name], list): if not isinstance(result[output_name], list):
if isinstance(result[output_name], type(None)):
if result[output_name] is None:
transformed_result[output_name] = None transformed_result[output_name] = None
else: else:
raise OutputValidationError( raise OutputValidationError(
elif output_config.type == "array[object]": elif output_config.type == "array[object]":
# check if array of object available # check if array of object available
if not isinstance(result[output_name], list): if not isinstance(result[output_name], list):
if isinstance(result[output_name], type(None)):
if result[output_name] is None:
transformed_result[output_name] = None transformed_result[output_name] = None
else: else:
raise OutputValidationError( raise OutputValidationError(

Loading…
Peruuta
Tallenna