Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
changeKind: fix
packages:
- "@autorest/python"
- "@azure-tools/typespec-python"
---

Properly cache enum values
4 changes: 2 additions & 2 deletions packages/autorest.python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"homepage": "https://github.com/Azure/autorest.python/blob/main/README.md",
"dependencies": {
"@typespec/http-client-python": "~0.26.1",
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTgxNTE4Ny9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.26.1.tgz",
"@autorest/system-requirements": "~1.0.2",
"fs-extra": "~11.2.0",
"tsx": "~4.19.1"
Expand All @@ -47,4 +47,4 @@
"requirements.txt",
"generator/"
]
}
}
14 changes: 7 additions & 7 deletions packages/typespec-python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@
"@typespec/streams": ">=0.78.0 <1.0.0",
"@typespec/xml": ">=0.78.0 <1.0.0",
"@azure-tools/typespec-azure-core": ">=0.64.0 <1.0.0",
"@azure-tools/typespec-azure-resource-manager": ">=0.64.0 <1.0.0",
"@azure-tools/typespec-autorest": ">=0.64.0 <1.0.0",
"@azure-tools/typespec-azure-resource-manager": ">=0.64.1 <1.0.0",
"@azure-tools/typespec-autorest": ">=0.64.1 <1.0.0",
"@azure-tools/typespec-azure-rulesets": ">=0.64.0 <1.0.0",
"@azure-tools/typespec-client-generator-core": ">=0.64.5 <1.0.0"
},
"dependencies": {
"js-yaml": "~4.1.0",
"semver": "~7.6.2",
"tsx": "~4.19.1",
"@typespec/http-client-python": "~0.26.1",
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTgxNTE4Ny9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.26.1.tgz",
"fs-extra": "~11.2.0"
},
"devDependencies": {
Expand All @@ -81,11 +81,11 @@
"@typespec/streams": "~0.78.0",
"@typespec/tspd": "~0.70.0",
"@typespec/xml": "~0.78.0",
"@azure-tools/typespec-azure-resource-manager": "~0.64.0",
"@azure-tools/typespec-azure-resource-manager": "~0.64.1",
"@azure-tools/typespec-azure-core": "~0.64.0",
"@azure-tools/typespec-azure-rulesets": "~0.64.0",
"@azure-tools/typespec-autorest": "~0.64.0",
"@azure-tools/typespec-client-generator-core": "~0.64.4",
"@azure-tools/typespec-autorest": "~0.64.1",
"@azure-tools/typespec-client-generator-core": "~0.64.5",
"@azure-tools/azure-http-specs": "0.1.0-alpha.36",
"@typespec/http-specs": "0.1.0-alpha.32-dev.1",
"@typespec/spector": "0.1.0-alpha.22",
Expand All @@ -103,4 +103,4 @@
"chalk": "5.3.0",
"@types/fs-extra": "11.0.4"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ class EnumEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Type of Enum."""

ENUM_VALUE1 = "EnumValue1"
"""ENUM_VALUE1."""
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def build_storage_accounts_get_request(
accept = _headers.pop("Accept", "application/json")

# Construct URL
_url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/storageAccounts/{accountName}"
_url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
Expand Down Expand Up @@ -141,7 +141,7 @@ def build_storage_accounts_create_or_update_request( # pylint: disable=name-too
accept = _headers.pop("Accept", "application/json")

# Construct URL
_url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/storageAccounts/{accountName}"
_url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"
path_format_arguments = {
"subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
"resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta):
CANCELED = "Canceled"
"""Resource creation was canceled."""
PROVISIONING = "Provisioning"
"""PROVISIONING."""
UPDATING = "Updating"
"""UPDATING."""
DELETING = "Deleting"
"""DELETING."""
ACCEPTED = "Accepted"
"""ACCEPTED."""
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ class SecondClientEnumType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Type of SecondClientEnumType."""

SECOND = "second"
"""SECOND."""
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Status enum in first namespace."""

ACTIVE = "active"
"""Active status"""
"""Active status."""
INACTIVE = "inactive"
"""Inactive status"""
"""Inactive status."""
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ class SecondStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Status enum in second namespace."""

RUNNING = "running"
"""Running status"""
"""Running status."""
STOPPED = "stopped"
"""Stopped status"""
"""Stopped status."""
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ class ClientExtensibleEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Type of ClientExtensibleEnum."""

ENUM_VALUE1 = "value1"
"""ENUM_VALUE1."""


class ExtensibleEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Type of ExtensibleEnum."""

CLIENT_ENUM_VALUE1 = "value1"
"""CLIENT_ENUM_VALUE1."""
CLIENT_ENUM_VALUE2 = "value2"
"""CLIENT_ENUM_VALUE2."""
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ class ClientType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Type of ClientType."""

DEFAULT = "default"
"""DEFAULT."""
MULTI_CLIENT = "multi-client"
"""MULTI_CLIENT."""
RENAMED_OPERATION = "renamed-operation"
"""RENAMED_OPERATION."""
TWO_OPERATION_GROUP = "two-operation-group"
"""TWO_OPERATION_GROUP."""
CLIENT_OPERATION_GROUP = "client-operation-group"
"""CLIENT_OPERATION_GROUP."""
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ class ClientType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Type of ClientType."""

DEFAULT = "default"
"""DEFAULT."""
MULTI_CLIENT = "multi-client"
"""MULTI_CLIENT."""
RENAMED_OPERATION = "renamed-operation"
"""RENAMED_OPERATION."""
TWO_OPERATION_GROUP = "two-operation-group"
"""TWO_OPERATION_GROUP."""
CLIENT_OPERATION_GROUP = "client-operation-group"
"""CLIENT_OPERATION_GROUP."""
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ class ClientType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Type of ClientType."""

DEFAULT = "default"
"""DEFAULT."""
MULTI_CLIENT = "multi-client"
"""MULTI_CLIENT."""
RENAMED_OPERATION = "renamed-operation"
"""RENAMED_OPERATION."""
TWO_OPERATION_GROUP = "two-operation-group"
"""TWO_OPERATION_GROUP."""
CLIENT_OPERATION_GROUP = "client-operation-group"
"""CLIENT_OPERATION_GROUP."""
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ class ClientType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Type of ClientType."""

DEFAULT = "default"
"""DEFAULT."""
MULTI_CLIENT = "multi-client"
"""MULTI_CLIENT."""
RENAMED_OPERATION = "renamed-operation"
"""RENAMED_OPERATION."""
TWO_OPERATION_GROUP = "two-operation-group"
"""TWO_OPERATION_GROUP."""
CLIENT_OPERATION_GROUP = "client-operation-group"
"""CLIENT_OPERATION_GROUP."""
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ class ClientType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Type of ClientType."""

DEFAULT = "default"
"""DEFAULT."""
MULTI_CLIENT = "multi-client"
"""MULTI_CLIENT."""
RENAMED_OPERATION = "renamed-operation"
"""RENAMED_OPERATION."""
TWO_OPERATION_GROUP = "two-operation-group"
"""TWO_OPERATION_GROUP."""
CLIENT_OPERATION_GROUP = "client-operation-group"
"""CLIENT_OPERATION_GROUP."""
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@ class Colors(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Type of Colors."""

BLUE = "blue"
"""BLUE."""
RED = "red"
"""RED."""
GREEN = "green"
"""GREEN."""


class ColorsExtensibleEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Type of ColorsExtensibleEnum."""

BLUE = "blue"
"""BLUE."""
RED = "red"
"""RED."""
GREEN = "green"
"""GREEN."""
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ class Versions(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Service versions."""

V1_0 = "v1.0"
"""Version 1.0"""
"""Version 1.0."""
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ class VersionsA(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Type of VersionsA."""

AV1 = "av1"
"""AV1."""
AV2 = "av2"
"""AV2."""


class VersionsB(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Type of VersionsB."""

BV1 = "bv1"
"""BV1."""
BV2 = "bv2"
"""BV2."""
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ class DogKind(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""extensible enum type for discriminator."""

GOLDEN = "golden"
"""Species golden"""
"""Species golden."""


class SnakeKind(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""fixed enum type for discriminator."""

COBRA = "cobra"
"""Species cobra"""
"""Species cobra."""
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ class Cobra(Snake, discriminator="cobra"):

:ivar length: Length of the snake. Required.
:vartype length: int
:ivar kind: discriminator property. Required. Species cobra
:ivar kind: discriminator property. Required. Species cobra.
:vartype kind: str or ~typetest.model.enumdiscriminator.models.COBRA
"""

kind: Literal[SnakeKind.COBRA] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore
"""discriminator property. Required. Species cobra"""
"""discriminator property. Required. Species cobra."""

@overload
def __init__(
Expand Down Expand Up @@ -124,12 +124,12 @@ class Golden(Dog, discriminator="golden"):

:ivar weight: Weight of the dog. Required.
:vartype weight: int
:ivar kind: discriminator property. Required. Species golden
:ivar kind: discriminator property. Required. Species golden.
:vartype kind: str or ~typetest.model.enumdiscriminator.models.GOLDEN
"""

kind: Literal[DogKind.GOLDEN] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore
"""discriminator property. Required. Species golden"""
"""discriminator property. Required. Species golden."""

@overload
def __init__(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ExtendedEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Type of ExtendedEnum."""

ENUM_VALUE2 = "value2"
"""ENUM_VALUE2."""


class FixedInnerEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,12 +566,12 @@ class UnionEnumValueProperty(_Model):
"""Template type for testing models with specific properties. Pass in the type of the property you
are looking for.

:ivar property: Property. Required.
:ivar property: Property. Required. ENUM_VALUE2.
:vartype property: str or ~typetest.property.valuetypes.models.ENUM_VALUE2
"""

property: Literal[ExtendedEnum.ENUM_VALUE2] = rest_field(visibility=["read", "create", "update", "delete", "query"])
"""Property. Required."""
"""Property. Required. ENUM_VALUE2."""

@overload
def __init__(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ class StringExtensibleNamedUnion(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Type of StringExtensibleNamedUnion."""

OPTION_B = "b"
"""OPTION_B."""
C = "c"
"""C."""
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ class EnumV1(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Type of EnumV1."""

ENUM_MEMBER_V1 = "enumMemberV1"
"""ENUM_MEMBER_V1."""
ENUM_MEMBER_V2 = "enumMemberV2"
"""ENUM_MEMBER_V2."""


class EnumV2(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Type of EnumV2."""

ENUM_MEMBER = "enumMember"
"""ENUM_MEMBER."""


class Versions(str, Enum, metaclass=CaseInsensitiveEnumMeta):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ class EnumV2(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Type of EnumV2."""

ENUM_MEMBER_V2 = "enumMemberV2"
"""ENUM_MEMBER_V2."""


class EnumV3(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Type of EnumV3."""

ENUM_MEMBER_V1 = "enumMemberV1"
"""ENUM_MEMBER_V1."""
ENUM_MEMBER_V2_PREVIEW = "enumMemberV2Preview"
"""ENUM_MEMBER_V2_PREVIEW."""


class Versions(str, Enum, metaclass=CaseInsensitiveEnumMeta):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class NewEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Type of NewEnum."""

NEW_ENUM_MEMBER = "newEnumMember"
"""NEW_ENUM_MEMBER."""


class Versions(str, Enum, metaclass=CaseInsensitiveEnumMeta):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ class Colors(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Type of Colors."""

BLUE = "blue"
"""BLUE."""
RED = "red"
"""RED."""
GREEN = "green"
"""GREEN."""


class ColorsExtensibleEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Type of ColorsExtensibleEnum."""

BLUE = "blue"
"""BLUE."""
RED = "red"
"""RED."""
GREEN = "green"
"""GREEN."""
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ class Versions(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Service versions."""

V1_0 = "v1.0"
"""Version 1.0"""
"""Version 1.0."""
Loading
Loading