Package extension adding new function/variables to package namespace

Hi all :slight_smile:

Short summary what I want:
Assume I have package A with main module/namespace A and a test extension for A that means the extension gets only loaded if Test is loaded.

Different package B imports A. In B’s test section I want to load A’s test extension for a function/variable f from A defined in A test extension - only used for testing. This function/variable f should not exist for normal use of A. That means if Test is not loaded. The function/variable f should be in the namespace of A directly.

Is there a way to do this and how?
If not would this a useful feature request?

Cheers

Not really, and I don’t think it is a great behavior if global variables exist or not in packages depending on what other packages are loaded. You can have the variable always existing (initialized to nothing) and then set it in the __init__ of the extension if you want for example.

2 Likes