From 1b245c059748e14c2a5e2d0efe45cc5c626b112c Mon Sep 17 00:00:00 2001 From: Edan Bainglass <45081142+edan-bainglass@users.noreply.github.com> Date: Sun, 5 Jan 2025 15:13:00 +0100 Subject: [PATCH] Add `None` to empty widget value check (#650) 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)`. --- aiidalab_widgets_base/computational_resources.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/aiidalab_widgets_base/computational_resources.py b/aiidalab_widgets_base/computational_resources.py index f88722bb..393a61a1 100644 --- a/aiidalab_widgets_base/computational_resources.py +++ b/aiidalab_widgets_base/computational_resources.py @@ -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 ".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: @@ -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 + " }}"