Skip to content

Conversation

@mauriciogardini
Copy link
Contributor

@mauriciogardini mauriciogardini commented Dec 5, 2025

There are certain scenarios in Python where we need to add imports at the top of the file without them necessarily being triggered by a symbol being referenced. One example is from __future__ import annotations.

To allow that, we are adding the futureImports prop, which already existed and wasn't being used.

Also, we are making the module docstring to be rendered at the top, as well as properly formatting the header and headerComment.

Finally, we are fixing some spacing-related situations to better adhere to PEP8.

With those changes, this is how a rendered file would look:

<module docstring>
<manually inserted imports>
<imports generated by the import engine>
<children>

@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

All changed packages have been documented.

  • @alloy-js/python
Show changes

@alloy-js/python - feature ✏️

Add support for extra imports

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 5, 2025

Open in StackBlitz

npm i https://pkg.pr.new/alloy-framework/alloy/@alloy-js/python@342

commit: c92fc79

@bterlson
Copy link
Contributor

bterlson commented Dec 9, 2025

Can we add a separate prop for futures? Source file headers are a specific thing (a comment at the top usually with copyright info).

@mauriciogardini
Copy link
Contributor Author

Can we add a separate prop for futures? Source file headers are a specific thing (a comment at the top usually with copyright info).

@bterlson Ok, I made header to behave like header, and then introduced futureImports prop.

@bterlson bterlson merged commit 84271d5 into alloy-framework:main Dec 9, 2025
9 checks passed
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.

3 participants