Documentation
The documentation of python import system explains that "namespaces" are meant to scatter the submodules of a same root package among several places.
It doesn't mention any change to the subpackages of a python package, which SHOULD by default include a __init__.py to be importable.
However, the attached test shows that empty folders inside a normal package or namespaces are themselves importable, thus unexpectedly creating namespaces (without any possibility to scatter files in the filesystem, when the root package itself is a normal package).
If it's a normal behaviour of the importer, shouldn't it be documented ?
Or is it actually a bug, which surprisingly makes data folders (eg. assets/ subfolders of a package) importable ?
If so, is it too late to undo that, and enforce the invariant that - except root namespaces - only folders with a __init__.py in them can be importable subpackages ?
PythonNamespaceTests.zip
Linked PRs
Documentation
The documentation of python import system explains that "namespaces" are meant to scatter the submodules of a same root package among several places.
It doesn't mention any change to the subpackages of a python package, which SHOULD by default include a
__init__.pyto be importable.However, the attached test shows that empty folders inside a normal package or namespaces are themselves importable, thus unexpectedly creating namespaces (without any possibility to scatter files in the filesystem, when the root package itself is a normal package).
If it's a normal behaviour of the importer, shouldn't it be documented ?
Or is it actually a bug, which surprisingly makes data folders (eg. assets/ subfolders of a package) importable ?
If so, is it too late to undo that, and enforce the invariant that - except root namespaces - only folders with a
__init__.pyin them can be importable subpackages ?PythonNamespaceTests.zip
Linked PRs