Fix lint errors

This commit is contained in:
c-bata
2023-01-26 18:43:16 +09:00
parent 3c628a463b
commit 5cfdedbf49
+9 -5
View File
@@ -1,6 +1,5 @@
from __future__ import annotations
import warnings
from dataclasses import dataclass
import json
from typing import TYPE_CHECKING
@@ -44,7 +43,9 @@ if TYPE_CHECKING:
{"type": Literal["text"], "description": Optional[str]},
)
UserAttrRefJSON = TypedDict("UserAttrRefJSON", {"type": Literal["user_attr"], "key": str})
ObjectiveFormWidgetJSON = Union[ChoiceWidgetJSON, SliderWidgetJSON, TextInputWidgetJSON, UserAttrRefJSON]
ObjectiveFormWidgetJSON = Union[
ChoiceWidgetJSON, SliderWidgetJSON, TextInputWidgetJSON, UserAttrRefJSON
]
@dataclass
@@ -103,8 +104,9 @@ class ObjectiveUserAttrRef:
}
ObjectiveFormWidget = Union[ObjectiveChoiceWidget, ObjectiveSliderWidget, ObjectiveTextInputWidget, ObjectiveUserAttrRef]
ObjectiveFormWidget = Union[
ObjectiveChoiceWidget, ObjectiveSliderWidget, ObjectiveTextInputWidget, ObjectiveUserAttrRef
]
SYSTEM_ATTR_KEY = "dashboard:objective_form_widgets"
@@ -112,7 +114,9 @@ def register_objective_form_widgets(study: optuna.Study, widgets: list[Objective
if len(study.directions) != len(widgets):
raise ValueError("The length of actions must be the same with the number of objectives.")
widget_dicts = [w.to_dict() for w in widgets]
study._storage.set_study_system_attr(study._study_id, SYSTEM_ATTR_KEY, json.dumps(widget_dicts))
study._storage.set_study_system_attr(
study._study_id, SYSTEM_ATTR_KEY, json.dumps(widget_dicts)
)
def get_objective_form_widgets_json(