mirror of
https://github.com/wassname/optuna-dashboard.git
synced 2026-09-12 12:40:33 +08:00
Change type annotation style
This commit is contained in:
@@ -15,6 +15,7 @@ if TYPE_CHECKING:
|
||||
from typing import Callable
|
||||
from typing import Optional
|
||||
from typing import Sequence
|
||||
from typing import Union
|
||||
|
||||
from .._form_widget import ChoiceWidgetJSON
|
||||
from .._form_widget import SliderWidgetJSON
|
||||
@@ -43,10 +44,12 @@ def _format_description(description: Optional[str]) -> str:
|
||||
|
||||
|
||||
def _render_widgets(
|
||||
widgets: Sequence[ChoiceWidgetJSON | SliderWidgetJSON | TextInputWidgetJSON | UserAttrRefJSON],
|
||||
widgets: Sequence[
|
||||
Union[ChoiceWidgetJSON, SliderWidgetJSON, TextInputWidgetJSON, UserAttrRefJSON]
|
||||
],
|
||||
trial: FrozenTrial,
|
||||
) -> tuple[bool, list[Optional[str | float]]]:
|
||||
values: list[Optional[str | float]] = []
|
||||
) -> tuple[bool, list[Optional[Union[str, float]]]]:
|
||||
values: list[Optional[Union[str, float]]] = []
|
||||
|
||||
with st.form("user_input", clear_on_submit=False):
|
||||
for widget in widgets:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import itertools
|
||||
from typing import Sequence
|
||||
from typing import Union
|
||||
|
||||
import optuna
|
||||
from optuna_dashboard import ChoiceWidget
|
||||
@@ -59,7 +60,7 @@ for r in range(len(widget_list) + 1):
|
||||
|
||||
@pytest.mark.parametrize("widgets", widgets_combinations_for_user_attr)
|
||||
def test_render_user_attr_form_widgets(
|
||||
widgets: Sequence[ChoiceWidget | SliderWidget | TextInputWidget],
|
||||
widgets: Sequence[Union[ChoiceWidget, SliderWidget, TextInputWidget]],
|
||||
) -> None:
|
||||
study = optuna.create_study()
|
||||
register_user_attr_form_widgets(study, widgets) # type: ignore
|
||||
@@ -76,7 +77,7 @@ for r in range(1, len(widget_list) + 1):
|
||||
|
||||
@pytest.mark.parametrize("widgets", widgets_combinations_for_objective)
|
||||
def test_render_objective_form_widgets(
|
||||
widgets: Sequence[ChoiceWidget | SliderWidget | TextInputWidget],
|
||||
widgets: Sequence[Union[ChoiceWidget, SliderWidget, TextInputWidget]],
|
||||
) -> None:
|
||||
study = optuna.create_study(directions=["maximize"] * len(widgets))
|
||||
register_objective_form_widgets(study, widgets) # type: ignore
|
||||
|
||||
Reference in New Issue
Block a user