From 937fbb69a763dc660a71da31caf4cb6cf78bf9e3 Mon Sep 17 00:00:00 2001 From: c-bata Date: Mon, 26 Oct 2020 02:05:11 +0900 Subject: [PATCH] Add type hints --- optuna_dashboard/app.py | 8 ++++---- setup.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/optuna_dashboard/app.py b/optuna_dashboard/app.py index ed42d654..e585a4de 100644 --- a/optuna_dashboard/app.py +++ b/optuna_dashboard/app.py @@ -10,7 +10,7 @@ from typing import Union, Dict, List from bottle import Bottle, redirect, request, response, static_file from optuna.storages import BaseStorage, get_storage from optuna.trial import FrozenTrial -from optuna.study import StudyDirection +from optuna.study import StudyDirection, StudySummary from . import serializer @@ -62,7 +62,7 @@ def handle_json_api_exception(view): return decorated -def get_study_summary(storage, study_id): +def get_study_summary(storage: BaseStorage, study_id: int) -> StudySummary: summaries = storage.get_all_study_summaries() for summary in summaries: if summary._study_id != study_id: @@ -71,7 +71,7 @@ def get_study_summary(storage, study_id): def get_trials( - storage: BaseStorage, study_id: int, ttl_seconds=10 + storage: BaseStorage, study_id: int, ttl_seconds: int = 10 ) -> List[FrozenTrial]: with trials_cache_lock: trials = trials_cache.get(study_id, None) @@ -142,7 +142,7 @@ def create_app(storage_or_url: Union[str, BaseStorage]) -> Bottle: @app.delete("/api/studies/") @handle_json_api_exception - def create_study(study_id: int): + def delete_study(study_id: int): response.content_type = "application/json" storage.delete_study(study_id) diff --git a/setup.py b/setup.py index 34f0692e..0778e242 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,7 @@ setup( packages=find_packages(), install_requires=["optuna", "bottle"], extras_require={ - "lint": ["black", "flake8"], + "lint": ["black"], "release": ["wheel", "twine"], }, package_data={"optuna_dashboard": ["public/*"]},