Skip to content

Commit

Permalink
Bump tsp version 0.58.0 (#2704)
Browse files Browse the repository at this point in the history
* bump tsp 0.58.0

* inv

* changelog
  • Loading branch information
msyyc committed Jul 18, 2024
1 parent 410e989 commit 1d654f4
Show file tree
Hide file tree
Showing 166 changed files with 17,706 additions and 575 deletions.
7 changes: 7 additions & 0 deletions .chronus/changes/bump-tsp-version-2024-2024-6-17-14-37-3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: dependencies
packages:
- "@azure-tools/typespec-python"
---

Bump typespec 0.58.0
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
},
"homepage": "https://github.com/Azure/autorest.python#readme",
"devDependencies": {
"@azure-tools/cadl-ranch": "~0.12.7",
"@azure-tools/cadl-ranch": "~0.13.4",
"@actions/github": "6.0.0",
"@chronus/chronus": "^0.10.2",
"@chronus/github": "^0.3.2",
"@typespec/prettier-plugin-typespec": "~0.55.0",
"@typespec/prettier-plugin-typespec": "~0.58.0",
"autorest": "3.6.3",
"eslint": "^8.57.0",
"eslint-plugin-import": "^2.29.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ def test_escaped_reserved_words():
"continuation_token": "continuation_token",
}
for name in expected_conversion_enum:
assert pad_reserved_words(name, pad_type=PadType.ENUM) == expected_conversion_enum[name]
assert pad_reserved_words(name, pad_type=PadType.ENUM_VALUE) == expected_conversion_enum[name]
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,16 @@ def update_types(self, yaml_data: List[Dict[str, Any]]) -> None:
property["clientName"] = self.pad_reserved_words(property["clientName"].lower(), PadType.PROPERTY)
add_redefined_builtin_info(property["clientName"], property)
if type.get("name"):
name = self.pad_reserved_words(type["name"], PadType.MODEL)
pad_type = PadType.MODEL if type["type"] == "model" else PadType.ENUM_CLASS
name = self.pad_reserved_words(type["name"], pad_type)
type["name"] = name[0].upper() + name[1:]
type["description"] = update_description(type.get("description", ""), type["name"])
type["snakeCaseName"] = to_snake_case(type["name"])
if type.get("values"):
# we're enums
values_to_add = []
for value in type["values"]:
padded_name = self.pad_reserved_words(value["name"].lower(), PadType.ENUM).upper()
padded_name = self.pad_reserved_words(value["name"].lower(), PadType.ENUM_VALUE).upper()
if self.version_tolerant:
if padded_name[0] in "0123456789":
padded_name = "ENUM_" + padded_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@

class PadType(str, Enum):
MODEL = "Model"
ENUM_CLASS = "Enum"
METHOD = "_method"
PARAMETER = "_parameter"
ENUM = "_enum"
ENUM_VALUE = "_enum"
PROPERTY = "_property"
OPERATION_GROUP = "Operations"

Expand Down Expand Up @@ -175,9 +176,10 @@ class PadType(str, Enum):
"retry_on_status_codes",
*_always_reserved,
],
PadType.MODEL: [*_always_reserved],
PadType.MODEL: ["enum", *_always_reserved],
PadType.PROPERTY: ["self", *_always_reserved],
PadType.ENUM: ["mro", *_always_reserved],
PadType.ENUM_CLASS: ["enum", *_always_reserved],
PadType.ENUM_VALUE: ["mro", *_always_reserved],
PadType.OPERATION_GROUP: [*_always_reserved],
}

Expand Down
46 changes: 23 additions & 23 deletions packages/typespec-python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@
"scripts/**"
],
"peerDependencies": {
"@azure-tools/typespec-azure-core": ">=0.43.0 <1.0.0",
"@azure-tools/typespec-azure-resource-manager": ">=0.43.0 <1.0.0",
"@azure-tools/typespec-autorest": ">=0.43.0 <1.0.0",
"@azure-tools/typespec-client-generator-core": ">=0.43.2 <1.0.0",
"@azure-tools/typespec-azure-rulesets": ">=0.43.0 <3.0.0",
"@typespec/compiler": ">=0.57.0 <1.0.0",
"@typespec/http": ">=0.57.0 <1.0.0",
"@typespec/rest": ">=0.57.0 <1.0.0",
"@typespec/versioning": ">=0.57.0 <1.0.0",
"@typespec/openapi": ">=0.57.0 <1.0.0"
"@azure-tools/typespec-azure-core": ">=0.44.0 <1.0.0",
"@azure-tools/typespec-azure-resource-manager": ">=0.44.0 <1.0.0",
"@azure-tools/typespec-autorest": ">=0.44.0 <1.0.0",
"@azure-tools/typespec-client-generator-core": ">=0.44.1 <1.0.0",
"@azure-tools/typespec-azure-rulesets": ">=0.44.0 <3.0.0",
"@typespec/compiler": ">=0.58.0 <1.0.0",
"@typespec/http": ">=0.58.0 <1.0.0",
"@typespec/rest": ">=0.58.0 <1.0.0",
"@typespec/versioning": ">=0.58.0 <1.0.0",
"@typespec/openapi": ">=0.58.0 <1.0.0"
},
"dependenciesMeta": {
"@azure-tools/typespec-client-generator-core": {
Expand All @@ -62,32 +62,32 @@
},
"dependencies": {
"js-yaml": "~4.1.0",
"@typespec/openapi3": "~0.57.0",
"@typespec/openapi3": "~0.58.0",
"@autorest/system-requirements": "~1.0.2",
"fs-extra": "~11.2.0",
"semver": "~7.6.2"
},
"devDependencies": {
"@azure-tools/typespec-azure-resource-manager": "~0.43.0",
"@azure-tools/typespec-autorest": "~0.43.0",
"@azure-tools/cadl-ranch-expect": "~0.14.0",
"@azure-tools/cadl-ranch-specs": "~0.34.3",
"@azure-tools/typespec-azure-resource-manager": "~0.44.0",
"@azure-tools/typespec-autorest": "~0.44.0",
"@azure-tools/cadl-ranch-expect": "~0.14.1",
"@azure-tools/cadl-ranch-specs": "~0.34.5",
"@types/js-yaml": "~4.0.5",
"@types/mocha": "~10.0.1",
"@types/node": "^18.16.3",
"@typespec/eslint-config-typespec": "~0.55.0",
"@typespec/openapi": "~0.57.0",
"@typespec/openapi": "~0.58.0",
"c8": "~7.13.0",
"eslint": "^8.57.0",
"mocha": "~10.2.0",
"rimraf": "~5.0.0",
"typescript": "~5.1.3",
"@azure-tools/typespec-azure-core": "~0.43.0",
"@azure-tools/typespec-client-generator-core": "~0.43.2",
"@typespec/compiler": "~0.57.0",
"@typespec/http": "~0.57.0",
"@typespec/rest": "~0.57.0",
"@typespec/versioning": "~0.57.0",
"@azure-tools/typespec-azure-rulesets": "0.43.0"
"@azure-tools/typespec-azure-core": "~0.44.0",
"@azure-tools/typespec-client-generator-core": "~0.44.1",
"@typespec/compiler": "~0.58.0",
"@typespec/http": "~0.58.0",
"@typespec/rest": "~0.58.0",
"@typespec/versioning": "~0.58.0",
"@azure-tools/typespec-azure-rulesets": "0.44.0"
}
}
2 changes: 1 addition & 1 deletion packages/typespec-python/src/code-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export function emitCodeModel<TServiceOperation extends SdkServiceOperation>(
sdkContext: PythonSdkContext<TServiceOperation>,
) {
// Get types
const sdkPackage = sdkContext.experimental_sdkPackage;
const sdkPackage = sdkContext.sdkPackage;
const codeModel: Record<string, any> = {
namespace: removeUnderscoresFromNamespace(sdkPackage.rootNamespace).toLowerCase(),
clients: [],
Expand Down
2 changes: 1 addition & 1 deletion packages/typespec-python/src/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function addDefaultOptions(sdkContext: SdkContext) {
}
if (!options["package-name"]) {
options["package-name"] = removeUnderscoresFromNamespace(
sdkContext.experimental_sdkPackage.rootNamespace.toLowerCase(),
sdkContext.sdkPackage.rootNamespace.toLowerCase(),
).replace(/\./g, "-");
}
if (options.flavor !== "azure") {
Expand Down
2 changes: 1 addition & 1 deletion packages/typespec-python/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function getAddedOn<TServiceOperation extends SdkServiceOperation>(
// if type is added in the first version of the client, we do not need to add the versioning info
if (
type.apiVersions[0] ===
context.experimental_sdkPackage.clients.find((c) => c.initialization.access === "public")?.apiVersions[0]
context.sdkPackage.clients.find((c) => c.initialization.access === "public")?.apiVersions[0]
)
return undefined;
return type.apiVersions[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class AbstractModel(_model_base.Model):
You probably want to use the sub-classes and not this class directly. Known sub-classes are:
RealModel
All required parameters must be populated in order to send to server.
:ivar kind: Discriminator property for AbstractModel. Required. Default value is None.
:vartype kind: str
Expand All @@ -40,6 +41,7 @@ class AbstractModel(_model_base.Model):
class BaseModel(_model_base.Model):
"""Used in internal operations, should be generated but not exported.
All required parameters must be populated in order to send to server.
:ivar name: Required.
:vartype name: str
Expand All @@ -52,6 +54,7 @@ class BaseModel(_model_base.Model):
class InnerModel(_model_base.Model):
"""Used in internal operations, should be generated but not exported.
All required parameters must be populated in order to send to server.
:ivar name: Required.
:vartype name: str
Expand All @@ -64,6 +67,7 @@ class InnerModel(_model_base.Model):
class InternalDecoratorModelInInternal(_model_base.Model):
"""Used in an internal operation, should be generated but not exported.
All required parameters must be populated in order to send to server.
:ivar name: Required.
:vartype name: str
Expand All @@ -76,6 +80,7 @@ class InternalDecoratorModelInInternal(_model_base.Model):
class NoDecoratorModelInInternal(_model_base.Model):
"""Used in an internal operation, should be generated but not exported.
All required parameters must be populated in order to send to server.
:ivar name: Required.
:vartype name: str
Expand All @@ -88,6 +93,7 @@ class NoDecoratorModelInInternal(_model_base.Model):
class NoDecoratorModelInPublic(_model_base.Model):
"""Used in a public operation, should be generated and exported.
All required parameters must be populated in order to send to server.
:ivar name: Required.
:vartype name: str
Expand Down Expand Up @@ -117,6 +123,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles
class OuterModel(BaseModel):
"""Used in internal operations, should be generated but not exported.
All required parameters must be populated in order to send to server.
:ivar name: Required.
:vartype name: str
Expand All @@ -131,6 +138,7 @@ class OuterModel(BaseModel):
class PublicDecoratorModelInInternal(_model_base.Model):
"""Used in an internal operation but with public decorator, should be generated and exported.
All required parameters must be populated in order to send to server.
:ivar name: Required.
:vartype name: str
Expand Down Expand Up @@ -160,6 +168,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles
class PublicDecoratorModelInPublic(_model_base.Model):
"""Used in a public operation, should be generated and exported.
All required parameters must be populated in order to send to server.
:ivar name: Required.
:vartype name: str
Expand Down Expand Up @@ -189,6 +198,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles
class RealModel(AbstractModel, discriminator="real"):
"""Used in internal operations, should be generated but not exported.
All required parameters must be populated in order to send to server.
:ivar name: Required.
:vartype name: str
Expand All @@ -203,6 +213,7 @@ class RealModel(AbstractModel, discriminator="real"):
class SharedModel(_model_base.Model):
"""Used by both public and internal operation. It should be generated and exported.
All required parameters must be populated in order to send to server.
:ivar name: Required.
:vartype name: str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles
class ResultModel(_model_base.Model):
"""ResultModel.
All required parameters must be populated in order to send to server.
:ivar name: Required.
:vartype name: str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class FirstItem(_model_base.Model):
Readonly variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to server.
:ivar id: The id of the item. Required.
:vartype id: int
Expand Down Expand Up @@ -66,6 +67,7 @@ class SecondItem(_model_base.Model):
Readonly variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to server.
:ivar name: The name of the item. Required.
:vartype name: str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
class ExportedUser(_model_base.Model):
"""The exported user data.
All required parameters must be populated in order to send to server.
:ivar name: The name of user. Required.
:vartype name: str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class User(_model_base.Model):
Readonly variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to server.
:ivar id: The user's id. Required.
:vartype id: int
Expand Down Expand Up @@ -81,6 +82,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles
class UserActionResponse(_model_base.Model):
"""User action response.
All required parameters must be populated in order to send to server.
:ivar user_action_result: User action result. Required.
:vartype user_action_result: str
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Release History

## 1.0.0b1 (1970-01-01)

- Initial version
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Copyright (c) Microsoft Corporation.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
include *.md
include LICENSE
include specs/azure/example/basic/py.typed
recursive-include tests *.py
recursive-include samples *.py *.md
include specs/__init__.py
include specs/azure/__init__.py
include specs/azure/example/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@


# Specs Azure Example Basic client library for Python
<!-- write necessary description of service -->

## Getting started

### Install the package

```bash
python -m pip install specs-azure-example-basic
```

#### Prequisites

- Python 3.8 or later is required to use this package.
- You need an [Azure subscription][azure_sub] to use this package.
- An existing Specs Azure Example Basic instance.

## Contributing

This project welcomes contributions and suggestions. Most contributions require
you to agree to a Contributor License Agreement (CLA) declaring that you have
the right to, and actually do, grant us the rights to use your contribution.
For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether
you need to provide a CLA and decorate the PR appropriately (e.g., label,
comment). Simply follow the instructions provided by the bot. You will only
need to do this once across all repos using our CLA.

This project has adopted the
[Microsoft Open Source Code of Conduct][code_of_conduct]. For more information,
see the Code of Conduct FAQ or contact [email protected] with any
additional questions or comments.

<!-- LINKS -->
[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/
[authenticate_with_token]: https://docs.microsoft.com/azure/cognitive-services/authentication?tabs=powershell#authenticate-with-an-authentication-token
[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#credentials
[azure_identity_pip]: https://pypi.org/project/azure-identity/
[default_azure_credential]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#defaultazurecredential
[pip]: https://pypi.org/project/pip/
[azure_sub]: https://azure.microsoft.com/free/

Loading

0 comments on commit 1d654f4

Please sign in to comment.