Skip to content

change: Clarify package vs module imported/available when loading packages #345

@ayjayt

Description

@ayjayt

Generally, I think that griffe should somehow separate between

a) modules imported
b) modules available because the loaded object is a package
and also
c) .is_package should be True whenever the module is, in fact, a package (it doesn't do this for subpackages right now)

Current Behavior:

Anytime a package (a folder with a __init__.py) is loaded, .modules will list

a) the other modules in that folder
b) all of the other packages in that folder
b) all of the modules imported

You can traverse the package tree by following .modules but the .is_package attribute returns False for subpackages.

package1/
    __init__.py
    package2/
        __init__.py
        ...other.pys

Lets say you .load('package1'), and traverse via .modules to package2, griffe wont recognize it as a package- just a module. However, its .modules will still show its ...other.pys, so in some way we know its a package, because those other modules are not imported.

I should note that a package, once imported in python, is really just a module, except named after the folder and containing the contents of __init__.py, AFAIK. The only time in python I've ever seen the fact that something is a package matter is when using import since it allows us to traverse directories.

Metadata

Metadata

Assignees

Labels

docsImprovements or additions to documentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions