From c578cb2fdd3e7fa87f0802afc126219a568f3e1e Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Wed, 16 Oct 2024 22:29:29 -0400 Subject: [PATCH] chore(py314): Replace deprecated pkgutil.find_loader (#1888) This PR removes [pkgutil.find_loader()][] and replaces it with [importlib.util.find_spec()][]. `find_loader` was deprecated in Python 3.12 and will be removed in 3.14. `find_spec` has been present since Python 3.4. Both functions return `None` if the module loader cannot be found. For its use in this project, this is sufficient and no translation of the return value is needed. [pkgutil.find_loader()]: https://docs.python.org/3/library/pkgutil.html#pkgutil.get_loader [importlib.util.find_spec()]: https://docs.python.org/3/library/importlib.html#importlib.util.find_spec --- python/pyfury/util.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/python/pyfury/util.py b/python/pyfury/util.py index b4a5a96b4e..a8d6cf7ded 100644 --- a/python/pyfury/util.py +++ b/python/pyfury/util.py @@ -17,7 +17,6 @@ import importlib import inspect -import pkgutil import sys from typing import Dict, Callable @@ -61,7 +60,7 @@ def add_load_handler(self, func: Callable): self._on_loads.append(func) return func - if pkgutil.find_loader(prefix_name) is not None: + if importlib.util.find_spec(prefix_name) is not None: return LazyModule() elif placeholder: return ModulePlaceholder(prefix_name)