From 0edcb375d4171c08ec82538eaf4edc692fa594d4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 26 May 2026 06:10:52 +0000 Subject: [PATCH 1/4] Initial plan From 96136d35c62a204e8d90f52649e8e423e99454f4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 26 May 2026 06:18:59 +0000 Subject: [PATCH 2/4] Add Python SDK tests for exact() client name feature Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- ...python-exact-name-test-2026-5-26-6-12-0.md | 7 +++ packages/http-client-python/package-lock.json | 28 ++++++------ packages/http-client-python/package.json | 4 +- ..._client_generator_core_exact_name_async.py | 43 +++++++++++++++++++ ..._azure_client_generator_core_exact_name.py | 40 +++++++++++++++++ 5 files changed, 106 insertions(+), 16 deletions(-) create mode 100644 .chronus/changes/python-exact-name-test-2026-5-26-6-12-0.md create mode 100644 packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_exact_name_async.py create mode 100644 packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_exact_name.py diff --git a/.chronus/changes/python-exact-name-test-2026-5-26-6-12-0.md b/.chronus/changes/python-exact-name-test-2026-5-26-6-12-0.md new file mode 100644 index 00000000000..7067f2774e4 --- /dev/null +++ b/.chronus/changes/python-exact-name-test-2026-5-26-6-12-0.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add mock_api tests for the `exact()` function used with `@clientName` to preserve exact naming. diff --git a/packages/http-client-python/package-lock.json b/packages/http-client-python/package-lock.json index 52118e4ce86..cc9078bf7e4 100644 --- a/packages/http-client-python/package-lock.json +++ b/packages/http-client-python/package-lock.json @@ -17,12 +17,12 @@ "tsx": "^4.21.0" }, "devDependencies": { - "@azure-tools/azure-http-specs": "0.1.0-alpha.40", + "@azure-tools/azure-http-specs": "0.1.0-alpha.41-dev.1", "@azure-tools/typespec-autorest": "~0.68.0", "@azure-tools/typespec-azure-core": "~0.68.0", "@azure-tools/typespec-azure-resource-manager": "~0.68.0", "@azure-tools/typespec-azure-rulesets": "~0.68.0", - "@azure-tools/typespec-client-generator-core": "~0.68.0", + "@azure-tools/typespec-client-generator-core": "~0.68.2", "@types/js-yaml": "~4.0.5", "@types/node": "~25.0.2", "@types/semver": "7.5.8", @@ -66,25 +66,25 @@ } }, "node_modules/@azure-tools/azure-http-specs": { - "version": "0.1.0-alpha.40", - "resolved": "https://registry.npmjs.org/@azure-tools/azure-http-specs/-/azure-http-specs-0.1.0-alpha.40.tgz", - "integrity": "sha512-1WhoWwV+SgpzLUHJdRPo+Ph5mQNe0FtDYHb0dVBhIzRMjWzBvYhdj1iK0yAkwYnm04WxLO5izz5sO6/Lq5KhnQ==", + "version": "0.1.0-alpha.41-dev.1", + "resolved": "https://registry.npmjs.org/@azure-tools/azure-http-specs/-/azure-http-specs-0.1.0-alpha.41-dev.1.tgz", + "integrity": "sha512-GaFmm7KP19YtxgdE2eyA37XusQCqoxo7UA6Lj9iLnXE77XPeDppE1pKstWFAbMcv/Jrc/EGqkl+TOGApej/JoA==", "dev": true, "license": "MIT", "dependencies": { - "@typespec/spec-api": "^0.1.0-alpha.14", - "@typespec/spector": "^0.1.0-alpha.25" + "@typespec/spec-api": "^0.1.0-alpha.14 || >=0.1.0-alpha.15-dev <0.1.0-alpha.15", + "@typespec/spector": "^0.1.0-alpha.25 || >=0.1.0-alpha.26-dev <0.1.0-alpha.26" }, "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@azure-tools/typespec-azure-core": "^0.68.0", + "@azure-tools/typespec-azure-core": "^0.68.0 || >=0.69.0-dev <0.69.0", "@typespec/compiler": "^1.12.0", "@typespec/http": "^1.12.0", - "@typespec/rest": "^0.82.0", - "@typespec/versioning": "^0.82.0", - "@typespec/xml": "^0.82.0" + "@typespec/rest": "^0.82.0 || >=0.83.0-dev <0.83.0", + "@typespec/versioning": "^0.82.0 || >=0.83.0-dev <0.83.0", + "@typespec/xml": "^0.82.0 || >=0.83.0-dev <0.83.0" } }, "node_modules/@azure-tools/typespec-autorest": { @@ -167,9 +167,9 @@ } }, "node_modules/@azure-tools/typespec-client-generator-core": { - "version": "0.68.0", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-client-generator-core/-/typespec-client-generator-core-0.68.0.tgz", - "integrity": "sha512-QDEAaT/9STiteTPH4qEKuwlIaLvWyAPf/+0XWyqj3vge6Zi7YdWBwB4PqaCMFptHRGAeWC2a14PDGY6kKyc2MQ==", + "version": "0.68.2", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-client-generator-core/-/typespec-client-generator-core-0.68.2.tgz", + "integrity": "sha512-i6McruyTzeP+CQ1klyEbFfz0gn/ERxkQf8qcrWASPz/ARMneUtZ1hCAmHcv22QuurA3eohn3QZI5r58BgwW87Q==", "dev": true, "license": "MIT", "dependencies": { diff --git a/packages/http-client-python/package.json b/packages/http-client-python/package.json index 3f8ab4a8d76..ef31a825df2 100644 --- a/packages/http-client-python/package.json +++ b/packages/http-client-python/package.json @@ -102,8 +102,8 @@ "@azure-tools/typespec-azure-core": "~0.68.0", "@azure-tools/typespec-azure-resource-manager": "~0.68.0", "@azure-tools/typespec-azure-rulesets": "~0.68.0", - "@azure-tools/typespec-client-generator-core": "~0.68.0", - "@azure-tools/azure-http-specs": "0.1.0-alpha.40", + "@azure-tools/typespec-client-generator-core": "~0.68.2", + "@azure-tools/azure-http-specs": "0.1.0-alpha.41-dev.1", "@typespec/compiler": "^1.12.0", "@typespec/http": "^1.12.0", "@typespec/openapi": "^1.12.0", diff --git a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_exact_name_async.py b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_exact_name_async.py new file mode 100644 index 00000000000..1b474436439 --- /dev/null +++ b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_exact_name_async.py @@ -0,0 +1,43 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import pytest +import pytest_asyncio +from specs.azure.clientgenerator.core.exactname.aio import ExactNameClient +from specs.azure.clientgenerator.core.exactname.model.models import My_model +from specs.azure.clientgenerator.core.exactname.property.models import ScopedModel + + +@pytest_asyncio.fixture +async def client(): + async with ExactNameClient() as client: + yield client + + +@pytest.mark.asyncio +async def test_model(client: ExactNameClient): + body = My_model(name="test") + response = await client.model.send(body=body) + assert response.name == "test" + + +@pytest.mark.asyncio +async def test_property(client: ExactNameClient): + body = ScopedModel({"name": "test"}) + response = await client.property.send(body=body) + assert response._my_name == "test" + + +def test_model_class_name_preserved(): + # exact("my_model") should preserve the name as-is without casing transformation, + # so the generated class is `My_model` (only the first letter capitalized for class naming), + # not `MyModel`. + assert My_model.__name__ == "My_model" + + +def test_property_name_preserved(): + # exact("_my_name") scoped to python should preserve the property name exactly, + # including the leading underscore, instead of being stripped/recased. + assert "_my_name" in ScopedModel.__annotations__ diff --git a/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_exact_name.py b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_exact_name.py new file mode 100644 index 00000000000..c3c5fe3649f --- /dev/null +++ b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_exact_name.py @@ -0,0 +1,40 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import pytest +from specs.azure.clientgenerator.core.exactname import ExactNameClient +from specs.azure.clientgenerator.core.exactname.model.models import My_model +from specs.azure.clientgenerator.core.exactname.property.models import ScopedModel + + +@pytest.fixture +def client(): + with ExactNameClient() as client: + yield client + + +def test_model(client: ExactNameClient): + body = My_model(name="test") + response = client.model.send(body=body) + assert response.name == "test" + + +def test_property(client: ExactNameClient): + body = ScopedModel({"name": "test"}) + response = client.property.send(body=body) + assert response._my_name == "test" + + +def test_model_class_name_preserved(): + # exact("my_model") should preserve the name as-is without casing transformation, + # so the generated class is `My_model` (only the first letter capitalized for class naming), + # not `MyModel`. + assert My_model.__name__ == "My_model" + + +def test_property_name_preserved(): + # exact("_my_name") scoped to python should preserve the property name exactly, + # including the leading underscore, instead of being stripped/recased. + assert "_my_name" in ScopedModel.__annotations__ From c265eeb08c194ac3754d3687bef341e007c6e190 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Tue, 26 May 2026 07:32:26 +0000 Subject: [PATCH 3/4] fix pylint in CI --- packages/http-client-python/eng/scripts/ci/run_pylint.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/http-client-python/eng/scripts/ci/run_pylint.py b/packages/http-client-python/eng/scripts/ci/run_pylint.py index c184c56a3de..d473b1e94e4 100644 --- a/packages/http-client-python/eng/scripts/ci/run_pylint.py +++ b/packages/http-client-python/eng/scripts/ci/run_pylint.py @@ -47,6 +47,15 @@ def _single_dir_pylint(mod): ] if is_azure: pylint_args.append("--load-plugins=pylint_guidelines_checker") + # Per-package suppressions for generated code where pylint's ignore-paths + # is not honored (pylint 4.x + recursive + plugin). Keep the scope as + # narrow as possible: only this package, only the offending check. + per_package_disables = { + "azure-client-generator-core-exact-name": ["client-incorrect-naming-convention"], + } + extra_disables = per_package_disables.get(mod.name) + if extra_disables: + pylint_args.append("--disable={}".format(",".join(extra_disables))) pylint_args.append(str(inner_class.absolute())) try: check_call(pylint_args) From bb90a7429b36b7a4c5ca285c1b08c3cca9dcc640 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Tue, 26 May 2026 07:42:18 +0000 Subject: [PATCH 4/4] fix cspell: replace 'recased' in test comments --- .../test_azure_client_generator_core_exact_name_async.py | 2 +- .../azure/test_azure_client_generator_core_exact_name.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_exact_name_async.py b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_exact_name_async.py index 1b474436439..af984634d49 100644 --- a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_exact_name_async.py +++ b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_exact_name_async.py @@ -39,5 +39,5 @@ def test_model_class_name_preserved(): def test_property_name_preserved(): # exact("_my_name") scoped to python should preserve the property name exactly, - # including the leading underscore, instead of being stripped/recased. + # including the leading underscore, instead of being stripped or having its case changed. assert "_my_name" in ScopedModel.__annotations__ diff --git a/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_exact_name.py b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_exact_name.py index c3c5fe3649f..90ae1d6ab9e 100644 --- a/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_exact_name.py +++ b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_exact_name.py @@ -36,5 +36,5 @@ def test_model_class_name_preserved(): def test_property_name_preserved(): # exact("_my_name") scoped to python should preserve the property name exactly, - # including the leading underscore, instead of being stripped/recased. + # including the leading underscore, instead of being stripped or having its case changed. assert "_my_name" in ScopedModel.__annotations__