Skip to content

Commit

Permalink
fixup! Only consider modules with submodule_search_locations namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
perrinjerome committed Apr 28, 2024
1 parent a418663 commit 1bf2c1a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion astroid/interpreter/_import/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
import sys
from functools import lru_cache
from importlib._bootstrap_external import _NamespacePath

if sys.version_info >= (3, 11):
from importlib.machinery import NamespaceLoader
else:
from importlib._bootstrap_external import _NamespaceLoader as NamespaceLoader
from importlib.util import _find_spec_from_path # type: ignore[attr-defined]

from astroid.const import IS_PYPY
Expand Down Expand Up @@ -99,6 +104,9 @@ def is_namespace(modname: str) -> bool:

return (
found_spec is not None
and found_spec.submodule_search_locations
and found_spec.submodule_search_locations is not None
and found_spec.origin is None
and (
found_spec.loader is None or isinstance(found_spec.loader, NamespaceLoader)
)
)

0 comments on commit 1bf2c1a

Please sign in to comment.