Fix some type annotations

This commit is contained in:
Matthew Wild
2023-12-08 11:51:39 +00:00
parent c63b95c6e0
commit 46a7d0c37d
3 changed files with 36 additions and 12 deletions

View File

@@ -87,15 +87,27 @@ def format_last_activity(timestamp: typing.Optional[int]) -> str:
yesterday = now - timedelta(days=1)
if last_active.year == now.year and last_active.month == now.month and last_active.day == now.day:
if (
last_active.year == now.year
and last_active.month == now.month
and last_active.day == now.day
):
return _l("Today")
elif last_active.year == yesterday.year and last_active.month == yesterday.month and last_active.day == yesterday.day:
elif (
last_active.year == yesterday.year
and last_active.month == yesterday.month
and last_active.day == yesterday.day
):
return _l("Yesterday")
return _.gettext("%(time)s ago", time=flask_babel.format_timedelta(time_ago, granularity="day"))
return _.gettext(
"%(time)s ago",
time=flask_babel.format_timedelta(time_ago, granularity="day"),
)
def template_now() -> datetime:
return dict(now=lambda : datetime.now(timezone.utc))
def template_now() -> typing.Dict[str, typing.Any]:
return dict(now=lambda: datetime.now(timezone.utc))
def add_vary_language_header(resp: quart.Response) -> quart.Response: