Certain packages that are 'namespace packages' don't return a loader object when they're, well, loaded. However in that case importhook still wraps spec.loader with a HookLoader(loader=None), which messes up Python/importlib's None checks so it tries to call spec.loader.load_module instead of skipping.
I was able to reproduce this on python3.10 with the following code:
I'm not too familiar with the internals of how modules are loaded by Python so it's possible there's a more elegant way around this, or something I'm missing. However this PR seems to solve the issue
c.f. issue #6: https://github.com/brettlangdon/importhook/issues/6 for more details/examples
Certain packages that are 'namespace packages' don't return a loader object when they're, well, loaded. However in that case
importhook
still wraps spec.loader with aHookLoader(loader=None)
, which messes up Python/importlib's None checks so it tries to call spec.loader.load_module instead of skipping.I was able to reproduce this on python3.10 with the following code:
The snowflake-related packages i have are:
I'm not too familiar with the internals of how modules are loaded by Python so it's possible there's a more elegant way around this, or something I'm missing. However this PR seems to solve the issue