forms: Fix to_python method signature.

According to the documentation, `to_python` should account for `None`
being a possible value to be processed.

See also: https://docs.djangoproject.com/en/4.0/howto/custom-model-fields/#converting-values-to-python-objects.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
Zixuan James Li 2022-07-21 12:01:22 -04:00 committed by Tim Abbott
parent 7bf58dbede
commit 56e22e1a92
1 changed files with 1 additions and 1 deletions

View File

@ -511,7 +511,7 @@ class AuthenticationTokenForm(TwoFactorAuthenticationTokenForm):
class MultiEmailField(forms.Field): class MultiEmailField(forms.Field):
def to_python(self, emails: str) -> List[str]: def to_python(self, emails: Optional[str]) -> List[str]:
"""Normalize data to a list of strings.""" """Normalize data to a list of strings."""
if not emails: if not emails:
return [] return []