Skip to content

typing.Annotated used in invalid context and raises error on python 3.13 #37600

Open

Description

Python 3.13 will be released in early October. We tested libraries against the final 3.13 release candidate in this PR: #37508

With running 3.13, azure-ai-ml raises an error due to how typing.Annotated is used in the utils.py file:

  File "/mnt/vss/_work/1/s/sdk/ml/azure-ai-ml/.tox/depends/lib/python3.13/site-packages/azure/ai/ml/_schema/pipeline/component_job.py", line 27, in <module>
    from ...entities._inputs_outputs import Input
  File "/mnt/vss/_work/1/s/sdk/ml/azure-ai-ml/.tox/depends/lib/python3.13/site-packages/azure/ai/ml/entities/_inputs_outputs/__init__.py", line 57, in <module>
    from .enum_input import EnumInput
  File "/mnt/vss/_work/1/s/sdk/ml/azure-ai-ml/.tox/depends/lib/python3.13/site-packages/azure/ai/ml/entities/_inputs_outputs/enum_input.py", line 10, in <module>
    from .input import Input
  File "/mnt/vss/_work/1/s/sdk/ml/azure-ai-ml/.tox/depends/lib/python3.13/site-packages/azure/ai/ml/entities/_inputs_outputs/input.py", line 25, in <module>
    from .utils import _get_param_with_standard_annotation, _remove_empty_values
  File "/mnt/vss/_work/1/s/sdk/ml/azure-ai-ml/.tox/depends/lib/python3.13/site-packages/azure/ai/ml/entities/_inputs_outputs/utils.py", line 28, in <module>
    Annotation: TypeAlias = Union[str, Type, Annotated, None]  # type: ignore
                            ~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.13.0-rc.2/x64/lib/python3.13/typing.py", line 432, in inner
    return func(*args, **kwds)
  File "/opt/hostedtoolcache/Python/3.13.0-rc.2/x64/lib/python3.13/typing.py", line 576, in __getitem__
    return self._getitem(self, parameters)
           ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.13.0-rc.2/x64/lib/python3.13/typing.py", line 789, in Union
    parameters = tuple(_type_check(p, msg) for p in parameters)
  File "/opt/hostedtoolcache/Python/3.13.0-rc.2/x64/lib/python3.13/typing.py", line 789, in <genexpr>
    parameters = tuple(_type_check(p, msg) for p in parameters)
                       ~~~~~~~~~~~^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.13.0-rc.2/x64/lib/python3.13/typing.py", line 200, in _type_check
    raise TypeError(f"Plain {arg} is not valid as type argument")
TypeError: Plain typing.Annotated is not valid as type argument

Link to build: https://dev.azure.com/azure-sdk/public/_build/results?buildId=4167512&view=logs&j=447d33cb-e696-5bdf-6dab-daffaacae469&t=2668954e-6e9c-59cf-d60a-a6cb495508c0&l=1743

It would be good to fix this promptly in case there are other issues with 3.13.

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

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.Machine LearningService AttentionWorkflow: This issue is responsible by Azure service team.bugThis issue requires a change to an existing behavior in the product in order to be resolved.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions