Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

整理: 204 path operation の Response 明示返り値を削除 #1237

Merged
merged 6 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions voicevox_engine/app/routers/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from io import BytesIO
from typing import Annotated

from fastapi import APIRouter, Depends, HTTPException, Path, Request, Response
from fastapi import APIRouter, Depends, HTTPException, Path, Request

from voicevox_engine.engine_manifest.EngineManifest import EngineManifest
from voicevox_engine.library_manager import LibraryManager
Expand Down Expand Up @@ -54,7 +54,7 @@ def installed_libraries() -> dict[str, InstalledLibraryInfo]:
async def install_library(
library_uuid: Annotated[str, Path(description="音声ライブラリのID")],
request: Request,
) -> Response:
) -> None:
"""
音声ライブラリをインストールします。
音声ライブラリのZIPファイルをリクエストボディとして送信してください。
Expand All @@ -66,7 +66,6 @@ async def install_library(
await loop.run_in_executor(
None, library_manager.install_library, library_uuid, archive
)
return Response(status_code=204)

@router.post(
"/uninstall_library/{library_uuid}",
Expand All @@ -76,13 +75,12 @@ async def install_library(
)
def uninstall_library(
library_uuid: Annotated[str, Path(description="音声ライブラリのID")]
) -> Response:
) -> None:
"""
音声ライブラリをアンインストールします。
"""
if not engine_manifest_data.supported_features.manage_library:
raise HTTPException(status_code=404, detail="この機能は実装されていません")
library_manager.uninstall_library(library_uuid)
return Response(status_code=204)

return router
5 changes: 2 additions & 3 deletions voicevox_engine/app/routers/preset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import Annotated

from fastapi import APIRouter, Body, Depends, HTTPException, Query, Response
from fastapi import APIRouter, Body, Depends, HTTPException, Query

from voicevox_engine.preset.Preset import Preset
from voicevox_engine.preset.PresetError import PresetInputError, PresetInternalError
Expand Down Expand Up @@ -90,7 +90,7 @@ def update_preset(
)
def delete_preset(
id: Annotated[int, Query(description="削除するプリセットのプリセットID")]
) -> Response:
) -> None:
"""
既存のプリセットを削除します
"""
Expand All @@ -100,6 +100,5 @@ def delete_preset(
raise HTTPException(status_code=422, detail=str(err))
except PresetInternalError as err:
raise HTTPException(status_code=500, detail=str(err))
return Response(status_code=204)

return router
5 changes: 2 additions & 3 deletions voicevox_engine/app/routers/speaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pathlib import Path
from typing import Annotated, Callable, Literal

from fastapi import APIRouter, HTTPException, Query, Response
from fastapi import APIRouter, HTTPException, Query
from pydantic import parse_obj_as

from voicevox_engine.core.core_adapter import CoreAdapter
Expand Down Expand Up @@ -175,14 +175,13 @@ def initialize_speaker(
),
] = False,
core_version: str | None = None,
) -> Response:
) -> None:
"""
指定されたスタイルを初期化します。
実行しなくても他のAPIは使用できますが、初回実行時に時間がかかることがあります。
"""
core = get_core(core_version)
core.initialize_style_id_synthesis(style_id, skip_reinit=skip_reinit)
return Response(status_code=204)

@router.get("/is_initialized_speaker", tags=["その他"])
def is_initialized_speaker(
Expand Down
11 changes: 4 additions & 7 deletions voicevox_engine/app/routers/user_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import traceback
from typing import Annotated

from fastapi import APIRouter, Body, Depends, HTTPException, Path, Query, Response
from fastapi import APIRouter, Body, Depends, HTTPException, Path, Query
from pydantic import ValidationError

from voicevox_engine.model import UserDictWord, WordTypes
Expand Down Expand Up @@ -114,7 +114,7 @@ def rewrite_user_dict_word(
description="単語の優先度(0から10までの整数)。数字が大きいほど優先度が高くなる。1から9までの値を指定することを推奨。",
),
] = None,
) -> Response:
) -> None:
"""
ユーザー辞書に登録されている言葉を更新します。
"""
Expand All @@ -127,7 +127,6 @@ def rewrite_user_dict_word(
word_type=word_type,
priority=priority,
)
return Response(status_code=204)
except ValidationError as e:
raise HTTPException(
status_code=422, detail="パラメータに誤りがあります。\n" + str(e)
Expand All @@ -148,13 +147,12 @@ def rewrite_user_dict_word(
)
def delete_user_dict_word(
word_uuid: Annotated[str, Path(description="削除する言葉のUUID")]
) -> Response:
) -> None:
"""
ユーザー辞書に登録されている言葉を削除します。
"""
try:
user_dict.delete_word(word_uuid=word_uuid)
return Response(status_code=204)
except UserDictInputError as err:
raise HTTPException(status_code=422, detail=str(err))
except Exception:
Expand All @@ -177,13 +175,12 @@ def import_user_dict_words(
override: Annotated[
bool, Query(description="重複したエントリがあった場合、上書きするかどうか")
],
) -> Response:
) -> None:
"""
他のユーザー辞書をインポートします。
"""
try:
user_dict.import_user_dict(dict_data=import_dict_data, override=override)
return Response(status_code=204)
except UserDictInputError as err:
raise HTTPException(status_code=422, detail=str(err))
except Exception:
Expand Down