The previous implementation had some issues while trying to load python modules ( execute __init__.py files) when you specify a handler in a directory.
By using importlib these issues go away and the implementation is way easier.
Description of changes
Remove usages of imp.find_module and imp.load_module and use importlib.import_module.
Relax pylint version since the pinned version wasn't supported by Python 3.8.
Deprecated since version 3.3: Use importlib.util.find_spec() instead unless Python 3.3 compatibility is required, in which case use importlib.find_loader(). For example usage of the former case, see the Examples section of the importlib documentation.
Deprecated since version 3.3: If previously used in conjunction with imp.find_module() then consider using importlib.import_module(), otherwise use the loader returned by the replacement you chose for imp.find_module(). If you called imp.load_module() and related functions directly with file path arguments then use a combination of importlib.util.spec_from_file_location() and importlib.util.module_from_spec(). See the Examples section of the importlib documentation for details of the various approaches.
If you are dynamically importing a module that was created since the interpreter began execution (e.g., created a Python source file), you may need to call invalidate_caches() in order for the new module to be noticed by the import system.
Problem
Remove
imp
in favor ofimportlib
imp
module is deprecated since Python 3.3The previous implementation had some issues while trying to load python modules ( execute
__init__.py
files) when you specify a handler in a directory.By using
importlib
these issues go away and the implementation is way easier.Description of changes
imp.find_module
andimp.load_module
and useimportlib.import_module
.pylint
version since the pinned version wasn't supported by Python 3.8.Source
https://docs.python.org/3/library/imp.html#imp.find_module
https://docs.python.org/3/library/imp.html#imp.load_module
https://docs.python.org/3/library/importlib.html#importlib.invalidate_caches