Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

typing: Fix typical typing typos.

Zixuan James Li4cf3ba5744f3
diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.py
index 3ab4917dd11..dce2b5fe04e 100644
--- a/corporate/lib/stripe.py
+++ b/corporate/lib/stripe.py
@@ -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
diff --git a/zerver/forms.py b/zerver/forms.py
index b8f00f1e604..79b9c30f990 100644
--- a/zerver/forms.py
+++ b/zerver/forms.py
@@ -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))
diff --git a/zerver/lib/test_classes.py b/zerver/lib/test_classes.py
index 0390210ccc2..260cc47e2db 100644
--- a/zerver/lib/test_classes.py
+++ b/zerver/lib/test_classes.py
@@ -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
)
diff --git a/zerver/migrations/0386_fix_attachment_caches.py b/zerver/migrations/0386_fix_attachment_caches.py
index 27c9af78e10..58a8dcddb5c 100644
--- a/zerver/migrations/0386_fix_attachment_caches.py
+++ b/zerver/migrations/0386_fix_attachment_caches.py
@@ -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(
diff --git a/zerver/views/upload.py b/zerver/views/upload.py
index 031e17f5428..5dff4666f59 100644
--- a/zerver/views/upload.py
+++ b/zerver/views/upload.py
@@ -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)