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

Generate __init__.py files for enum-only modules #16229

Merged
merged 1 commit into from
May 20, 2024
Merged

Conversation

lunaris
Copy link
Contributor

@lunaris lunaris commented May 20, 2024

The current Python code generator does not emit __init__.py files for modules that only contain enumerations. This is problematic in cases such as #16221, whereby pulumi-command wishes to define an enumeration to be shared across modules, in a module with no other types or resources. In such cases, an SDK is generated that does not type check, since the enumeration types are not exported appropriately. This commit addresses this by generating __init__.py files in these cases as expected.

Fixes #16221

@lunaris lunaris requested a review from a team as a code owner May 20, 2024 11:08
@pulumi-bot
Copy link
Contributor

Changelog

[uncommitted] (2024-05-20)

Bug Fixes

  • [sdkgen/python] Generate init.py files for modules that only contain enumerations
    #16229

The current Python code generator does not emit `__init__.py` files for
modules that only contain enumerations. This is problematic in cases
such as #16221, whereby
`pulumi-command` wishes to define an enumeration to be shared across
modules, in a module with no other types or resources. In such cases, an
SDK is generated that does not type check, since the enumeration types
are not exported appropriately. This commit addresses this by generating
`__init__.py` files in these cases as expected.
@lunaris lunaris added this pull request to the merge queue May 20, 2024
Merged via the queue into master with commit 8e31490 May 20, 2024
54 of 60 checks passed
@lunaris lunaris deleted the wjones/16221 branch May 20, 2024 15:11
github-merge-queue bot pushed a commit that referenced this pull request May 24, 2024
Tentative changelog:

### Features

- [engine] Guess ID references of dependant resources when generating
code for import operations
  [#16208](#16208)


### Bug Fixes

- [engine] Check property dependencies and deleted-with relationships
for target dependents
  [#16220](#16220)

- [engine] Propagate dependencies of untargeted resources correctly
during targeted updates
  [#16247](#16247)

- [backend/diy] Rewrite DeletedWith references when renaming stacks
  [#16216](#16216)

- [sdk/python] Use a separate type variable for static methods on Output
  [#16172](#16172)

- [sdk/python] Relax Output.all types to better match the implementation
  [#16172](#16172)

- [sdkgen/python] Generate __init__.py files for modules that only
contain enumerations
  [#16229](#16229)
@justinvp justinvp mentioned this pull request May 24, 2024
github-merge-queue bot pushed a commit that referenced this pull request May 24, 2024
To be merged after:
- #16261
- pulumi/pulumi-docker-containers#195

Tentative changelog...

### Features

- [engine] Guess ID references of dependant resources when generating
code for import operations
  [#16208](#16208)


### Bug Fixes

- [engine] Check property dependencies and deleted-with relationships
for target dependents
  [#16220](#16220)

- [engine] Propagate dependencies of untargeted resources correctly
during targeted updates
  [#16247](#16247)

- [backend/diy] Rewrite DeletedWith references when renaming stacks
  [#16216](#16216)

- [cli/state] Fix state renames involving DeletedWith

- [sdk/python] Use a separate type variable for static methods on Output
  [#16172](#16172)

- [sdk/python] Relax Output.all types to better match the implementation
  [#16172](#16172)

- [sdkgen/python] Generate __init__.py files for modules that only
contain enumerations
  [#16229](#16229)
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 this pull request may close these issues.

Python codegen omits __init__.py when only enums are present
3 participants