Skip to content

Commit

Permalink
Add check for is_flag but use hasattr and still assign given value (#115
Browse files Browse the repository at this point in the history
)
  • Loading branch information
chrisfandrade16 authored Aug 30, 2024
1 parent b257ab1 commit a3a1cab
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions workflow/lifecycle/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,24 @@ def defaults(func: Callable[..., Any], work: Work) -> Work:
name_in_function = parameter.name

if name_in_function not in known:
if hasattr(parameter, "default"):
options[name_in_cli] = parameter.default
elif name_in_function in known:
options[name_in_cli] = parameters.get(name_in_function) # type: ignore
if hasattr(parameter, "default") and parameter.default:
parameter_default_value = parameter.default

if hasattr(parameter, "is_flag") and parameter.is_flag:
if parameter_default_value is True:
# Flags aren't assigned values, its CLI name is just included or not included
options[name_in_cli] = None
else:
options[name_in_cli] = parameter_default_value
else:
parameter_given_value = parameters.get(name_in_function) # type: ignore

if hasattr(parameter, "is_flag") and parameter.is_flag:
if parameter_given_value is True:
# Flags aren't assigned values, its CLI name is just included or not included
options[name_in_cli] = None
else:
options[name_in_cli] = parameter_given_value
logger.info(f"click cli options: {options}")
work.parameters = options
logger.debug(f"work parameters: {work.parameters}")
Expand Down

0 comments on commit a3a1cab

Please sign in to comment.