Skip to content

Commit

Permalink
chore(py314): Replace deprecated pkgutil.find_loader (#1888)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
effigies authored Oct 17, 2024
1 parent d44e27d commit c578cb2
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions python/pyfury/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import importlib
import inspect
import pkgutil
import sys
from typing import Dict, Callable

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c578cb2

Please sign in to comment.