Skip to content

Commit

Permalink
fix: only legal widgets in the docstring will be processed
Browse files Browse the repository at this point in the history
  • Loading branch information
Yazawazi committed Jul 15, 2024
1 parent caf8fdb commit c740cd9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
25 changes: 15 additions & 10 deletions backend/funix/decorator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
TreatAsType,
WhitelistType,
WidgetsType,
AcceptableWidgetsList,
)
from funix.jupyter import jupyter
from funix.util.module import funix_menu_to_safe_function_name
Expand Down Expand Up @@ -520,16 +521,20 @@ def _function_reactive_update():
decorated_param_ = decorated_params.get(
param_.arg_name, None
)
widget_ = param_.description.split(",")[0].strip()
if decorated_param_ is None:
decorated_params[param_.arg_name] = {
"widget": widget_,
}
else:
if "widget" not in decorated_param_: # no cover
decorated_params[param_.arg_name][
"widget"
] = widget_
try:
widget_ = param_.description.split(",")[0].strip()
if widget_ in AcceptableWidgetsList:
if decorated_param_ is None:
decorated_params[param_.arg_name] = {
"widget": widget_,
}
else:
if "widget" not in decorated_param_: # no cover
decorated_params[param_.arg_name][
"widget"
] = widget_
except:
pass

safe_argument_config = {} if argument_config is None else argument_config

Expand Down
2 changes: 2 additions & 0 deletions backend/funix/hint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
Acceptable widgets. Implemented now.
"""

AcceptableWidgetsList = list(getattr(AcceptableWidgets, "__args__"))

WidgetsValue = (
list[AcceptableWidgets | tuple[AcceptableWidgets, dict]]
| AcceptableWidgets
Expand Down

0 comments on commit c740cd9

Please sign in to comment.