From ae47de36c9afe7f24ab8afa39bc23cc8a0ce3efc Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Mon, 1 Apr 2024 14:16:52 -0700 Subject: [PATCH] python: Add missing TypeAlias annotations. See commit c2c96eb0cf3b9d9ba0452eb74ab71248f461b1cf (#26405). Signed-off-by: Anders Kaseorg --- confirmation/models.py | 2 +- corporate/views/remote_billing_page.py | 5 ++++- zerver/tests/test_typed_endpoint.py | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/confirmation/models.py b/confirmation/models.py index 5409e7637f..fdb343f8e4 100644 --- a/confirmation/models.py +++ b/confirmation/models.py @@ -76,7 +76,7 @@ ZilencerConfirmationObjT: TypeAlias = Union[ "PreregistrationRemoteRealmBillingUser", ] -ConfirmationObjT = Union[NoZilencerConfirmationObjT, ZilencerConfirmationObjT] +ConfirmationObjT: TypeAlias = Union[NoZilencerConfirmationObjT, ZilencerConfirmationObjT] def get_object_from_key( diff --git a/corporate/views/remote_billing_page.py b/corporate/views/remote_billing_page.py index 124c70fd67..41bda0279b 100644 --- a/corporate/views/remote_billing_page.py +++ b/corporate/views/remote_billing_page.py @@ -15,6 +15,7 @@ from django.utils.translation import get_language from django.utils.translation import gettext as _ from django.views.decorators.csrf import csrf_exempt from pydantic import Json +from typing_extensions import TypeAlias from confirmation.models import ( Confirmation, @@ -71,7 +72,9 @@ billing_logger = logging.getLogger("corporate.stripe") VALID_NEXT_PAGES = [None, "sponsorship", "upgrade", "billing", "plans", "deactivate"] -VALID_NEXT_PAGES_TYPE = Literal[None, "sponsorship", "upgrade", "billing", "plans", "deactivate"] +VALID_NEXT_PAGES_TYPE: TypeAlias = Literal[ + None, "sponsorship", "upgrade", "billing", "plans", "deactivate" +] REMOTE_BILLING_SIGNED_ACCESS_TOKEN_VALIDITY_IN_SECONDS = 2 * 60 * 60 # We use units of hours here so that we can pass this through to the diff --git a/zerver/tests/test_typed_endpoint.py b/zerver/tests/test_typed_endpoint.py index d77c9fc147..a0d9e719ed 100644 --- a/zerver/tests/test_typed_endpoint.py +++ b/zerver/tests/test_typed_endpoint.py @@ -6,7 +6,7 @@ from django.http import HttpRequest, HttpResponse from pydantic import BaseModel, ConfigDict, Json, StringConstraints, ValidationInfo, WrapValidator from pydantic.dataclasses import dataclass from pydantic.functional_validators import ModelWrapValidatorHandler -from typing_extensions import Annotated, override +from typing_extensions import Annotated, TypeAlias, override from zerver.lib.exceptions import ApiParamValidationError, JsonableError from zerver.lib.request import RequestConfusingParamsError, RequestVariableMissingError @@ -26,7 +26,7 @@ from zerver.lib.typed_endpoint import ( from zerver.lib.validator import WildValue, check_bool from zerver.models import UserProfile -ParamTypes = Literal["none", "json_only", "both"] +ParamTypes: TypeAlias = Literal["none", "json_only", "both"] T = TypeVar("T")