WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

List type annotations leads to syntax error #9248

@lmazuel

Description

@lmazuel

I used the latest Python TypeSpec emitter on this tsplocation:

directory: specification/purview/data-plane/datamap
commit: 0c932f4a1e126784161397209484678f3adda2f6
repo: Azure/azure-rest-api-specs
additionalDirectories: 

I get annotation using list, so the code is not valid:

azure/purview/datamap/__init__.py:15: in <module>
    from ._client import DataMapClient  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
azure/purview/datamap/_client.py:19: in <module>
    from .operations import (
azure/purview/datamap/operations/__init__.py:15: in <module>
    from ._operations import EntityOperations  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
azure/purview/datamap/operations/_operations.py:30: in <module>
    from .. import models as _models
azure/purview/datamap/models/__init__.py:16: in <module>
    from ._models import (  # type: ignore
azure/purview/datamap/models/_models.py:496: in <module>
    class AtlasClassifications(_Model):
azure/purview/datamap/models/_models.py:514: in AtlasClassifications
    list: Optional[list[Any]] = rest_field(visibility=["read", "create", "update", "delete", "query"])
                   ^^^^^^^^^
E   TypeError: '_RestField' object is not subscriptable

Either we import "from future import annotation", or we use List. I think I prefer to import future annotations, since it's more oriented to the future.

I'm using Python 3.12.3, so totally recent runtime.

Metadata

Metadata

Assignees

Labels

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

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions