Skip to content

Comments

Add Type Imports for Python#367

Open
mauriciogardini wants to merge 1 commit intoalloy-framework:mainfrom
pinterest:feature/add-python-type-imports
Open

Add Type Imports for Python#367
mauriciogardini wants to merge 1 commit intoalloy-framework:mainfrom
pinterest:feature/add-python-type-imports

Conversation

@mauriciogardini
Copy link
Contributor

This PR adds support for Python's type-only imports.

  • Automatic type-only detection: When a symbol is only used in type annotation contexts (e.g., function parameters, return types), it's automatically placed inside if TYPE_CHECKING:
  • Smart import upgrading: If a symbol is initially used only for types but later used as a value, the import is automatically upgraded to a regular import
  • TypeRefContext component: Explicitly mark references as type-only when needed

@github-actions
Copy link
Contributor

github-actions bot commented Feb 16, 2026

All changed packages have been documented.

  • @alloy-js/python
Show changes

@alloy-js/python - feature ✏️

Add type-only imports support in Python code generation.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 16, 2026

Open in StackBlitz

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

commit: d573f54

@mauriciogardini mauriciogardini force-pushed the feature/add-python-type-imports branch from 2160197 to b45a657 Compare February 16, 2026 20:58
@mauriciogardini mauriciogardini force-pushed the feature/add-python-type-imports branch from 04940ab to d573f54 Compare February 16, 2026 21:00
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.

1 participant