Replace pkgutil.get_loader() with importlib.util.find_spec()

Proprietary

The pkgutil.get_loader() function was deprecated in Python 3.12 and removed in 3.14. Replace with importlib.util.find_spec(), which returns a ModuleSpec, so code that needs the loader reads its .loader. A call passing the name as a keyword is left alone. get_loader() also accepted a module object, which find_spec() does not.

org.openrewrite.python.migrate.ReplacePkgutilGetLoader
mod run . --recipe=org.openrewrite.python.migrate.ReplacePkgutilGetLoader

Install it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.