python: Annotate type aliases with TypeAlias.

This is not strictly necessary but it’s clearer and improves mypy’s
error messages.

https://docs.python.org/3/library/typing.html#typing.TypeAlias
https://mypy.readthedocs.io/en/stable/kinds_of_types.html#type-aliases

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2023-08-02 14:53:10 -07:00
committed by Tim Abbott
parent f55711dae3
commit c2c96eb0cf
24 changed files with 81 additions and 52 deletions

View File

@@ -7,6 +7,7 @@ from typing import Any, Collection, Dict, List, Set, Tuple
from django.conf import settings
from django.db import transaction
from django.utils.timezone import now as timezone_now
from typing_extensions import TypeAlias
from confirmation.models import one_click_unsubscribe_link
from zerver.context_processors import common_context
@@ -34,7 +35,7 @@ log_to_file(logger, settings.DIGEST_LOG_PATH)
DIGEST_CUTOFF = 5
MAX_HOT_TOPICS_TO_BE_INCLUDED_IN_DIGEST = 4
TopicKey = Tuple[int, str]
TopicKey: TypeAlias = Tuple[int, str]
class DigestTopic: