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 """
import datetime
from typing import Any, Optional
from dateutil.relativedelta import relativedelta
from django import template
@ -55,7 +56,7 @@ def get_boosted(boost: models.Boost) -> Any:
@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"""
if not date:
return ""

View file

@ -93,7 +93,7 @@ def get_book_cover_thumbnail(
@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"""
auth_isni = re.sub(r"\D", "", str(author.isni))
if len(existing) == 0: