typing: Fix typical typing typos.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
Zixuan James Li
2022-06-13 15:46:53 -04:00
committed by Tim Abbott
parent 3dcb4ca20a
commit 4cf3ba5744
5 changed files with 15 additions and 8 deletions

View File

@@ -612,7 +612,7 @@ def is_free_trial_offer_enabled() -> bool:
return settings.FREE_TRIAL_DAYS not in (None, 0)
def ensure_realm_does_not_have_active_plan(realm: Customer) -> None:
def ensure_realm_does_not_have_active_plan(realm: Realm) -> None:
if get_current_plan_by_realm(realm) is not None:
# Unlikely race condition from two people upgrading (clicking "Make payment")
# at exactly the same time. Doesn't fully resolve the race condition, but having

View File

@@ -296,7 +296,7 @@ class ZulipPasswordResetForm(PasswordResetForm):
use_https: bool = False,
token_generator: PasswordResetTokenGenerator = default_token_generator,
from_email: Optional[str] = None,
request: HttpRequest = None,
request: Optional[HttpRequest] = None,
html_email_template_name: Optional[str] = None,
extra_email_context: Optional[Dict[str, Any]] = None,
) -> None:
@@ -312,6 +312,9 @@ class ZulipPasswordResetForm(PasswordResetForm):
are an artifact of using Django's password reset framework).
"""
email = self.cleaned_data["email"]
# The form is only used in zerver.views.auth.password_rest, we know that
# the request must not be None
assert request is not None
realm = get_realm(get_subdomain(request))

View File

@@ -129,12 +129,12 @@ class UploadSerializeMixin(SerializeMixin):
lockfile = "var/upload_lock"
@classmethod
def setUpClass(cls: Any, *args: Any, **kwargs: Any) -> None:
def setUpClass(cls: Any) -> None:
if not os.path.exists(cls.lockfile):
with open(cls.lockfile, "w"): # nocoverage - rare locking case
pass
super().setUpClass(*args, **kwargs)
super().setUpClass()
# We could be more specific about which arguments are bool (Django's
@@ -1659,9 +1659,9 @@ You can fix this by adding "{complete_event_type}" to ALL_EVENT_TYPES for this w
content_type: Optional[str] = "application/json",
expect_noop: bool = False,
**kwargs: ClientArg,
) -> "TestHttpResponse":
) -> None:
kwargs["HTTP_AUTHORIZATION"] = self.encode_user(user)
return self.check_webhook(
self.check_webhook(
fixture_name, expected_topic, expected_message, content_type, expect_noop, **kwargs
)

View File

@@ -1,5 +1,7 @@
# Generated by Django 3.2.12 on 2022-03-23 04:32
from typing import Type
from django.db import migrations, models
from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditor
from django.db.migrations.state import StateApps
@@ -14,7 +16,9 @@ def fix_attachment_caches(apps: StateApps, schema_editor: BaseDatabaseSchemaEdit
BATCH_SIZE = 10000
def update_batch(attachment_model: Model, message_model: Model, lower_bound: int) -> None:
def update_batch(
attachment_model: Type[Model], message_model: Type[Model], lower_bound: int
) -> None:
attachment_model.objects.filter(
id__gt=lower_bound, id__lte=lower_bound + BATCH_SIZE
).update(

View File

@@ -74,7 +74,7 @@ def serve_local(
def serve_file_download_backend(
request: HttpRequest, user_profile: UserProfile, realm_id_str: str, filename: str
) -> HttpRequest:
) -> HttpResponse:
return serve_file(request, user_profile, realm_id_str, filename, url_only=False, download=True)