From efc2cf0fa4116d9b2b233bd976596b2db14cb5cf Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 13 Feb 2026 12:13:42 +0000 Subject: [PATCH 1/2] Fix import sorting: add blank line between stdlib and third-party imports Ruff I001 was failing because the typing import ran directly into the mashumaro import without a blank line separator. https://claude.ai/code/session_01K8GeVjG7MjJzhZMtrzRh48 --- ankihub/ankihub_client/models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ankihub/ankihub_client/models.py b/ankihub/ankihub_client/models.py index 6dd19bf28..6617367be 100644 --- a/ankihub/ankihub_client/models.py +++ b/ankihub/ankihub_client/models.py @@ -8,6 +8,7 @@ from datetime import date, datetime from enum import Enum from typing import Any, Callable, Dict, List, Optional, Sequence, Set + from mashumaro import field_options from mashumaro.config import BaseConfig from mashumaro.mixins.json import DataClassJSONMixin From 4693a3140452626f4ef140232960f3d400d1dfaf Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 13 Feb 2026 12:23:48 +0000 Subject: [PATCH 2/2] Remove fragile get_media_names_from_notetype mock in client tests Replace `lambda mid: {}` (which would crash with KeyError if the mock were removed) with a proper empty notetype dict `{"css": "", "tmpls": []}`. This removes the implicit dependency on the get_media_names_from_notetype mock and makes each call site self-sufficient. https://claude.ai/code/session_01K8GeVjG7MjJzhZMtrzRh48 --- tests/client/test_client.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/client/test_client.py b/tests/client/test_client.py index 1d6ccd229..be1f103b8 100644 --- a/tests/client/test_client.py +++ b/tests/client/test_client.py @@ -11,7 +11,7 @@ from copy import deepcopy from datetime import date, datetime, timedelta, timezone from pathlib import Path -from typing import Callable, Generator, List, Optional, cast +from typing import Any, Callable, Dict, Generator, List, Optional, cast from unittest.mock import Mock import pytest @@ -1606,7 +1606,7 @@ def test_zips_media_files_from_deck_notes( # We will create and check for just one chunk in this test path_to_created_zip_file = Path(TEST_MEDIA_PATH / f"{deck_id}_0_deck_assets_part.zip") - all_media_names_in_notes = get_media_names_from_notes_data(notes_data, lambda mid: {}) + all_media_names_in_notes = get_media_names_from_notes_data(notes_data, lambda mid: self._empty_notetype()) assert path_to_created_zip_file.is_file() assert len(all_media_names_in_notes) == 14 with zipfile.ZipFile(path_to_created_zip_file, "r") as zip_ref: @@ -1673,11 +1673,14 @@ def test_removes_zipped_file_after_upload( assert not path_to_created_zip_file.is_file() + @staticmethod + def _empty_notetype() -> Dict[str, Any]: + return {"css": "", "tmpls": []} + def _upload_media_for_notes_data( self, mocker: MockerFixture, client: AnkiHubClient, notes_data: List[NoteInfo], ah_did: uuid.UUID ): - mocker.patch("ankihub.ankihub_client.models.get_media_names_from_notetype", return_value=set()) - media_names = get_media_names_from_notes_data(notes_data, lambda mid: {}) + media_names = get_media_names_from_notes_data(notes_data, lambda mid: self._empty_notetype()) media_paths = {TEST_MEDIA_PATH / media_name for media_name in media_names} client.upload_media(media_paths, ah_did)