diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 304a3c440..99dd3f0f8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,6 +20,9 @@ repos: rev: v3.17.0 hooks: - id: pyupgrade + # TODO: Remove when Pydantic supports `datetime.date | None` type annotation. + # Otherwise, `pyupgrade` will rewrite from `Optional[datetime.date]`. + exclude: ^src/palace/manager/api/circulation.py args: - --py310-plus diff --git a/src/palace/manager/api/circulation.py b/src/palace/manager/api/circulation.py index 605419c77..6952e080e 100644 --- a/src/palace/manager/api/circulation.py +++ b/src/palace/manager/api/circulation.py @@ -5,7 +5,7 @@ import logging from abc import ABC, abstractmethod from collections.abc import Iterable, Mapping -from typing import Literal, TypeVar +from typing import Literal, Optional, TypeVar import flask import requests @@ -564,7 +564,9 @@ class BaseCirculationApiSettings(BaseSettings): ) } - subscription_activation_date: str | None = FormField( + # TODO: Using `Optional[datetime.date]` here because Pydantic does not + # currently handle the annotation of `datetime.date | None` properly. + subscription_activation_date: Optional[datetime.date] = FormField( default=None, form=ConfigurationFormItem( label=_("Collection Subscription Activation Date"), @@ -577,7 +579,7 @@ class BaseCirculationApiSettings(BaseSettings): required=False, ), ) - subscription_expiration_date: str | None = FormField( + subscription_expiration_date: Optional[datetime.date] = FormField( default=None, form=ConfigurationFormItem( label=_("Collection Subscription Expiration Date"),