From 484a7b032527f745049108937477c1b984827baf Mon Sep 17 00:00:00 2001 From: Jonathan Green Date: Tue, 19 Nov 2024 13:54:41 -0400 Subject: [PATCH] Code review feedback --- src/palace/manager/opds/palace.py | 4 ++-- src/palace/manager/opds/types/currency.py | 13 +------------ tests/manager/opds/types/test_language.py | 2 +- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/palace/manager/opds/palace.py b/src/palace/manager/opds/palace.py index 15fc36a9a..88787651f 100644 --- a/src/palace/manager/opds/palace.py +++ b/src/palace/manager/opds/palace.py @@ -67,7 +67,7 @@ class PalacePublicationMetadata(BaseOpdsModel, LoggerMixin): # type of publication based on the type set, it would be nice to do some additional validation here # and constrain this to PublicationTypes. Right now the Palace Bookshelf feed uses # 'https://schema.org/EBook' (which is not a valid type) both because it starts with - # https:// (schema.org uses http://) and because it's its a Format, not a Type. Once we + # https:// (schema.org uses http://) and because its a Format, not a Type. Once we get # this sorted out, we should add validation here. For now we just accept any string but # log a warning if it's not a valid PublicationType. type: str = Field(..., alias="@type") @@ -86,6 +86,6 @@ class PalacePublicationMetadata(BaseOpdsModel, LoggerMixin): @field_validator("type") @classmethod def warning_when_type_is_not_valid(cls, type_: str) -> str: - if type_ not in [t for t in PublicationTypes]: + if type_ not in list(PublicationTypes): cls.logger().warning(f"@type '{type_}' is not a valid PublicationType.") return type_ diff --git a/src/palace/manager/opds/types/currency.py b/src/palace/manager/opds/types/currency.py index 2f5587fb9..414da817c 100644 --- a/src/palace/manager/opds/types/currency.py +++ b/src/palace/manager/opds/types/currency.py @@ -44,18 +44,7 @@ def __get_pydantic_core_schema__( cls, _: type[Any], __: GetCoreSchemaHandler ) -> core_schema.CoreSchema: """ - Return a Pydantic CoreSchema with the currency subset of the - [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) format. - It excludes bonds testing codes and precious metals. - - Args: - _: The source type. - __: The handler to get the CoreSchema. - - Returns: - A Pydantic CoreSchema with the subset of the currency subset of the - [ISO4217](https://en.wikipedia.org/wiki/ISO_4217) format. - It excludes bonds testing codes and precious metals. + Return a Pydantic CoreSchema for validating this object. """ return core_schema.with_info_after_validator_function( cls._validate, diff --git a/tests/manager/opds/types/test_language.py b/tests/manager/opds/types/test_language.py index d171a89b5..863bf675e 100644 --- a/tests/manager/opds/types/test_language.py +++ b/tests/manager/opds/types/test_language.py @@ -85,7 +85,7 @@ def test__eq__(self) -> None: assert test_map != "baz" # When comparing with a dictionary, the comparison will return True - # the dictionary would create an equivalent LanguageMap. + # if the dictionary would create an equivalent LanguageMap. assert test_map == {"eng": "foo", "fra": "bar"} assert test_map == {"fr": "bar", "en": "foo"} assert test_map != {"en": "foo"}