mirror of
https://github.com/zulip/zulip.git
synced 2025-10-25 09:03:57 +00:00
mypy: Enable new error explicit-override.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Anders Kaseorg
parent
d257002ad8
commit
a50eb2e809
@@ -20,6 +20,7 @@ from django.utils.translation import gettext as _
|
||||
from markupsafe import Markup
|
||||
from two_factor.forms import AuthenticationTokenForm as TwoFactorAuthenticationTokenForm
|
||||
from two_factor.utils import totp_digits
|
||||
from typing_extensions import override
|
||||
|
||||
from zerver.actions.user_settings import do_change_password
|
||||
from zerver.lib.email_validation import (
|
||||
@@ -324,6 +325,7 @@ class LoggingSetPasswordForm(SetPasswordForm):
|
||||
|
||||
return new_password
|
||||
|
||||
@override
|
||||
def save(self, commit: bool = True) -> UserProfile:
|
||||
assert isinstance(self.user, UserProfile)
|
||||
do_change_password(self.user, self.cleaned_data["new_password1"], commit=commit)
|
||||
@@ -340,6 +342,7 @@ def generate_password_reset_url(
|
||||
|
||||
|
||||
class ZulipPasswordResetForm(PasswordResetForm):
|
||||
@override
|
||||
def save(
|
||||
self,
|
||||
domain_override: Optional[str] = None,
|
||||
@@ -452,9 +455,11 @@ class RateLimitedPasswordResetByEmail(RateLimitedObject):
|
||||
self.email = email
|
||||
super().__init__()
|
||||
|
||||
@override
|
||||
def key(self) -> str:
|
||||
return f"{type(self).__name__}:{self.email}"
|
||||
|
||||
@override
|
||||
def rules(self) -> List[Tuple[int, int]]:
|
||||
return settings.RATE_LIMITING_RULES["password_reset_form_by_email"]
|
||||
|
||||
@@ -473,6 +478,7 @@ class CreateUserForm(forms.Form):
|
||||
class OurAuthenticationForm(AuthenticationForm):
|
||||
logger = logging.getLogger("zulip.auth.OurAuthenticationForm")
|
||||
|
||||
@override
|
||||
def clean(self) -> Dict[str, Any]:
|
||||
username = self.cleaned_data.get("username")
|
||||
password = self.cleaned_data.get("password")
|
||||
@@ -540,6 +546,7 @@ class OurAuthenticationForm(AuthenticationForm):
|
||||
|
||||
return self.cleaned_data
|
||||
|
||||
@override
|
||||
def add_prefix(self, field_name: str) -> str:
|
||||
"""Disable prefix, since Zulip doesn't use this Django forms feature
|
||||
(and django-two-factor does use it), and we'd like both to be
|
||||
@@ -561,6 +568,7 @@ class AuthenticationTokenForm(TwoFactorAuthenticationTokenForm):
|
||||
|
||||
|
||||
class MultiEmailField(forms.Field):
|
||||
@override
|
||||
def to_python(self, emails: Optional[str]) -> List[str]:
|
||||
"""Normalize data to a list of strings."""
|
||||
if not emails:
|
||||
@@ -568,6 +576,7 @@ class MultiEmailField(forms.Field):
|
||||
|
||||
return [email.strip() for email in emails.split(",")]
|
||||
|
||||
@override
|
||||
def validate(self, emails: List[str]) -> None:
|
||||
"""Check if value consists only of valid emails."""
|
||||
super().validate(emails)
|
||||
|
||||
Reference in New Issue
Block a user