diff --git a/django/core/validators.py b/django/core/validators.py index 913e38eea4..72fbe15551 100644 --- a/django/core/validators.py +++ b/django/core/validators.py @@ -1,12 +1,10 @@ import ipaddress import re -import warnings from pathlib import Path from urllib.parse import urlsplit, urlunsplit from django.core.exceptions import ValidationError from django.utils.deconstruct import deconstructible -from django.utils.deprecation import RemovedInDjango41Warning from django.utils.encoding import punycode from django.utils.ipv6 import is_valid_ipv6_address from django.utils.regex_helper import _lazy_re_compile @@ -174,34 +172,7 @@ class EmailValidator: re.IGNORECASE) domain_allowlist = ['localhost'] - @property - def domain_whitelist(self): - warnings.warn( - 'The domain_whitelist attribute is deprecated in favor of ' - 'domain_allowlist.', - RemovedInDjango41Warning, - stacklevel=2, - ) - return self.domain_allowlist - - @domain_whitelist.setter - def domain_whitelist(self, allowlist): - warnings.warn( - 'The domain_whitelist attribute is deprecated in favor of ' - 'domain_allowlist.', - RemovedInDjango41Warning, - stacklevel=2, - ) - self.domain_allowlist = allowlist - - def __init__(self, message=None, code=None, allowlist=None, *, whitelist=None): - if whitelist is not None: - allowlist = whitelist - warnings.warn( - 'The whitelist argument is deprecated in favor of allowlist.', - RemovedInDjango41Warning, - stacklevel=2, - ) + def __init__(self, message=None, code=None, allowlist=None): if message is not None: self.message = message if code is not None: diff --git a/docs/ref/validators.txt b/docs/ref/validators.txt index 50761e5a42..4230738a2b 100644 --- a/docs/ref/validators.txt +++ b/docs/ref/validators.txt @@ -151,13 +151,6 @@ to, or in lieu of custom ``field.clean()`` methods. validation, so you'd need to add them to the ``allowlist`` as necessary. - .. deprecated:: 3.2 - - The ``whitelist`` parameter is deprecated. Use :attr:`allowlist` - instead. - The undocumented ``domain_whitelist`` attribute is deprecated. Use - ``domain_allowlist`` instead. - ``URLValidator`` ---------------- diff --git a/docs/releases/4.1.txt b/docs/releases/4.1.txt index 96ac8cc19d..80f749a047 100644 --- a/docs/releases/4.1.txt +++ b/docs/releases/4.1.txt @@ -252,3 +252,6 @@ to remove usage of these features. * Support for using a boolean value in :attr:`.BaseCommand.requires_system_checks` is removed. + +* The ``whitelist`` argument and ``domain_whitelist`` attribute of + ``django.core.validators.EmailValidator`` are removed. diff --git a/tests/validators/tests.py b/tests/validators/tests.py index 98da8b012c..78063a58cc 100644 --- a/tests/validators/tests.py +++ b/tests/validators/tests.py @@ -15,8 +15,7 @@ from django.core.validators import ( validate_ipv4_address, validate_ipv6_address, validate_ipv46_address, validate_slug, validate_unicode_slug, ) -from django.test import SimpleTestCase, ignore_warnings -from django.utils.deprecation import RemovedInDjango41Warning +from django.test import SimpleTestCase try: from PIL import Image # noqa @@ -738,42 +737,3 @@ class TestValidatorEquality(TestCase): ProhibitNullCharactersValidator(message='message', code='code1'), ProhibitNullCharactersValidator(message='message', code='code2') ) - - -class DeprecationTests(SimpleTestCase): - @ignore_warnings(category=RemovedInDjango41Warning) - def test_whitelist(self): - validator = EmailValidator(whitelist=['localdomain']) - self.assertEqual(validator.domain_allowlist, ['localdomain']) - self.assertIsNone(validator('email@localdomain')) - self.assertEqual(validator.domain_allowlist, validator.domain_whitelist) - - def test_whitelist_warning(self): - msg = "The whitelist argument is deprecated in favor of allowlist." - with self.assertRaisesMessage(RemovedInDjango41Warning, msg): - EmailValidator(whitelist='localdomain') - - @ignore_warnings(category=RemovedInDjango41Warning) - def test_domain_whitelist(self): - validator = EmailValidator() - validator.domain_whitelist = ['mydomain'] - self.assertEqual(validator.domain_allowlist, ['mydomain']) - self.assertEqual(validator.domain_allowlist, validator.domain_whitelist) - - def test_domain_whitelist_access_warning(self): - validator = EmailValidator() - msg = ( - 'The domain_whitelist attribute is deprecated in favor of ' - 'domain_allowlist.' - ) - with self.assertRaisesMessage(RemovedInDjango41Warning, msg): - validator.domain_whitelist - - def test_domain_whitelist_set_warning(self): - validator = EmailValidator() - msg = ( - 'The domain_whitelist attribute is deprecated in favor of ' - 'domain_allowlist.' - ) - with self.assertRaisesMessage(RemovedInDjango41Warning, msg): - validator.domain_whitelist = ['mydomain']