From 40b0bf38bd3d67d43a81151df102ce8c709e633d Mon Sep 17 00:00:00 2001 From: William Morrell Date: Mon, 13 Nov 2023 23:52:07 -0800 Subject: [PATCH] Fix DeprecationWarning for pkgutil.find_loader The `find_loader` function is deprecated in Python 3.12 and slated for removal in Python 3.14. The function is a wrapper around `importlib.util.find_spec`, and returning the `loader` attribute from that call. The code isn't using the loader, and only checking that the import path exists, so we may use the wrapped function directly, instead. fixes: #1616 --- django_filters/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/django_filters/__init__.py b/django_filters/__init__.py index c854b2c3..3586f660 100644 --- a/django_filters/__init__.py +++ b/django_filters/__init__.py @@ -1,14 +1,14 @@ # flake8: noqa -import pkgutil +from importlib import util as importlib_util from .filters import * from .filterset import FilterSet # We make the `rest_framework` module available without an additional import. # If DRF is not installed, no-op. -if pkgutil.find_loader("rest_framework") is not None: +if importlib_util.find_spec("rest_framework"): from . import rest_framework -del pkgutil +del importlib_util __version__ = "23.3"