Skip to content

Commit 4ef4de6

Browse files
authored
[Python] Support move method level signature to client level (#3222)
* add test case * Update dependencies * Update dependencies (2025-09-26 05:08:58) * Regenerate for typespec-python (2025-09-26 05:14:04) * Add changelog .chronus/changes/auto-microsoft-python-fix-client-initialization-2025-8-25-17-45-10.md --------- Co-authored-by: AutoPrFromHttpClientPython <AutoPrFromHttpClientPython>
1 parent aeca2ab commit 4ef4de6

59 files changed

Lines changed: 5125 additions & 42 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
changeKind: feature
3+
packages:
4+
- "@autorest/python"
5+
- "@azure-tools/typespec-python"
6+
---
7+
8+
Support move method level signature to client level

packages/autorest.python/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
},
3030
"homepage": "https://github.com/Azure/autorest.python/blob/main/README.md",
3131
"dependencies": {
32-
"@typespec/http-client-python": "~0.18.1",
32+
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTM4Nzg0Ni9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.18.1.tgz",
3333
"@autorest/system-requirements": "~1.0.2",
3434
"fs-extra": "~11.2.0",
3535
"tsx": "~4.19.1"
@@ -47,4 +47,4 @@
4747
"requirements.txt",
4848
"generator/"
4949
]
50-
}
50+
}

packages/typespec-python/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"js-yaml": "~4.1.0",
6868
"semver": "~7.6.2",
6969
"tsx": "~4.19.1",
70-
"@typespec/http-client-python": "~0.18.1",
70+
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTM4Nzg0Ni9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.18.1.tgz",
7171
"fs-extra": "~11.2.0"
7272
},
7373
"devDependencies": {
@@ -86,7 +86,7 @@
8686
"@azure-tools/typespec-azure-rulesets": "~0.60.0",
8787
"@azure-tools/typespec-autorest": "~0.60.0",
8888
"@azure-tools/typespec-client-generator-core": "~0.60.2",
89-
"@azure-tools/azure-http-specs": "0.1.0-alpha.28",
89+
"@azure-tools/azure-http-specs": "0.1.0-alpha.29",
9090
"@typespec/http-specs": "0.1.0-alpha.26",
9191
"@typespec/spector": "0.1.0-alpha.18",
9292
"@typespec/spec-api": "0.1.0-alpha.9",
@@ -103,4 +103,4 @@
103103
"chalk": "5.3.0",
104104
"@types/fs-extra": "11.0.4"
105105
}
106-
}
106+
}

packages/typespec-python/scripts/eng/regenerate.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ const AZURE_EMITTER_OPTIONS: Record<string, Record<string, string> | Record<stri
8080
"azure/payload/pageable": {
8181
namespace: "specs.azure.payload.pageable",
8282
},
83+
"azure/versioning/previewVersion": {
84+
namespace: "specs.azure.versioning.previewversion",
85+
},
8386
"client/structure/default": {
8487
namespace: "client.structure.service",
8588
},

packages/typespec-python/test/azure/generated/azure-client-generator-core-client-initialization/specs/azure/clientgenerator/core/clientinitialization/_client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,15 +421,18 @@ class ParentClient: # pylint: disable=client-accepts-api-version-keyword
421421
:ivar child_client: ChildClientOperations operations
422422
:vartype child_client:
423423
specs.azure.clientgenerator.core.clientinitialization.operations.ChildClientOperations
424+
:param blob_name: The name of the blob. This parameter is used as a path parameter in all
425+
operations. Required.
426+
:type blob_name: str
424427
:keyword endpoint: Service host. Default value is "http://localhost:3000".
425428
:paramtype endpoint: str
426429
"""
427430

428431
def __init__( # pylint: disable=missing-client-constructor-parameter-credential
429-
self, *, endpoint: str = "http://localhost:3000", **kwargs: Any
432+
self, blob_name: str, *, endpoint: str = "http://localhost:3000", **kwargs: Any
430433
) -> None:
431434
_endpoint = "{endpoint}"
432-
self._config = ParentClientConfiguration(endpoint=endpoint, **kwargs)
435+
self._config = ParentClientConfiguration(blob_name=blob_name, endpoint=endpoint, **kwargs)
433436

434437
_policies = kwargs.pop("policies", None)
435438
if _policies is None:

packages/typespec-python/test/azure/generated/azure-client-generator-core-client-initialization/specs/azure/clientgenerator/core/clientinitialization/_configuration.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,18 @@ class ParentClientConfiguration: # pylint: disable=too-many-instance-attributes
199199
Note that all parameters used to create this instance are saved as instance
200200
attributes.
201201
202+
:param blob_name: The name of the blob. This parameter is used as a path parameter in all
203+
operations. Required.
204+
:type blob_name: str
202205
:param endpoint: Service host. Default value is "http://localhost:3000".
203206
:type endpoint: str
204207
"""
205208

206-
def __init__(self, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None:
209+
def __init__(self, blob_name: str, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None:
210+
if blob_name is None:
211+
raise ValueError("Parameter 'blob_name' must not be None.")
207212

213+
self.blob_name = blob_name
208214
self.endpoint = endpoint
209215
kwargs.setdefault("sdk_moniker", "specs-azure-clientgenerator-core-clientinitialization/{}".format(VERSION))
210216
self.polling_interval = kwargs.get("polling_interval", 30)

packages/typespec-python/test/azure/generated/azure-client-generator-core-client-initialization/specs/azure/clientgenerator/core/clientinitialization/aio/_client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,15 +431,18 @@ class ParentClient: # pylint: disable=client-accepts-api-version-keyword
431431
:ivar child_client: ChildClientOperations operations
432432
:vartype child_client:
433433
specs.azure.clientgenerator.core.clientinitialization.aio.operations.ChildClientOperations
434+
:param blob_name: The name of the blob. This parameter is used as a path parameter in all
435+
operations. Required.
436+
:type blob_name: str
434437
:keyword endpoint: Service host. Default value is "http://localhost:3000".
435438
:paramtype endpoint: str
436439
"""
437440

438441
def __init__( # pylint: disable=missing-client-constructor-parameter-credential
439-
self, *, endpoint: str = "http://localhost:3000", **kwargs: Any
442+
self, blob_name: str, *, endpoint: str = "http://localhost:3000", **kwargs: Any
440443
) -> None:
441444
_endpoint = "{endpoint}"
442-
self._config = ParentClientConfiguration(endpoint=endpoint, **kwargs)
445+
self._config = ParentClientConfiguration(blob_name=blob_name, endpoint=endpoint, **kwargs)
443446

444447
_policies = kwargs.pop("policies", None)
445448
if _policies is None:

packages/typespec-python/test/azure/generated/azure-client-generator-core-client-initialization/specs/azure/clientgenerator/core/clientinitialization/aio/_configuration.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,18 @@ class ParentClientConfiguration: # pylint: disable=too-many-instance-attributes
199199
Note that all parameters used to create this instance are saved as instance
200200
attributes.
201201
202+
:param blob_name: The name of the blob. This parameter is used as a path parameter in all
203+
operations. Required.
204+
:type blob_name: str
202205
:param endpoint: Service host. Default value is "http://localhost:3000".
203206
:type endpoint: str
204207
"""
205208

206-
def __init__(self, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None:
209+
def __init__(self, blob_name: str, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None:
210+
if blob_name is None:
211+
raise ValueError("Parameter 'blob_name' must not be None.")
207212

213+
self.blob_name = blob_name
208214
self.endpoint = endpoint
209215
kwargs.setdefault("sdk_moniker", "specs-azure-clientgenerator-core-clientinitialization/{}".format(VERSION))
210216
self.polling_interval = kwargs.get("polling_interval", 30)

packages/typespec-python/test/azure/generated/azure-client-generator-core-client-location/generated_tests/test_location_move_method_parameter_to_client_operations.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class TestLocationMoveMethodParameterToClientOperations(ClientLocationClientTest
1717
def test_move_method_parameter_to_client_blob_operations_get_blob(self, location_endpoint):
1818
client = self.create_client(endpoint=location_endpoint)
1919
response = client.move_method_parameter_to_client.blob_operations.get_blob(
20-
storage_account="str",
2120
container="str",
2221
blob="str",
2322
)

packages/typespec-python/test/azure/generated/azure-client-generator-core-client-location/generated_tests/test_location_move_method_parameter_to_client_operations_async.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class TestLocationMoveMethodParameterToClientOperationsAsync(ClientLocationClien
1818
async def test_move_method_parameter_to_client_blob_operations_get_blob(self, location_endpoint):
1919
client = self.create_async_client(endpoint=location_endpoint)
2020
response = await client.move_method_parameter_to_client.blob_operations.get_blob(
21-
storage_account="str",
2221
container="str",
2322
blob="str",
2423
)

0 commit comments

Comments
 (0)