Skip to content

Commit

Permalink
Use datetime, instead of string, for subscription dates.
Browse files Browse the repository at this point in the history
  • Loading branch information
tdilauro committed Jan 13, 2025
1 parent 27a08ee commit 413c3bd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 5 additions & 3 deletions src/palace/manager/api/circulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"),
Expand All @@ -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"),
Expand Down

0 comments on commit 413c3bd

Please sign in to comment.