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.

forms: Use monkey-patched SetPasswordForm generic.

Anders Kaseorgb1a7db36622a
diff --git a/zerver/apps.py b/zerver/apps.py
index b762b540c22..6caf0d46dca 100644
--- a/zerver/apps.py
+++ b/zerver/apps.py
@@ -25,7 +25,9 @@ class ZerverConfig(AppConfig):
setup_sentry(settings.SENTRY_DSN, get_config("machine", "deploy_type", "development"))
- django_stubs_ext.monkeypatch()
+ from django.contrib.auth.forms import SetPasswordMixin
+
+ django_stubs_ext.monkeypatch(extra_classes=[SetPasswordMixin])
# We import zerver.signals here for the side effect of
# registering the user_logged_in signal receiver. This import
diff --git a/zerver/forms.py b/zerver/forms.py
index 0463045dfd4..1fbd6140550 100644
--- a/zerver/forms.py
+++ b/zerver/forms.py
@@ -2,7 +2,7 @@ import base64
import logging
import re
from email.headerregistry import Address
-from typing import TYPE_CHECKING, Any, TypeAlias
+from typing import Any
import dns.resolver
import orjson
@@ -430,14 +430,7 @@ class CaptchaRealmCreationForm(RealmCreationForm):
return payload
-# https://github.com/typeddjango/django-stubs/pull/2384#pullrequestreview-2813849209
-if TYPE_CHECKING:
- BaseSetPasswordForm: TypeAlias = SetPasswordForm[UserProfile]
-else:
- BaseSetPasswordForm = SetPasswordForm
-
-
-class LoggingSetPasswordForm(BaseSetPasswordForm):
+class LoggingSetPasswordForm(SetPasswordForm[UserProfile]):
new_password1 = forms.CharField(
label=_("New password"),
widget=forms.PasswordInput(attrs={"autocomplete": "new-password"}),