Better typing for get_published_date() and get_isni_bio()

This commit is contained in:
Dato Simó 2024-09-01 02:21:10 -03:00
parent e2d8ae7157
commit 4852f7ff1e
2 changed files with 3 additions and 2 deletions

View file

@ -1,4 +1,5 @@
""" template filters """ """ template filters """
import datetime
from typing import Any, Optional from typing import Any, Optional
from dateutil.relativedelta import relativedelta from dateutil.relativedelta import relativedelta
from django import template from django import template
@ -55,7 +56,7 @@ def get_boosted(boost: models.Boost) -> Any:
@register.filter(name="published_date") @register.filter(name="published_date")
def get_published_date(date: str) -> Any: def get_published_date(date: datetime.datetime) -> str | None:
"""less verbose combo of humanize filters""" """less verbose combo of humanize filters"""
if not date: if not date:
return "" return ""

View file

@ -93,7 +93,7 @@ def get_book_cover_thumbnail(
@register.filter(name="get_isni_bio") @register.filter(name="get_isni_bio")
def get_isni_bio(existing: int, author: Author) -> str: def get_isni_bio(existing: list[str], author: Author) -> str:
"""Returns the isni bio string if an existing author has an isni listed""" """Returns the isni bio string if an existing author has an isni listed"""
auth_isni = re.sub(r"\D", "", str(author.isni)) auth_isni = re.sub(r"\D", "", str(author.isni))
if len(existing) == 0: if len(existing) == 0: