Skip to content

Conversation

@msyyc
Copy link
Contributor

@msyyc msyyc commented Feb 10, 2026

for #9529

Summary

Remove the TypingSection.CONDITIONAL enum value from the Python code generator. This was a legacy concept for Python 2 compatibility that is no longer needed.

Background

CONDITIONAL was intended to place imports under TYPE_CHECKING for Python 2 files and as regular imports for Python 3 files. Since Python 2 support has been dropped, CONDITIONAL was always treated identically to REGULAR — there was no code path that ever placed it under TYPE_CHECKING.

Changes

  • imports.py — Removed CONDITIONAL from TypingSection enum
  • import_serializer.py — Simplified _get_imports_list by removing the conditional merging logic (20 lines → 2 lines)
  • 10 model files — Replaced all TypingSection.CONDITIONAL references with TypingSection.REGULAR

Net result: -21 lines of dead code removed.

Validation

  • All 159 unit tests pass
  • No behavioral change (CONDITIONAL was already treated as REGULAR)

CONDITIONAL was a legacy concept for Python 2 compatibility. It was
intended to place imports under TYPE_CHECKING for Python 2 files and
as regular imports for Python 3 files. Since Python 2 support has been
dropped, CONDITIONAL was always treated identically to REGULAR.

- Remove CONDITIONAL from TypingSection enum
- Replace all TypingSection.CONDITIONAL usages with TypingSection.REGULAR
- Simplify FileImportSerializer._get_imports_list by removing the
  conditional merging logic
@msyyc msyyc changed the title Remove dead TypingSection.CONDITIONAL enum value [python] Remove dead TypingSection.CONDITIONAL enum value Feb 10, 2026
@microsoft-github-policy-service microsoft-github-policy-service bot added the emitter:client:python Issue for the Python client emitter: @typespec/http-client-python label Feb 10, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 10, 2026

Open in StackBlitz

npm i https://pkg.pr.new/microsoft/typespec/@typespec/http@9667
npm i https://pkg.pr.new/microsoft/typespec/@typespec/http-client@9667

commit: 05bff37

@github-actions
Copy link
Contributor

github-actions bot commented Feb 10, 2026

All changed packages have been documented.

  • @typespec/http-client-python
Show changes

@typespec/http-client-python - internal ✏️

Remove dead TypingSection.CONDITIONAL enum value that was only needed for Python 2 compatibility

@azure-sdk
Copy link
Collaborator

azure-sdk commented Feb 10, 2026

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:python Issue for the Python client emitter: @typespec/http-client-python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants