Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python modules don't export sub-module names #1155

Closed
joeduffy opened this issue Jun 11, 2020 · 1 comment · Fixed by #1160
Closed

Python modules don't export sub-module names #1155

joeduffy opened this issue Jun 11, 2020 · 1 comment · Fixed by #1160

Comments

@joeduffy
Copy link
Member

It looks like we don't export sub-module names for the Kubernetes provider in Python like we do all other resource providers.

That means this style isn't supported:

import pulumi_kubernetes as k8s
pull_secret = k8s.core.v1.Secret(...)

This leads to an error: AttributeError: module 'pulumi_kubernetes' has no attribute 'core'.

This inconsistency is unfortunate and, personally, I prefer to use this style when mixing lots of different resource providers (like AWS) since otherwise you end up with pull_secret = Secret(...) or things like pull_secret = v1.Secret(...), which doesn't tell you contextually what's happening.

The other resource packages do this:

for pkg in __all__:
    if pkg != 'config':
        importlib.import_module(f'{__name__}.{pkg}')

to re-export module names. I realize that dynamic export doesn't work well with MyPy (see pulumi/pulumi#4416) but -- unless this was done intentionally in the Kubernetes package -- I'd vote for just doing it until we have a better story there, so we're consistent across all of our providers.

@lukehoban
Copy link
Contributor

I believe this will get fixed as part of #1085.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants