diff --git a/.chronus/changes/python-regeneration-fixtures-2026-7-28.md b/.chronus/changes/python-regeneration-fixtures-2026-7-28.md new file mode 100644 index 00000000000..a2ce1204e28 --- /dev/null +++ b/.chronus/changes/python-regeneration-fixtures-2026-7-28.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Track only hand-authored test fixture files instead of whole generated packages, and clean generated test code with `git clean` during regeneration. diff --git a/packages/http-client-python/.gitignore b/packages/http-client-python/.gitignore index 752599c032c..878018f1d08 100644 --- a/packages/http-client-python/.gitignore +++ b/packages/http-client-python/.gitignore @@ -14,3 +14,56 @@ alpha # pip component detection reports (generated during build) component-detection-pip-report.json generator/component-detection-pip-report.json + +# Generated SDK fixtures with hand-authored/customized code required by tests. (begin) +# +# Generated SDK packages under `tests/generated/` are recreated from the specs by +# `npm run regenerate`, so they are not committed. Only the hand-authored files +# that regeneration deliberately preserves are tracked; every exception below +# documents why the file cannot be regenerated. +# +# The repo-root .gitignore excludes `tests/**/generated/` as a whole directory, +# which would stop git from ever descending into it, so re-include the directory +# itself first and then ignore its contents. +!tests/**/generated/ +tests/generated/** +# Re-include directories so the exceptions below are reachable (git does not +# descend into an ignored directory). +!tests/generated/**/ + +# `_operations/_patch.py` adds `patch_added_operation`, asserted by +# tests/mock_api/shared/test_patch.py. +!tests/generated/azure/authentication-api-key/authentication/apikey/_operations/_patch.py +!tests/generated/azure/authentication-api-key/authentication/apikey/aio/_operations/_patch.py +!tests/generated/unbranded/authentication-api-key/authentication/apikey/_operations/_patch.py +!tests/generated/unbranded/authentication-api-key/authentication/apikey/aio/_operations/_patch.py + +# `models/_patch.py` registers the custom GeoJSON serializer/deserializer used by +# tests/mock_api/azure/test_client_generator_core_alternate_type.py. +!tests/generated/azure/azure-client-generator-core-alternate-type/specs/azure/clientgenerator/core/alternatetype/models/_patch.py + +# `pyproject.toml` carries a hand-added `[tool.azure-sdk-build]` section. It is +# the fixture for the emitter behavior that keeps existing `[tool.*]` fields when +# it rewrites `pyproject.toml`, so the file has to exist before regeneration. +!tests/generated/azure/authentication-union/pyproject.toml + +# `generation-subdir`/`generation-subdir2` emit into a `_generated/` subfolder; +# the surrounding package is a hand-written wrapper (`CustomizedClient` / +# `AddedClient`) that regeneration must leave untouched. +!tests/generated/azure/generation-subdir/generation/subdir/__init__.py +!tests/generated/azure/generation-subdir/generation/subdir/_client.py +!tests/generated/azure/generation-subdir/generation/subdir/aio/__init__.py +!tests/generated/azure/generation-subdir/generation/subdir/aio/_client.py +!tests/generated/unbranded/generation-subdir/generation/subdir/__init__.py +!tests/generated/unbranded/generation-subdir/generation/subdir/_client.py +!tests/generated/unbranded/generation-subdir/generation/subdir/aio/__init__.py +!tests/generated/unbranded/generation-subdir/generation/subdir/aio/_client.py +!tests/generated/azure/generation-subdir2/generation/subdir2/__init__.py +!tests/generated/azure/generation-subdir2/generation/subdir2/_client.py +!tests/generated/azure/generation-subdir2/generation/subdir2/aio/__init__.py +!tests/generated/azure/generation-subdir2/generation/subdir2/aio/_client.py +!tests/generated/unbranded/generation-subdir2/generation/subdir2/__init__.py +!tests/generated/unbranded/generation-subdir2/generation/subdir2/_client.py +!tests/generated/unbranded/generation-subdir2/generation/subdir2/aio/__init__.py +!tests/generated/unbranded/generation-subdir2/generation/subdir2/aio/_client.py +# Generated SDK fixtures with hand-authored/customized code required by tests. (end) diff --git a/packages/http-client-python/CONTRIBUTING.md b/packages/http-client-python/CONTRIBUTING.md index 7ee4d6ed7ed..2af3ad96403 100644 --- a/packages/http-client-python/CONTRIBUTING.md +++ b/packages/http-client-python/CONTRIBUTING.md @@ -135,22 +135,6 @@ When you open a PR against this package: Both must pass before your PR can be merged. -### Manual Regeneration Testing - -You can manually trigger the [TypeSpec Python Regenerate Tests](https://github.com/Azure/azure-sdk-for-python/actions/workflows/typespec-python-regenerate.yml) workflow in `azure-sdk-for-python` to regenerate tests. The workflow checks out `microsoft/typespec` (at the ref you specify, defaulting to `main`), builds the regeneration infrastructure, installs the target emitter from npm, and runs the full regeneration. - -### Post-Release: Updating azure-sdk-for-python - -Once a new version of this emitter is released, follow these steps to update `azure-sdk-for-python`: - -1. Follow skill [emitter-package-update](https://github.com/Azure/azure-sdk-for-python/tree/main/.github/skills/emitter-package-update) to **create a PR** to update `eng/emitter-package.json` and `eng/emitter-package-lock.json` and submit them to `azure-sdk-for-python`. - -2. **Automatic regeneration**: Once the PR merges to `main`, the [TypeSpec Python Regenerate Tests](https://github.com/Azure/azure-sdk-for-python/actions/workflows/typespec-python-regenerate.yml) workflow triggers automatically (it watches for changes to `eng/emitter-package.json`). It regenerates all test code and creates a follow-up issue with the updated generated files. - -3. **Generated code location**: The regenerated tests are checked in at [`eng/tools/azure-sdk-tools/emitter/generated`](https://github.com/Azure/azure-sdk-for-python/tree/typespec-python-generated-tests/eng/tools/azure-sdk-tools/emitter/generated) in `azure-sdk-for-python`, split into: - - `azure/` — Tests generated with the branded emitter (Azure HTTP specs) - - `unbranded/` — Tests generated with the unbranded emitter (HTTP specs) - ## Release Process The release process for `@typespec/http-client-python` follows these steps: diff --git a/packages/http-client-python/eng/scripts/ci/regenerate-common.ts b/packages/http-client-python/eng/scripts/ci/regenerate-common.ts index 630bee17c7c..e4fdc6c1291 100644 --- a/packages/http-client-python/eng/scripts/ci/regenerate-common.ts +++ b/packages/http-client-python/eng/scripts/ci/regenerate-common.ts @@ -16,8 +16,7 @@ import { compile, NodeHost } from "@typespec/compiler"; import { execSync } from "child_process"; import { existsSync, rmSync } from "fs"; -import { access, cp, mkdir, mkdtemp, readdir, writeFile } from "fs/promises"; -import { tmpdir } from "os"; +import { access, mkdir, readdir, writeFile } from "fs/promises"; import { dirname, join, relative, resolve } from "path"; import pc from "picocolors"; @@ -655,6 +654,28 @@ export async function runParallel( return results; } +/** + * Removes every generated file under `tests/generated`, keeping only the + * hand-authored files that are tracked in git. `git clean -xdf` deletes ignored + * and untracked files but never tracked ones, so `.gitignore` stays the single + * source of truth for which fixtures survive regeneration (each exception there + * documents why it cannot be regenerated). + */ +export async function cleanGeneratedCode(generatedFolder: string): Promise { + const repoDir = resolve(generatedFolder, ".."); + const testsGeneratedDir = resolve(repoDir, "tests/generated"); + if (!existsSync(testsGeneratedDir)) return; + + console.log(pc.cyan(`\n${"=".repeat(60)}`)); + console.log(pc.cyan(`Cleaning generated test packages`)); + console.log(pc.cyan(`${"=".repeat(60)}\n`)); + + execSync(`git clean -x -d -f -q -- "${testsGeneratedDir}"`, { + cwd: repoDir, + stdio: ["ignore", "inherit", "inherit"], + }); +} + /** * Pre-create the marker files that the test harness expects to find before * regeneration so it can verify they're cleared/preserved correctly. @@ -698,99 +719,3 @@ export async function preprocess(flavor: string, generatedFolder: string): Promi }), ); } - -/** - * Resets the `tests/generated/{azure,unbranded}` baseline by sparse-checking-out - * `eng/tools/azure-sdk-tools/emitter/generated` from the Azure/azure-sdk-for-python repo, then - * deleting a couple of fully-generated package folders so regeneration has to - * recreate them from scratch (smoke test of full-emit path). - * - * `generatedFolder` is the per-repo `generator/` directory; baseline lands at - * `/../tests/generated`. - */ -export async function prepareBaselineOfGeneratedCode(generatedFolder: string): Promise { - const repoUrl = "https://github.com/Azure/azure-sdk-for-python.git"; - const branch = "typespec-python-generated-tests"; - const sourceSubdir = "eng/tools/azure-sdk-tools/emitter/generated"; - const testsGeneratedDir = resolve(generatedFolder, "../tests/generated"); - - console.log(pc.cyan(`\n${"=".repeat(60)}`)); - console.log(pc.cyan(`Resetting baseline from ${repoUrl} (${branch}/${sourceSubdir})`)); - console.log(pc.cyan(`${"=".repeat(60)}\n`)); - - // Wipe tests/generated - if (existsSync(testsGeneratedDir)) { - console.log(pc.dim(`Removing ${testsGeneratedDir}`)); - rmSync(testsGeneratedDir, { recursive: true, force: true }); - } - - // Sparse-checkout the baseline folder into a temp directory - const tempDir = await mkdtemp(join(tmpdir(), "azsdk-baseline-")); - try { - console.log(pc.dim(`Cloning into ${tempDir}`)); - const run = (cmd: string) => - execSync(cmd, { cwd: tempDir, stdio: ["ignore", "ignore", "inherit"] }); - - run(`git init`); - run(`git config core.longpaths true`); - run(`git remote add origin ${repoUrl}`); - run(`git config core.sparseCheckout true`); - run(`git sparse-checkout init --cone`); - run(`git sparse-checkout set ${sourceSubdir}`); - run(`git fetch --depth 1 origin ${branch}`); - run(`git checkout FETCH_HEAD`); - - // we don't copy whole generated folder, just the specific subfolders needed for tests - // to verify correct preservation/deletion of files and folders during regeneration, - // to avoid accidentally including any manually edited code that might be in the repo - // and cause confusion when it doesn't get updated during regeneration - const legacyCodePathNeededForTests = [ - "azure/authentication-api-key", - "unbranded/authentication-api-key", - "azure/authentication-union", - "azure/generation-subdir", - "azure/generation-subdir2", - "unbranded/generation-subdir", - "unbranded/generation-subdir2", - "azure/azure-client-generator-core-alternate-type", - ]; - - const sourceRoot = join(tempDir, ...sourceSubdir.split("/")); - for (const subPath of legacyCodePathNeededForTests) { - const segments = subPath.split("/"); - const src = join(sourceRoot, ...segments); - const dest = join(testsGeneratedDir, ...segments); - if (!existsSync(src)) { - console.warn(pc.yellow(`Baseline folder not found: ${src}`)); - continue; - } - console.log(pc.dim(`Copying ${subPath} -> ${dest}`)); - await mkdir(dirname(dest), { recursive: true }); - await cp(src, dest, { recursive: true }); - } - - console.log(pc.green(`Baseline reset complete.\n`)); - } finally { - rmSync(tempDir, { recursive: true, force: true }); - } - - // Smoke test the full-emit path: delete a couple of fully-generated package - // folders and every README.md so regeneration has to recreate them. - const deleteIfExists = (path: string) => { - if (!existsSync(path)) return; - console.log(pc.dim(`Deleting ${path}`)); - rmSync(path, { recursive: true, force: true }); - }; - - deleteIfExists(join(testsGeneratedDir, "azure", "authentication-http-custom")); - deleteIfExists(join(testsGeneratedDir, "unbranded", "encode-array")); - - if (existsSync(testsGeneratedDir)) { - const entries = await readdir(testsGeneratedDir, { recursive: true, withFileTypes: true }); - for (const entry of entries) { - if (entry.isFile() && entry.name === "README.md") { - deleteIfExists(join(entry.parentPath, entry.name)); - } - } - } -} diff --git a/packages/http-client-python/eng/scripts/ci/regenerate.ts b/packages/http-client-python/eng/scripts/ci/regenerate.ts index e6c8cee1110..a162445f928 100644 --- a/packages/http-client-python/eng/scripts/ci/regenerate.ts +++ b/packages/http-client-python/eng/scripts/ci/regenerate.ts @@ -22,8 +22,8 @@ import { parseArgs } from "util"; import { buildTaskGroups, + cleanGeneratedCode, getSubdirectories, - prepareBaselineOfGeneratedCode, preprocess, RegenerateContext, RegenerateFlags, @@ -256,7 +256,7 @@ async function main() { const startTime = performance.now(); let success: boolean; - await prepareBaselineOfGeneratedCode(GENERATED_FOLDER); + await cleanGeneratedCode(GENERATED_FOLDER); if (flavor) { success = await regenerateFlavor(flavor, name, debug, jobs); diff --git a/packages/http-client-python/generator/pygen/codegen/serializers/types_serializer.py b/packages/http-client-python/generator/pygen/codegen/serializers/types_serializer.py index 77cfcb112af..9236e3cdc9a 100644 --- a/packages/http-client-python/generator/pygen/codegen/serializers/types_serializer.py +++ b/packages/http-client-python/generator/pygen/codegen/serializers/types_serializer.py @@ -189,9 +189,7 @@ def typeddict_models(self) -> list[ModelType]: property — are kept, ensuring no forward reference is left undefined. """ needed = self._types_file_model_names - candidates = [ - m for m in self._models if m.base != "json" and not m.discriminated_subtypes and m.name in needed - ] + candidates = [m for m in self._models if m.base != "json" and not m.discriminated_subtypes and m.name in needed] seen_names: dict[str, "ModelType"] = {} result: list["ModelType"] = [] for m in candidates: diff --git a/packages/http-client-python/package-lock.json b/packages/http-client-python/package-lock.json index 24fce49d063..420beebe892 100644 --- a/packages/http-client-python/package-lock.json +++ b/packages/http-client-python/package-lock.json @@ -1,12 +1,12 @@ { "name": "@typespec/http-client-python", - "version": "0.34.2", + "version": "0.35.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@typespec/http-client-python", - "version": "0.34.2", + "version": "0.35.0", "hasInstallScript": true, "license": "MIT", "dependencies": { @@ -40,6 +40,7 @@ "@typespec/xml": "~0.84.0", "c8": "^10.1.3", "picocolors": "~1.1.1", + "prettier": "^3.9.5", "rimraf": "~6.1.2", "typescript": "~5.9.2", "typescript-eslint": "^8.49.0", @@ -5837,9 +5838,9 @@ } }, "node_modules/prettier": { - "version": "3.8.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.1.tgz", - "integrity": "sha512-UOnG6LftzbdaHZcKoPFtOcCKztrQ57WkHDeRD9t/PTQtmT0NHSeWWepj6pS0z/N7+08BHFDQVUrfmfMRcZwbMg==", + "version": "3.9.6", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.9.6.tgz", + "integrity": "sha512-OpN0zzVdiaiAhxpuuj5efpIS4sY9j7bY6uR5mnj5yPzGkdkjNKSJeUThPb60Jw29QuAZgA4o+/iB49kFiaBX6g==", "dev": true, "license": "MIT", "bin": { diff --git a/packages/http-client-python/package.json b/packages/http-client-python/package.json index 25f1b0409a5..3cba5c7892e 100644 --- a/packages/http-client-python/package.json +++ b/packages/http-client-python/package.json @@ -50,7 +50,8 @@ "typecheck": "tsx ./eng/scripts/ci/typecheck.ts", "typecheck:generated": "tsx ./eng/scripts/ci/typecheck.ts --generated", "regenerate": "tsx ./eng/scripts/ci/regenerate.ts", - "ci": "npm run test:emitter && npm run ci:generated", + "check-unstaged": "git -c core.safecrlf=false diff --ignore-space-at-eol --exit-code HEAD -- .", + "ci": "npm run check-unstaged && npm run test:emitter && npm run ci:generated", "ci:generated": "tsx ./eng/scripts/ci/run-tests.ts --generator --env=ci", "change:version": "pnpm chronus version --ignore-policies --only @typespec/http-client-python", "change:add": "pnpm chronus add", @@ -129,6 +130,7 @@ "rimraf": "~6.1.2", "typescript": "~5.9.2", "typescript-eslint": "^8.49.0", - "vitest": "^4.0.15" + "vitest": "^4.0.15", + "prettier": "^3.9.5" } } diff --git a/packages/http-client-python/tests/generated/azure/authentication-api-key/authentication/apikey/_operations/_patch.py b/packages/http-client-python/tests/generated/azure/authentication-api-key/authentication/apikey/_operations/_patch.py new file mode 100644 index 00000000000..8391c35e9d5 --- /dev/null +++ b/packages/http-client-python/tests/generated/azure/authentication-api-key/authentication/apikey/_operations/_patch.py @@ -0,0 +1,37 @@ +# coding=utf-8 + +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + +from typing import List + +from ._operations import _ApiKeyClientOperationsMixin as Generated + + +class _ApiKeyClientOperationsMixin(Generated): + + def patch_added_operation(self) -> bool: + """This is a placeholder for the operation that was added in the patch. + + This method is a no-op and does not perform any action. + + :return: Always returns True. + :rtype: bool + """ + return True + + +__all__: List[str] = [ + "_ApiKeyClientOperationsMixin" +] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/packages/http-client-python/tests/generated/azure/authentication-api-key/authentication/apikey/aio/_operations/_patch.py b/packages/http-client-python/tests/generated/azure/authentication-api-key/authentication/apikey/aio/_operations/_patch.py new file mode 100644 index 00000000000..8391c35e9d5 --- /dev/null +++ b/packages/http-client-python/tests/generated/azure/authentication-api-key/authentication/apikey/aio/_operations/_patch.py @@ -0,0 +1,37 @@ +# coding=utf-8 + +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + +from typing import List + +from ._operations import _ApiKeyClientOperationsMixin as Generated + + +class _ApiKeyClientOperationsMixin(Generated): + + def patch_added_operation(self) -> bool: + """This is a placeholder for the operation that was added in the patch. + + This method is a no-op and does not perform any action. + + :return: Always returns True. + :rtype: bool + """ + return True + + +__all__: List[str] = [ + "_ApiKeyClientOperationsMixin" +] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/packages/http-client-python/tests/generated/azure/authentication-union/pyproject.toml b/packages/http-client-python/tests/generated/azure/authentication-union/pyproject.toml new file mode 100644 index 00000000000..c31cd4a1a76 --- /dev/null +++ b/packages/http-client-python/tests/generated/azure/authentication-union/pyproject.toml @@ -0,0 +1,63 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +[build-system] +requires = ["setuptools>=77.0.3", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "authentication-union" +authors = [ + { name = "Microsoft Corporation", email = "azpysdkhelp@microsoft.com" }, +] +description = "Microsoft Corporation Azure Authentication Union Client Library for Python" +license = "MIT" +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", +] +requires-python = ">=3.10" +keywords = ["azure", "azure sdk"] + +dependencies = [ + "isodate>=0.6.1", + "azure-core>=1.37.0", + "typing-extensions>=4.6.0", +] +dynamic = [ +"version", "readme" +] + +[project.urls] +repository = "https://github.com/Azure/azure-sdk-for-python" + +[tool.setuptools.dynamic] +version = {attr = "authentication.union._version.VERSION"} +readme = {file = ["README.md", "CHANGELOG.md"], content-type = "text/markdown"} + +[tool.setuptools.packages.find] +exclude = [ + "tests*", + "generated_tests*", + "samples*", + "generated_samples*", + "doc*", + "authentication", +] + +[tool.setuptools.package-data] +pytyped = ["py.typed"] + +[tool.azure-sdk-build] +pyright = false diff --git a/packages/http-client-python/tests/generated/azure/azure-client-generator-core-alternate-type/specs/azure/clientgenerator/core/alternatetype/models/_patch.py b/packages/http-client-python/tests/generated/azure/azure-client-generator-core-alternate-type/specs/azure/clientgenerator/core/alternatetype/models/_patch.py new file mode 100644 index 00000000000..74cf0769bd7 --- /dev/null +++ b/packages/http-client-python/tests/generated/azure/azure-client-generator-core-alternate-type/specs/azure/clientgenerator/core/alternatetype/models/_patch.py @@ -0,0 +1,61 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + +from typing import Type +import geojson +from .._utils.model_base import TYPE_HANDLER_REGISTRY + + +@TYPE_HANDLER_REGISTRY.register_serializer(geojson.Feature) +def feature_serializer(obj: geojson.Feature) -> dict: + """Serialize a geojson.Feature to a dict. + + :param obj: The geojson.Feature object to serialize. + :type obj: geojson.Feature + :return: The serialized feature as a dictionary. + :rtype: dict + """ + return { + "type": obj.type, + "geometry": {"type": obj.geometry.type, "coordinates": obj.geometry.coordinates}, + "properties": obj.properties, + "id": obj.id, + } + + +@TYPE_HANDLER_REGISTRY.register_deserializer(geojson.Feature) +def feature_deserializer(cls: Type[geojson.Feature], data: dict) -> geojson.Feature: + """Deserialize a dict to a geojson.Feature. + + :param data: The dictionary data to deserialize. + :type data: dict + :return: The deserialized geojson.Feature object. + :rtype: geojson.Feature + """ + return cls( + type=data.get("type"), + geometry=geojson.geometry.Geometry( # type: ignore + type=data["geometry"].get("type"), coordinates=data["geometry"].get("coordinates") + ), + properties=data.get("properties"), + id=data.get("id"), + ) + + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/packages/http-client-python/tests/generated/azure/generation-subdir/generation/subdir/__init__.py b/packages/http-client-python/tests/generated/azure/generation-subdir/generation/subdir/__init__.py new file mode 100644 index 00000000000..2368247d3c1 --- /dev/null +++ b/packages/http-client-python/tests/generated/azure/generation-subdir/generation/subdir/__init__.py @@ -0,0 +1,12 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from ._client import CustomizedClient +from ._generated.models import Extension + +__all__ = [ + "CustomizedClient", + "Extension", +] diff --git a/packages/http-client-python/tests/generated/azure/generation-subdir/generation/subdir/_client.py b/packages/http-client-python/tests/generated/azure/generation-subdir/generation/subdir/_client.py new file mode 100644 index 00000000000..352d9a45cca --- /dev/null +++ b/packages/http-client-python/tests/generated/azure/generation-subdir/generation/subdir/_client.py @@ -0,0 +1,31 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from typing import Any +from azure.core.tracing.decorator import distributed_trace +from ._generated import RecursiveClient as GeneratedClient, models as _models + + +class CustomizedClient: # pylint: disable=client-accepts-api-version-keyword + """Tests customization of a client that is fully wrapped. + + :keyword endpoint: Service host. Default value is "http://localhost:3000". + :paramtype endpoint: str + """ + + def __init__( # pylint: disable=missing-client-constructor-parameter-credential + self, *, endpoint: str = "http://localhost:3000", **kwargs: Any + ) -> None: + self._client = GeneratedClient(endpoint=endpoint, **kwargs) + + @distributed_trace + def customized_get(self, **kwargs: Any) -> _models.Extension: + """get. + + :return: Extension. The Extension is compatible with MutableMapping + :rtype: ~generation.subdir._generated.models.Extension + :raises ~corehttp.exceptions.HttpResponseError: + """ + return self._client.get(**kwargs) diff --git a/packages/http-client-python/tests/generated/azure/generation-subdir/generation/subdir/aio/__init__.py b/packages/http-client-python/tests/generated/azure/generation-subdir/generation/subdir/aio/__init__.py new file mode 100644 index 00000000000..e00f0911dad --- /dev/null +++ b/packages/http-client-python/tests/generated/azure/generation-subdir/generation/subdir/aio/__init__.py @@ -0,0 +1,11 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + +from ._client import CustomizedClient + +__all__ = [ + "CustomizedClient", +] diff --git a/packages/http-client-python/tests/generated/azure/generation-subdir/generation/subdir/aio/_client.py b/packages/http-client-python/tests/generated/azure/generation-subdir/generation/subdir/aio/_client.py new file mode 100644 index 00000000000..e63bca263cf --- /dev/null +++ b/packages/http-client-python/tests/generated/azure/generation-subdir/generation/subdir/aio/_client.py @@ -0,0 +1,32 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from typing import Any +from azure.core.tracing.decorator_async import distributed_trace_async +from .._generated.aio import RecursiveClient as GeneratedClient +from .._generated import models as _models + + +class CustomizedClient: # pylint: disable=client-accepts-api-version-keyword + """Tests customization of a client that is fully wrapped. + + :keyword endpoint: Service host. Default value is "http://localhost:3000". + :paramtype endpoint: str + """ + + def __init__( # pylint: disable=missing-client-constructor-parameter-credential + self, *, endpoint: str = "http://localhost:3000", **kwargs: Any + ) -> None: + self._client = GeneratedClient(endpoint=endpoint, **kwargs) + + @distributed_trace_async + async def customized_get(self, **kwargs: Any) -> _models.Extension: + """get. + + :return: Extension. The Extension is compatible with MutableMapping + :rtype: ~generation.subdir._generated.models.Extension + :raises ~corehttp.exceptions.HttpResponseError: + """ + return await self._client.get(**kwargs) diff --git a/packages/http-client-python/tests/generated/azure/generation-subdir2/generation/subdir2/__init__.py b/packages/http-client-python/tests/generated/azure/generation-subdir2/generation/subdir2/__init__.py new file mode 100644 index 00000000000..696a76a39d3 --- /dev/null +++ b/packages/http-client-python/tests/generated/azure/generation-subdir2/generation/subdir2/__init__.py @@ -0,0 +1,16 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from ._client import AddedClient +from ._generated.models import ModelV1, ModelV2, EnumV1, EnumV2, Versions + +__all__ = [ + "AddedClient", + "ModelV1", + "ModelV2", + "EnumV1", + "EnumV2", + "Versions", +] diff --git a/packages/http-client-python/tests/generated/azure/generation-subdir2/generation/subdir2/_client.py b/packages/http-client-python/tests/generated/azure/generation-subdir2/generation/subdir2/_client.py new file mode 100644 index 00000000000..7ac04804ca6 --- /dev/null +++ b/packages/http-client-python/tests/generated/azure/generation-subdir2/generation/subdir2/_client.py @@ -0,0 +1,10 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from ._generated._client import AddedClient as _GeneratedAddedClient + + +class AddedClient(_GeneratedAddedClient): + """Public wrapper around the generated AddedClient implementation.""" diff --git a/packages/http-client-python/tests/generated/azure/generation-subdir2/generation/subdir2/aio/__init__.py b/packages/http-client-python/tests/generated/azure/generation-subdir2/generation/subdir2/aio/__init__.py new file mode 100644 index 00000000000..ef389b5aba6 --- /dev/null +++ b/packages/http-client-python/tests/generated/azure/generation-subdir2/generation/subdir2/aio/__init__.py @@ -0,0 +1,11 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + +from ._client import AddedClient + +__all__ = [ + "AddedClient", +] diff --git a/packages/http-client-python/tests/generated/azure/generation-subdir2/generation/subdir2/aio/_client.py b/packages/http-client-python/tests/generated/azure/generation-subdir2/generation/subdir2/aio/_client.py new file mode 100644 index 00000000000..df64d117ed5 --- /dev/null +++ b/packages/http-client-python/tests/generated/azure/generation-subdir2/generation/subdir2/aio/_client.py @@ -0,0 +1,10 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from .._generated.aio._client import AddedClient as _GeneratedAddedClient + + +class AddedClient(_GeneratedAddedClient): + """Public async wrapper around the generated AddedClient implementation.""" diff --git a/packages/http-client-python/tests/generated/unbranded/authentication-api-key/authentication/apikey/_operations/_patch.py b/packages/http-client-python/tests/generated/unbranded/authentication-api-key/authentication/apikey/_operations/_patch.py new file mode 100644 index 00000000000..8391c35e9d5 --- /dev/null +++ b/packages/http-client-python/tests/generated/unbranded/authentication-api-key/authentication/apikey/_operations/_patch.py @@ -0,0 +1,37 @@ +# coding=utf-8 + +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + +from typing import List + +from ._operations import _ApiKeyClientOperationsMixin as Generated + + +class _ApiKeyClientOperationsMixin(Generated): + + def patch_added_operation(self) -> bool: + """This is a placeholder for the operation that was added in the patch. + + This method is a no-op and does not perform any action. + + :return: Always returns True. + :rtype: bool + """ + return True + + +__all__: List[str] = [ + "_ApiKeyClientOperationsMixin" +] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/packages/http-client-python/tests/generated/unbranded/authentication-api-key/authentication/apikey/aio/_operations/_patch.py b/packages/http-client-python/tests/generated/unbranded/authentication-api-key/authentication/apikey/aio/_operations/_patch.py new file mode 100644 index 00000000000..8391c35e9d5 --- /dev/null +++ b/packages/http-client-python/tests/generated/unbranded/authentication-api-key/authentication/apikey/aio/_operations/_patch.py @@ -0,0 +1,37 @@ +# coding=utf-8 + +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + +from typing import List + +from ._operations import _ApiKeyClientOperationsMixin as Generated + + +class _ApiKeyClientOperationsMixin(Generated): + + def patch_added_operation(self) -> bool: + """This is a placeholder for the operation that was added in the patch. + + This method is a no-op and does not perform any action. + + :return: Always returns True. + :rtype: bool + """ + return True + + +__all__: List[str] = [ + "_ApiKeyClientOperationsMixin" +] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/packages/http-client-python/tests/generated/unbranded/generation-subdir/generation/subdir/__init__.py b/packages/http-client-python/tests/generated/unbranded/generation-subdir/generation/subdir/__init__.py new file mode 100644 index 00000000000..2368247d3c1 --- /dev/null +++ b/packages/http-client-python/tests/generated/unbranded/generation-subdir/generation/subdir/__init__.py @@ -0,0 +1,12 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from ._client import CustomizedClient +from ._generated.models import Extension + +__all__ = [ + "CustomizedClient", + "Extension", +] diff --git a/packages/http-client-python/tests/generated/unbranded/generation-subdir/generation/subdir/_client.py b/packages/http-client-python/tests/generated/unbranded/generation-subdir/generation/subdir/_client.py new file mode 100644 index 00000000000..7904e9db034 --- /dev/null +++ b/packages/http-client-python/tests/generated/unbranded/generation-subdir/generation/subdir/_client.py @@ -0,0 +1,31 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from typing import Any +from ._generated import RecursiveClient as GeneratedClient, models as _models + + +class CustomizedClient: # pylint: disable=client-accepts-api-version-keyword + """Tests customization of a client that is fully wrapped. + + :keyword endpoint: Service host. Default value is "http://localhost:3000". + :paramtype endpoint: str + """ + + def __init__( # pylint: disable=missing-client-constructor-parameter-credential + self, *, endpoint: str = "http://localhost:3000", **kwargs: Any + ) -> None: + self._client = GeneratedClient(endpoint=endpoint, **kwargs) + + def customized_get( # pylint: disable=client-method-missing-tracing-decorator + self, **kwargs: Any + ) -> _models.Extension: + """get. + + :return: Extension. The Extension is compatible with MutableMapping + :rtype: ~generation.subdir._generated.models.Extension + :raises ~corehttp.exceptions.HttpResponseError: + """ + return self._client.get(**kwargs) diff --git a/packages/http-client-python/tests/generated/unbranded/generation-subdir/generation/subdir/aio/__init__.py b/packages/http-client-python/tests/generated/unbranded/generation-subdir/generation/subdir/aio/__init__.py new file mode 100644 index 00000000000..e00f0911dad --- /dev/null +++ b/packages/http-client-python/tests/generated/unbranded/generation-subdir/generation/subdir/aio/__init__.py @@ -0,0 +1,11 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + +from ._client import CustomizedClient + +__all__ = [ + "CustomizedClient", +] diff --git a/packages/http-client-python/tests/generated/unbranded/generation-subdir/generation/subdir/aio/_client.py b/packages/http-client-python/tests/generated/unbranded/generation-subdir/generation/subdir/aio/_client.py new file mode 100644 index 00000000000..e27581b5986 --- /dev/null +++ b/packages/http-client-python/tests/generated/unbranded/generation-subdir/generation/subdir/aio/_client.py @@ -0,0 +1,32 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from typing import Any +from .._generated.aio import RecursiveClient as GeneratedClient +from .._generated import models as _models + + +class CustomizedClient: # pylint: disable=client-accepts-api-version-keyword + """Tests customization of a client that is fully wrapped. + + :keyword endpoint: Service host. Default value is "http://localhost:3000". + :paramtype endpoint: str + """ + + def __init__( # pylint: disable=missing-client-constructor-parameter-credential + self, *, endpoint: str = "http://localhost:3000", **kwargs: Any + ) -> None: + self._client = GeneratedClient(endpoint=endpoint, **kwargs) + + async def customized_get( # pylint: disable=client-method-missing-tracing-decorator-async + self, **kwargs: Any + ) -> _models.Extension: + """get. + + :return: Extension. The Extension is compatible with MutableMapping + :rtype: ~generation.subdir._generated.models.Extension + :raises ~corehttp.exceptions.HttpResponseError: + """ + return await self._client.get(**kwargs) diff --git a/packages/http-client-python/tests/generated/unbranded/generation-subdir2/generation/subdir2/__init__.py b/packages/http-client-python/tests/generated/unbranded/generation-subdir2/generation/subdir2/__init__.py new file mode 100644 index 00000000000..696a76a39d3 --- /dev/null +++ b/packages/http-client-python/tests/generated/unbranded/generation-subdir2/generation/subdir2/__init__.py @@ -0,0 +1,16 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from ._client import AddedClient +from ._generated.models import ModelV1, ModelV2, EnumV1, EnumV2, Versions + +__all__ = [ + "AddedClient", + "ModelV1", + "ModelV2", + "EnumV1", + "EnumV2", + "Versions", +] diff --git a/packages/http-client-python/tests/generated/unbranded/generation-subdir2/generation/subdir2/_client.py b/packages/http-client-python/tests/generated/unbranded/generation-subdir2/generation/subdir2/_client.py new file mode 100644 index 00000000000..7ac04804ca6 --- /dev/null +++ b/packages/http-client-python/tests/generated/unbranded/generation-subdir2/generation/subdir2/_client.py @@ -0,0 +1,10 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from ._generated._client import AddedClient as _GeneratedAddedClient + + +class AddedClient(_GeneratedAddedClient): + """Public wrapper around the generated AddedClient implementation.""" diff --git a/packages/http-client-python/tests/generated/unbranded/generation-subdir2/generation/subdir2/aio/__init__.py b/packages/http-client-python/tests/generated/unbranded/generation-subdir2/generation/subdir2/aio/__init__.py new file mode 100644 index 00000000000..ef389b5aba6 --- /dev/null +++ b/packages/http-client-python/tests/generated/unbranded/generation-subdir2/generation/subdir2/aio/__init__.py @@ -0,0 +1,11 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + +from ._client import AddedClient + +__all__ = [ + "AddedClient", +] diff --git a/packages/http-client-python/tests/generated/unbranded/generation-subdir2/generation/subdir2/aio/_client.py b/packages/http-client-python/tests/generated/unbranded/generation-subdir2/generation/subdir2/aio/_client.py new file mode 100644 index 00000000000..df64d117ed5 --- /dev/null +++ b/packages/http-client-python/tests/generated/unbranded/generation-subdir2/generation/subdir2/aio/_client.py @@ -0,0 +1,10 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +from .._generated.aio._client import AddedClient as _GeneratedAddedClient + + +class AddedClient(_GeneratedAddedClient): + """Public async wrapper around the generated AddedClient implementation."""