Skip to content

Figure out load_lib() package-related behavior #4

Description

@natezb

Currently load_lib() relies on being passed a pkg argument, typically the __package__ attribute of the file from which it's being called. However, this is the empty string for standalone modules. Currently, this results in a confusing error message coming from importlib.import_module():

TypeError: the 'package' argument is required to perform a relative import for '._mylib'.

Maybe it doesn't make sense to allow use of load_lib() by non-packages, because there's the generated _mylib.py file and maybe a _build_mylib.py too. However, if this is the case, we should provide an error message that makes this clear, and probably a note about this in the docs somewhere.

We may also want to provide a way for the user to modify where load_lib() looks for the generated files.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions