forms: Use monkey-patched SetPasswordForm generic.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2025-07-14 18:59:53 -04:00
committed by Tim Abbott
parent 3be686fa86
commit b1a7db3662
2 changed files with 5 additions and 10 deletions

View File

@@ -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

View File

@@ -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"}),