Skip to content

Support imports of namespaces in python>=3.3 (modules without __init__.py files) #842

@mishas

Description

@mishas

Python 3.3 introduced "Implicit Namespace Packages" (based on PEP-420), which states the following:
"Native support for package directories that don’t require __init__.py marker files [...]".

In other words, if I have the following file structure (without any __init__.py files whatsoever):

foo/
    bar/
        baz.py
blah.py

And the content of blah.py is from foo.bar import baz; print(baz), then python3.5 ./blah.py will successfully output: <module 'foo.bar.baz' from '/tmp/foo/bar/baz.py'>.

The problem is, that pylint ./blah.py outputs:
E: 1, 0: Unable to import 'foo.bar' (import-error)

I tried to manipulate sys.path (from init-hook of my .pylintrc) in any which way, and nothing seemed to help except for adding the __init__.py files everywhere :(.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions