From f3a2509a54e0b5513199efca5e41a5183fc097f0 Mon Sep 17 00:00:00 2001 From: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> Date: Fri, 13 Dec 2024 09:05:59 +0100 Subject: [PATCH] Refs #34983 -- Removed django.utils.itercompat per deprecation timeline. --- django/utils/itercompat.py | 21 --------------------- docs/releases/6.0.txt | 3 +++ tests/utils_tests/test_itercompat.py | 16 ---------------- 3 files changed, 3 insertions(+), 37 deletions(-) delete mode 100644 django/utils/itercompat.py delete mode 100644 tests/utils_tests/test_itercompat.py diff --git a/django/utils/itercompat.py b/django/utils/itercompat.py deleted file mode 100644 index e4b34cd534..0000000000 --- a/django/utils/itercompat.py +++ /dev/null @@ -1,21 +0,0 @@ -# RemovedInDjango60Warning: Remove this entire module. - -import warnings - -from django.utils.deprecation import RemovedInDjango60Warning - - -def is_iterable(x): - "An implementation independent way of checking for iterables" - warnings.warn( - "django.utils.itercompat.is_iterable() is deprecated. " - "Use isinstance(..., collections.abc.Iterable) instead.", - RemovedInDjango60Warning, - stacklevel=2, - ) - try: - iter(x) - except TypeError: - return False - else: - return True diff --git a/docs/releases/6.0.txt b/docs/releases/6.0.txt index e3f6c8afed..5871f09e7b 100644 --- a/docs/releases/6.0.txt +++ b/docs/releases/6.0.txt @@ -302,3 +302,6 @@ to remove usage of these features. * The ``ModelAdmin.log_deletion()`` and ``LogEntryManager.log_action()`` methods are removed. + +* The undocumented ``django.utils.itercompat.is_iterable()`` function and the + ``django.utils.itercompat`` module is removed. diff --git a/tests/utils_tests/test_itercompat.py b/tests/utils_tests/test_itercompat.py deleted file mode 100644 index a95867c621..0000000000 --- a/tests/utils_tests/test_itercompat.py +++ /dev/null @@ -1,16 +0,0 @@ -# RemovedInDjango60Warning: Remove this entire module. - -from django.test import SimpleTestCase -from django.utils.deprecation import RemovedInDjango60Warning -from django.utils.itercompat import is_iterable - - -class TestIterCompat(SimpleTestCase): - def test_is_iterable_deprecation(self): - msg = ( - "django.utils.itercompat.is_iterable() is deprecated. " - "Use isinstance(..., collections.abc.Iterable) instead." - ) - with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx: - is_iterable([]) - self.assertEqual(ctx.filename, __file__)