Skip to content

Commit

Permalink
Activate strict mode in mypy and fix new typing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Kutu committed Apr 21, 2024
1 parent 7586f31 commit 403988d
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ repos:
rev: v1.4.1
hooks:
- id: mypy
additional_dependencies: [types-requests, types-python-dateutil]
additional_dependencies: [types-requests, types-python-dateutil, pytest, responses]
5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ build-backend = "poetry.core.masonry.api"
select = ["E", "F", "I001"]

[tool.mypy]
disallow_untyped_defs = true
warn_unused_ignores = true
warn_return_any = true
warn_unused_configs = true
strict = true

[[tool.mypy.overrides]]
module = "tests.*"
Expand Down
5 changes: 4 additions & 1 deletion src/knuckles/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from .api import RequestMethod
from .models.album import Album
from .models.artist import Artist
from .models.chat_message import ChatMessage
from .models.cover_art import CoverArt
from .models.jukebox import Jukebox
from .models.scan_status import ScanStatus
from .models.song import Album, Artist, CoverArt, Song
from .models.song import Song
from .models.system import License, SubsonicResponse
from .subsonic import Subsonic

Expand Down
3 changes: 2 additions & 1 deletion src/knuckles/models/playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

from dateutil import parser

from .cover_art import CoverArt
from .model import Model
from .song import CoverArt, Song
from .song import Song
from .user import User

if TYPE_CHECKING:
Expand Down
6 changes: 3 additions & 3 deletions tests/api/test_media_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def test_get_captions_with_a_given_filename(
placeholder_data: str,
video: dict[str, Any],
vtt_metadata: FileMetadata,
):
) -> None:
add_responses(mock_get_captions_vtt)

response = subsonic.media_retrieval.get_captions(
Expand Down Expand Up @@ -159,7 +159,7 @@ def test_get_captions_without_a_given_filename(
placeholder_data: str,
video: dict[str, Any],
metadata: str,
):
) -> None:
# Retrieve the mocks dynamically as their tests are equal
get_mock: list[Response] = request.getfixturevalue(mock)
get_metadata: FileMetadata = request.getfixturevalue(metadata)
Expand Down Expand Up @@ -193,7 +193,7 @@ def test_get_captions_with_a_preferred_file_format(
video: dict[str, Any],
metadata: str,
file_format: SubtitlesFileFormat,
):
) -> None:
# Retrieve the mocks dynamically as their tests are equal
get_mock: list[Response] = request.getfixturevalue(mock)
get_metadata: FileMetadata = request.getfixturevalue(metadata)
Expand Down
2 changes: 1 addition & 1 deletion tests/api/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
def test_ping(
add_responses: AddResponses,
subsonic: Subsonic,
subsonic_response,
subsonic_response: dict[str, Any],
mock_ping: list[Response],
) -> None:

Expand Down
8 changes: 4 additions & 4 deletions tests/mocks/internet_radio.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def internet_radio_station() -> dict[str, Any]:

@pytest.fixture
def mock_get_internet_radio_stations(
mock_generator: MockGenerator, internet_radio_station
mock_generator: MockGenerator, internet_radio_station: dict[str, Any]
) -> list[Response]:
return mock_generator(
"getInternetRadioStations",
Expand All @@ -29,7 +29,7 @@ def mock_get_internet_radio_stations(

@pytest.fixture
def mock_create_internet_radio_station(
mock_generator: MockGenerator, internet_radio_station
mock_generator: MockGenerator, internet_radio_station: dict[str, Any]
) -> list[Response]:
return mock_generator(
"createInternetRadioStation",
Expand All @@ -43,7 +43,7 @@ def mock_create_internet_radio_station(

@pytest.fixture
def mock_update_internet_radio_station(
mock_generator: MockGenerator, internet_radio_station
mock_generator: MockGenerator, internet_radio_station: dict[str, Any]
) -> list[Response]:
return mock_generator(
"updateInternetRadioStation",
Expand All @@ -58,7 +58,7 @@ def mock_update_internet_radio_station(

@pytest.fixture
def mock_delete_internet_radio_station(
mock_generator: MockGenerator, internet_radio_station
mock_generator: MockGenerator, internet_radio_station: dict[str, Any]
) -> list[Response]:
return mock_generator(
"deleteInternetRadioStation",
Expand Down
8 changes: 6 additions & 2 deletions tests/mocks/searching.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ def mock_search_song(

@pytest.fixture
def mock_search_album(
mock_generator: MockGenerator, music_folders, album: dict[str, Any]
mock_generator: MockGenerator,
music_folders: list[dict[str, Any]],
album: dict[str, Any],
) -> list[Response]:
return mock_generator(
"search3",
Expand All @@ -32,7 +34,9 @@ def mock_search_album(

@pytest.fixture
def mock_search_artist(
mock_generator: MockGenerator, music_folders, artist: dict[str, Any]
mock_generator: MockGenerator,
music_folders: list[dict[str, Any]],
artist: dict[str, Any],
) -> list[Response]:
return mock_generator(
"search3",
Expand Down
2 changes: 1 addition & 1 deletion tests/models/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_user_delete(
def test_user_change_password(
add_responses: AddResponses,
subsonic: Subsonic,
mock_get_user,
mock_get_user: list[Response],
mock_change_password: list[Response],
user: dict[str, Any],
new_password: str,
Expand Down

0 comments on commit 403988d

Please sign in to comment.