Drop Python 3.9 support in http-client-python (min Python 3.10)#10500
Drop Python 3.9 support in http-client-python (min Python 3.10)#10500
Conversation
Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/4528d934-af72-4520-89b9-5de603ef92d6 Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
commit: |
|
All changed packages have been documented.
Show changes
|
|
You can try these changes here
|
|
@copilot is there anything in our generated code (for example, using typing_extensions) that we can drop now that we don't have to support 3.9? If so please also make those changes |
- model_type.py: remove sys.version_info >= (3, 8) check for Literal, just use `from typing import Literal` directly (generator requires 3.10+) - client.py: use version_modules to generate conditional Self import (typing.Self on 3.11+, typing_extensions.Self on 3.10) - model_base.py.jinja2: replace unconditional typing_extensions.Self with sys.version_info >= (3, 11) conditional import - serialization.py.jinja2: same Self conditional import - model_base.py.jinja2: replace typing.Dict with built-in dict Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/0f0373c2-a172-4430-b890-208867183d7b Co-authored-by: iscai-msft <43154838+iscai-msft@users.noreply.github.com>
|
@copilot you've removed |
…ated The `_serialize_versioned_package` function generates `if sys.version_info >=` checks but `sys` was not being imported. Add `_add_sys_import_if_needed()` to `FileImportSerializer.__str__` to automatically add `import sys` whenever any `version_modules` imports are present in the file. Fixes NameError: name 'sys' is not defined in generated _client.py files. Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/c39c3758-fcf0-425a-8636-8b292579b6fa Co-authored-by: iscai-msft <43154838+iscai-msft@users.noreply.github.com>
Fixed in bce2378. The |
|
@copilot fix the following lint error of generated code: |
- Move `if sys.version_info >= (3, 11)` Self import block to after all other imports in `model_base.py.jinja2` and `serialization.py.jinja2` - Remove duplicate `import sys` in `model_base.py.jinja2` - Update `_get_import_clauses` to emit all versioned imports after all regular imports across all import types, fixing wrong-import-position errors in generated `_client.py` files Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/09068dd1-b11f-48cd-a78a-fa047be09e96 Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
... Fixed in 24f3918. Three issues addressed:
|
model_type.py: Removesys.version_info >= (3, 8)version check forLiteralimport — generator requires Python 3.10+, also removes now-unusedsysimportclient.py: ChangeSelfimport generation to use version-conditional import (typing.Selfon 3.11+,typing_extensions.Selfon 3.10)model_base.py.jinja2: Replacefrom typing_extensions import Selfwithif sys.version_info >= (3, 11): from typing import Self else: from typing_extensions import Selfserialization.py.jinja2: SameSelfconditional import patternmodel_base.py.jinja2: Replacetyping.Dict[str, typing.Any]with built-indict[str, typing.Any]import_serializer.py: Auto-addimport syswhen anyversion_modulesimports are present to fixNameError: name 'sys' is not definedin generated_client.pyfileswrong-import-position/reimportedlint errors: move conditionalSelfblock to end of imports in templates, remove duplicateimport sys, and emit versioned imports at end in_get_import_clauses