Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def get_first_non_null(self, variable_list):
v = self.workflow_manage.get_reference_field(
variable.get('variable')[0],
variable.get('variable')[1:])
if v is not None:
if v is not None and not(isinstance(v, (str,list,dict)) and len(v) == 0) :
return v
return None

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided code has a few minor issues and improvements that can be made:

  1. Redundant Condition: The current condition if isinstance(v, (str,list,dict)) and len(v) == 0 is redundant because an empty string ('') or other falsy values won't evaluate to True. Therefore, you can simplify this part of the check to just v is not None.

  2. Line Length: There's one line too long, which might make it harder to read. You can break the line using parentheses or a backslash.

  3. Whitespace Improvements: Ensure consistent indentation to maintain readability.

Here's the improved version:

def get_first_non_null(self, variable_list):
    for variable in variable_list:
        ref_var = self.workflow_manage.get_reference_field(
            variable.get('variable')[0],
            variable.get('variable')[1:]
        )
        if ref_var is not None:
            return ref_var
    return None

Note: This assumes that ref_var returned from get_reference_field() cannot be considered "null" in the sense defined by checking its truthiness after stripping whitespace if needed (though strings are inherently non-empty in Python). If that assumption changes, additional checks should be implemented accordingly.

Expand Down
Loading