Skip to content

Document the unexpected importing of sub-namespaces inside normal python packages/namespaces (or treat it as bug) #148672

@pakal

Description

@pakal

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions