diff --git a/jedi/imports.py b/jedi/imports.py index 3d708329..3986b0ea 100644 --- a/jedi/imports.py +++ b/jedi/imports.py @@ -322,7 +322,7 @@ class ImportPath(pr.Base): rel_path = self.get_relative_path() with common.ignored(ImportError): current_namespace = follow_str(rel_path, '__init__') - else: + elif current_namespace[2]: # is a package for n in self._namespace_packages(current_namespace[1], self.import_path[:i]): try: diff --git a/pytest.ini b/pytest.ini index ab58a87e..21f00ce2 100644 --- a/pytest.ini +++ b/pytest.ini @@ -2,7 +2,7 @@ addopts = --doctest-modules # Ignore broken files in blackbox test directories -norecursedirs = .* docs completion refactor absolute_import +norecursedirs = .* docs completion refactor absolute_import namespace_package # Activate `clean_jedi_cache` fixture for all tests. This should be # fine as long as we are using `clean_jedi_cache` as a session scoped diff --git a/test/namespace_package/ns1/pkg/__init__.py b/test/namespace_package/ns1/pkg/__init__.py index 9f7cd1fb..bc10ee24 100644 --- a/test/namespace_package/ns1/pkg/__init__.py +++ b/test/namespace_package/ns1/pkg/__init__.py @@ -1,7 +1,7 @@ foo = 'ns1!' # this is a namespace package -try +try: import pkg_resources pkg_resources.declare_namespace(__name__) except ImportError: