Skip to content

Commit 0933459

Browse files
authored
chore: mypy設定をstrictにする (#1580)
1 parent 2613260 commit 0933459

File tree

9 files changed

+24
-37
lines changed

9 files changed

+24
-37
lines changed

mypy.ini

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,7 @@
1-
# TODO: Review mypy settings
21
# TODO: Move it to pyproject.toml after the review is done
32
[mypy]
4-
check_untyped_defs = True
5-
disallow_any_decorated = False
6-
disallow_any_generics = False
7-
disallow_any_unimported = False
8-
disallow_incomplete_defs = True
9-
disallow_subclassing_any = True
10-
disallow_untyped_calls = True
11-
disallow_untyped_decorators = False
12-
disallow_untyped_defs = True
13-
ignore_errors = False
14-
ignore_missing_imports = True
15-
no_implicit_optional = True
3+
strict = True
164
plugins = numpy.typing.mypy_plugin,pydantic.mypy
175
python_version = 3.11
18-
show_error_codes = True
19-
strict_equality = True
20-
strict_optional = True
21-
warn_redundant_casts = True
22-
warn_return_any = True
6+
ignore_missing_imports = True
237
warn_unreachable = True
24-
warn_unused_configs = True
25-
warn_unused_ignores = False

test/e2e/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def app_params(tmp_path: Path) -> dict[str, Any]:
6767

6868

6969
@pytest.fixture()
70-
def app(app_params: dict) -> FastAPI:
70+
def app(app_params: dict[str, Any]) -> FastAPI:
7171
return generate_app(**app_params)
7272

7373

test/e2e/single_api/tts_pipeline/test_cancellable_synthesis.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
/cancellable_synthesis API のテスト
33
"""
44

5+
from typing import Any
6+
57
import pytest
68
from fastapi.testclient import TestClient
79
from syrupy.assertion import SnapshotAssertion
@@ -13,7 +15,7 @@
1315

1416

1517
@pytest.fixture()
16-
def cancellable_client(app_params: dict) -> TestClient:
18+
def cancellable_client(app_params: dict[str, Any]) -> TestClient:
1719
app_params["cancellable_engine"] = CancellableEngine(
1820
init_processes=1,
1921
use_gpu=False,

test/e2e/test_disable_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
APIを無効化するテスト
33
"""
44

5-
from typing import Literal
5+
from typing import Any, Literal
66

77
from fastapi.testclient import TestClient
88

@@ -29,7 +29,7 @@ def _assert_request_and_response_403(
2929
assert response.status_code == 403, f"{method} {path} が403を返しませんでした"
3030

3131

32-
def test_disable_mutable_api(app_params: dict) -> None:
32+
def test_disable_mutable_api(app_params: dict[str, Any]) -> None:
3333
"""エンジンの静的なデータを変更するAPIを無効化するテスト"""
3434
client = TestClient(generate_app(**app_params, disable_mutable_api=True))
3535

test/unit/tts_pipeline/test_tts_engine.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ def test_update_pitch() -> None:
151151

152152
# 空のリストでエラーを吐かないか
153153
# Inputs
154-
phrases: list = []
154+
phrases: list[AccentPhrase] = []
155155
# Outputs
156156
result = tts_engine.update_pitch(phrases, StyleId(1))
157157
# Expects
158-
true_result: list = []
158+
true_result: list[AccentPhrase] = []
159159
# Tests
160160
assert result == true_result
161161

test/unit/user_dict/test_user_dict.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
import pytest
66
from pyopenjtalk import g2p, unset_user_dict
77

8-
from voicevox_engine.user_dict.model import UserDictWord, WordTypes
8+
from voicevox_engine.user_dict.model import (
9+
USER_DICT_MAX_PRIORITY,
10+
UserDictWord,
11+
WordTypes,
12+
)
913
from voicevox_engine.user_dict.user_dict_manager import UserDictionary
1014
from voicevox_engine.user_dict.user_dict_word import (
11-
USER_DICT_MAX_PRIORITY,
1215
UserDictInputError,
1316
WordProperty,
1417
create_word,

test/utility.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import numpy as np
66
import soundfile as sf
77
from fastapi.encoders import jsonable_encoder
8+
from numpy.typing import NDArray
89

910

1011
def round_floats(value: Any, round_value: int) -> Any:
@@ -45,7 +46,7 @@ def to_hash(value: str) -> str:
4546
def summarize_big_ndarray(value: Any) -> Any:
4647
"""要素数が100を超える NDArray を、ハッシュ値と shape からなる文字列へ要約する"""
4748

48-
def to_hash(value: np.ndarray) -> str:
49+
def to_hash(value: NDArray[Any]) -> str:
4950
return "MD5:" + hashlib.md5(value.tobytes()).hexdigest()
5051

5152
if isinstance(value, np.ndarray):

tools/merge_engine_manifest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@
1010

1111

1212
def merge_json_string(src: str, dst: str) -> str:
13-
src_json: dict[str, JsonValue | dict[str, dict]] = json.loads(src)
14-
dst_json: dict[str, JsonValue | dict[str, dict]] = json.loads(dst)
13+
src_json: dict[str, JsonValue | dict[str, dict[str, JsonValue]]] = json.loads(src)
14+
dst_json: dict[str, JsonValue | dict[str, dict[str, JsonValue]]] = json.loads(dst)
1515

1616
for key, dst_value in dst_json.items():
1717
assert key in src_json, f"Key {key} is not found in src_json"
1818

1919
# `manage_library` のみdictなので特別に処理
2020
if key == "supported_features":
2121
assert isinstance(dst_value, dict)
22-
2322
src_value = src_json[key]
2423
assert isinstance(src_value, dict)
2524
src_value.update(dst_value)

voicevox_engine/app/routers/user_dict.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
from pydantic import ValidationError
77
from pydantic.json_schema import SkipJsonSchema
88

9-
from voicevox_engine.user_dict.model import UserDictWord, WordTypes
10-
from voicevox_engine.user_dict.user_dict_manager import UserDictionary
11-
from voicevox_engine.user_dict.user_dict_word import (
9+
from voicevox_engine.user_dict.model import (
1210
USER_DICT_MAX_PRIORITY,
1311
USER_DICT_MIN_PRIORITY,
14-
UserDictInputError,
15-
WordProperty,
12+
UserDictWord,
13+
WordTypes,
1614
)
15+
from voicevox_engine.user_dict.user_dict_manager import UserDictionary
16+
from voicevox_engine.user_dict.user_dict_word import UserDictInputError, WordProperty
1717

1818
from ..dependencies import VerifyMutabilityAllowed
1919

0 commit comments

Comments
 (0)