Skip to content

Commit

Permalink
Add None to empty widget value check (#650)
Browse files Browse the repository at this point in the history
This PR corrects a guard for unfilled template variables which checks if the value of the corresponding widget is an empty string. Empty widgets may also be represented by `None`, especially dropdown selectors. This PR adds `None` to the check by comparing the widget's value to both, i.e., it replaces `== ""` with `in ("", None)`.
  • Loading branch information
edan-bainglass authored Jan 5, 2025
1 parent 7a93035 commit 1b245c0
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions aiidalab_widgets_base/computational_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -1302,13 +1302,6 @@ def _observe_code_setup(self, _=None):
for key, value in self.code_setup.items():
if hasattr(self, key):
if key == "default_calc_job_plugin":
if "None" in value:
# NOTE: Using this widget through the `_ResourceSetupBaseWidget`
# without an explicit `default_calc_job_plugin` causes `value`
# to be "<plugin>.None", which is not a valid plugin name.
# HACK to avoid the warning message
# TODO see https://github.com/aiidalab/aiidalab-widgets-base/issues/648
return
try:
self.default_calc_job_plugin.value = value
except tl.TraitError:
Expand Down Expand Up @@ -1597,7 +1590,7 @@ def fill(self):
# if the widget is not filled, use the original template var string e.g. {{ var }}
inp_dict = {}
for _var in line.vars:
if self._template_variables[_var].widget.value == "":
if self._template_variables[_var].widget.value in ("", None):
variable_key = self._template_variables[_var].widget.description
self.unfilled_variables.append(variable_key.strip(":"))
inp_dict[_var] = "{{ " + _var + " }}"
Expand Down

0 comments on commit 1b245c0

Please sign in to comment.