From 0cfb3f68029063bc5a6f5fa686f450155061f134 Mon Sep 17 00:00:00 2001 From: Daniel Bernstein Date: Fri, 1 Nov 2024 17:54:00 -0700 Subject: [PATCH] Fix mypy and other compile errors. --- src/palace/manager/feed/opds.py | 2 +- src/palace/manager/feed/serializer/opds2.py | 4 ++-- tests/manager/api/controller/test_loan.py | 6 +++--- tests/manager/feed/test_opds2_serializer.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/palace/manager/feed/opds.py b/src/palace/manager/feed/opds.py index eee54051f..c69d323bb 100644 --- a/src/palace/manager/feed/opds.py +++ b/src/palace/manager/feed/opds.py @@ -94,7 +94,7 @@ def entry_as_response( ), **response_kwargs, ) - if isinstance(serializer, OPDS2Version1Serializer): + if isinstance(serializer, OPDS2Serializer): # Only OPDS2 has the same content type for feed and entry response.content_type = serializer.content_type() return response diff --git a/src/palace/manager/feed/serializer/opds2.py b/src/palace/manager/feed/serializer/opds2.py index 5d78b6a2e..8ccc493df 100644 --- a/src/palace/manager/feed/serializer/opds2.py +++ b/src/palace/manager/feed/serializer/opds2.py @@ -145,7 +145,7 @@ def serialize_work_entry(self, data: WorkEntryData) -> dict[str, Any]: return publication def _serialize_link(self, link: Link) -> dict[str, Any]: - serialized = {"href": link.href, "rel": link.rel} + serialized: dict[str, Any] = {"href": link.href, "rel": link.rel} if link.type: serialized["type"] = link.type if link.title: @@ -226,7 +226,7 @@ def content_type(self) -> str: def to_string(cls, data: dict[str, Any]) -> str: return json.dumps(data, indent=2) - def _serialize_feed_links(self, feed: FeedData) -> list[Link]: + def _serialize_feed_links(self, feed: FeedData) -> list[dict[str, Any]]: links = [] if feed.links: for link in feed.links: diff --git a/tests/manager/api/controller/test_loan.py b/tests/manager/api/controller/test_loan.py index 4fb2de03d..e9c69a821 100644 --- a/tests/manager/api/controller/test_loan.py +++ b/tests/manager/api/controller/test_loan.py @@ -46,7 +46,7 @@ ) from palace.manager.core.opds_import import OPDSAPI from palace.manager.core.problem_details import INTEGRATION_ERROR, INVALID_INPUT -from palace.manager.feed.serializer.opds2 import OPDS2Version1Serializer +from palace.manager.feed.serializer.opds2 import OPDS2Serializer from palace.manager.service.redis.models.patron_activity import PatronActivity from palace.manager.sqlalchemy.constants import MediaTypes from palace.manager.sqlalchemy.model.collection import Collection @@ -132,8 +132,8 @@ class OPDSSerializationTestHelper: ("default-foo-bar", OPDSFeed.ENTRY_TYPE), (AtomFeed.ATOM_TYPE, OPDSFeed.ENTRY_TYPE), ( - OPDS2Version1Serializer.CONTENT_TYPE, - OPDS2Version1Serializer.CONTENT_TYPE, + OPDS2Serializer.CONTENT_TYPE, + OPDS2Serializer.CONTENT_TYPE, ), ], ) diff --git a/tests/manager/feed/test_opds2_serializer.py b/tests/manager/feed/test_opds2_serializer.py index dcd47123e..0fd64bd9c 100644 --- a/tests/manager/feed/test_opds2_serializer.py +++ b/tests/manager/feed/test_opds2_serializer.py @@ -233,7 +233,7 @@ def test_serialize_opds_message(self): OPDSMessage("URN", 200, "Description") ) == dict(urn="URN", description="Description") - def test_serialize_feed(self): + def test_serialize_feed_sort_and_facet_links(self): feed_data = FeedData() # specify a sort link