From 9c81581f87489ffc0d84c17ae2fddb6be68504dc Mon Sep 17 00:00:00 2001 From: AutoPrFromHttpClientPython Date: Wed, 12 Feb 2025 03:48:31 +0000 Subject: [PATCH 01/14] Update dependencies (2025-02-12 03:48:31) --- packages/autorest.python/package.json | 4 +- packages/typespec-python/package.json | 56 +- pnpm-lock.yaml | 1642 ++++++++++++++++++------- 3 files changed, 1252 insertions(+), 450 deletions(-) diff --git a/packages/autorest.python/package.json b/packages/autorest.python/package.json index a4d3c9cde1c..08ddc36faa6 100644 --- a/packages/autorest.python/package.json +++ b/packages/autorest.python/package.json @@ -29,7 +29,7 @@ }, "homepage": "https://github.com/Azure/autorest.python/blob/main/README.md", "dependencies": { - "@typespec/http-client-python": "~0.6.10", + "@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1NTg1Ny9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz", "@autorest/system-requirements": "~1.0.2", "fs-extra": "~11.2.0", "tsx": "~4.19.1" @@ -47,4 +47,4 @@ "requirements.txt", "generator/" ] -} +} \ No newline at end of file diff --git a/packages/typespec-python/package.json b/packages/typespec-python/package.json index 3a14383abc9..682ab42158f 100644 --- a/packages/typespec-python/package.json +++ b/packages/typespec-python/package.json @@ -45,48 +45,48 @@ "generator/**" ], "peerDependencies": { - "@typespec/compiler": ">=0.64.0 <1.0.0", - "@typespec/http": ">=0.64.0 <1.0.0", - "@typespec/rest": ">=0.64.0 <1.0.0", - "@typespec/versioning": ">=0.64.0 <1.0.0", - "@typespec/openapi": ">=0.64.0 <1.0.0", - "@azure-tools/typespec-azure-core": ">=0.50.0 <1.0.0", - "@azure-tools/typespec-azure-resource-manager": ">=0.50.0 <1.0.0", - "@azure-tools/typespec-autorest": ">=0.50.0 <1.0.0", - "@azure-tools/typespec-azure-rulesets": ">=0.50.0 <3.0.0", - "@azure-tools/typespec-client-generator-core": ">=0.50.2 <1.0.0" + "@typespec/compiler": ">=0.65.0 <1.0.0", + "@typespec/http": ">=0.65.0 <1.0.0", + "@typespec/rest": ">=0.65.0 <1.0.0", + "@typespec/versioning": ">=0.65.0 <1.0.0", + "@typespec/openapi": ">=0.65.0 <1.0.0", + "@azure-tools/typespec-azure-core": ">=0.51.0 <1.0.0", + "@azure-tools/typespec-azure-resource-manager": ">=0.51.0 <1.0.0", + "@azure-tools/typespec-autorest": ">=0.51.0 <1.0.0", + "@azure-tools/typespec-azure-rulesets": ">=0.51.0 <3.0.0", + "@azure-tools/typespec-client-generator-core": ">=0.51.0 <1.0.0" }, "dependencies": { "js-yaml": "~4.1.0", "semver": "~7.6.2", "tsx": "~4.19.1", - "@typespec/http-client-python": "~0.6.10", + "@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1NTg1Ny9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz", "fs-extra": "~11.2.0" }, "devDependencies": { - "@typespec/compiler": "~0.64.0", - "@typespec/http": "~0.64.0", - "@typespec/rest": "~0.64.0", - "@typespec/versioning": "~0.64.0", - "@typespec/openapi": "~0.64.0", - "@azure-tools/typespec-azure-resource-manager": "~0.50.0", - "@azure-tools/typespec-azure-core": "~0.50.0", - "@azure-tools/typespec-azure-rulesets": "~0.50.0", - "@azure-tools/typespec-autorest": "~0.50.0", - "@azure-tools/typespec-client-generator-core": "~0.50.2", - "@azure-tools/azure-http-specs": "0.1.0-alpha.5", - "@typespec/http-specs": "0.1.0-alpha.8", + "@typespec/compiler": "~0.65.0", + "@typespec/http": "~0.65.0", + "@typespec/rest": "~0.65.0", + "@typespec/versioning": "~0.65.0", + "@typespec/openapi": "~0.65.0", + "@azure-tools/typespec-azure-resource-manager": "~0.51.0", + "@azure-tools/typespec-azure-core": "~0.51.0", + "@azure-tools/typespec-azure-rulesets": "~0.51.0", + "@azure-tools/typespec-autorest": "~0.51.0", + "@azure-tools/typespec-client-generator-core": "~0.51.0", + "@azure-tools/azure-http-specs": "0.1.0-alpha.6", + "@typespec/http-specs": "0.1.0-alpha.9", "@types/js-yaml": "~4.0.5", "@types/node": "~22.5.4", "@types/yargs": "~17.0.33", "@types/semver": "7.5.8", - "c8": "^10.1.2", - "vitest": "^2.1.9", + "c8": "^10.1.3", + "vitest": "^3.0.5", "rimraf": "~6.0.1", - "typescript": "~5.6.3", - "typescript-eslint": "^8.8.1", + "typescript": "~5.7.3", + "typescript-eslint": "^8.21.0", "yargs": "~17.7.2", "chalk": "5.3.0", "@types/fs-extra": "11.0.4" } -} +} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d912076a60b..4b5cf8aecbb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -57,8 +57,8 @@ importers: specifier: ~1.0.2 version: 1.0.2 '@typespec/http-client-python': - specifier: ~0.6.10 - version: 0.6.10(6gdwtcj6sqvu3zk5kjo6g4na54) + specifier: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1NTg1Ny9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz + version: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1NTg1Ny9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz(pj75u6zo6obzdihzpwvg36i7j4) fs-extra: specifier: ~11.2.0 version: 11.2.0 @@ -79,8 +79,8 @@ importers: packages/typespec-python: dependencies: '@typespec/http-client-python': - specifier: ~0.6.10 - version: 0.6.10(6gdwtcj6sqvu3zk5kjo6g4na54) + specifier: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1NTg1Ny9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz + version: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1NTg1Ny9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz(pj75u6zo6obzdihzpwvg36i7j4) fs-extra: specifier: ~11.2.0 version: 11.2.0 @@ -95,23 +95,23 @@ importers: version: 4.19.2 devDependencies: '@azure-tools/azure-http-specs': - specifier: 0.1.0-alpha.5 - version: 0.1.0-alpha.5(@azure-tools/typespec-azure-core@0.50.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))))(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)))(@typespec/versioning@0.64.0(@typespec/compiler@0.64.0))(@typespec/xml@0.59.0(@typespec/compiler@0.64.0)) + specifier: 0.1.0-alpha.6 + version: 0.1.0-alpha.6(@azure-tools/typespec-azure-core@0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))))(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/versioning@0.65.0(@typespec/compiler@0.65.0))(@typespec/xml@0.59.0(@typespec/compiler@0.65.0)) '@azure-tools/typespec-autorest': - specifier: ~0.50.0 - version: 0.50.0(ammezjnwgu4cizwmocq7itwhje) + specifier: ~0.51.0 + version: 0.51.0(46ydeuneniox7cgf5iph2c2gou) '@azure-tools/typespec-azure-core': - specifier: ~0.50.0 - version: 0.50.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))) + specifier: ~0.51.0 + version: 0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))) '@azure-tools/typespec-azure-resource-manager': - specifier: ~0.50.0 - version: 0.50.0(@azure-tools/typespec-azure-core@0.50.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))))(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/openapi@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)))(@typespec/versioning@0.64.0(@typespec/compiler@0.64.0)) + specifier: ~0.51.0 + version: 0.51.0(@azure-tools/typespec-azure-core@0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))))(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/openapi@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/versioning@0.65.0(@typespec/compiler@0.65.0)) '@azure-tools/typespec-azure-rulesets': - specifier: ~0.50.0 - version: 0.50.0(yzhyyprushasiqgxhoazmhsei4) + specifier: ~0.51.0 + version: 0.51.0(jfzpdywzlhylutuaycp4bg7qk4) '@azure-tools/typespec-client-generator-core': - specifier: ~0.50.2 - version: 0.50.2(@azure-tools/typespec-azure-core@0.50.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))))(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/openapi@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)))(@typespec/versioning@0.64.0(@typespec/compiler@0.64.0))(@typespec/xml@0.59.0(@typespec/compiler@0.64.0)) + specifier: ~0.51.0 + version: 0.51.0(@azure-tools/typespec-azure-core@0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))))(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/openapi@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/versioning@0.65.0(@typespec/compiler@0.65.0))(@typespec/xml@0.59.0(@typespec/compiler@0.65.0)) '@types/fs-extra': specifier: 11.0.4 version: 11.0.4 @@ -128,26 +128,26 @@ importers: specifier: ~17.0.33 version: 17.0.33 '@typespec/compiler': - specifier: ~0.64.0 - version: 0.64.0 + specifier: ~0.65.0 + version: 0.65.0 '@typespec/http': - specifier: ~0.64.0 - version: 0.64.0(@typespec/compiler@0.64.0) + specifier: ~0.65.0 + version: 0.65.0(@typespec/compiler@0.65.0) '@typespec/http-specs': - specifier: 0.1.0-alpha.8 - version: 0.1.0-alpha.8(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)))(@typespec/versioning@0.64.0(@typespec/compiler@0.64.0))(@typespec/xml@0.59.0(@typespec/compiler@0.64.0)) + specifier: 0.1.0-alpha.9 + version: 0.1.0-alpha.9(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/versioning@0.65.0(@typespec/compiler@0.65.0))(@typespec/xml@0.59.0(@typespec/compiler@0.65.0)) '@typespec/openapi': - specifier: ~0.64.0 - version: 0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)) + specifier: ~0.65.0 + version: 0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)) '@typespec/rest': - specifier: ~0.64.0 - version: 0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)) + specifier: ~0.65.0 + version: 0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)) '@typespec/versioning': - specifier: ~0.64.0 - version: 0.64.0(@typespec/compiler@0.64.0) + specifier: ~0.65.0 + version: 0.65.0(@typespec/compiler@0.65.0) c8: - specifier: ^10.1.2 - version: 10.1.2 + specifier: ^10.1.3 + version: 10.1.3 chalk: specifier: 5.3.0 version: 5.3.0 @@ -155,14 +155,14 @@ importers: specifier: ~6.0.1 version: 6.0.1 typescript: - specifier: ~5.6.3 - version: 5.6.3 + specifier: ~5.7.3 + version: 5.7.3 typescript-eslint: - specifier: ^8.8.1 - version: 8.13.0(eslint@9.11.1)(typescript@5.6.3) + specifier: ^8.21.0 + version: 8.24.0(eslint@9.11.1)(typescript@5.7.3) vitest: - specifier: ^2.1.9 - version: 2.1.9(@types/node@22.5.5) + specifier: ^3.0.5 + version: 3.0.5(@types/node@22.5.5) yargs: specifier: ~17.7.2 version: 17.7.2 @@ -179,73 +179,69 @@ packages: resolution: {integrity: sha512-T21naRb6JDdjjn2s/zwr9iCIv/9jviL/PRtiWAhi+3UA2WKH2wrId2VqJa4uVD7iEV8BLkuGgFmMkaMBG26hFw==} engines: {node: '>=12.0.0'} - '@azure-tools/azure-http-specs@0.1.0-alpha.5': - resolution: {integrity: sha512-U4/rArTPuU5endAO68eY3fx3yqaS7rZNn+/kGmJUV3qPmGDxRPfMes6RJ7D98bfdpD2k60wufrhk5REbqnhhDA==} + '@azure-tools/azure-http-specs@0.1.0-alpha.6': + resolution: {integrity: sha512-ET3k4DXvKvtij3hCyPgM6LOgsTZyfHc1kHtYEI7wdWHQb7wPyKlhUD+yf2YUoFjdQ8ea0GRfsCK1oECfME641Q==} engines: {node: '>=18.0.0'} peerDependencies: - '@azure-tools/typespec-azure-core': ~0.50.0 - '@typespec/compiler': ~0.64.0 - '@typespec/http': ~0.64.0 - '@typespec/rest': ~0.64.0 - '@typespec/versioning': ~0.64.0 - '@typespec/xml': ~0.64.0 - - '@azure-tools/typespec-autorest@0.50.0': - resolution: {integrity: sha512-CYzqN11NGU2HNJcycph7HCpjQoOR+XzyySDi6Z6rsXhZa/XTPDYJtmGHNVHXYGgvxJPxPJ9jm13DiLf/ReJnSA==} + '@azure-tools/typespec-azure-core': ~0.51.0 + '@typespec/compiler': ~0.65.0 + '@typespec/http': ~0.65.0 + '@typespec/rest': ~0.65.0 + '@typespec/versioning': ~0.65.0 + '@typespec/xml': ~0.65.0 + + '@azure-tools/typespec-autorest@0.51.0': + resolution: {integrity: sha512-PmhY5zxtsebTqNDRcssc1faaTuXyh284iwVY0Qn/mwNDczBOstqPbuBq/0j1LePnagRndvINowhqrePBmxCi6A==} engines: {node: '>=18.0.0'} peerDependencies: - '@azure-tools/typespec-azure-core': ~0.50.0 - '@azure-tools/typespec-azure-resource-manager': ~0.50.0 - '@azure-tools/typespec-client-generator-core': ~0.50.0 - '@typespec/compiler': ~0.64.0 - '@typespec/http': ~0.64.0 - '@typespec/openapi': ~0.64.0 - '@typespec/rest': ~0.64.0 - '@typespec/versioning': ~0.64.0 - - '@azure-tools/typespec-azure-core@0.50.0': - resolution: {integrity: sha512-6kUhWNQc4Btgx7rIbx3dubBLst73qv04dGWg0yNoVi86iIXy+8wr4ee6pgk+niMsZDeHEBEWeeLy9VwCg3MgTg==} + '@azure-tools/typespec-azure-core': ~0.51.0 + '@azure-tools/typespec-azure-resource-manager': ~0.51.0 + '@azure-tools/typespec-client-generator-core': ~0.51.0 + '@typespec/compiler': ~0.65.0 + '@typespec/http': ~0.65.0 + '@typespec/openapi': ~0.65.0 + '@typespec/rest': ~0.65.0 + '@typespec/versioning': ~0.65.0 + + '@azure-tools/typespec-azure-core@0.51.0': + resolution: {integrity: sha512-ig27mvrxVEfyIzTPnWWk1ASkL0x8jKx5V3sanICv1p8iW6qXEcGZZHTmI2onfFcXSoEV52r0MWj9iu0yI4bxMA==} engines: {node: '>=18.0.0'} peerDependencies: - '@typespec/compiler': ~0.64.0 - '@typespec/http': ~0.64.0 - '@typespec/rest': ~0.64.0 + '@typespec/compiler': ~0.65.0 + '@typespec/http': ~0.65.0 + '@typespec/rest': ~0.65.0 - '@azure-tools/typespec-azure-resource-manager@0.50.0': - resolution: {integrity: sha512-ekLAyPyy9eMMqdi3pj3g+iw9NNiK6ObDIU/W/bwSBSPwN2Po9d46fb65vcsjPeEkBceeRIPP6p54QtG9JYhSfg==} + '@azure-tools/typespec-azure-resource-manager@0.51.0': + resolution: {integrity: sha512-vqEwAsT8pkG90V3u1cPTKV3nZTuuyl6W+GMBeDfVLYmhQmJQBiJ78jTgFEqsGarAvp9KSRdY4+HUvaOGonONPA==} engines: {node: '>=18.0.0'} peerDependencies: - '@azure-tools/typespec-azure-core': ~0.50.0 - '@typespec/compiler': ~0.64.0 - '@typespec/http': ~0.64.0 - '@typespec/openapi': ~0.64.0 - '@typespec/rest': ~0.64.0 - '@typespec/versioning': ~0.64.0 - - '@azure-tools/typespec-azure-rulesets@0.50.0': - resolution: {integrity: sha512-b2YjhaUqPxk53eswZKPzK1IzTJJe/AD+Yi/G15+fiar7oozQJtZpe7ysrSsknzKEoy92iiknsIVa5giRie0ATg==} + '@azure-tools/typespec-azure-core': ~0.51.0 + '@typespec/compiler': ~0.65.0 + '@typespec/http': ~0.65.0 + '@typespec/openapi': ~0.65.0 + '@typespec/rest': ~0.65.0 + '@typespec/versioning': ~0.65.0 + + '@azure-tools/typespec-azure-rulesets@0.51.0': + resolution: {integrity: sha512-R20BCEjdN0KT1uAk6cWK44j3ELD9x1oJlYCiXOSY7A2g30nzBvr2E7BT3V09A9Og9ArP+Uwh0J5ZvD7dn/cLCQ==} engines: {node: '>=18.0.0'} peerDependencies: - '@azure-tools/typespec-azure-core': ~0.50.0 - '@azure-tools/typespec-azure-resource-manager': ~0.50.0 - '@azure-tools/typespec-client-generator-core': ~0.50.0 - '@typespec/compiler': ~0.64.0 + '@azure-tools/typespec-azure-core': ~0.51.0 + '@azure-tools/typespec-azure-resource-manager': ~0.51.0 + '@azure-tools/typespec-client-generator-core': ~0.51.0 + '@typespec/compiler': ~0.65.0 - '@azure-tools/typespec-client-generator-core@0.50.2': - resolution: {integrity: sha512-xSyJ5OWqu9BToUoQrmoN6a9pxHpTUqDEyc5pmhRwzeuz3zOIvFs2DFKimE2wqVmhFTYg6LTVqle/UU4sr/vdyQ==} + '@azure-tools/typespec-client-generator-core@0.51.0': + resolution: {integrity: sha512-nhnG5EmZmWlvofKipVz4PJEhq95MlO8SqYINvU33SQOI+/8QBp3Y0JV7NJPxKObWdOPZli98VZ/glLEV8YX8YQ==} engines: {node: '>=18.0.0'} peerDependencies: - '@azure-tools/typespec-azure-core': ~0.50.0 - '@typespec/compiler': ~0.64.0 - '@typespec/http': ~0.64.0 - '@typespec/openapi': ~0.64.0 - '@typespec/rest': ~0.64.0 - '@typespec/versioning': ~0.64.0 - '@typespec/xml': ~0.64.0 - - '@azure/abort-controller@1.1.0': - resolution: {integrity: sha512-TrRLIoSQVzfAJX9H1JeFjzAoDGcoK1IYX1UImfceTZpsyYfWr09Ss1aHW1y5TrrR3iq6RZLBwJ3E24uwPhwahw==} - engines: {node: '>=12.0.0'} + '@azure-tools/typespec-azure-core': ~0.51.0 + '@typespec/compiler': ~0.65.0 + '@typespec/http': ~0.65.0 + '@typespec/openapi': ~0.65.0 + '@typespec/rest': ~0.65.0 + '@typespec/versioning': ~0.65.0 + '@typespec/xml': ~0.65.0 '@azure/abort-controller@2.1.2': resolution: {integrity: sha512-nBrLsEWm4J2u5LpAPjxADTlq3trDgVZZXHNKabeXZtpq3d3AbN/KGO82R87rdDz5/lYB024rtEf10/q0urNgsA==} @@ -255,6 +251,10 @@ packages: resolution: {integrity: sha512-YvFMowkXzLbXNM11yZtVLhUCmuG0ex7JKOH366ipjmHBhL3vpDcPAeWF+jf0X+jVXwFqo3UhsWUq4kH0ZPdu/g==} engines: {node: '>=18.0.0'} + '@azure/core-auth@1.9.0': + resolution: {integrity: sha512-FPwHpZywuyasDSLMqJ6fhbOK3TqUdviZNF8OqRGA4W5Ewib2lEEZ+pBsYcBa88B2NGO/SEnYPGhyBqNlE8ilSw==} + engines: {node: '>=18.0.0'} + '@azure/core-client@1.9.2': resolution: {integrity: sha512-kRdry/rav3fUKHl/aDLd/pDLcB+4pOFwPPTVEExuMyaI5r+JBbMWqRbCY1pn5BniDaU3lRxO9eaQ1AmSMehl/w==} engines: {node: '>=18.0.0'} @@ -283,38 +283,54 @@ packages: resolution: {integrity: sha512-dqLWQsh9Nro1YQU+405POVtXnwrIVqPyfUzc4zXCbThTg7+vNNaiMkwbX9AMXKyoFYFClxmB3s25ZFr3+jZkww==} engines: {node: '>=18.0.0'} + '@azure/core-util@1.11.0': + resolution: {integrity: sha512-DxOSLua+NdpWoSqULhjDyAZTXFdP/LKkqtYuxxz1SCN289zk3OG8UOpnCQAz/tygyACBtWp/BoO72ptK7msY8g==} + engines: {node: '>=18.0.0'} + '@azure/core-xml@1.4.3': resolution: {integrity: sha512-D6G7FEmDiTctPKuWegX2WTrS1enKZwqYwdKTO6ZN6JMigcCehlT0/CYl+zWpI9vQ9frwwp7GQT3/owaEXgnOsA==} engines: {node: '>=18.0.0'} - '@azure/identity@4.4.1': - resolution: {integrity: sha512-DwnG4cKFEM7S3T+9u05NstXU/HN0dk45kPOinUyNKsn5VWwpXd9sbPKEg6kgJzGbm1lMuhx9o31PVbCtM5sfBA==} + '@azure/identity@4.6.0': + resolution: {integrity: sha512-ANpO1iAvcZmpD4QY7/kaE/P2n66pRXsDp3nMUC6Ow3c9KfXOZF7qMU9VgqPw8m7adP7TVIbVyrCEmD9cth3KQQ==} engines: {node: '>=18.0.0'} '@azure/logger@1.1.4': resolution: {integrity: sha512-4IXXzcCdLdlXuCG+8UKEwLA1T1NHqUfanhXYHiQTn+6sfWCZXduqbtXDGceg3Ce5QxTGo7EqmbV6Bi+aqKuClQ==} engines: {node: '>=18.0.0'} - '@azure/msal-browser@3.24.0': - resolution: {integrity: sha512-JGNV9hTYAa7lsum9IMIibn2kKczAojNihGo1hi7pG0kNrcKej530Fl6jxwM05A44/6I079CSn6WxYxbVhKUmWg==} + '@azure/msal-browser@4.2.1': + resolution: {integrity: sha512-pJX+HNVxEEvxqj3xvnFKMi/Yb6jadwOWN2QkDagj2GV2XXxJg3qq5zkE+czVw6Cmf4QiXxct+J0WF23sE8vZyA==} + engines: {node: '>=0.8.0'} + + '@azure/msal-common@14.16.0': + resolution: {integrity: sha512-1KOZj9IpcDSwpNiQNjt0jDYZpQvNZay7QAEi/5DLubay40iGYtLzya/jbjRPLyOTZhEKyL1MzPuw2HqBCjceYA==} engines: {node: '>=0.8.0'} - '@azure/msal-common@14.15.0': - resolution: {integrity: sha512-ImAQHxmpMneJ/4S8BRFhjt1MZ3bppmpRPYYNyzeQPeFN288YKbb8TmmISQEbtfkQ1BPASvYZU5doIZOPBAqENQ==} + '@azure/msal-common@15.1.1': + resolution: {integrity: sha512-bvLWYq9fleAcTJ6H+hfkG91On6vI/UhGyOB7Z6r0Bsa+KTL3zPtigmGCOJgdxrEklOYD88X9SehexLDH/5NRKQ==} engines: {node: '>=0.8.0'} - '@azure/msal-node@2.14.0': - resolution: {integrity: sha512-rrfzIpG3Q1rHjVYZmHAEDidWAZZ2cgkxlIcMQ8dHebRISaZ2KCV33Q8Vs+uaV6lxweROabNxKFlR2lIKagZqYg==} + '@azure/msal-node@2.16.2': + resolution: {integrity: sha512-An7l1hEr0w1HMMh1LU+rtDtqL7/jw74ORlc9Wnh06v7TU/xpG39/Zdr1ZJu3QpjUfKJ+E0/OXMW8DRSWTlh7qQ==} engines: {node: '>=16'} '@azure/storage-blob@12.25.0': resolution: {integrity: sha512-oodouhA3nCCIh843tMMbxty3WqfNT+Vgzj3Xo5jqR9UPnzq3d7mzLjlHAYz7lW+b4km3SIgz+NAgztvhm7Z6kQ==} engines: {node: '>=18.0.0'} + '@azure/storage-blob@12.26.0': + resolution: {integrity: sha512-SriLPKezypIsiZ+TtlFfE46uuBIap2HeaQVS78e1P7rz5OSbq0rsd52WE1mC5f7vAeLiXqv7I7oRhL3WFZEw3Q==} + engines: {node: '>=18.0.0'} + '@babel/code-frame@7.25.9': resolution: {integrity: sha512-z88xeGxnzehn2sqZ8UdGQEvYErF1odv2CftxInpSYJt6uHuPe9YjahKZITGs3l5LeI9d2ROG+obuDAoSlqbNfQ==} engines: {node: '>=6.9.0'} + '@babel/code-frame@7.26.2': + resolution: {integrity: sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==} + engines: {node: '>=6.9.0'} + '@babel/helper-validator-identifier@7.24.7': resolution: {integrity: sha512-rR+PBcQ1SMQDDyF6X0wxtG8QyLCgUB0eRAGguqRLfkCA87l7yAP7ehq8SNj96OOGTO8OBV70KhuFYcIkHXOg0w==} engines: {node: '>=6.9.0'} @@ -327,8 +343,9 @@ packages: resolution: {integrity: sha512-llL88JShoCsth8fF8R4SJnIn+WLvR6ccFxu1H3FlMhDontdcmZWf2HgIZ7AIqV3Xcck1idlohrN4EUBQz6klbw==} engines: {node: '>=6.9.0'} - '@bcoe/v8-coverage@0.2.3': - resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==} + '@bcoe/v8-coverage@1.0.2': + resolution: {integrity: sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA==} + engines: {node: '>=18'} '@chronus/chronus@0.12.1': resolution: {integrity: sha512-ZnWAeYA7gi7Hk27F4Fn18pfaZYkhSetnhqWvp1hZBDlAgrmpXFcXYHaA69BbXtAIGkomJ5s9k12wmjkiJQeJ4g==} @@ -871,6 +888,13 @@ packages: resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==} engines: {node: '>=12'} + '@isaacs/fs-minipass@4.0.1': + resolution: {integrity: sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w==} + engines: {node: '>=18.0.0'} + + '@isaacs/string-locale-compare@1.1.0': + resolution: {integrity: sha512-SQ7Kzhh9+D+ZW9MA0zkYv3VXhIDNx+LzM6EJ+/65I3QY+enU6Itte7E5XX7EWrqLW2FN4n06GWzBnPoC3th2aQ==} + '@istanbuljs/schema@0.1.3': resolution: {integrity: sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==} engines: {node: '>=8'} @@ -906,39 +930,97 @@ packages: resolution: {integrity: sha512-OrcNPXdpSl9UX7qPVRWbmWMCSXrcDa2M9DvrbOTj7ao1S4PlqVFYv9/yLKMkrJKZ/V5A/kDBC690or307i26Og==} engines: {node: ^16.14.0 || >=18.0.0} + '@npmcli/agent@3.0.0': + resolution: {integrity: sha512-S79NdEgDQd/NGCay6TCoVzXSj74skRZIKJcpJjC5lOq34SZzyI6MqtiiWoiVWoVrTcGjNeC4ipbh1VIHlpfF5Q==} + engines: {node: ^18.17.0 || >=20.5.0} + + '@npmcli/arborist@9.0.0': + resolution: {integrity: sha512-ZFsI/VJ7wJ2rTksLNJ9xqr75Ste/wiKvW+7w12ZGbcT67xWii97yS+aDlh3edNhqlqoXvdzYG4hTNui81VxJCA==} + engines: {node: ^20.17.0 || >=22.9.0} + hasBin: true + '@npmcli/fs@3.1.1': resolution: {integrity: sha512-q9CRWjpHCMIh5sVyefoD1cA7PkvILqCZsnSOEUUivORLjxCO/Irmue2DprETiNgEqktDBZaM1Bi+jrarx1XdCg==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + '@npmcli/fs@4.0.0': + resolution: {integrity: sha512-/xGlezI6xfGO9NwuJlnwz/K14qD1kCSAGtacBHnGzeAIuJGazcp45KP5NuyARXoKb7cwulAGWVsbeSxdG/cb0Q==} + engines: {node: ^18.17.0 || >=20.5.0} + '@npmcli/git@5.0.8': resolution: {integrity: sha512-liASfw5cqhjNW9UFd+ruwwdEf/lbOAQjLL2XY2dFW/bkJheXDYZgOyul/4gVvEV4BWkTXjYGmDqMw9uegdbJNQ==} engines: {node: ^16.14.0 || >=18.0.0} + '@npmcli/git@6.0.1': + resolution: {integrity: sha512-BBWMMxeQzalmKadyimwb2/VVQyJB01PH0HhVSNLHNBDZN/M/h/02P6f8fxedIiFhpMj11SO9Ep5tKTBE7zL2nw==} + engines: {node: ^18.17.0 || >=20.5.0} + '@npmcli/installed-package-contents@2.1.0': resolution: {integrity: sha512-c8UuGLeZpm69BryRykLuKRyKFZYJsZSCT4aVY5ds4omyZqJ172ApzgfKJ5eV/r3HgLdUYgFVe54KSFVjKoe27w==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} hasBin: true + '@npmcli/installed-package-contents@3.0.0': + resolution: {integrity: sha512-fkxoPuFGvxyrH+OQzyTkX2LUEamrF4jZSmxjAtPPHHGO0dqsQ8tTKjnIS8SAnPHdk2I03BDtSMR5K/4loKg79Q==} + engines: {node: ^18.17.0 || >=20.5.0} + hasBin: true + + '@npmcli/map-workspaces@4.0.2': + resolution: {integrity: sha512-mnuMuibEbkaBTYj9HQ3dMe6L0ylYW+s/gfz7tBDMFY/la0w9Kf44P9aLn4/+/t3aTR3YUHKoT6XQL9rlicIe3Q==} + engines: {node: ^18.17.0 || >=20.5.0} + + '@npmcli/metavuln-calculator@9.0.0': + resolution: {integrity: sha512-znLKqdy1ZEGNK3VB9j/RzGyb/P0BJb3fGpvEbHIAyBAXsps2l1ce8SVHfsGAFLl9s8072PxafqTn7RC8wSnQPg==} + engines: {node: ^20.17.0 || >=22.9.0} + + '@npmcli/name-from-folder@3.0.0': + resolution: {integrity: sha512-61cDL8LUc9y80fXn+lir+iVt8IS0xHqEKwPu/5jCjxQTVoSCmkXvw4vbMrzAMtmghz3/AkiBjhHkDKUH+kf7kA==} + engines: {node: ^18.17.0 || >=20.5.0} + '@npmcli/node-gyp@3.0.0': resolution: {integrity: sha512-gp8pRXC2oOxu0DUE1/M3bYtb1b3/DbJ5aM113+XJBgfXdussRAsX0YOrOhdd8WvnAR6auDBvJomGAkLKA5ydxA==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + '@npmcli/node-gyp@4.0.0': + resolution: {integrity: sha512-+t5DZ6mO/QFh78PByMq1fGSAub/agLJZDRfJRMeOSNCt8s9YVlTjmGpIPwPhvXTGUIJk+WszlT0rQa1W33yzNA==} + engines: {node: ^18.17.0 || >=20.5.0} + '@npmcli/package-json@5.2.1': resolution: {integrity: sha512-f7zYC6kQautXHvNbLEWgD/uGu1+xCn9izgqBfgItWSx22U0ZDekxN08A1vM8cTxj/cRVe0Q94Ode+tdoYmIOOQ==} engines: {node: ^16.14.0 || >=18.0.0} + '@npmcli/package-json@6.1.1': + resolution: {integrity: sha512-d5qimadRAUCO4A/Txw71VM7UrRZzV+NPclxz/dc+M6B2oYwjWTjqh8HA/sGQgs9VZuJ6I/P7XIAlJvgrl27ZOw==} + engines: {node: ^18.17.0 || >=20.5.0} + '@npmcli/promise-spawn@7.0.2': resolution: {integrity: sha512-xhfYPXoV5Dy4UkY0D+v2KkwvnDfiA/8Mt3sWCGI/hM03NsYIH8ZaG6QzS9x7pje5vHZBZJ2v6VRFVTWACnqcmQ==} engines: {node: ^16.14.0 || >=18.0.0} + '@npmcli/promise-spawn@8.0.2': + resolution: {integrity: sha512-/bNJhjc+o6qL+Dwz/bqfTQClkEO5nTQ1ZEcdCkAQjhkZMHIh22LPG7fNh1enJP1NKWDqYiiABnjFCY7E0zHYtQ==} + engines: {node: ^18.17.0 || >=20.5.0} + + '@npmcli/query@4.0.0': + resolution: {integrity: sha512-3pPbese0fbCiFJ/7/X1GBgxAKYFE8sxBddA7GtuRmOgNseH4YbGsXJ807Ig3AEwNITjDUISHglvy89cyDJnAwA==} + engines: {node: ^18.17.0 || >=20.5.0} + '@npmcli/redact@2.0.1': resolution: {integrity: sha512-YgsR5jCQZhVmTJvjduTOIHph0L73pK8xwMVaDY0PatySqVM9AZj93jpoXYSJqfHFxFkN9dmqTw6OiqExsS3LPw==} engines: {node: ^16.14.0 || >=18.0.0} + '@npmcli/redact@3.1.1': + resolution: {integrity: sha512-3Hc2KGIkrvJWJqTbvueXzBeZlmvoOxc2jyX00yzr3+sNFquJg0N8hH4SAPLPVrkWIRQICVpVgjrss971awXVnA==} + engines: {node: ^18.17.0 || >=20.5.0} + '@npmcli/run-script@8.1.0': resolution: {integrity: sha512-y7efHHwghQfk28G2z3tlZ67pLG0XdfYbcVG26r7YIXALRsrVQcTq4/tdenSmdOrEsNahIYA/eh8aEVROWGFUDg==} engines: {node: ^16.14.0 || >=18.0.0} + '@npmcli/run-script@9.0.2': + resolution: {integrity: sha512-cJXiUlycdizQwvqE1iaAb4VRUM3RX09/8q46zjvy+ct9GhfZRWd7jXYVc1tn/CfRlGPVkX/u4sstRlepsm7hfw==} + engines: {node: ^18.17.0 || >=20.5.0} + '@octokit/app@15.1.0': resolution: {integrity: sha512-TkBr7QgOmE6ORxvIAhDbZsqPkF7RSqTY4pLTtUQCvr6dTXqvi2fFo46q3h1lxlk/sGMQjqyZ0kEahkD/NyzOHg==} engines: {node: '>= 18'} @@ -1204,26 +1286,50 @@ packages: resolution: {integrity: sha512-wueKWDk70QixNLB363yHc2D2ItTgYiMTdPwK8D9dKQMR3ZQ0c35IxP5xnwQ8cNLoCgCRcHf14kE+CLIvNX1zmA==} engines: {node: ^16.14.0 || >=18.0.0} + '@sigstore/bundle@3.1.0': + resolution: {integrity: sha512-Mm1E3/CmDDCz3nDhFKTuYdB47EdRFRQMOE/EAbiG1MJW77/w1b3P7Qx7JSrVJs8PfwOLOVcKQCHErIwCTyPbag==} + engines: {node: ^18.17.0 || >=20.5.0} + '@sigstore/core@1.1.0': resolution: {integrity: sha512-JzBqdVIyqm2FRQCulY6nbQzMpJJpSiJ8XXWMhtOX9eKgaXXpfNOF53lzQEjIydlStnd/eFtuC1dW4VYdD93oRg==} engines: {node: ^16.14.0 || >=18.0.0} + '@sigstore/core@2.0.0': + resolution: {integrity: sha512-nYxaSb/MtlSI+JWcwTHQxyNmWeWrUXJJ/G4liLrGG7+tS4vAz6LF3xRXqLH6wPIVUoZQel2Fs4ddLx4NCpiIYg==} + engines: {node: ^18.17.0 || >=20.5.0} + '@sigstore/protobuf-specs@0.3.2': resolution: {integrity: sha512-c6B0ehIWxMI8wiS/bj6rHMPqeFvngFV7cDU/MY+B16P9Z3Mp9k8L93eYZ7BYzSickzuqAQqAq0V956b3Ju6mLw==} engines: {node: ^16.14.0 || >=18.0.0} + '@sigstore/protobuf-specs@0.4.0': + resolution: {integrity: sha512-o09cLSIq9EKyRXwryWDOJagkml9XgQCoCSRjHOnHLnvsivaW7Qznzz6yjfV7PHJHhIvyp8OH7OX8w0Dc5bQK7A==} + engines: {node: ^18.17.0 || >=20.5.0} + '@sigstore/sign@2.3.2': resolution: {integrity: sha512-5Vz5dPVuunIIvC5vBb0APwo7qKA4G9yM48kPWJT+OEERs40md5GoUR1yedwpekWZ4m0Hhw44m6zU+ObsON+iDA==} engines: {node: ^16.14.0 || >=18.0.0} + '@sigstore/sign@3.1.0': + resolution: {integrity: sha512-knzjmaOHOov1Ur7N/z4B1oPqZ0QX5geUfhrVaqVlu+hl0EAoL4o+l0MSULINcD5GCWe3Z0+YJO8ues6vFlW0Yw==} + engines: {node: ^18.17.0 || >=20.5.0} + '@sigstore/tuf@2.3.4': resolution: {integrity: sha512-44vtsveTPUpqhm9NCrbU8CWLe3Vck2HO1PNLw7RIajbB7xhtn5RBPm1VNSCMwqGYHhDsBJG8gDF0q4lgydsJvw==} engines: {node: ^16.14.0 || >=18.0.0} + '@sigstore/tuf@3.1.0': + resolution: {integrity: sha512-suVMQEA+sKdOz5hwP9qNcEjX6B45R+hFFr4LAWzbRc5O+U2IInwvay/bpG5a4s+qR35P/JK/PiKiRGjfuLy1IA==} + engines: {node: ^18.17.0 || >=20.5.0} + '@sigstore/verify@1.2.1': resolution: {integrity: sha512-8iKx79/F73DKbGfRf7+t4dqrc0bRr0thdPrxAtCKWRm/F0tG71i6O1rvlnScncJLLBZHn3h8M3c1BSUAb9yu8g==} engines: {node: ^16.14.0 || >=18.0.0} + '@sigstore/verify@2.1.0': + resolution: {integrity: sha512-kAAM06ca4CzhvjIZdONAL9+MLppW3K48wOFy1TbuaWFW/OMfl8JuTgW0Bm02JB1WJGT/ET2eqav0KTEKmxqkIA==} + engines: {node: ^18.17.0 || >=20.5.0} + '@sindresorhus/merge-streams@2.3.0': resolution: {integrity: sha512-LtoMMhxAlorcGhmFYI+LhPgbPZCkgP6ra1YL604EeF6U98pLlQ3iWIGMdWSC+vWmPBWBNgmDBAhnAobLROJmwg==} engines: {node: '>=18'} @@ -1236,6 +1342,10 @@ packages: resolution: {integrity: sha512-92F7/SFyufn4DXsha9+QfKnN03JGqtMFMXgSHbZOo8JG59WkTni7UzAouNQDf7AuP9OAMxVOPQcqG3sB7w+kkg==} engines: {node: ^16.14.0 || >=18.0.0} + '@tufjs/models@3.0.1': + resolution: {integrity: sha512-UUYHISyhCU3ZgN8yaear3cGATHb3SMuKHsQ/nVbHXcmnBf+LzQ/cQfhNG+rfaSHgqGKNEm2cOCLVLELStUQ1JA==} + engines: {node: ^18.17.0 || >=20.5.0} + '@types/aws-lambda@8.10.145': resolution: {integrity: sha512-dtByW6WiFk5W5Jfgz1VM+YPA21xMXTuSFoLYIDY0L44jDLLflVPtZkYuu3/YxpGcvjzKFBZLU+GyKjR0HOYtyw==} @@ -1260,12 +1370,12 @@ packages: '@types/jsonfile@6.1.4': resolution: {integrity: sha512-D5qGUYwjvnNNextdU59/+fI+spnwtTFmyQP0h+PfIOSkNfpU6AOICUOkm4i0OnSk+NyjdPJrxCDro0sJsWlRpQ==} + '@types/node@22.10.10': + resolution: {integrity: sha512-X47y/mPNzxviAGY5TcYPtYL8JsY3kAq2n8fMmKoRCxq/c4v4pyGNCzM2R6+M5/umG4ZfHuT+sgqDYqWc9rJ6ww==} + '@types/node@22.5.5': resolution: {integrity: sha512-Xjs4y5UPO/CLdzpgR6GirZJx36yScjh73+2NlLlkFRSoQN8B0DpfXPdZGnvVmLRLOsqDpOfTNv7D9trgGhmOIA==} - '@types/node@22.7.9': - resolution: {integrity: sha512-jrTfRC7FM6nChvU7X2KqcrgquofrWLFDeYC1hKfwNWomVvrn7JIksqf344WN2X/y8xrgqBd2dJATZV4GbatBfg==} - '@types/normalize-package-data@2.4.4': resolution: {integrity: sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==} @@ -1281,16 +1391,13 @@ packages: '@types/yargs@17.0.33': resolution: {integrity: sha512-WpxBCKWPLr4xSsHgz511rFJAM+wS28w2zEO1QDNY5zM/S8ok70NNfztH0xwhqKyaK0OHCbN98LDAZuy1ctxDkA==} - '@typescript-eslint/eslint-plugin@8.13.0': - resolution: {integrity: sha512-nQtBLiZYMUPkclSeC3id+x4uVd1SGtHuElTxL++SfP47jR0zfkZBJHc+gL4qPsgTuypz0k8Y2GheaDYn6Gy3rg==} + '@typescript-eslint/eslint-plugin@8.24.0': + resolution: {integrity: sha512-aFcXEJJCI4gUdXgoo/j9udUYIHgF23MFkg09LFz2dzEmU0+1Plk4rQWv/IYKvPHAtlkkGoB3m5e6oUp+JPsNaQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: '@typescript-eslint/parser': ^8.0.0 || ^8.0.0-alpha.0 eslint: ^8.57.0 || ^9.0.0 - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true + typescript: '>=4.8.4 <5.8.0' '@typescript-eslint/eslint-plugin@8.7.0': resolution: {integrity: sha512-RIHOoznhA3CCfSTFiB6kBGLQtB/sox+pJ6jeFu6FxJvqL8qRxq/FfGO/UhsGgQM9oGdXkV4xUgli+dt26biB6A==} @@ -1303,15 +1410,12 @@ packages: typescript: optional: true - '@typescript-eslint/parser@8.13.0': - resolution: {integrity: sha512-w0xp+xGg8u/nONcGw1UXAr6cjCPU1w0XVyBs6Zqaj5eLmxkKQAByTdV/uGgNN5tVvN/kKpoQlP2cL7R+ajZZIQ==} + '@typescript-eslint/parser@8.24.0': + resolution: {integrity: sha512-MFDaO9CYiard9j9VepMNa9MTcqVvSny2N4hkY6roquzj8pdCBRENhErrteaQuu7Yjn1ppk0v1/ZF9CG3KIlrTA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true + typescript: '>=4.8.4 <5.8.0' '@typescript-eslint/parser@8.7.0': resolution: {integrity: sha512-lN0btVpj2unxHlNYLI//BQ7nzbMJYBVQX5+pbNXvGYazdlgYonMn4AhhHifQ+J4fGRYA/m1DjaQjx+fDetqBOQ==} @@ -1323,22 +1427,20 @@ packages: typescript: optional: true - '@typescript-eslint/scope-manager@8.13.0': - resolution: {integrity: sha512-XsGWww0odcUT0gJoBZ1DeulY1+jkaHUciUq4jKNv4cpInbvvrtDoyBH9rE/n2V29wQJPk8iCH1wipra9BhmiMA==} + '@typescript-eslint/scope-manager@8.24.0': + resolution: {integrity: sha512-HZIX0UByphEtdVBKaQBgTDdn9z16l4aTUz8e8zPQnyxwHBtf5vtl1L+OhH+m1FGV9DrRmoDuYKqzVrvWDcDozw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} '@typescript-eslint/scope-manager@8.7.0': resolution: {integrity: sha512-87rC0k3ZlDOuz82zzXRtQ7Akv3GKhHs0ti4YcbAJtaomllXoSO8hi7Ix3ccEvCd824dy9aIX+j3d2UMAfCtVpg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/type-utils@8.13.0': - resolution: {integrity: sha512-Rqnn6xXTR316fP4D2pohZenJnp+NwQ1mo7/JM+J1LWZENSLkJI8ID8QNtlvFeb0HnFSK94D6q0cnMX6SbE5/vA==} + '@typescript-eslint/type-utils@8.24.0': + resolution: {integrity: sha512-8fitJudrnY8aq0F1wMiPM1UUgiXQRJ5i8tFjq9kGfRajU+dbPyOuHbl0qRopLEidy0MwqgTHDt6CnSeXanNIwA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true + eslint: ^8.57.0 || ^9.0.0 + typescript: '>=4.8.4 <5.8.0' '@typescript-eslint/type-utils@8.7.0': resolution: {integrity: sha512-tl0N0Mj3hMSkEYhLkjREp54OSb/FI6qyCzfiiclvJvOqre6hsZTGSnHtmFLDU8TIM62G7ygEa1bI08lcuRwEnQ==} @@ -1349,22 +1451,19 @@ packages: typescript: optional: true - '@typescript-eslint/types@8.13.0': - resolution: {integrity: sha512-4cyFErJetFLckcThRUFdReWJjVsPCqyBlJTi6IDEpc1GWCIIZRFxVppjWLIMcQhNGhdWJJRYFHpHoDWvMlDzng==} + '@typescript-eslint/types@8.24.0': + resolution: {integrity: sha512-VacJCBTyje7HGAw7xp11q439A+zeGG0p0/p2zsZwpnMzjPB5WteaWqt4g2iysgGFafrqvyLWqq6ZPZAOCoefCw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} '@typescript-eslint/types@8.7.0': resolution: {integrity: sha512-LLt4BLHFwSfASHSF2K29SZ+ZCsbQOM+LuarPjRUuHm+Qd09hSe3GCeaQbcCr+Mik+0QFRmep/FyZBO6fJ64U3w==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/typescript-estree@8.13.0': - resolution: {integrity: sha512-v7SCIGmVsRK2Cy/LTLGN22uea6SaUIlpBcO/gnMGT/7zPtxp90bphcGf4fyrCQl3ZtiBKqVTG32hb668oIYy1g==} + '@typescript-eslint/typescript-estree@8.24.0': + resolution: {integrity: sha512-ITjYcP0+8kbsvT9bysygfIfb+hBj6koDsu37JZG7xrCiy3fPJyNmfVtaGsgTUSEuTzcvME5YI5uyL5LD1EV5ZQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true + typescript: '>=4.8.4 <5.8.0' '@typescript-eslint/typescript-estree@8.7.0': resolution: {integrity: sha512-MC8nmcGHsmfAKxwnluTQpNqceniT8SteVwd2voYlmiSWGOtjvGXdPl17dYu2797GVscK30Z04WRM28CrKS9WOg==} @@ -1375,11 +1474,12 @@ packages: typescript: optional: true - '@typescript-eslint/utils@8.13.0': - resolution: {integrity: sha512-A1EeYOND6Uv250nybnLZapeXpYMl8tkzYUxqmoKAWnI4sei3ihf2XdZVd+vVOmHGcp3t+P7yRrNsyyiXTvShFQ==} + '@typescript-eslint/utils@8.24.0': + resolution: {integrity: sha512-07rLuUBElvvEb1ICnafYWr4hk8/U7X9RDCOqd9JcAMtjh/9oRmcfN4yGzbPVirgMR0+HLVHehmu19CWeh7fsmQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 + typescript: '>=4.8.4 <5.8.0' '@typescript-eslint/utils@8.7.0': resolution: {integrity: sha512-ZbdUdwsl2X/s3CiyAu3gOlfQzpbuG3nTWKPoIvAu1pu5r8viiJvv2NPN2AqArL35NCYtw/lrPPfM4gxrMLNLPw==} @@ -1387,86 +1487,87 @@ packages: peerDependencies: eslint: ^8.57.0 || ^9.0.0 - '@typescript-eslint/visitor-keys@8.13.0': - resolution: {integrity: sha512-7N/+lztJqH4Mrf0lb10R/CbI1EaAMMGyF5y0oJvFoAhafwgiRA7TXyd8TFn8FC8k5y2dTsYogg238qavRGNnlw==} + '@typescript-eslint/visitor-keys@8.24.0': + resolution: {integrity: sha512-kArLq83QxGLbuHrTMoOEWO+l2MwsNS2TGISEdx8xgqpkbytB07XmlQyQdNDrCc1ecSqx0cnmhGvpX+VBwqqSkg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} '@typescript-eslint/visitor-keys@8.7.0': resolution: {integrity: sha512-b1tx0orFCCh/THWPQa2ZwWzvOeyzzp36vkJYOpVg0u8UVOIsfVrnuC9FqAw9gRKn+rG2VmWQ/zDJZzkxUnj/XQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typespec/compiler@0.64.0': - resolution: {integrity: sha512-LnQGlQMWyqvhGg4Z9iyr5qSBTjI9zd49sodbEJbLafrxbj9pbHyjfSFbvt60gVbfuNvLErsdXvZiqqXV5nZdmQ==} + '@typespec/compiler@0.65.0': + resolution: {integrity: sha512-L86mb0aVxhh7z+8Ea1W28TKuGbZk+/ELXjnQOJK4RWXXCoVtxictSXTTX4mZPFoEwOUde5+jQ2Pf8YuUD2frUw==} engines: {node: '>=18.0.0'} hasBin: true - '@typespec/http-client-python@0.6.10': - resolution: {integrity: sha512-LSZbb4F853X8CwqgVGxIIgltmhSYsJhgtWQtRO5drtEA5MpTekchGyC5eljsFzk8+pHw7/KzBxz9NdCCkD0CuQ==} + '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1NTg1Ny9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz': + resolution: {tarball: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1NTg1Ny9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz} + version: 0.6.11 engines: {node: '>=18.0.0'} peerDependencies: - '@azure-tools/typespec-autorest': '>=0.50.0 <1.0.0' - '@azure-tools/typespec-azure-core': '>=0.50.0 <1.0.0' - '@azure-tools/typespec-azure-resource-manager': '>=0.50.0 <1.0.0' - '@azure-tools/typespec-azure-rulesets': '>=0.50.0 <3.0.0' - '@azure-tools/typespec-client-generator-core': '>=0.50.2 <1.0.0' - '@typespec/compiler': '>=0.64.0 <1.0.0' - '@typespec/http': '>=0.64.0 <1.0.0' - '@typespec/openapi': '>=0.64.0 <1.0.0' - '@typespec/rest': '>=0.64.0 <1.0.0' - '@typespec/versioning': '>=0.64.0 <1.0.0' - - '@typespec/http-specs@0.1.0-alpha.8': - resolution: {integrity: sha512-1BJfxDDYe8IoRBD2eNizG4nKfscn5G4HVHqveVHHKajUPyhTjQ97IG+BQAIrGAEBJLupQzv5hVCeA1VCgzP1qA==} + '@azure-tools/typespec-autorest': '>=0.51.0 <1.0.0' + '@azure-tools/typespec-azure-core': '>=0.51.0 <1.0.0' + '@azure-tools/typespec-azure-resource-manager': '>=0.51.0 <1.0.0' + '@azure-tools/typespec-azure-rulesets': '>=0.51.0 <3.0.0' + '@azure-tools/typespec-client-generator-core': '>=0.51.0 <1.0.0' + '@typespec/compiler': '>=0.65.0 <1.0.0' + '@typespec/http': '>=0.65.0 <1.0.0' + '@typespec/openapi': '>=0.65.0 <1.0.0' + '@typespec/rest': '>=0.65.0 <1.0.0' + '@typespec/versioning': '>=0.65.0 <1.0.0' + + '@typespec/http-specs@0.1.0-alpha.9': + resolution: {integrity: sha512-IIzW606BcfVzAz9U6cWf4u4lGXlTy+UQI69mvW3qM5x2XfcMQJ5RRk/7vnjiendv2zVHBtW7ZRBMezqXkM6nNg==} engines: {node: '>=16.0.0'} peerDependencies: - '@typespec/compiler': ~0.64.0 - '@typespec/http': ~0.64.0 - '@typespec/rest': ~0.64.0 - '@typespec/versioning': ~0.64.0 - '@typespec/xml': ~0.64.0 - - '@typespec/http@0.64.0': - resolution: {integrity: sha512-vyyZP3Woo7or/2Oiq1fH+R0X/4WOBDjAlGsb9tLQzswfQHp710kNfiecA10y9gDC/9h+PjKsTElS1RcRRanpwA==} + '@typespec/compiler': ~0.65.0 + '@typespec/http': ~0.65.0 + '@typespec/rest': ~0.65.0 + '@typespec/versioning': ~0.65.0 + '@typespec/xml': ~0.65.0 + + '@typespec/http@0.65.0': + resolution: {integrity: sha512-mSJUVmlBq4VO2Pv+mXNXccsuq+8AySWUwbJbbyNQTtpb2M9MIKh2+fbnyb8EMjskxpBWNP2DqABhfEMVesVUkg==} engines: {node: '>=18.0.0'} peerDependencies: - '@typespec/compiler': ~0.64.0 - '@typespec/streams': ~0.64.0 + '@typespec/compiler': ~0.65.0 + '@typespec/streams': ~0.65.0 peerDependenciesMeta: '@typespec/streams': optional: true - '@typespec/openapi@0.64.0': - resolution: {integrity: sha512-C4sPdj86ejsNkpmEaAMMqQR+0kq4Ayp4sPKvj4OTtawLXacXKzZ9NYng2jrguO6WbLr5f3NyRZKi7Ys2suT27A==} + '@typespec/openapi@0.65.0': + resolution: {integrity: sha512-BMrdO2BOTo2Yiz/GMIwZuLSJbtodbKsYTAEOxbKTdrROs8Sgl2QLNitD3W48k3I9KQ69nx4RJt0kSbaAYb8L4Q==} engines: {node: '>=18.0.0'} peerDependencies: - '@typespec/compiler': ~0.64.0 - '@typespec/http': ~0.64.0 + '@typespec/compiler': ~0.65.0 + '@typespec/http': ~0.65.0 - '@typespec/rest@0.64.0': - resolution: {integrity: sha512-7+oUajQzOkZPTMtRiGp6hzTTmy7mRaxOYqxIPgDhYyr9I6oQPLAcBsYhFNk/ulcqld/ApaV5ycXaOlK41REOyQ==} + '@typespec/rest@0.65.0': + resolution: {integrity: sha512-279qiO8wy5Ks2nZ/byoXhSey8Gk+leUFJVDMNkjxtxGIswN19EV/MwawUcFQF+gNvExM58RHTx+7BJuA22K6aQ==} engines: {node: '>=18.0.0'} peerDependencies: - '@typespec/compiler': ~0.64.0 - '@typespec/http': ~0.64.0 + '@typespec/compiler': ~0.65.0 + '@typespec/http': ~0.65.0 - '@typespec/spec-api@0.1.0-alpha.0': - resolution: {integrity: sha512-SgWSt5mnl9bbc+C9toMzh4i8RESWcAfMg/Wyq+3oY+0EcKlmDYNWgDhQi/Eh8bA4zyMoymj48hcEzD97E1ERtQ==} + '@typespec/spec-api@0.1.0-alpha.1': + resolution: {integrity: sha512-WjZ3D/Narn264gUIU4bZ1iSLsPeIMUjCX1k91+H93UNCp7TeX/RO5jDG08Ryp9TnZDRITMPcs4TRfO3p0551AA==} engines: {node: '>=18.0.0'} - '@typespec/spec-coverage-sdk@0.1.0-alpha.2': - resolution: {integrity: sha512-bdU5K6jZ12+wEH4b7I7aiytIJu2M+tAigoxxc9Tz7UrucbA5PZqgO+uFoqMKRYcmNjwC4EmvEIVmyzNEKUzUmA==} + '@typespec/spec-coverage-sdk@0.1.0-alpha.3': + resolution: {integrity: sha512-1n6xng80jPkS05S8vkkQ6eHtud4hIxe5VtxrqUjx5LfLPE4azV3CiVf8zbzzsR6c2DFsF7XtfcjVjcUgBHDaMA==} engines: {node: '>=16.0.0'} - '@typespec/spector@0.1.0-alpha.6': - resolution: {integrity: sha512-5ILBGSa77hxYMu1BedtISYrQxk8sqKZSUvzUlBas048hOgy/Rsqh7lkZo8hG7oRwBWbKLYYKxm+srQ7pCmzRUA==} + '@typespec/spector@0.1.0-alpha.7': + resolution: {integrity: sha512-lYjozAlEubTnOxgua6SzHYmYAqfVUtyWbUwaM9tqSBKC70HAZBCTi9rzWAbJPgyRFAQ8gs/GQinFvusrJeTQQA==} engines: {node: '>=16.0.0'} hasBin: true - '@typespec/versioning@0.64.0': - resolution: {integrity: sha512-GtmuE7UwVYuVwgSpbSWzZB5UO6O/f/o1NqjLStctF8zkv2/5s+RbeqRyamjDuUyhMrIwqw+TMXtAnMXpSHlB8A==} + '@typespec/versioning@0.65.0': + resolution: {integrity: sha512-ACNOSgWVpiBwLyA8UlDSDeby+xDYm6wnRCPmdtdoyUpEwgBV/DcJerYf/ujVSCF0jDHItLQ65pC3ydMJDsJWdQ==} engines: {node: '>=18.0.0'} peerDependencies: - '@typespec/compiler': ~0.64.0 + '@typespec/compiler': ~0.65.0 '@typespec/xml@0.59.0': resolution: {integrity: sha512-UoSsEmm7SXEtL9OXsqotu1TjruJSobqZMhUKAAlC9EP2WfQIHLRfBu7xaZB0sgwq7CM6zy/Hq1RZfQyL1KqEvg==} @@ -1474,39 +1575,43 @@ packages: peerDependencies: '@typespec/compiler': ~0.59.0 - '@vitest/expect@2.1.9': - resolution: {integrity: sha512-UJCIkTBenHeKT1TTlKMJWy1laZewsRIzYighyYiJKZreqtdxSos/S1t+ktRMQWu2CKqaarrkeszJx1cgC5tGZw==} + '@vitest/expect@3.0.5': + resolution: {integrity: sha512-nNIOqupgZ4v5jWuQx2DSlHLEs7Q4Oh/7AYwNyE+k0UQzG7tSmjPXShUikn1mpNGzYEN2jJbTvLejwShMitovBA==} - '@vitest/mocker@2.1.9': - resolution: {integrity: sha512-tVL6uJgoUdi6icpxmdrn5YNo3g3Dxv+IHJBr0GXHaEdTcw3F+cPKnsXFhli6nO+f/6SDKPHEK1UN+k+TQv0Ehg==} + '@vitest/mocker@3.0.5': + resolution: {integrity: sha512-CLPNBFBIE7x6aEGbIjaQAX03ZZlBMaWwAjBdMkIf/cAn6xzLTiM3zYqO/WAbieEjsAZir6tO71mzeHZoodThvw==} peerDependencies: msw: ^2.4.9 - vite: ^5.0.0 + vite: ^5.0.0 || ^6.0.0 peerDependenciesMeta: msw: optional: true vite: optional: true - '@vitest/pretty-format@2.1.9': - resolution: {integrity: sha512-KhRIdGV2U9HOUzxfiHmY8IFHTdqtOhIzCpd8WRdJiE7D/HUcZVD0EgQCVjm+Q9gkUXWgBvMmTtZgIG48wq7sOQ==} + '@vitest/pretty-format@3.0.5': + resolution: {integrity: sha512-CjUtdmpOcm4RVtB+up8r2vVDLR16Mgm/bYdkGFe3Yj/scRfCpbSi2W/BDSDcFK7ohw8UXvjMbOp9H4fByd/cOA==} - '@vitest/runner@2.1.9': - resolution: {integrity: sha512-ZXSSqTFIrzduD63btIfEyOmNcBmQvgOVsPNPe0jYtESiXkhd8u2erDLnMxmGrDCwHCCHE7hxwRDCT3pt0esT4g==} + '@vitest/runner@3.0.5': + resolution: {integrity: sha512-BAiZFityFexZQi2yN4OX3OkJC6scwRo8EhRB0Z5HIGGgd2q+Nq29LgHU/+ovCtd0fOfXj5ZI6pwdlUmC5bpi8A==} - '@vitest/snapshot@2.1.9': - resolution: {integrity: sha512-oBO82rEjsxLNJincVhLhaxxZdEtV0EFHMK5Kmx5sJ6H9L183dHECjiefOAdnqpIgT5eZwT04PoggUnW88vOBNQ==} + '@vitest/snapshot@3.0.5': + resolution: {integrity: sha512-GJPZYcd7v8QNUJ7vRvLDmRwl+a1fGg4T/54lZXe+UOGy47F9yUfE18hRCtXL5aHN/AONu29NGzIXSVFh9K0feA==} - '@vitest/spy@2.1.9': - resolution: {integrity: sha512-E1B35FwzXXTs9FHNK6bDszs7mtydNi5MIfUWpceJ8Xbfb1gBMscAnwLbEu+B44ed6W3XjL9/ehLPHR1fkf1KLQ==} + '@vitest/spy@3.0.5': + resolution: {integrity: sha512-5fOzHj0WbUNqPK6blI/8VzZdkBlQLnT25knX0r4dbZI9qoZDf3qAdjoMmDcLG5A83W6oUUFJgUd0EYBc2P5xqg==} - '@vitest/utils@2.1.9': - resolution: {integrity: sha512-v0psaMSkNJ3A2NMrUEHFRzJtDPFn+/VWZ5WxImB21T9fjucJRmS7xCS3ppEnARb9y11OAzaD+P2Ps+b+BGX5iQ==} + '@vitest/utils@3.0.5': + resolution: {integrity: sha512-N9AX0NUoUtVwKwy21JtwzaqR5L5R5A99GAbrHfCCXK1lp593i/3AZAXhSP43wRQuxYsflrdzEfXZFo1reR1Nkg==} abbrev@2.0.0: resolution: {integrity: sha512-6/mh1E2u2YgEsCHdY0Yx5oW+61gZU+1vXaoiHHrpKeuRNNgFvS+/jrwHiQhB5apAf5oB7UB7E19ol2R2LKH8hQ==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + abbrev@3.0.0: + resolution: {integrity: sha512-+/kfrslGQ7TNV2ecmQwMJj/B65g5KVq1/L3SGVZ3tCYGqlzFuFCGBZJtMP99wH3NpEUyAjn0zPdPUg0D+DwrOA==} + engines: {node: ^18.17.0 || >=20.5.0} + accepts@1.3.8: resolution: {integrity: sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==} engines: {node: '>= 0.6'} @@ -1614,8 +1719,8 @@ packages: resolution: {integrity: sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==} engines: {node: '>= 0.4'} - axios@1.7.7: - resolution: {integrity: sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==} + axios@1.7.9: + resolution: {integrity: sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==} balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} @@ -1630,6 +1735,10 @@ packages: before-after-hook@3.0.2: resolution: {integrity: sha512-Nik3Sc0ncrMK4UUdXQmAnRtzmNQTAAXmXIopizwZ1W1t8QmfJj+zL4OA2I7XPTPW5z5TDqv4hRo/JzouDJnX3A==} + bin-links@5.0.0: + resolution: {integrity: sha512-sdleLVfCjBtgO5cNjA2HVRvWBJAHs4zwenaCPMNJAJU0yNxpzj80IpjOIimkpkr+mhlA+how5poQtt53PygbHA==} + engines: {node: ^18.17.0 || >=20.5.0} + body-parser@1.20.3: resolution: {integrity: sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==} engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16} @@ -1670,8 +1779,8 @@ packages: resolution: {integrity: sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==} engines: {node: '>= 0.8'} - c8@10.1.2: - resolution: {integrity: sha512-Qr6rj76eSshu5CgRYvktW0uM0CFY0yi4Fd5D0duDXO6sYinyopmftUiJVuzBQxQcwQLor7JWDVRP+dUfCmzgJw==} + c8@10.1.3: + resolution: {integrity: sha512-LvcyrOAaOnrrlMpW22n690PUvxiq4Uf9WMhQwNJ9vgagkL/ph1+D4uvjvDA5XCbykrc0sx+ay6pVi9YZ1GnhyA==} engines: {node: '>=18'} hasBin: true peerDependencies: @@ -1688,6 +1797,10 @@ packages: resolution: {integrity: sha512-B+L5iIa9mgcjLbliir2th36yEwPftrzteHYujzsx3dFP/31GCHcIeS8f5MGd80odLOjaOvSpU3EEAmRQptkxLQ==} engines: {node: ^16.14.0 || >=18.0.0} + cacache@19.0.1: + resolution: {integrity: sha512-hdsUxulXCi5STId78vRVYEtDAjq99ICAUktLTeTYsLoTE6Z8dS0c8pWNCxwdrk9YfJeobDZc2Y186hD/5ZQgFQ==} + engines: {node: ^18.17.0 || >=20.5.0} + call-bind@1.0.7: resolution: {integrity: sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==} engines: {node: '>= 0.4'} @@ -1730,6 +1843,10 @@ packages: resolution: {integrity: sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==} engines: {node: '>=10'} + chownr@3.0.0: + resolution: {integrity: sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==} + engines: {node: '>=18'} + ci-info@4.0.0: resolution: {integrity: sha512-TdHqgGf9odd8SXNuxtUBVx8Nv+qZOejE6qyqiy5NtbYYQOeFa6zmHkxlPzmaLxWWHsU6nJmB7AETdVPi+2NBUg==} engines: {node: '>=8'} @@ -1758,6 +1875,10 @@ packages: resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==} engines: {node: '>=12'} + cmd-shim@7.0.0: + resolution: {integrity: sha512-rtpaCbr164TPPh+zFdkWpCyZuKkjpAzODfaZCf/SVJZzJN+4bHQb/LP3Jzq5/+84um3XXY8r548XiWKSborwVw==} + engines: {node: ^18.17.0 || >=20.5.0} + color-convert@1.9.3: resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==} @@ -1799,6 +1920,9 @@ packages: resolution: {integrity: sha512-bKw/r35jR3HGt5PEPm1ljsQQGyCrR8sFGNiN5L+ykDHdpO8Smxkrkla9Yi6NkQyUrb8V54PGhfMs6NrIwtxtdw==} engines: {node: '>= 6'} + common-ancestor-path@1.0.1: + resolution: {integrity: sha512-L3sHRo1pXXEqX8VU28kfgUY+YGsk09hPqZiZmLacNib6XNTCM8ubYeT7ryXQw8asB1sKgcU5lkB7ONug08aB8w==} + commonmark@0.30.0: resolution: {integrity: sha512-j1yoUo4gxPND1JWV9xj5ELih0yMv1iCWDG6eEQIPLSWLxzCXiFoyS7kvB+WwU+tZMf4snwJMMtaubV0laFpiBA==} hasBin: true @@ -1903,6 +2027,11 @@ packages: engines: {node: '>=16'} hasBin: true + cssesc@3.0.0: + resolution: {integrity: sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==} + engines: {node: '>=4'} + hasBin: true + data-uri-to-buffer@4.0.1: resolution: {integrity: sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==} engines: {node: '>= 12'} @@ -2164,6 +2293,10 @@ packages: resolution: {integrity: sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + eslint-visitor-keys@4.2.0: + resolution: {integrity: sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + eslint@9.11.1: resolution: {integrity: sha512-MobhYKIoAO1s1e4VUrgx1l1Sk2JBR/Gqjjgw8+mfgoLE2xwsHur4gdfTxyTgShrhvdVFTaJSgMiQBl1jv/AWxg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -2503,6 +2636,10 @@ packages: resolution: {integrity: sha512-puUZAUKT5m8Zzvs72XWy3HtvVbTWljRE66cP60bxJzAqf2DgICo7lYTY2IHUmLnNpjYvw5bvmoHvPc0QO2a62w==} engines: {node: ^16.14.0 || >=18.0.0} + hosted-git-info@8.0.2: + resolution: {integrity: sha512-sYKnA7eGln5ov8T8gnYlkSOxFJvywzEx9BueN6xo/GKO8PGiI6uK6xx+DIGe45T3bdVjLAQDQW1aicT8z8JwQg==} + engines: {node: ^18.17.0 || >=20.5.0} + html-escaper@2.0.2: resolution: {integrity: sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==} @@ -2533,6 +2670,10 @@ packages: resolution: {integrity: sha512-VuuG0wCnjhnylG1ABXT3dAuIpTNDs/G8jlpmwXY03fXoXy/8ZK8/T+hMzt8L4WnrLCJgdybqgPagnF/f97cg3A==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + ignore-walk@7.0.0: + resolution: {integrity: sha512-T4gbf83A4NH95zvhVYZc+qWocBBGlpzUXLPGurJggw/WIOwicfXJChLDP/iBZnN5WqROSu5Bm3hhle4z8a8YGQ==} + engines: {node: ^18.17.0 || >=20.5.0} + ignore@5.3.2: resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==} engines: {node: '>= 4'} @@ -2567,6 +2708,10 @@ packages: resolution: {integrity: sha512-X7rqawQBvfdjS10YU1y1YVreA3SsLrW9dX2CewP2EbBJM4ypVNLDkO5y04gejPwKIY9lR+7r9gn3rFPt/kmWFg==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + ini@5.0.0: + resolution: {integrity: sha512-+N0ngpO3e7cRUWOJAS7qw0IZIVc6XPrW4MlFBdD066F2L4k1L6ker3hLqSq7iXxU5tgS4WGkIUElWn5vogAEnw==} + engines: {node: ^18.17.0 || >=20.5.0} + internal-slot@1.0.7: resolution: {integrity: sha512-NGnrKwXzSms2qUUih/ILZ5JBqNTSa1+ZmP6flaIp6KmSElgE9qdndzS3cqjrDovwFdmwsGsLdeFgB6suw+1e9g==} engines: {node: '>= 0.4'} @@ -2790,6 +2935,10 @@ packages: resolution: {integrity: sha512-fi0NG4bPjCHunUJffmLd0gxssIgkNmArMvis4iNah6Owg1MCJjWhEcDLmsK6iGkJq3tHwbDkTlce70/tmXN4cQ==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + json-parse-even-better-errors@4.0.0: + resolution: {integrity: sha512-lR4MXjGNgkJc7tkQ97kb2nuEMnNCyU//XYVH0MKTGcXEiSudQ5MKGKen3C5QubYy0vmq+JGitUg92uuywGEwIA==} + engines: {node: ^18.17.0 || >=20.5.0} + json-schema-traverse@0.4.1: resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==} @@ -2799,6 +2948,9 @@ packages: json-stable-stringify-without-jsonify@1.0.1: resolution: {integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==} + json-stringify-nice@1.1.4: + resolution: {integrity: sha512-5Z5RFW63yxReJ7vANgW6eZFGWaQvnPE3WNmZoOJrSkGju2etKA2L5rrOa1sm877TVTFt57A80BH1bArcmlLfPw==} + json5@1.0.2: resolution: {integrity: sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==} hasBin: true @@ -2817,6 +2969,12 @@ packages: resolution: {integrity: sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==} engines: {node: '>=12', npm: '>=6'} + just-diff-apply@5.5.0: + resolution: {integrity: sha512-OYTthRfSh55WOItVqwpefPtNt2VdKsq5AnAK6apdtR6yCH8pr0CmSr710J0Mf+WdQy7K/OzMy7K2MgAfdQURDw==} + + just-diff@6.0.2: + resolution: {integrity: sha512-S59eriX5u3/QhMNq3v/gm8Kd0w8OS6Tz2FS1NG4blv+z0MuQcBRJyFWjdovM0Rad4/P4aUPFtnkNjMjyMlMSYA==} + jwa@1.4.1: resolution: {integrity: sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==} @@ -2918,6 +3076,10 @@ packages: resolution: {integrity: sha512-cKTUFc/rbKUd/9meOvgrpJ2WrNzymt6jfRDdwg5UCnVzv9dTpEj9JS5m3wtziXVCjluIXyL8pcaukYqezIzZQA==} engines: {node: ^16.14.0 || >=18.0.0} + make-fetch-happen@14.0.3: + resolution: {integrity: sha512-QMjGbFTP0blj97EeidG5hk/QhKQ3T4ICckQGLgz38QF7Vgbk6e6FTARN8KhKxyBbWn8R0HU+bnw8aSoFPD4qtQ==} + engines: {node: ^18.17.0 || >=20.5.0} + mdurl@1.0.1: resolution: {integrity: sha512-/sKlQJCBYVY9Ers9hqzKou4H6V5UWc/M59TH2dvkt+84itfnq7uFOMLpOiOS4ujvHP4etln18fmIxA5R5fll0g==} @@ -2987,6 +3149,10 @@ packages: resolution: {integrity: sha512-2N8elDQAtSnFV0Dk7gt15KHsS0Fyz6CbYZ360h0WTYV1Ty46li3rAXVOQj1THMNLdmrD9Vt5pBPtWtVkpwGBqg==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + minipass-fetch@4.0.0: + resolution: {integrity: sha512-2v6aXUXwLP1Epd/gc32HAMIWoczx+fZwEPRHm/VwtrJzRGwR1qGZXEYV3Zp8ZjjbwaZhMrM6uHV4KVkk+XCc2w==} + engines: {node: ^18.17.0 || >=20.5.0} + minipass-flush@1.0.5: resolution: {integrity: sha512-JmQSYYpPUqX5Jyn1mXaRwOda1uQ8HP5KAT/oDSLCzt1BYRhQU0/hDtsB1ufZfEEzMZ9aAVmsBw8+FWsIXlClWw==} engines: {node: '>= 8'} @@ -3015,6 +3181,10 @@ packages: resolution: {integrity: sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==} engines: {node: '>= 8'} + minizlib@3.0.1: + resolution: {integrity: sha512-umcy022ILvb5/3Djuu8LWeqUa8D68JaBzlttKeMWen48SjabqS3iY5w/vzeMzMUNhLDifyhbOwKDSznB1vvrwg==} + engines: {node: '>= 18'} + mkdirp@0.5.6: resolution: {integrity: sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==} hasBin: true @@ -3024,6 +3194,11 @@ packages: engines: {node: '>=10'} hasBin: true + mkdirp@3.0.1: + resolution: {integrity: sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==} + engines: {node: '>=10'} + hasBin: true + morgan@1.10.0: resolution: {integrity: sha512-AbegBVI4sh6El+1gNwvD5YIck7nSA36weD7xvIxG4in80j/UoK8AEGaWnnz8v1GxonMCltmlNs5ZKbGvl9b1XQ==} engines: {node: '>= 0.8.0'} @@ -3054,6 +3229,10 @@ packages: resolution: {integrity: sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==} engines: {node: '>= 0.6'} + negotiator@1.0.0: + resolution: {integrity: sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==} + engines: {node: '>= 0.6'} + node-domexception@1.0.0: resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} engines: {node: '>=10.5.0'} @@ -3076,6 +3255,11 @@ packages: engines: {node: ^16.14.0 || >=18.0.0} hasBin: true + node-gyp@11.1.0: + resolution: {integrity: sha512-/+7TuHKnBpnMvUQnsYEb0JOozDZqarQbfNuSGLXIjhStMT0fbw7IdSqWgopOP5xhRZE+lsbIvAHcekddruPZgQ==} + engines: {node: ^18.17.0 || >=20.5.0} + hasBin: true + node-releases@2.0.18: resolution: {integrity: sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g==} @@ -3084,6 +3268,11 @@ packages: engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} hasBin: true + nopt@8.1.0: + resolution: {integrity: sha512-ieGu42u/Qsa4TFktmaKEwM6MQH0pOWnaB3htzh0JRtx84+Mebc0cbZYN5bC+6WTZ4+77xrL9Pn5m7CV6VIkV7A==} + engines: {node: ^18.17.0 || >=20.5.0} + hasBin: true + normalize-package-data@2.5.0: resolution: {integrity: sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==} @@ -3095,22 +3284,46 @@ packages: resolution: {integrity: sha512-+AvaheE/ww1JEwRHOrn4WHNzOxGtVp+adrg2AeZS/7KuxGUYFuBta98wYpfHBbJp6Tg6j1NKSEVHNcfZzJHQwQ==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + npm-bundled@4.0.0: + resolution: {integrity: sha512-IxaQZDMsqfQ2Lz37VvyyEtKLe8FsRZuysmedy/N06TU1RyVppYKXrO4xIhR0F+7ubIBox6Q7nir6fQI3ej39iA==} + engines: {node: ^18.17.0 || >=20.5.0} + npm-install-checks@6.3.0: resolution: {integrity: sha512-W29RiK/xtpCGqn6f3ixfRYGk+zRyr+Ew9F2E20BfXxT5/euLdA/Nm7fO7OeTGuAmTs30cpgInyJ0cYe708YTZw==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + npm-install-checks@7.1.1: + resolution: {integrity: sha512-u6DCwbow5ynAX5BdiHQ9qvexme4U3qHW3MWe5NqH+NeBm0LbiH6zvGjNNew1fY+AZZUtVHbOPF3j7mJxbUzpXg==} + engines: {node: ^18.17.0 || >=20.5.0} + npm-normalize-package-bin@3.0.1: resolution: {integrity: sha512-dMxCf+zZ+3zeQZXKxmyuCKlIDPGuv8EF940xbkC4kQVDTtqoh6rJFO+JTKSA6/Rwi0getWmtuy4Itup0AMcaDQ==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + npm-normalize-package-bin@4.0.0: + resolution: {integrity: sha512-TZKxPvItzai9kN9H/TkmCtx/ZN/hvr3vUycjlfmH0ootY9yFBzNOpiXAdIn1Iteqsvk4lQn6B5PTrt+n6h8k/w==} + engines: {node: ^18.17.0 || >=20.5.0} + npm-package-arg@11.0.3: resolution: {integrity: sha512-sHGJy8sOC1YraBywpzQlIKBE4pBbGbiF95U6Auspzyem956E0+FtDtsx1ZxlOJkQCZ1AFXAY/yuvtFYrOxF+Bw==} engines: {node: ^16.14.0 || >=18.0.0} + npm-package-arg@12.0.2: + resolution: {integrity: sha512-f1NpFjNI9O4VbKMOlA5QoBq/vSQPORHcTZ2feJpFkTHJ9eQkdlmZEKSjcAhxTGInC7RlEyScT9ui67NaOsjFWA==} + engines: {node: ^18.17.0 || >=20.5.0} + + npm-packlist@10.0.0: + resolution: {integrity: sha512-rht9U6nS8WOBDc53eipZNPo5qkAV4X2rhKE2Oj1DYUQ3DieXfj0mKkVmjnf3iuNdtMd8WfLdi2L6ASkD/8a+Kg==} + engines: {node: ^20.17.0 || >=22.9.0} + npm-packlist@8.0.2: resolution: {integrity: sha512-shYrPFIS/JLP4oQmAwDyk5HcyysKW8/JLTEA32S0Z5TzvpaeeX2yMFfoK1fjEBnCBvVyIB/Jj/GBFdm0wsgzbA==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + npm-pick-manifest@10.0.0: + resolution: {integrity: sha512-r4fFa4FqYY8xaM7fHecQ9Z2nE9hgNfJR+EmoKv0+chvzWkBcORX3r0FpTByP+CbOVJDladMXnPQGVN8PBLGuTQ==} + engines: {node: ^18.17.0 || >=20.5.0} + npm-pick-manifest@9.1.0: resolution: {integrity: sha512-nkc+3pIIhqHVQr085X9d2JzPzLyjzQS96zbruppqC9aZRm/x8xx6xhI98gHtsfELP2bE+loHq8ZaHFHhe+NauA==} engines: {node: ^16.14.0 || >=18.0.0} @@ -3119,6 +3332,10 @@ packages: resolution: {integrity: sha512-5+bKQRH0J1xG1uZ1zMNvxW0VEyoNWgJpY9UDuluPFLKDfJ9u2JmmjmTJV1srBGQOROfdBMiVvnH2Zvpbm+xkVA==} engines: {node: ^16.14.0 || >=18.0.0} + npm-registry-fetch@18.0.2: + resolution: {integrity: sha512-LeVMZBBVy+oQb5R6FDV9OlJCcWDU+al10oKpe+nsvcHnG24Z3uM3SvJYKfGJlfGjVU8v9liejCrUR/M5HO5NEQ==} + engines: {node: ^18.17.0 || >=20.5.0} + object-assign@4.1.1: resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==} engines: {node: '>=0.10.0'} @@ -3217,6 +3434,10 @@ packages: resolution: {integrity: sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ==} engines: {node: '>=10'} + p-map@7.0.3: + resolution: {integrity: sha512-VkndIv2fIB99swvQoA65bm+fsmt6UNdGeIB0oxBs+WhAhdh08QA04JXpI7rbB9r08/nkbysKoya9rtDERYOYMA==} + engines: {node: '>=18'} + p-try@2.2.0: resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==} engines: {node: '>=6'} @@ -3229,6 +3450,11 @@ packages: engines: {node: ^16.14.0 || >=18.0.0} hasBin: true + pacote@21.0.0: + resolution: {integrity: sha512-lcqexq73AMv6QNLo7SOpz0JJoaGdS3rBFgF122NZVl1bApo2mfu+XzUBU/X/XsiJu+iUmKpekRayqQYAs+PhkA==} + engines: {node: ^20.17.0 || >=22.9.0} + hasBin: true + parent-module@1.0.1: resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==} engines: {node: '>=6'} @@ -3237,6 +3463,10 @@ packages: resolution: {integrity: sha512-uo0Z9JJeWzv8BG+tRcapBKNJ0dro9cLyczGzulS6EfeyAdeC9sbojtW6XwvYxJkEne9En+J2XEl4zyglVeIwFg==} engines: {node: '>=8'} + parse-conflict-json@4.0.0: + resolution: {integrity: sha512-37CN2VtcuvKgHUs8+0b1uJeEsbGn61GRHz469C94P5xiOoqpDYJYwjg4RY9Vmz39WyZAVkR5++nbJwLMIgOCnQ==} + engines: {node: ^18.17.0 || >=20.5.0} + parse-json@5.2.0: resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} engines: {node: '>=8'} @@ -3286,8 +3516,8 @@ packages: resolution: {integrity: sha512-5HviZNaZcfqP95rwpv+1HDgUamezbqdSYTyzjTvwtJSnIH+3vnbmWsItli8OFEndS984VT55M3jduxZbX351gg==} engines: {node: '>=12'} - pathe@1.1.2: - resolution: {integrity: sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==} + pathe@2.0.3: + resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==} pathval@2.0.0: resolution: {integrity: sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==} @@ -3311,6 +3541,10 @@ packages: resolution: {integrity: sha512-d7Uw+eZoloe0EHDIYoe+bQ5WXnGMOpmiZFTuMWCwpjzzkL2nTjcKiAk4hh8TjnGye2TwWOk3UXucZ+3rbmBa8Q==} engines: {node: '>= 0.4'} + postcss-selector-parser@6.1.2: + resolution: {integrity: sha512-Q8qQfPiZ+THO/3ZrOrO0cJJKfpYCagtMUkXbnEfmgUjwXg6z/WBeOyS9APBBPCTSiDV+s4SwQGu8yFsiMRIudg==} + engines: {node: '>=4'} + postcss@8.5.1: resolution: {integrity: sha512-6oz2beyjc5VMn/KV1pPw8fliQkhBXrVn1Z3TVyqZxU8kZpzEKhBdmCFqI6ZbmGtamQvQGuU1sgPTk8ZrXDD7jQ==} engines: {node: ^10 || ^12 || >=14} @@ -3324,13 +3558,32 @@ packages: engines: {node: '>=14'} hasBin: true + prettier@3.4.2: + resolution: {integrity: sha512-e9MewbtFo+Fevyuxn/4rrcDAaq0IYxPGLvObpQjiZBMAzB9IGmzlnG9RZy3FFas+eBMu2vA0CszMeduow5dIuQ==} + engines: {node: '>=14'} + hasBin: true + proc-log@4.2.0: resolution: {integrity: sha512-g8+OnU/L2v+wyiVK+D5fA34J7EH8jZ8DDlvwhRCMxmMj7UCBvxiO1mGeN+36JXIKF4zevU4kRBd8lVgG9vLelA==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + proc-log@5.0.0: + resolution: {integrity: sha512-Azwzvl90HaF0aCz1JrDdXQykFakSSNPaPoiZ9fm5qJIMHioDZEi7OAdRwSm6rSoPtY3Qutnm3L7ogmg3dc+wbQ==} + engines: {node: ^18.17.0 || >=20.5.0} + process-nextick-args@2.0.1: resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} + proggy@3.0.0: + resolution: {integrity: sha512-QE8RApCM3IaRRxVzxrjbgNMpQEX6Wu0p0KBeoSiSEw5/bsGwZHsshF4LCxH2jp/r6BU+bqA3LrMDEYNfJnpD8Q==} + engines: {node: ^18.17.0 || >=20.5.0} + + promise-all-reject-late@1.0.1: + resolution: {integrity: sha512-vuf0Lf0lOxyQREH7GDIOUMLS7kz+gs8i6B+Yi8dC68a2sychGrHTJYghMBD6k7eUcH0H5P73EckCA48xijWqXw==} + + promise-call-limit@3.0.2: + resolution: {integrity: sha512-mRPQO2T1QQVw11E7+UdCJu7S61eJVWknzml9sC1heAdj1jxl0fWMBypIt9ZOcLFf8FkG995ZD7RnVk7HH72fZw==} + promise-inflight@1.0.1: resolution: {integrity: sha512-6zWPyEOFaQBJYcGMHBKTKJ3u6TBsnMFOIZSa6ce1e/ZrrsOlnHRHbabMjLiBYKp+n44X9eUI6VUPaukCXHuG4g==} peerDependencies: @@ -3380,6 +3633,14 @@ packages: resolution: {integrity: sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==} engines: {node: '>= 0.8'} + read-cmd-shim@5.0.0: + resolution: {integrity: sha512-SEbJV7tohp3DAAILbEMPXavBjAnMN0tVnh4+9G8ihV4Pq3HYF9h8QNez9zkJ1ILkv9G2BjdzwctznGZXgu/HGw==} + engines: {node: ^18.17.0 || >=20.5.0} + + read-package-json-fast@4.0.0: + resolution: {integrity: sha512-qpt8EwugBWDw2cgE2W+/3oxC+KTez2uSVR8JU9Q36TXPAGCaozfQUs59v4j4GFpWTaw0i6hAZSvOmu1J0uOEUg==} + engines: {node: ^18.17.0 || >=20.5.0} + read-pkg-up@7.0.1: resolution: {integrity: sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==} engines: {node: '>=8'} @@ -3455,6 +3716,10 @@ packages: deprecated: Rimraf versions prior to v4 are no longer supported hasBin: true + rimraf@5.0.10: + resolution: {integrity: sha512-l0OE8wL34P4nJH/H2ffoaniAokM2qSmrtXHmlpvYr5AVVX8msAyW0l8NVJFDxlSK4u3Uh/f41cQheDVdnYijwQ==} + hasBin: true + rimraf@6.0.1: resolution: {integrity: sha512-9dkvaxAsk/xNXSJzMgFqqMCuFgt2+KsOFek3TMLfo8NCPfWpBmqwyNn5Y+NX56QUYfCtsyhF3ayiboEoUmJk/A==} engines: {node: 20 || >=22} @@ -3550,6 +3815,10 @@ packages: resolution: {integrity: sha512-8G+/XDU8wNsJOQS5ysDVO0Etg9/2uA5gR9l4ZwijjlwxBcrU6RPfwi2+jJmbP+Ap1Hlp/nVAaEO4Fj22/SL2gQ==} engines: {node: ^16.14.0 || >=18.0.0} + sigstore@3.1.0: + resolution: {integrity: sha512-ZpzWAFHIFqyFE56dXqgX/DkDRZdz+rRcjoIk/RQU4IX0wiCv1l8S7ZrXDHcCc+uaf+6o7w3h2l3g6GYG5TKN9Q==} + engines: {node: ^18.17.0 || >=20.5.0} + simple-swizzle@0.2.2: resolution: {integrity: sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==} @@ -3602,6 +3871,10 @@ packages: resolution: {integrity: sha512-MGrFH9Z4NP9Iyhqn16sDtBpRRNJ0Y2hNa6D65h736fVSaPCHr4DM4sWUNvVaSuC+0OBGhwsrydQwmgfg5LncqQ==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + ssri@12.0.0: + resolution: {integrity: sha512-S7iGNosepx9RadX82oimUkvr0Ct7IjJbEbs4mJcTxst8um95J3sDYU1RBEOvdu6oL1Wek2ODI5i4MAw+dZ6cAQ==} + engines: {node: ^18.17.0 || >=20.5.0} + stack-trace@0.0.10: resolution: {integrity: sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg==} @@ -3714,6 +3987,10 @@ packages: resolution: {integrity: sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==} engines: {node: '>=10'} + tar@7.4.3: + resolution: {integrity: sha512-5S7Va8hKfV7W5U6g3aYxXmlPoZVAwUMy9AOKyF2fVuZa2UD3qZjg578OrLRt8PcNN1PleVaL/5/yYATNL0ICUw==} + engines: {node: '>=18'} + temporal-polyfill@0.2.5: resolution: {integrity: sha512-ye47xp8Cb0nDguAhrrDS1JT1SzwEV9e26sSsrWzVu+yPZ7LzceEcH0i2gci9jWfOfSCCgM3Qv5nOYShVUUFUXA==} @@ -3744,8 +4021,8 @@ packages: resolution: {integrity: sha512-al6n+QEANGFOMf/dmUMsuS5/r9B06uwlyNjZZql/zv8J7ybHCgoihBNORZCY2mzUuAnomQa2JdhyHKzZxPCrFA==} engines: {node: ^18.0.0 || >=20.0.0} - tinyrainbow@1.2.0: - resolution: {integrity: sha512-weEDEq7Z5eTHPDh4xjX789+fHfF+P8boiFB+0vbWzpbnbsEr/GRaohi/uMKxg8RZMXnl1ItAi/IUHWMsjDV7kQ==} + tinyrainbow@2.0.0: + resolution: {integrity: sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw==} engines: {node: '>=14.0.0'} tinyspy@3.0.2: @@ -3763,6 +4040,10 @@ packages: tr46@0.0.3: resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} + treeverse@3.0.0: + resolution: {integrity: sha512-gcANaAnd2QDZFmHFEOF4k7uc1J/6a6z3DJMd/QwEyxLoKGiptJRwid582r7QIsFlFMIZ3SnxfS52S4hm2DHkuQ==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + triple-beam@1.4.1: resolution: {integrity: sha512-aZbgViZrg1QNcG+LULa7nhZpJTZSLm/mXnHXnbAbjmN5aSa0y7V+wvv6+4WaBtpISJzThKy+PIPxc1Nq1EJ9mg==} engines: {node: '>= 14.0.0'} @@ -3773,6 +4054,12 @@ packages: peerDependencies: typescript: '>=4.2.0' + ts-api-utils@2.0.1: + resolution: {integrity: sha512-dnlgjFSVetynI8nzgJ+qF62efpglpWRk8isUEWZGWlJYySCTD6aKvbUDu+zbPeDakk3bg5H4XpitHukgfL1m9w==} + engines: {node: '>=18.12'} + peerDependencies: + typescript: '>=4.8.4' + ts-toolbelt@9.6.0: resolution: {integrity: sha512-nsZd8ZeNUzukXPlJmTBwUAuABDe/9qtVDelJeT/qW0ow3ZS3BsQJtNkan1802aM9Uf68/Y8ljw86Hu0h5IUW3w==} @@ -3791,6 +4078,10 @@ packages: resolution: {integrity: sha512-GwIJau9XaA8nLVbUXsN3IlFi7WmQ48gBUrl3FTkkL/XLu/POhBzfmX9hd33FNMX1qAsfl6ozO1iMmW9NC8YniA==} engines: {node: ^16.14.0 || >=18.0.0} + tuf-js@3.0.1: + resolution: {integrity: sha512-+68OP1ZzSF84rTckf3FA95vJ1Zlx/uaXyiiKyPd1pA4rZNkpEvDAKmsu1xUSmbF/chCRYgZ6UZkDwC7PmzmAyA==} + engines: {node: ^18.17.0 || >=20.5.0} + tunnel@0.0.6: resolution: {integrity: sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==} engines: {node: '>=0.6.11 <=0.7.0 || >=0.7.3'} @@ -3837,14 +4128,12 @@ packages: typedarray@0.0.6: resolution: {integrity: sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==} - typescript-eslint@8.13.0: - resolution: {integrity: sha512-vIMpDRJrQd70au2G8w34mPps0ezFSPMEX4pXkTzUkrNbRX+36ais2ksGWN0esZL+ZMaFJEneOBHzCgSqle7DHw==} + typescript-eslint@8.24.0: + resolution: {integrity: sha512-/lmv4366en/qbB32Vz5+kCNZEMf6xYHwh1z48suBwZvAtnXKbP+YhGe8OLE2BqC67LMqKkCNLtjejdwsdW6uOQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true + eslint: ^8.57.0 || ^9.0.0 + typescript: '>=4.8.4 <5.8.0' typescript-eslint@8.7.0: resolution: {integrity: sha512-nEHbEYJyHwsuf7c3V3RS7Saq+1+la3i0ieR3qP0yjqWSzVmh8Drp47uOl9LjbPANac4S7EFSqvcYIKXUUwIfIQ==} @@ -3865,8 +4154,8 @@ packages: engines: {node: '>=14.17'} hasBin: true - typescript@5.6.3: - resolution: {integrity: sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==} + typescript@5.7.3: + resolution: {integrity: sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==} engines: {node: '>=14.17'} hasBin: true @@ -3879,6 +4168,9 @@ packages: undici-types@6.19.8: resolution: {integrity: sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==} + undici-types@6.20.0: + resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==} + undici@5.28.4: resolution: {integrity: sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==} engines: {node: '>=14.0'} @@ -3891,10 +4183,18 @@ packages: resolution: {integrity: sha512-afXhuC55wkAmZ0P18QsVE6kp8JaxrEokN2HGIoIVv2ijHQd419H0+6EigAFcIzXeMIkcIkNBpB3L/DXB3cTS/g==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + unique-filename@4.0.0: + resolution: {integrity: sha512-XSnEewXmQ+veP7xX2dS5Q4yZAvO40cBN2MWkJ7D/6sW4Dg6wYBNwM1Vrnz1FhH5AdeLIlUXRI9e28z1YZi71NQ==} + engines: {node: ^18.17.0 || >=20.5.0} + unique-slug@4.0.0: resolution: {integrity: sha512-WrcA6AyEfqDX5bWige/4NQfPZMtASNVxdmWR76WESYQVAACSgWcR6e9i0mofqqBxYFtL4oAxPIptY73/0YE1DQ==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + unique-slug@5.0.0: + resolution: {integrity: sha512-9OdaqO5kwqR+1kVgHAhsp5vPNU0hnxRa26rBFNfNgM7M6pNtgzeBn3s/xbyCQL3dcjzOatcef6UUHpB/6MaETg==} + engines: {node: ^18.17.0 || >=20.5.0} + unique-string@3.0.0: resolution: {integrity: sha512-VGXBUVwxKMBUznyffQweQABPRRW1vHZAbadFZud4pLFAqRGvv/96vafgjWFqzourzr8YonlQiPgH0YCJfawoGQ==} engines: {node: '>=12'} @@ -3947,13 +4247,17 @@ packages: resolution: {integrity: sha512-OljLrQ9SQdOUqTaQxqL5dEfZWrXExyyWsozYlAWFawPVNuD83igl7uJD2RTkNMbniIYgt8l81eCJGIdQF7avLQ==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + validate-npm-package-name@6.0.0: + resolution: {integrity: sha512-d7KLgL1LD3U3fgnvWEY1cQXoO/q6EQ1BSz48Sa149V/5zVTAbgmZIpyI8TRi6U9/JNyeYLlTKsEMPtLC27RFUg==} + engines: {node: ^18.17.0 || >=20.5.0} + vary@1.1.2: resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==} engines: {node: '>= 0.8'} - vite-node@2.1.9: - resolution: {integrity: sha512-AM9aQ/IPrW/6ENLQg3AGY4K1N2TGZdR5e4gu/MmmR2xR3Ll1+dib+nook92g4TV3PXVyeyxdWwtaCAiUL0hMxA==} - engines: {node: ^18.0.0 || >=20.0.0} + vite-node@3.0.5: + resolution: {integrity: sha512-02JEJl7SbtwSDJdYS537nU6l+ktdvcREfLksk/NDAqtdKWGqHl+joXzEubHROmS3E6pip+Xgu2tFezMu75jH7A==} + engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} hasBin: true vite@5.4.14: @@ -3987,20 +4291,23 @@ packages: terser: optional: true - vitest@2.1.9: - resolution: {integrity: sha512-MSmPM9REYqDGBI8439mA4mWhV5sKmDlBKWIYbA3lRb2PTHACE0mgKwA8yQ2xq9vxDTuk4iPrECBAEW2aoFXY0Q==} - engines: {node: ^18.0.0 || >=20.0.0} + vitest@3.0.5: + resolution: {integrity: sha512-4dof+HvqONw9bvsYxtkfUp2uHsTN9bV2CZIi1pWgoFpL1Lld8LA1ka9q/ONSsoScAKG7NVGf2stJTI7XRkXb2Q==} + engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} hasBin: true peerDependencies: '@edge-runtime/vm': '*' - '@types/node': ^18.0.0 || >=20.0.0 - '@vitest/browser': 2.1.9 - '@vitest/ui': 2.1.9 + '@types/debug': ^4.1.12 + '@types/node': ^18.0.0 || ^20.0.0 || >=22.0.0 + '@vitest/browser': 3.0.5 + '@vitest/ui': 3.0.5 happy-dom: '*' jsdom: '*' peerDependenciesMeta: '@edge-runtime/vm': optional: true + '@types/debug': + optional: true '@types/node': optional: true '@vitest/browser': @@ -4032,6 +4339,10 @@ packages: vscode-uri@3.0.8: resolution: {integrity: sha512-AyFQ0EVmsOZOlAnxoFOGOq1SQDWAB7C6aqMGS23svWAllfOaxbuFvcT8D1i8z3Gyn8fraVeZNNmN6e9bxxXkKw==} + walk-up-path@4.0.0: + resolution: {integrity: sha512-3hu+tD8YzSLGuFYtPRb48vdhKMi0KQV5sn+uWr8+7dMEq/2G/dtLrdDinkLjqq5TIbIBjYJ4Ax/n3YiaW7QM8A==} + engines: {node: 20 || >=22} + web-streams-polyfill@3.3.3: resolution: {integrity: sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==} engines: {node: '>= 8'} @@ -4063,6 +4374,11 @@ packages: engines: {node: ^16.13.0 || >=18.0.0} hasBin: true + which@5.0.0: + resolution: {integrity: sha512-JEdGzHwwkrbWoGOlIHqQ5gtprKGOenpDHpxE9zVR1bWbOtYRyPPHMe9FaP6x61CmNaTThSkb0DAJte5jD+DmzQ==} + engines: {node: ^18.17.0 || >=20.5.0} + hasBin: true + why-is-node-running@2.3.0: resolution: {integrity: sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==} engines: {node: '>=8'} @@ -4102,6 +4418,10 @@ packages: write-file-atomic@3.0.3: resolution: {integrity: sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==} + write-file-atomic@6.0.0: + resolution: {integrity: sha512-GmqrO8WJ1NuzJ2DrziEI2o57jKAVIQNf8a18W3nCYU3H7PNWqCCVTeH6/NQE93CIllIgQS98rrmVkYgTX9fFJQ==} + engines: {node: ^18.17.0 || >=20.5.0} + ws@8.18.0: resolution: {integrity: sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==} engines: {node: '>=10.0.0'} @@ -4137,11 +4457,20 @@ packages: yallist@4.0.0: resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} + yallist@5.0.0: + resolution: {integrity: sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==} + engines: {node: '>=18'} + yaml@2.5.1: resolution: {integrity: sha512-bLQOjaX/ADgQ20isPJRvF0iRUHIxVhYvr53Of7wGcWlO2jvtUlH5m87DsmulFVxRpNLOnI4tB6p/oh8D7kpn9Q==} engines: {node: '>= 14'} hasBin: true + yaml@2.7.0: + resolution: {integrity: sha512-+hSoy/QHluxmC9kCIJyL/uyFmLmc+e5CFR5Wa+bpIhIj85LVb9ZH2nVnqrHoSvKogwODv0ClqZkmiSSaIH5LTA==} + engines: {node: '>= 14'} + hasBin: true + yargs-parser@21.1.1: resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==} engines: {node: '>=12'} @@ -4181,73 +4510,70 @@ snapshots: command-exists: 1.2.9 semver: 7.6.3 - '@azure-tools/azure-http-specs@0.1.0-alpha.5(@azure-tools/typespec-azure-core@0.50.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))))(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)))(@typespec/versioning@0.64.0(@typespec/compiler@0.64.0))(@typespec/xml@0.59.0(@typespec/compiler@0.64.0))': + '@azure-tools/azure-http-specs@0.1.0-alpha.6(@azure-tools/typespec-azure-core@0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))))(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/versioning@0.65.0(@typespec/compiler@0.65.0))(@typespec/xml@0.59.0(@typespec/compiler@0.65.0))': dependencies: - '@azure-tools/typespec-azure-core': 0.50.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))) - '@typespec/compiler': 0.64.0 - '@typespec/http': 0.64.0(@typespec/compiler@0.64.0) - '@typespec/rest': 0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)) - '@typespec/spec-api': 0.1.0-alpha.0 - '@typespec/spector': 0.1.0-alpha.6 - '@typespec/versioning': 0.64.0(@typespec/compiler@0.64.0) - '@typespec/xml': 0.59.0(@typespec/compiler@0.64.0) + '@azure-tools/typespec-azure-core': 0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))) + '@typespec/compiler': 0.65.0 + '@typespec/http': 0.65.0(@typespec/compiler@0.65.0) + '@typespec/rest': 0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)) + '@typespec/spec-api': 0.1.0-alpha.1 + '@typespec/spector': 0.1.0-alpha.7 + '@typespec/versioning': 0.65.0(@typespec/compiler@0.65.0) + '@typespec/xml': 0.59.0(@typespec/compiler@0.65.0) transitivePeerDependencies: - '@types/express' - '@typespec/streams' + - bluebird - debug - supports-color - '@azure-tools/typespec-autorest@0.50.0(ammezjnwgu4cizwmocq7itwhje)': + '@azure-tools/typespec-autorest@0.51.0(46ydeuneniox7cgf5iph2c2gou)': dependencies: - '@azure-tools/typespec-azure-core': 0.50.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))) - '@azure-tools/typespec-azure-resource-manager': 0.50.0(@azure-tools/typespec-azure-core@0.50.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))))(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/openapi@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)))(@typespec/versioning@0.64.0(@typespec/compiler@0.64.0)) - '@azure-tools/typespec-client-generator-core': 0.50.2(@azure-tools/typespec-azure-core@0.50.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))))(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/openapi@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)))(@typespec/versioning@0.64.0(@typespec/compiler@0.64.0))(@typespec/xml@0.59.0(@typespec/compiler@0.64.0)) - '@typespec/compiler': 0.64.0 - '@typespec/http': 0.64.0(@typespec/compiler@0.64.0) - '@typespec/openapi': 0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)) - '@typespec/rest': 0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)) - '@typespec/versioning': 0.64.0(@typespec/compiler@0.64.0) + '@azure-tools/typespec-azure-core': 0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))) + '@azure-tools/typespec-azure-resource-manager': 0.51.0(@azure-tools/typespec-azure-core@0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))))(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/openapi@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/versioning@0.65.0(@typespec/compiler@0.65.0)) + '@azure-tools/typespec-client-generator-core': 0.51.0(@azure-tools/typespec-azure-core@0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))))(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/openapi@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/versioning@0.65.0(@typespec/compiler@0.65.0))(@typespec/xml@0.59.0(@typespec/compiler@0.65.0)) + '@typespec/compiler': 0.65.0 + '@typespec/http': 0.65.0(@typespec/compiler@0.65.0) + '@typespec/openapi': 0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)) + '@typespec/rest': 0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)) + '@typespec/versioning': 0.65.0(@typespec/compiler@0.65.0) - '@azure-tools/typespec-azure-core@0.50.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)))': + '@azure-tools/typespec-azure-core@0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))': dependencies: - '@typespec/compiler': 0.64.0 - '@typespec/http': 0.64.0(@typespec/compiler@0.64.0) - '@typespec/rest': 0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)) + '@typespec/compiler': 0.65.0 + '@typespec/http': 0.65.0(@typespec/compiler@0.65.0) + '@typespec/rest': 0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)) - '@azure-tools/typespec-azure-resource-manager@0.50.0(@azure-tools/typespec-azure-core@0.50.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))))(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/openapi@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)))(@typespec/versioning@0.64.0(@typespec/compiler@0.64.0))': + '@azure-tools/typespec-azure-resource-manager@0.51.0(@azure-tools/typespec-azure-core@0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))))(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/openapi@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/versioning@0.65.0(@typespec/compiler@0.65.0))': dependencies: - '@azure-tools/typespec-azure-core': 0.50.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))) - '@typespec/compiler': 0.64.0 - '@typespec/http': 0.64.0(@typespec/compiler@0.64.0) - '@typespec/openapi': 0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)) - '@typespec/rest': 0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)) - '@typespec/versioning': 0.64.0(@typespec/compiler@0.64.0) + '@azure-tools/typespec-azure-core': 0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))) + '@typespec/compiler': 0.65.0 + '@typespec/http': 0.65.0(@typespec/compiler@0.65.0) + '@typespec/openapi': 0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)) + '@typespec/rest': 0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)) + '@typespec/versioning': 0.65.0(@typespec/compiler@0.65.0) change-case: 5.4.4 pluralize: 8.0.0 - '@azure-tools/typespec-azure-rulesets@0.50.0(yzhyyprushasiqgxhoazmhsei4)': + '@azure-tools/typespec-azure-rulesets@0.51.0(jfzpdywzlhylutuaycp4bg7qk4)': dependencies: - '@azure-tools/typespec-azure-core': 0.50.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))) - '@azure-tools/typespec-azure-resource-manager': 0.50.0(@azure-tools/typespec-azure-core@0.50.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))))(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/openapi@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)))(@typespec/versioning@0.64.0(@typespec/compiler@0.64.0)) - '@azure-tools/typespec-client-generator-core': 0.50.2(@azure-tools/typespec-azure-core@0.50.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))))(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/openapi@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)))(@typespec/versioning@0.64.0(@typespec/compiler@0.64.0))(@typespec/xml@0.59.0(@typespec/compiler@0.64.0)) - '@typespec/compiler': 0.64.0 + '@azure-tools/typespec-azure-core': 0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))) + '@azure-tools/typespec-azure-resource-manager': 0.51.0(@azure-tools/typespec-azure-core@0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))))(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/openapi@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/versioning@0.65.0(@typespec/compiler@0.65.0)) + '@azure-tools/typespec-client-generator-core': 0.51.0(@azure-tools/typespec-azure-core@0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))))(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/openapi@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/versioning@0.65.0(@typespec/compiler@0.65.0))(@typespec/xml@0.59.0(@typespec/compiler@0.65.0)) + '@typespec/compiler': 0.65.0 - '@azure-tools/typespec-client-generator-core@0.50.2(@azure-tools/typespec-azure-core@0.50.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))))(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/openapi@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)))(@typespec/versioning@0.64.0(@typespec/compiler@0.64.0))(@typespec/xml@0.59.0(@typespec/compiler@0.64.0))': + '@azure-tools/typespec-client-generator-core@0.51.0(@azure-tools/typespec-azure-core@0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))))(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/openapi@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/versioning@0.65.0(@typespec/compiler@0.65.0))(@typespec/xml@0.59.0(@typespec/compiler@0.65.0))': dependencies: - '@azure-tools/typespec-azure-core': 0.50.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))) - '@typespec/compiler': 0.64.0 - '@typespec/http': 0.64.0(@typespec/compiler@0.64.0) - '@typespec/openapi': 0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)) - '@typespec/rest': 0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)) - '@typespec/versioning': 0.64.0(@typespec/compiler@0.64.0) - '@typespec/xml': 0.59.0(@typespec/compiler@0.64.0) + '@azure-tools/typespec-azure-core': 0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))) + '@typespec/compiler': 0.65.0 + '@typespec/http': 0.65.0(@typespec/compiler@0.65.0) + '@typespec/openapi': 0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)) + '@typespec/rest': 0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)) + '@typespec/versioning': 0.65.0(@typespec/compiler@0.65.0) + '@typespec/xml': 0.59.0(@typespec/compiler@0.65.0) change-case: 5.4.4 pluralize: 8.0.0 - yaml: 2.5.1 - - '@azure/abort-controller@1.1.0': - dependencies: - tslib: 2.7.0 + yaml: 2.7.0 '@azure/abort-controller@2.1.2': dependencies: @@ -4259,6 +4585,12 @@ snapshots: '@azure/core-util': 1.10.0 tslib: 2.7.0 + '@azure/core-auth@1.9.0': + dependencies: + '@azure/abort-controller': 2.1.2 + '@azure/core-util': 1.11.0 + tslib: 2.7.0 + '@azure/core-client@1.9.2': dependencies: '@azure/abort-controller': 2.1.2 @@ -4293,9 +4625,9 @@ snapshots: '@azure/core-rest-pipeline@1.17.0': dependencies: '@azure/abort-controller': 2.1.2 - '@azure/core-auth': 1.8.0 + '@azure/core-auth': 1.9.0 '@azure/core-tracing': 1.1.2 - '@azure/core-util': 1.10.0 + '@azure/core-util': 1.11.0 '@azure/logger': 1.1.4 http-proxy-agent: 7.0.2 https-proxy-agent: 7.0.5 @@ -4312,22 +4644,27 @@ snapshots: '@azure/abort-controller': 2.1.2 tslib: 2.7.0 + '@azure/core-util@1.11.0': + dependencies: + '@azure/abort-controller': 2.1.2 + tslib: 2.7.0 + '@azure/core-xml@1.4.3': dependencies: fast-xml-parser: 4.5.0 tslib: 2.7.0 - '@azure/identity@4.4.1': + '@azure/identity@4.6.0': dependencies: - '@azure/abort-controller': 1.1.0 - '@azure/core-auth': 1.8.0 + '@azure/abort-controller': 2.1.2 + '@azure/core-auth': 1.9.0 '@azure/core-client': 1.9.2 '@azure/core-rest-pipeline': 1.17.0 '@azure/core-tracing': 1.1.2 - '@azure/core-util': 1.10.0 + '@azure/core-util': 1.11.0 '@azure/logger': 1.1.4 - '@azure/msal-browser': 3.24.0 - '@azure/msal-node': 2.14.0 + '@azure/msal-browser': 4.2.1 + '@azure/msal-node': 2.16.2 events: 3.3.0 jws: 4.0.0 open: 8.4.2 @@ -4340,15 +4677,17 @@ snapshots: dependencies: tslib: 2.7.0 - '@azure/msal-browser@3.24.0': + '@azure/msal-browser@4.2.1': dependencies: - '@azure/msal-common': 14.15.0 + '@azure/msal-common': 15.1.1 - '@azure/msal-common@14.15.0': {} + '@azure/msal-common@14.16.0': {} - '@azure/msal-node@2.14.0': + '@azure/msal-common@15.1.1': {} + + '@azure/msal-node@2.16.2': dependencies: - '@azure/msal-common': 14.15.0 + '@azure/msal-common': 14.16.0 jsonwebtoken: 9.0.2 uuid: 8.3.2 @@ -4370,11 +4709,35 @@ snapshots: transitivePeerDependencies: - supports-color + '@azure/storage-blob@12.26.0': + dependencies: + '@azure/abort-controller': 2.1.2 + '@azure/core-auth': 1.8.0 + '@azure/core-client': 1.9.2 + '@azure/core-http-compat': 2.1.2 + '@azure/core-lro': 2.7.2 + '@azure/core-paging': 1.6.2 + '@azure/core-rest-pipeline': 1.17.0 + '@azure/core-tracing': 1.1.2 + '@azure/core-util': 1.10.0 + '@azure/core-xml': 1.4.3 + '@azure/logger': 1.1.4 + events: 3.3.0 + tslib: 2.7.0 + transitivePeerDependencies: + - supports-color + '@babel/code-frame@7.25.9': dependencies: '@babel/highlight': 7.25.9 picocolors: 1.1.1 + '@babel/code-frame@7.26.2': + dependencies: + '@babel/helper-validator-identifier': 7.25.9 + js-tokens: 4.0.0 + picocolors: 1.1.1 + '@babel/helper-validator-identifier@7.24.7': {} '@babel/helper-validator-identifier@7.25.9': {} @@ -4386,7 +4749,7 @@ snapshots: js-tokens: 4.0.0 picocolors: 1.1.1 - '@bcoe/v8-coverage@0.2.3': {} + '@bcoe/v8-coverage@1.0.2': {} '@chronus/chronus@0.12.1': dependencies: @@ -4824,6 +5187,12 @@ snapshots: wrap-ansi: 8.1.0 wrap-ansi-cjs: wrap-ansi@7.0.0 + '@isaacs/fs-minipass@4.0.1': + dependencies: + minipass: 7.1.2 + + '@isaacs/string-locale-compare@1.1.0': {} + '@istanbuljs/schema@0.1.3': {} '@jridgewell/resolve-uri@3.1.2': {} @@ -4879,10 +5248,64 @@ snapshots: transitivePeerDependencies: - supports-color + '@npmcli/agent@3.0.0': + dependencies: + agent-base: 7.1.1 + http-proxy-agent: 7.0.2 + https-proxy-agent: 7.0.5 + lru-cache: 10.4.3 + socks-proxy-agent: 8.0.4 + transitivePeerDependencies: + - supports-color + + '@npmcli/arborist@9.0.0': + dependencies: + '@isaacs/string-locale-compare': 1.1.0 + '@npmcli/fs': 4.0.0 + '@npmcli/installed-package-contents': 3.0.0 + '@npmcli/map-workspaces': 4.0.2 + '@npmcli/metavuln-calculator': 9.0.0 + '@npmcli/name-from-folder': 3.0.0 + '@npmcli/node-gyp': 4.0.0 + '@npmcli/package-json': 6.1.1 + '@npmcli/query': 4.0.0 + '@npmcli/redact': 3.1.1 + '@npmcli/run-script': 9.0.2 + bin-links: 5.0.0 + cacache: 19.0.1 + common-ancestor-path: 1.0.1 + hosted-git-info: 8.0.2 + json-stringify-nice: 1.1.4 + lru-cache: 10.4.3 + minimatch: 9.0.5 + nopt: 8.1.0 + npm-install-checks: 7.1.1 + npm-package-arg: 12.0.2 + npm-pick-manifest: 10.0.0 + npm-registry-fetch: 18.0.2 + pacote: 21.0.0 + parse-conflict-json: 4.0.0 + proc-log: 5.0.0 + proggy: 3.0.0 + promise-all-reject-late: 1.0.1 + promise-call-limit: 3.0.2 + read-package-json-fast: 4.0.0 + semver: 7.6.3 + ssri: 12.0.0 + treeverse: 3.0.0 + walk-up-path: 4.0.0 + transitivePeerDependencies: + - bluebird + - supports-color + '@npmcli/fs@3.1.1': dependencies: semver: 7.6.3 + '@npmcli/fs@4.0.0': + dependencies: + semver: 7.6.3 + '@npmcli/git@5.0.8': dependencies: '@npmcli/promise-spawn': 7.0.2 @@ -4897,13 +5320,56 @@ snapshots: transitivePeerDependencies: - bluebird + '@npmcli/git@6.0.1': + dependencies: + '@npmcli/promise-spawn': 8.0.2 + ini: 5.0.0 + lru-cache: 10.4.3 + npm-pick-manifest: 10.0.0 + proc-log: 5.0.0 + promise-inflight: 1.0.1 + promise-retry: 2.0.1 + semver: 7.6.3 + which: 5.0.0 + transitivePeerDependencies: + - bluebird + '@npmcli/installed-package-contents@2.1.0': dependencies: npm-bundled: 3.0.1 npm-normalize-package-bin: 3.0.1 + '@npmcli/installed-package-contents@3.0.0': + dependencies: + npm-bundled: 4.0.0 + npm-normalize-package-bin: 4.0.0 + + '@npmcli/map-workspaces@4.0.2': + dependencies: + '@npmcli/name-from-folder': 3.0.0 + '@npmcli/package-json': 6.1.1 + glob: 10.4.5 + minimatch: 9.0.5 + transitivePeerDependencies: + - bluebird + + '@npmcli/metavuln-calculator@9.0.0': + dependencies: + cacache: 19.0.1 + json-parse-even-better-errors: 4.0.0 + pacote: 21.0.0 + proc-log: 5.0.0 + semver: 7.6.3 + transitivePeerDependencies: + - bluebird + - supports-color + + '@npmcli/name-from-folder@3.0.0': {} + '@npmcli/node-gyp@3.0.0': {} + '@npmcli/node-gyp@4.0.0': {} + '@npmcli/package-json@5.2.1': dependencies: '@npmcli/git': 5.0.8 @@ -4916,12 +5382,34 @@ snapshots: transitivePeerDependencies: - bluebird + '@npmcli/package-json@6.1.1': + dependencies: + '@npmcli/git': 6.0.1 + glob: 10.4.5 + hosted-git-info: 8.0.2 + json-parse-even-better-errors: 4.0.0 + proc-log: 5.0.0 + semver: 7.6.3 + validate-npm-package-license: 3.0.4 + transitivePeerDependencies: + - bluebird + '@npmcli/promise-spawn@7.0.2': dependencies: which: 4.0.0 + '@npmcli/promise-spawn@8.0.2': + dependencies: + which: 5.0.0 + + '@npmcli/query@4.0.0': + dependencies: + postcss-selector-parser: 6.1.2 + '@npmcli/redact@2.0.1': {} + '@npmcli/redact@3.1.1': {} + '@npmcli/run-script@8.1.0': dependencies: '@npmcli/node-gyp': 3.0.0 @@ -4934,6 +5422,18 @@ snapshots: - bluebird - supports-color + '@npmcli/run-script@9.0.2': + dependencies: + '@npmcli/node-gyp': 4.0.0 + '@npmcli/package-json': 6.1.1 + '@npmcli/promise-spawn': 8.0.2 + node-gyp: 11.1.0 + proc-log: 5.0.0 + which: 5.0.0 + transitivePeerDependencies: + - bluebird + - supports-color + '@octokit/app@15.1.0': dependencies: '@octokit/auth-app': 7.1.1 @@ -5209,10 +5709,18 @@ snapshots: dependencies: '@sigstore/protobuf-specs': 0.3.2 + '@sigstore/bundle@3.1.0': + dependencies: + '@sigstore/protobuf-specs': 0.4.0 + '@sigstore/core@1.1.0': {} + '@sigstore/core@2.0.0': {} + '@sigstore/protobuf-specs@0.3.2': {} + '@sigstore/protobuf-specs@0.4.0': {} + '@sigstore/sign@2.3.2': dependencies: '@sigstore/bundle': 2.3.2 @@ -5224,6 +5732,17 @@ snapshots: transitivePeerDependencies: - supports-color + '@sigstore/sign@3.1.0': + dependencies: + '@sigstore/bundle': 3.1.0 + '@sigstore/core': 2.0.0 + '@sigstore/protobuf-specs': 0.4.0 + make-fetch-happen: 14.0.3 + proc-log: 5.0.0 + promise-retry: 2.0.1 + transitivePeerDependencies: + - supports-color + '@sigstore/tuf@2.3.4': dependencies: '@sigstore/protobuf-specs': 0.3.2 @@ -5231,12 +5750,25 @@ snapshots: transitivePeerDependencies: - supports-color + '@sigstore/tuf@3.1.0': + dependencies: + '@sigstore/protobuf-specs': 0.4.0 + tuf-js: 3.0.1 + transitivePeerDependencies: + - supports-color + '@sigstore/verify@1.2.1': dependencies: '@sigstore/bundle': 2.3.2 '@sigstore/core': 1.1.0 '@sigstore/protobuf-specs': 0.3.2 + '@sigstore/verify@2.1.0': + dependencies: + '@sigstore/bundle': 3.1.0 + '@sigstore/core': 2.0.0 + '@sigstore/protobuf-specs': 0.4.0 + '@sindresorhus/merge-streams@2.3.0': {} '@tufjs/canonical-json@2.0.0': {} @@ -5246,6 +5778,11 @@ snapshots: '@tufjs/canonical-json': 2.0.0 minimatch: 9.0.5 + '@tufjs/models@3.0.1': + dependencies: + '@tufjs/canonical-json': 2.0.0 + minimatch: 9.0.5 + '@types/aws-lambda@8.10.145': {} '@types/estree@1.0.6': {} @@ -5267,11 +5804,11 @@ snapshots: dependencies: '@types/node': 22.5.5 - '@types/node@22.5.5': + '@types/node@22.10.10': dependencies: - undici-types: 6.19.8 + undici-types: 6.20.0 - '@types/node@22.7.9': + '@types/node@22.5.5': dependencies: undici-types: 6.19.8 @@ -5287,21 +5824,20 @@ snapshots: dependencies: '@types/yargs-parser': 21.0.3 - '@typescript-eslint/eslint-plugin@8.13.0(@typescript-eslint/parser@8.13.0(eslint@9.11.1)(typescript@5.6.3))(eslint@9.11.1)(typescript@5.6.3)': + '@typescript-eslint/eslint-plugin@8.24.0(@typescript-eslint/parser@8.24.0(eslint@9.11.1)(typescript@5.7.3))(eslint@9.11.1)(typescript@5.7.3)': dependencies: '@eslint-community/regexpp': 4.11.1 - '@typescript-eslint/parser': 8.13.0(eslint@9.11.1)(typescript@5.6.3) - '@typescript-eslint/scope-manager': 8.13.0 - '@typescript-eslint/type-utils': 8.13.0(eslint@9.11.1)(typescript@5.6.3) - '@typescript-eslint/utils': 8.13.0(eslint@9.11.1)(typescript@5.6.3) - '@typescript-eslint/visitor-keys': 8.13.0 + '@typescript-eslint/parser': 8.24.0(eslint@9.11.1)(typescript@5.7.3) + '@typescript-eslint/scope-manager': 8.24.0 + '@typescript-eslint/type-utils': 8.24.0(eslint@9.11.1)(typescript@5.7.3) + '@typescript-eslint/utils': 8.24.0(eslint@9.11.1)(typescript@5.7.3) + '@typescript-eslint/visitor-keys': 8.24.0 eslint: 9.11.1 graphemer: 1.4.0 ignore: 5.3.2 natural-compare: 1.4.0 - ts-api-utils: 1.3.0(typescript@5.6.3) - optionalDependencies: - typescript: 5.6.3 + ts-api-utils: 2.0.1(typescript@5.7.3) + typescript: 5.7.3 transitivePeerDependencies: - supports-color @@ -5323,16 +5859,15 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@8.13.0(eslint@9.11.1)(typescript@5.6.3)': + '@typescript-eslint/parser@8.24.0(eslint@9.11.1)(typescript@5.7.3)': dependencies: - '@typescript-eslint/scope-manager': 8.13.0 - '@typescript-eslint/types': 8.13.0 - '@typescript-eslint/typescript-estree': 8.13.0(typescript@5.6.3) - '@typescript-eslint/visitor-keys': 8.13.0 + '@typescript-eslint/scope-manager': 8.24.0 + '@typescript-eslint/types': 8.24.0 + '@typescript-eslint/typescript-estree': 8.24.0(typescript@5.7.3) + '@typescript-eslint/visitor-keys': 8.24.0 debug: 4.4.0 eslint: 9.11.1 - optionalDependencies: - typescript: 5.6.3 + typescript: 5.7.3 transitivePeerDependencies: - supports-color @@ -5349,26 +5884,25 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/scope-manager@8.13.0': + '@typescript-eslint/scope-manager@8.24.0': dependencies: - '@typescript-eslint/types': 8.13.0 - '@typescript-eslint/visitor-keys': 8.13.0 + '@typescript-eslint/types': 8.24.0 + '@typescript-eslint/visitor-keys': 8.24.0 '@typescript-eslint/scope-manager@8.7.0': dependencies: '@typescript-eslint/types': 8.7.0 '@typescript-eslint/visitor-keys': 8.7.0 - '@typescript-eslint/type-utils@8.13.0(eslint@9.11.1)(typescript@5.6.3)': + '@typescript-eslint/type-utils@8.24.0(eslint@9.11.1)(typescript@5.7.3)': dependencies: - '@typescript-eslint/typescript-estree': 8.13.0(typescript@5.6.3) - '@typescript-eslint/utils': 8.13.0(eslint@9.11.1)(typescript@5.6.3) + '@typescript-eslint/typescript-estree': 8.24.0(typescript@5.7.3) + '@typescript-eslint/utils': 8.24.0(eslint@9.11.1)(typescript@5.7.3) debug: 4.4.0 - ts-api-utils: 1.3.0(typescript@5.6.3) - optionalDependencies: - typescript: 5.6.3 + eslint: 9.11.1 + ts-api-utils: 2.0.1(typescript@5.7.3) + typescript: 5.7.3 transitivePeerDependencies: - - eslint - supports-color '@typescript-eslint/type-utils@8.7.0(eslint@9.11.1)(typescript@5.6.2)': @@ -5383,22 +5917,21 @@ snapshots: - eslint - supports-color - '@typescript-eslint/types@8.13.0': {} + '@typescript-eslint/types@8.24.0': {} '@typescript-eslint/types@8.7.0': {} - '@typescript-eslint/typescript-estree@8.13.0(typescript@5.6.3)': + '@typescript-eslint/typescript-estree@8.24.0(typescript@5.7.3)': dependencies: - '@typescript-eslint/types': 8.13.0 - '@typescript-eslint/visitor-keys': 8.13.0 + '@typescript-eslint/types': 8.24.0 + '@typescript-eslint/visitor-keys': 8.24.0 debug: 4.4.0 fast-glob: 3.3.2 is-glob: 4.0.3 minimatch: 9.0.5 semver: 7.6.3 - ts-api-utils: 1.3.0(typescript@5.6.3) - optionalDependencies: - typescript: 5.6.3 + ts-api-utils: 2.0.1(typescript@5.7.3) + typescript: 5.7.3 transitivePeerDependencies: - supports-color @@ -5417,16 +5950,16 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@8.13.0(eslint@9.11.1)(typescript@5.6.3)': + '@typescript-eslint/utils@8.24.0(eslint@9.11.1)(typescript@5.7.3)': dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@9.11.1) - '@typescript-eslint/scope-manager': 8.13.0 - '@typescript-eslint/types': 8.13.0 - '@typescript-eslint/typescript-estree': 8.13.0(typescript@5.6.3) + '@typescript-eslint/scope-manager': 8.24.0 + '@typescript-eslint/types': 8.24.0 + '@typescript-eslint/typescript-estree': 8.24.0(typescript@5.7.3) eslint: 9.11.1 + typescript: 5.7.3 transitivePeerDependencies: - supports-color - - typescript '@typescript-eslint/utils@8.7.0(eslint@9.11.1)(typescript@5.6.2)': dependencies: @@ -5439,45 +5972,49 @@ snapshots: - supports-color - typescript - '@typescript-eslint/visitor-keys@8.13.0': + '@typescript-eslint/visitor-keys@8.24.0': dependencies: - '@typescript-eslint/types': 8.13.0 - eslint-visitor-keys: 3.4.3 + '@typescript-eslint/types': 8.24.0 + eslint-visitor-keys: 4.2.0 '@typescript-eslint/visitor-keys@8.7.0': dependencies: '@typescript-eslint/types': 8.7.0 eslint-visitor-keys: 3.4.3 - '@typespec/compiler@0.64.0': + '@typespec/compiler@0.65.0': dependencies: - '@babel/code-frame': 7.25.9 + '@babel/code-frame': 7.26.2 + '@npmcli/arborist': 9.0.0 ajv: 8.17.1 change-case: 5.4.4 globby: 14.0.2 mustache: 4.2.0 picocolors: 1.1.1 - prettier: 3.3.3 + prettier: 3.4.2 prompts: 2.4.2 semver: 7.6.3 temporal-polyfill: 0.2.5 vscode-languageserver: 9.0.1 vscode-languageserver-textdocument: 1.0.12 - yaml: 2.5.1 + yaml: 2.7.0 yargs: 17.7.2 + transitivePeerDependencies: + - bluebird + - supports-color - '@typespec/http-client-python@0.6.10(6gdwtcj6sqvu3zk5kjo6g4na54)': - dependencies: - '@azure-tools/typespec-autorest': 0.50.0(ammezjnwgu4cizwmocq7itwhje) - '@azure-tools/typespec-azure-core': 0.50.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))) - '@azure-tools/typespec-azure-resource-manager': 0.50.0(@azure-tools/typespec-azure-core@0.50.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))))(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/openapi@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)))(@typespec/versioning@0.64.0(@typespec/compiler@0.64.0)) - '@azure-tools/typespec-azure-rulesets': 0.50.0(yzhyyprushasiqgxhoazmhsei4) - '@azure-tools/typespec-client-generator-core': 0.50.2(@azure-tools/typespec-azure-core@0.50.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))))(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/openapi@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)))(@typespec/versioning@0.64.0(@typespec/compiler@0.64.0))(@typespec/xml@0.59.0(@typespec/compiler@0.64.0)) - '@typespec/compiler': 0.64.0 - '@typespec/http': 0.64.0(@typespec/compiler@0.64.0) - '@typespec/openapi': 0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)) - '@typespec/rest': 0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)) - '@typespec/versioning': 0.64.0(@typespec/compiler@0.64.0) + '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1NTg1Ny9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz(pj75u6zo6obzdihzpwvg36i7j4)': + dependencies: + '@azure-tools/typespec-autorest': 0.51.0(46ydeuneniox7cgf5iph2c2gou) + '@azure-tools/typespec-azure-core': 0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))) + '@azure-tools/typespec-azure-resource-manager': 0.51.0(@azure-tools/typespec-azure-core@0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))))(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/openapi@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/versioning@0.65.0(@typespec/compiler@0.65.0)) + '@azure-tools/typespec-azure-rulesets': 0.51.0(jfzpdywzlhylutuaycp4bg7qk4) + '@azure-tools/typespec-client-generator-core': 0.51.0(@azure-tools/typespec-azure-core@0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))))(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/openapi@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/versioning@0.65.0(@typespec/compiler@0.65.0))(@typespec/xml@0.59.0(@typespec/compiler@0.65.0)) + '@typespec/compiler': 0.65.0 + '@typespec/http': 0.65.0(@typespec/compiler@0.65.0) + '@typespec/openapi': 0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)) + '@typespec/rest': 0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)) + '@typespec/versioning': 0.65.0(@typespec/compiler@0.65.0) js-yaml: 4.1.0 pyodide: 0.26.2 semver: 7.6.3 @@ -5486,36 +6023,37 @@ snapshots: - bufferutil - utf-8-validate - '@typespec/http-specs@0.1.0-alpha.8(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))(@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)))(@typespec/versioning@0.64.0(@typespec/compiler@0.64.0))(@typespec/xml@0.59.0(@typespec/compiler@0.64.0))': + '@typespec/http-specs@0.1.0-alpha.9(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/versioning@0.65.0(@typespec/compiler@0.65.0))(@typespec/xml@0.59.0(@typespec/compiler@0.65.0))': dependencies: - '@typespec/compiler': 0.64.0 - '@typespec/http': 0.64.0(@typespec/compiler@0.64.0) - '@typespec/rest': 0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)) - '@typespec/spec-api': 0.1.0-alpha.0 - '@typespec/spector': 0.1.0-alpha.6 - '@typespec/versioning': 0.64.0(@typespec/compiler@0.64.0) - '@typespec/xml': 0.59.0(@typespec/compiler@0.64.0) + '@typespec/compiler': 0.65.0 + '@typespec/http': 0.65.0(@typespec/compiler@0.65.0) + '@typespec/rest': 0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)) + '@typespec/spec-api': 0.1.0-alpha.1 + '@typespec/spector': 0.1.0-alpha.7 + '@typespec/versioning': 0.65.0(@typespec/compiler@0.65.0) + '@typespec/xml': 0.59.0(@typespec/compiler@0.65.0) transitivePeerDependencies: - '@types/express' - '@typespec/streams' + - bluebird - debug - supports-color - '@typespec/http@0.64.0(@typespec/compiler@0.64.0)': + '@typespec/http@0.65.0(@typespec/compiler@0.65.0)': dependencies: - '@typespec/compiler': 0.64.0 + '@typespec/compiler': 0.65.0 - '@typespec/openapi@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))': + '@typespec/openapi@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))': dependencies: - '@typespec/compiler': 0.64.0 - '@typespec/http': 0.64.0(@typespec/compiler@0.64.0) + '@typespec/compiler': 0.65.0 + '@typespec/http': 0.65.0(@typespec/compiler@0.65.0) - '@typespec/rest@0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0))': + '@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))': dependencies: - '@typespec/compiler': 0.64.0 - '@typespec/http': 0.64.0(@typespec/compiler@0.64.0) + '@typespec/compiler': 0.65.0 + '@typespec/http': 0.65.0(@typespec/compiler@0.65.0) - '@typespec/spec-api@0.1.0-alpha.0': + '@typespec/spec-api@0.1.0-alpha.1': dependencies: body-parser: 1.20.3 deep-equal: 2.2.3 @@ -5524,7 +6062,7 @@ snapshots: morgan: 1.10.0 multer: 1.4.5-lts.1 picocolors: 1.1.1 - prettier: 3.3.3 + prettier: 3.4.2 winston: 3.17.0 xml2js: 0.6.2 yargs: 17.7.2 @@ -5532,26 +6070,26 @@ snapshots: - '@types/express' - supports-color - '@typespec/spec-coverage-sdk@0.1.0-alpha.2': + '@typespec/spec-coverage-sdk@0.1.0-alpha.3': dependencies: - '@azure/identity': 4.4.1 - '@azure/storage-blob': 12.25.0 - '@types/node': 22.7.9 + '@azure/identity': 4.6.0 + '@azure/storage-blob': 12.26.0 + '@types/node': 22.10.10 transitivePeerDependencies: - supports-color - '@typespec/spector@0.1.0-alpha.6': + '@typespec/spector@0.1.0-alpha.7': dependencies: - '@azure/identity': 4.4.1 + '@azure/identity': 4.6.0 '@types/js-yaml': 4.0.9 - '@typespec/compiler': 0.64.0 - '@typespec/http': 0.64.0(@typespec/compiler@0.64.0) - '@typespec/rest': 0.64.0(@typespec/compiler@0.64.0)(@typespec/http@0.64.0(@typespec/compiler@0.64.0)) - '@typespec/spec-api': 0.1.0-alpha.0 - '@typespec/spec-coverage-sdk': 0.1.0-alpha.2 - '@typespec/versioning': 0.64.0(@typespec/compiler@0.64.0) + '@typespec/compiler': 0.65.0 + '@typespec/http': 0.65.0(@typespec/compiler@0.65.0) + '@typespec/rest': 0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)) + '@typespec/spec-api': 0.1.0-alpha.1 + '@typespec/spec-coverage-sdk': 0.1.0-alpha.3 + '@typespec/versioning': 0.65.0(@typespec/compiler@0.65.0) ajv: 8.17.1 - axios: 1.7.7 + axios: 1.7.9 body-parser: 1.20.3 deep-equal: 2.2.3 express: 4.21.2 @@ -5571,59 +6109,62 @@ snapshots: transitivePeerDependencies: - '@types/express' - '@typespec/streams' + - bluebird - debug - supports-color - '@typespec/versioning@0.64.0(@typespec/compiler@0.64.0)': + '@typespec/versioning@0.65.0(@typespec/compiler@0.65.0)': dependencies: - '@typespec/compiler': 0.64.0 + '@typespec/compiler': 0.65.0 - '@typespec/xml@0.59.0(@typespec/compiler@0.64.0)': + '@typespec/xml@0.59.0(@typespec/compiler@0.65.0)': dependencies: - '@typespec/compiler': 0.64.0 + '@typespec/compiler': 0.65.0 - '@vitest/expect@2.1.9': + '@vitest/expect@3.0.5': dependencies: - '@vitest/spy': 2.1.9 - '@vitest/utils': 2.1.9 + '@vitest/spy': 3.0.5 + '@vitest/utils': 3.0.5 chai: 5.1.2 - tinyrainbow: 1.2.0 + tinyrainbow: 2.0.0 - '@vitest/mocker@2.1.9(vite@5.4.14(@types/node@22.5.5))': + '@vitest/mocker@3.0.5(vite@5.4.14(@types/node@22.5.5))': dependencies: - '@vitest/spy': 2.1.9 + '@vitest/spy': 3.0.5 estree-walker: 3.0.3 magic-string: 0.30.17 optionalDependencies: vite: 5.4.14(@types/node@22.5.5) - '@vitest/pretty-format@2.1.9': + '@vitest/pretty-format@3.0.5': dependencies: - tinyrainbow: 1.2.0 + tinyrainbow: 2.0.0 - '@vitest/runner@2.1.9': + '@vitest/runner@3.0.5': dependencies: - '@vitest/utils': 2.1.9 - pathe: 1.1.2 + '@vitest/utils': 3.0.5 + pathe: 2.0.3 - '@vitest/snapshot@2.1.9': + '@vitest/snapshot@3.0.5': dependencies: - '@vitest/pretty-format': 2.1.9 + '@vitest/pretty-format': 3.0.5 magic-string: 0.30.17 - pathe: 1.1.2 + pathe: 2.0.3 - '@vitest/spy@2.1.9': + '@vitest/spy@3.0.5': dependencies: tinyspy: 3.0.2 - '@vitest/utils@2.1.9': + '@vitest/utils@3.0.5': dependencies: - '@vitest/pretty-format': 2.1.9 + '@vitest/pretty-format': 3.0.5 loupe: 3.1.3 - tinyrainbow: 1.2.0 + tinyrainbow: 2.0.0 abbrev@2.0.0: {} + abbrev@3.0.0: {} + accepts@1.3.8: dependencies: mime-types: 2.1.35 @@ -5744,7 +6285,7 @@ snapshots: dependencies: possible-typed-array-names: 1.0.0 - axios@1.7.7: + axios@1.7.9: dependencies: follow-redirects: 1.15.9 form-data: 4.0.1 @@ -5762,6 +6303,14 @@ snapshots: before-after-hook@3.0.2: {} + bin-links@5.0.0: + dependencies: + cmd-shim: 7.0.0 + npm-normalize-package-bin: 4.0.0 + proc-log: 5.0.0 + read-cmd-shim: 5.0.0 + write-file-atomic: 6.0.0 + body-parser@1.20.3: dependencies: bytes: 3.1.2 @@ -5813,9 +6362,9 @@ snapshots: bytes@3.1.2: {} - c8@10.1.2: + c8@10.1.3: dependencies: - '@bcoe/v8-coverage': 0.2.3 + '@bcoe/v8-coverage': 1.0.2 '@istanbuljs/schema': 0.1.3 find-up: 5.0.0 foreground-child: 3.3.0 @@ -5844,6 +6393,21 @@ snapshots: tar: 6.2.1 unique-filename: 3.0.0 + cacache@19.0.1: + dependencies: + '@npmcli/fs': 4.0.0 + fs-minipass: 3.0.3 + glob: 10.4.5 + lru-cache: 10.4.3 + minipass: 7.1.2 + minipass-collect: 2.0.1 + minipass-flush: 1.0.5 + minipass-pipeline: 1.2.4 + p-map: 7.0.3 + ssri: 12.0.0 + tar: 7.4.3 + unique-filename: 4.0.0 + call-bind@1.0.7: dependencies: es-define-property: 1.0.0 @@ -5887,6 +6451,8 @@ snapshots: chownr@2.0.0: {} + chownr@3.0.0: {} + ci-info@4.0.0: {} clean-regexp@1.0.0: @@ -5912,6 +6478,8 @@ snapshots: strip-ansi: 6.0.1 wrap-ansi: 7.0.0 + cmd-shim@7.0.0: {} + color-convert@1.9.3: dependencies: color-name: 1.1.3 @@ -5957,6 +6525,8 @@ snapshots: has-own-prop: 2.0.0 repeat-string: 1.6.1 + common-ancestor-path@1.0.1: {} + commonmark@0.30.0: dependencies: entities: 2.0.3 @@ -6116,6 +6686,8 @@ snapshots: transitivePeerDependencies: - encoding + cssesc@3.0.0: {} + data-uri-to-buffer@4.0.1: {} data-view-buffer@1.0.1: @@ -6476,6 +7048,8 @@ snapshots: eslint-visitor-keys@4.0.0: {} + eslint-visitor-keys@4.2.0: {} + eslint@9.11.1: dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@9.11.1) @@ -6913,6 +7487,10 @@ snapshots: dependencies: lru-cache: 10.4.3 + hosted-git-info@8.0.2: + dependencies: + lru-cache: 10.4.3 + html-escaper@2.0.2: {} http-cache-semantics@4.1.1: {} @@ -6952,6 +7530,10 @@ snapshots: dependencies: minimatch: 9.0.5 + ignore-walk@7.0.0: + dependencies: + minimatch: 9.0.5 + ignore@5.3.2: {} import-fresh@3.3.0: @@ -6976,6 +7558,8 @@ snapshots: ini@4.1.3: {} + ini@5.0.0: {} + internal-slot@1.0.7: dependencies: es-errors: 1.3.0 @@ -7161,12 +7745,16 @@ snapshots: json-parse-even-better-errors@3.0.2: {} + json-parse-even-better-errors@4.0.0: {} + json-schema-traverse@0.4.1: {} json-schema-traverse@1.0.0: {} json-stable-stringify-without-jsonify@1.0.1: {} + json-stringify-nice@1.1.4: {} + json5@1.0.2: dependencies: minimist: 1.2.8 @@ -7194,6 +7782,10 @@ snapshots: ms: 2.1.3 semver: 7.6.3 + just-diff-apply@5.5.0: {} + + just-diff@6.0.2: {} + jwa@1.4.1: dependencies: buffer-equal-constant-time: 1.0.1 @@ -7315,6 +7907,22 @@ snapshots: transitivePeerDependencies: - supports-color + make-fetch-happen@14.0.3: + dependencies: + '@npmcli/agent': 3.0.0 + cacache: 19.0.1 + http-cache-semantics: 4.1.1 + minipass: 7.1.2 + minipass-fetch: 4.0.0 + minipass-flush: 1.0.5 + minipass-pipeline: 1.2.4 + negotiator: 1.0.0 + proc-log: 5.0.0 + promise-retry: 2.0.1 + ssri: 12.0.0 + transitivePeerDependencies: + - supports-color + mdurl@1.0.1: {} media-typer@0.3.0: {} @@ -7372,6 +7980,14 @@ snapshots: optionalDependencies: encoding: 0.1.13 + minipass-fetch@4.0.0: + dependencies: + minipass: 7.1.2 + minipass-sized: 1.0.3 + minizlib: 3.0.1 + optionalDependencies: + encoding: 0.1.13 + minipass-flush@1.0.5: dependencies: minipass: 3.3.6 @@ -7397,12 +8013,19 @@ snapshots: minipass: 3.3.6 yallist: 4.0.0 + minizlib@3.0.1: + dependencies: + minipass: 7.1.2 + rimraf: 5.0.10 + mkdirp@0.5.6: dependencies: minimist: 1.2.8 mkdirp@1.0.4: {} + mkdirp@3.0.1: {} + morgan@1.10.0: dependencies: basic-auth: 2.0.1 @@ -7435,6 +8058,8 @@ snapshots: negotiator@0.6.3: {} + negotiator@1.0.0: {} + node-domexception@1.0.0: {} node-fetch@2.7.0(encoding@0.1.13): @@ -7464,12 +8089,31 @@ snapshots: transitivePeerDependencies: - supports-color + node-gyp@11.1.0: + dependencies: + env-paths: 2.2.1 + exponential-backoff: 3.1.1 + glob: 10.4.5 + graceful-fs: 4.2.11 + make-fetch-happen: 14.0.3 + nopt: 8.1.0 + proc-log: 5.0.0 + semver: 7.6.3 + tar: 7.4.3 + which: 5.0.0 + transitivePeerDependencies: + - supports-color + node-releases@2.0.18: {} nopt@7.2.1: dependencies: abbrev: 2.0.0 + nopt@8.1.0: + dependencies: + abbrev: 3.0.0 + normalize-package-data@2.5.0: dependencies: hosted-git-info: 2.8.9 @@ -7487,12 +8131,22 @@ snapshots: dependencies: npm-normalize-package-bin: 3.0.1 + npm-bundled@4.0.0: + dependencies: + npm-normalize-package-bin: 4.0.0 + npm-install-checks@6.3.0: dependencies: semver: 7.6.3 + npm-install-checks@7.1.1: + dependencies: + semver: 7.6.3 + npm-normalize-package-bin@3.0.1: {} + npm-normalize-package-bin@4.0.0: {} + npm-package-arg@11.0.3: dependencies: hosted-git-info: 7.0.2 @@ -7500,10 +8154,28 @@ snapshots: semver: 7.6.3 validate-npm-package-name: 5.0.1 + npm-package-arg@12.0.2: + dependencies: + hosted-git-info: 8.0.2 + proc-log: 5.0.0 + semver: 7.6.3 + validate-npm-package-name: 6.0.0 + + npm-packlist@10.0.0: + dependencies: + ignore-walk: 7.0.0 + npm-packlist@8.0.2: dependencies: ignore-walk: 6.0.5 + npm-pick-manifest@10.0.0: + dependencies: + npm-install-checks: 7.1.1 + npm-normalize-package-bin: 4.0.0 + npm-package-arg: 12.0.2 + semver: 7.6.3 + npm-pick-manifest@9.1.0: dependencies: npm-install-checks: 6.3.0 @@ -7524,6 +8196,19 @@ snapshots: transitivePeerDependencies: - supports-color + npm-registry-fetch@18.0.2: + dependencies: + '@npmcli/redact': 3.1.1 + jsonparse: 1.3.1 + make-fetch-happen: 14.0.3 + minipass: 7.1.2 + minipass-fetch: 4.0.0 + minizlib: 3.0.1 + npm-package-arg: 12.0.2 + proc-log: 5.0.0 + transitivePeerDependencies: + - supports-color + object-assign@4.1.1: {} object-inspect@1.13.2: {} @@ -7651,6 +8336,8 @@ snapshots: dependencies: aggregate-error: 3.1.0 + p-map@7.0.3: {} + p-try@2.2.0: {} package-json-from-dist@1.0.0: {} @@ -7678,6 +8365,29 @@ snapshots: - bluebird - supports-color + pacote@21.0.0: + dependencies: + '@npmcli/git': 6.0.1 + '@npmcli/installed-package-contents': 3.0.0 + '@npmcli/package-json': 6.1.1 + '@npmcli/promise-spawn': 8.0.2 + '@npmcli/run-script': 9.0.2 + cacache: 19.0.1 + fs-minipass: 3.0.3 + minipass: 7.1.2 + npm-package-arg: 12.0.2 + npm-packlist: 10.0.0 + npm-pick-manifest: 10.0.0 + npm-registry-fetch: 18.0.2 + proc-log: 5.0.0 + promise-retry: 2.0.1 + sigstore: 3.1.0 + ssri: 12.0.0 + tar: 6.2.1 + transitivePeerDependencies: + - bluebird + - supports-color + parent-module@1.0.1: dependencies: callsites: 3.1.0 @@ -7686,6 +8396,12 @@ snapshots: dependencies: callsites: 3.1.0 + parse-conflict-json@4.0.0: + dependencies: + json-parse-even-better-errors: 4.0.0 + just-diff: 6.0.2 + just-diff-apply: 5.5.0 + parse-json@5.2.0: dependencies: '@babel/code-frame': 7.25.9 @@ -7723,7 +8439,7 @@ snapshots: path-type@5.0.0: {} - pathe@1.1.2: {} + pathe@2.0.3: {} pathval@2.0.0: {} @@ -7737,6 +8453,11 @@ snapshots: possible-typed-array-names@1.0.0: {} + postcss-selector-parser@6.1.2: + dependencies: + cssesc: 3.0.0 + util-deprecate: 1.0.2 + postcss@8.5.1: dependencies: nanoid: 3.3.8 @@ -7747,10 +8468,20 @@ snapshots: prettier@3.3.3: {} + prettier@3.4.2: {} + proc-log@4.2.0: {} + proc-log@5.0.0: {} + process-nextick-args@2.0.1: {} + proggy@3.0.0: {} + + promise-all-reject-late@1.0.1: {} + + promise-call-limit@3.0.2: {} + promise-inflight@1.0.1: {} promise-retry@2.0.1: @@ -7796,6 +8527,13 @@ snapshots: iconv-lite: 0.4.24 unpipe: 1.0.0 + read-cmd-shim@5.0.0: {} + + read-package-json-fast@4.0.0: + dependencies: + json-parse-even-better-errors: 4.0.0 + npm-normalize-package-bin: 4.0.0 + read-pkg-up@7.0.1: dependencies: find-up: 4.1.0 @@ -7874,6 +8612,10 @@ snapshots: dependencies: glob: 7.2.3 + rimraf@5.0.10: + dependencies: + glob: 10.4.5 + rimraf@6.0.1: dependencies: glob: 11.0.0 @@ -8012,6 +8754,17 @@ snapshots: transitivePeerDependencies: - supports-color + sigstore@3.1.0: + dependencies: + '@sigstore/bundle': 3.1.0 + '@sigstore/core': 2.0.0 + '@sigstore/protobuf-specs': 0.4.0 + '@sigstore/sign': 3.1.0 + '@sigstore/tuf': 3.1.0 + '@sigstore/verify': 2.1.0 + transitivePeerDependencies: + - supports-color + simple-swizzle@0.2.2: dependencies: is-arrayish: 0.3.2 @@ -8064,6 +8817,10 @@ snapshots: dependencies: minipass: 7.1.2 + ssri@12.0.0: + dependencies: + minipass: 7.1.2 + stack-trace@0.0.10: {} stackback@0.0.2: {} @@ -8193,6 +8950,15 @@ snapshots: mkdirp: 1.0.4 yallist: 4.0.0 + tar@7.4.3: + dependencies: + '@isaacs/fs-minipass': 4.0.1 + chownr: 3.0.0 + minipass: 7.1.2 + minizlib: 3.0.1 + mkdirp: 3.0.1 + yallist: 5.0.0 + temporal-polyfill@0.2.5: dependencies: temporal-spec: 0.2.4 @@ -8217,7 +8983,7 @@ snapshots: tinypool@1.0.2: {} - tinyrainbow@1.2.0: {} + tinyrainbow@2.0.0: {} tinyspy@3.0.2: {} @@ -8229,15 +8995,17 @@ snapshots: tr46@0.0.3: {} + treeverse@3.0.0: {} + triple-beam@1.4.1: {} ts-api-utils@1.3.0(typescript@5.6.2): dependencies: typescript: 5.6.2 - ts-api-utils@1.3.0(typescript@5.6.3): + ts-api-utils@2.0.1(typescript@5.7.3): dependencies: - typescript: 5.6.3 + typescript: 5.7.3 ts-toolbelt@9.6.0: {} @@ -8265,6 +9033,14 @@ snapshots: transitivePeerDependencies: - supports-color + tuf-js@3.0.1: + dependencies: + '@tufjs/models': 3.0.1 + debug: 4.4.0 + make-fetch-happen: 14.0.3 + transitivePeerDependencies: + - supports-color + tunnel@0.0.6: {} type-check@0.4.0: @@ -8320,15 +9096,14 @@ snapshots: typedarray@0.0.6: {} - typescript-eslint@8.13.0(eslint@9.11.1)(typescript@5.6.3): + typescript-eslint@8.24.0(eslint@9.11.1)(typescript@5.7.3): dependencies: - '@typescript-eslint/eslint-plugin': 8.13.0(@typescript-eslint/parser@8.13.0(eslint@9.11.1)(typescript@5.6.3))(eslint@9.11.1)(typescript@5.6.3) - '@typescript-eslint/parser': 8.13.0(eslint@9.11.1)(typescript@5.6.3) - '@typescript-eslint/utils': 8.13.0(eslint@9.11.1)(typescript@5.6.3) - optionalDependencies: - typescript: 5.6.3 + '@typescript-eslint/eslint-plugin': 8.24.0(@typescript-eslint/parser@8.24.0(eslint@9.11.1)(typescript@5.7.3))(eslint@9.11.1)(typescript@5.7.3) + '@typescript-eslint/parser': 8.24.0(eslint@9.11.1)(typescript@5.7.3) + '@typescript-eslint/utils': 8.24.0(eslint@9.11.1)(typescript@5.7.3) + eslint: 9.11.1 + typescript: 5.7.3 transitivePeerDependencies: - - eslint - supports-color typescript-eslint@8.7.0(eslint@9.11.1)(typescript@5.6.2): @@ -8346,7 +9121,7 @@ snapshots: typescript@5.6.2: {} - typescript@5.6.3: {} + typescript@5.7.3: {} unbox-primitive@1.0.2: dependencies: @@ -8359,6 +9134,8 @@ snapshots: undici-types@6.19.8: {} + undici-types@6.20.0: {} + undici@5.28.4: dependencies: '@fastify/busboy': 2.1.1 @@ -8369,10 +9146,18 @@ snapshots: dependencies: unique-slug: 4.0.0 + unique-filename@4.0.0: + dependencies: + unique-slug: 5.0.0 + unique-slug@4.0.0: dependencies: imurmurhash: 0.1.4 + unique-slug@5.0.0: + dependencies: + imurmurhash: 0.1.4 + unique-string@3.0.0: dependencies: crypto-random-string: 4.0.0 @@ -8416,14 +9201,16 @@ snapshots: validate-npm-package-name@5.0.1: {} + validate-npm-package-name@6.0.0: {} + vary@1.1.2: {} - vite-node@2.1.9(@types/node@22.5.5): + vite-node@3.0.5(@types/node@22.5.5): dependencies: cac: 6.7.14 debug: 4.4.0 es-module-lexer: 1.6.0 - pathe: 1.1.2 + pathe: 2.0.3 vite: 5.4.14(@types/node@22.5.5) transitivePeerDependencies: - '@types/node' @@ -8445,27 +9232,27 @@ snapshots: '@types/node': 22.5.5 fsevents: 2.3.3 - vitest@2.1.9(@types/node@22.5.5): + vitest@3.0.5(@types/node@22.5.5): dependencies: - '@vitest/expect': 2.1.9 - '@vitest/mocker': 2.1.9(vite@5.4.14(@types/node@22.5.5)) - '@vitest/pretty-format': 2.1.9 - '@vitest/runner': 2.1.9 - '@vitest/snapshot': 2.1.9 - '@vitest/spy': 2.1.9 - '@vitest/utils': 2.1.9 + '@vitest/expect': 3.0.5 + '@vitest/mocker': 3.0.5(vite@5.4.14(@types/node@22.5.5)) + '@vitest/pretty-format': 3.0.5 + '@vitest/runner': 3.0.5 + '@vitest/snapshot': 3.0.5 + '@vitest/spy': 3.0.5 + '@vitest/utils': 3.0.5 chai: 5.1.2 debug: 4.4.0 expect-type: 1.1.0 magic-string: 0.30.17 - pathe: 1.1.2 + pathe: 2.0.3 std-env: 3.8.0 tinybench: 2.9.0 tinyexec: 0.3.2 tinypool: 1.0.2 - tinyrainbow: 1.2.0 + tinyrainbow: 2.0.0 vite: 5.4.14(@types/node@22.5.5) - vite-node: 2.1.9(@types/node@22.5.5) + vite-node: 3.0.5(@types/node@22.5.5) why-is-node-running: 2.3.0 optionalDependencies: '@types/node': 22.5.5 @@ -8497,6 +9284,8 @@ snapshots: vscode-uri@3.0.8: {} + walk-up-path@4.0.0: {} + web-streams-polyfill@3.3.3: {} webidl-conversions@3.0.1: {} @@ -8537,6 +9326,10 @@ snapshots: dependencies: isexe: 3.1.1 + which@5.0.0: + dependencies: + isexe: 3.1.1 + why-is-node-running@2.3.0: dependencies: siginfo: 2.0.0 @@ -8605,6 +9398,11 @@ snapshots: signal-exit: 3.0.7 typedarray-to-buffer: 3.1.5 + write-file-atomic@6.0.0: + dependencies: + imurmurhash: 0.1.4 + signal-exit: 4.1.0 + ws@8.18.0: {} xdg-basedir@5.1.0: {} @@ -8622,8 +9420,12 @@ snapshots: yallist@4.0.0: {} + yallist@5.0.0: {} + yaml@2.5.1: {} + yaml@2.7.0: {} + yargs-parser@21.1.1: {} yargs@17.7.2: From 06c36de9bc392ca797e1c282c29b0ec0ee7536f0 Mon Sep 17 00:00:00 2001 From: AutoPrFromHttpClientPython Date: Wed, 12 Feb 2025 03:53:07 +0000 Subject: [PATCH 02/14] Regenerate for typespec-python (2025-02-12 03:53:07) --- .../authentication/apikey/models/_models.py | 2 +- .../http/custom/models/_models.py | 2 +- .../authentication/oauth2/models/_models.py | 2 +- .../core/access/models/_models.py | 22 +- .../CHANGELOG.md | 5 + .../LICENSE | 21 + .../MANIFEST.in | 8 + .../README.md | 45 + .../apiview-properties.json | 6 + .../client/__init__.py | 1 + .../client/alternateapiversion/__init__.py | 1 + .../alternateapiversion/service/__init__.py | 1 + .../service/header/__init__.py | 32 + .../service/header/_client.py | 94 + .../service/header/_configuration.py | 47 + .../service/header/_model_base.py | 1235 ++++++++++ .../service/header/_operations/__init__.py | 25 + .../service/header/_operations/_operations.py | 96 + .../service/header/_operations/_patch.py | 20 + .../service/header/_patch.py | 20 + .../service/header/_serialization.py | 2050 +++++++++++++++++ .../service/header/_vendor.py | 25 + .../service/header/_version.py | 9 + .../service/header/aio/__init__.py | 29 + .../service/header/aio/_client.py | 96 + .../service/header/aio/_configuration.py | 47 + .../header/aio/_operations/__init__.py | 25 + .../header/aio/_operations/_operations.py | 79 + .../service/header/aio/_operations/_patch.py | 20 + .../service/header/aio/_patch.py | 20 + .../service/header/aio/_vendor.py | 25 + .../service/header/py.typed | 1 + .../dev_requirements.txt | 3 + .../generated_tests/conftest.py | 35 + .../generated_tests/test_header.py | 22 + .../generated_tests/test_header_async.py | 23 + .../generated_tests/testpreparer.py | 24 + .../generated_tests/testpreparer_async.py | 20 + .../setup.py | 72 + .../CHANGELOG.md | 5 + .../LICENSE | 21 + .../MANIFEST.in | 8 + .../README.md | 45 + .../apiview-properties.json | 6 + .../client/__init__.py | 1 + .../client/alternateapiversion/__init__.py | 1 + .../alternateapiversion/service/__init__.py | 1 + .../service/path/__init__.py | 32 + .../service/path/_client.py | 94 + .../service/path/_configuration.py | 47 + .../service/path/_model_base.py | 1235 ++++++++++ .../service/path/_operations/__init__.py | 25 + .../service/path/_operations/_operations.py | 95 + .../service/path/_operations/_patch.py | 20 + .../service/path/_patch.py | 20 + .../service/path/_serialization.py | 2050 +++++++++++++++++ .../service/path/_vendor.py | 25 + .../service/path/_version.py | 9 + .../service/path/aio/__init__.py | 29 + .../service/path/aio/_client.py | 96 + .../service/path/aio/_configuration.py | 47 + .../service/path/aio/_operations/__init__.py | 25 + .../path/aio/_operations/_operations.py | 79 + .../service/path/aio/_operations/_patch.py | 20 + .../service/path/aio/_patch.py | 20 + .../service/path/aio/_vendor.py | 25 + .../alternateapiversion/service/path/py.typed | 1 + .../dev_requirements.txt | 3 + .../generated_tests/conftest.py | 35 + .../generated_tests/test_path.py | 22 + .../generated_tests/test_path_async.py | 23 + .../generated_tests/testpreparer.py | 24 + .../generated_tests/testpreparer_async.py | 20 + .../setup.py | 72 + .../CHANGELOG.md | 5 + .../LICENSE | 21 + .../MANIFEST.in | 8 + .../README.md | 45 + .../apiview-properties.json | 6 + .../client/__init__.py | 1 + .../client/alternateapiversion/__init__.py | 1 + .../alternateapiversion/service/__init__.py | 1 + .../service/query/__init__.py | 32 + .../service/query/_client.py | 94 + .../service/query/_configuration.py | 47 + .../service/query/_model_base.py | 1235 ++++++++++ .../service/query/_operations/__init__.py | 25 + .../service/query/_operations/_operations.py | 96 + .../service/query/_operations/_patch.py | 20 + .../service/query/_patch.py | 20 + .../service/query/_serialization.py | 2050 +++++++++++++++++ .../service/query/_vendor.py | 25 + .../service/query/_version.py | 9 + .../service/query/aio/__init__.py | 29 + .../service/query/aio/_client.py | 96 + .../service/query/aio/_configuration.py | 47 + .../service/query/aio/_operations/__init__.py | 25 + .../query/aio/_operations/_operations.py | 79 + .../service/query/aio/_operations/_patch.py | 20 + .../service/query/aio/_patch.py | 20 + .../service/query/aio/_vendor.py | 25 + .../service/query/py.typed | 1 + .../dev_requirements.txt | 3 + .../generated_tests/conftest.py | 35 + .../generated_tests/test_query.py | 22 + .../generated_tests/test_query_async.py | 23 + .../generated_tests/testpreparer.py | 24 + .../generated_tests/testpreparer_async.py | 20 + .../setup.py | 72 + .../core/flattenproperty/models/_models.py | 16 +- .../core/usage/models/_models.py | 8 +- .../specs/azure/core/basic/models/_models.py | 10 +- .../azure/core/lro/standard/models/_models.py | 6 +- .../specs/azure/core/model/models/_models.py | 2 +- .../specs/azure/core/page/models/_models.py | 10 +- .../specs/azure/core/scalar/models/_models.py | 2 +- .../specs/azure/core/traits/models/_models.py | 10 +- .../azure/example/basic/models/_models.py | 40 +- .../azure/payload/pageable/models/_models.py | 2 +- .../commonproperties/models/_models.py | 48 +- .../operationtemplates/models/_models.py | 54 +- .../resources/models/_models.py | 60 +- .../azurecore/lro/rpc/models/_models.py | 4 +- .../clientnamespace/first/models/_models.py | 2 +- .../clientnamespace/second/models/_models.py | 4 +- .../client/naming/models/_models.py | 10 +- .../encode/bytes/models/_models.py | 8 +- .../encode/datetime/models/_models.py | 14 +- .../encode/duration/models/_models.py | 12 +- .../encode/numeric/models/_models.py | 6 +- .../parameters/basic/models/_models.py | 2 +- .../bodyoptionality/models/_models.py | 2 +- .../parameters/spread/models/_models.py | 2 +- .../contentnegotiation/models/_models.py | 2 +- .../payload/jsonmergepatch/models/_models.py | 50 +- .../payload/multipart/models/_models.py | 70 +- .../payload/pageable/models/_models.py | 4 +- .../payload-xml/payload/xml/models/_models.py | 83 +- .../response-status-code-range/CHANGELOG.md | 5 + .../response-status-code-range/LICENSE | 21 + .../response-status-code-range/MANIFEST.in | 6 + .../response-status-code-range/README.md | 45 + .../apiview-properties.json | 11 + .../dev_requirements.txt | 3 + .../generated_tests/conftest.py | 39 + .../generated_tests/test_status_code_range.py | 31 + .../test_status_code_range_async.py | 32 + .../generated_tests/testpreparer.py | 26 + .../generated_tests/testpreparer_async.py | 20 + .../response/__init__.py | 1 + .../response/statuscoderange/__init__.py | 32 + .../response/statuscoderange/_client.py | 91 + .../statuscoderange/_configuration.py | 42 + .../response/statuscoderange/_model_base.py | 1235 ++++++++++ .../statuscoderange/_operations/__init__.py | 25 + .../_operations/_operations.py | 194 ++ .../statuscoderange/_operations/_patch.py | 20 + .../response/statuscoderange/_patch.py | 20 + .../statuscoderange/_serialization.py | 2050 +++++++++++++++++ .../response/statuscoderange/_vendor.py | 25 + .../response/statuscoderange/_version.py | 9 + .../response/statuscoderange/aio/__init__.py | 29 + .../response/statuscoderange/aio/_client.py | 93 + .../statuscoderange/aio/_configuration.py | 42 + .../aio/_operations/__init__.py | 25 + .../aio/_operations/_operations.py | 161 ++ .../statuscoderange/aio/_operations/_patch.py | 20 + .../response/statuscoderange/aio/_patch.py | 20 + .../response/statuscoderange/aio/_vendor.py | 25 + .../statuscoderange/models/__init__.py | 33 + .../statuscoderange/models/_models.py | 143 ++ .../response/statuscoderange/models/_patch.py | 20 + .../response/statuscoderange/py.typed | 1 + .../response-status-code-range/setup.py | 70 + .../encodedname/json/models/_models.py | 2 +- .../specialwords/models/_models.py | 68 +- .../typetest/array/models/_models.py | 6 +- .../typetest/dictionary/models/_models.py | 6 +- .../model/enumdiscriminator/models/_models.py | 12 +- .../nesteddiscriminator/models/_models.py | 18 +- .../model/notdiscriminated/models/_models.py | 6 +- .../model/recursive/models/_models.py | 6 +- .../singlediscriminator/models/_models.py | 22 +- .../typetest/model/usage/models/_models.py | 6 +- .../additionalproperties/models/_models.py | 118 +- .../property/nullable/models/_models.py | 58 +- .../property/optional/models/_models.py | 46 +- .../property/valuetypes/models/_models.py | 62 +- .../typetest/union/models/_models.py | 72 +- .../versioning/added/models/_models.py | 20 +- .../versioning/madeoptional/models/_models.py | 6 +- .../versioning/removed/models/_models.py | 16 +- .../versioning/renamedfrom/models/_models.py | 10 +- .../typechangedfrom/models/_models.py | 4 +- .../authentication/apikey/models/_models.py | 2 +- .../http/custom/models/_models.py | 2 +- .../authentication/oauth2/models/_models.py | 2 +- .../encode/bytes/models/_models.py | 8 +- .../encode/datetime/models/_models.py | 14 +- .../duration/property/models/_models.py | 12 +- .../encode/numeric/property/models/_models.py | 6 +- .../basic/explicitbody/models/_models.py | 2 +- .../bodyoptionality/models/_models.py | 2 +- .../parameters/spread/model/models/_models.py | 2 +- .../differentbody/models/_models.py | 2 +- .../payload/jsonmergepatch/models/_models.py | 50 +- .../httpparts/nonstring/models/_models.py | 2 +- .../payload/multipart/models/_models.py | 68 +- .../payload/pageable/models/_models.py | 4 +- .../payload-xml/payload/xml/models/_models.py | 83 +- .../response-status-code-range/CHANGELOG.md | 5 + .../response-status-code-range/LICENSE | 21 + .../response-status-code-range/MANIFEST.in | 6 + .../response-status-code-range/README.md | 0 .../response/__init__.py | 1 + .../response/statuscoderange/__init__.py | 32 + .../response/statuscoderange/_client.py | 84 + .../statuscoderange/_configuration.py | 39 + .../response/statuscoderange/_model_base.py | 1235 ++++++++++ .../statuscoderange/_operations/__init__.py | 25 + .../_operations/_operations.py | 187 ++ .../statuscoderange/_operations/_patch.py | 20 + .../response/statuscoderange/_patch.py | 20 + .../statuscoderange/_serialization.py | 2050 +++++++++++++++++ .../response/statuscoderange/_vendor.py | 25 + .../response/statuscoderange/_version.py | 9 + .../response/statuscoderange/aio/__init__.py | 29 + .../response/statuscoderange/aio/_client.py | 86 + .../statuscoderange/aio/_configuration.py | 39 + .../aio/_operations/__init__.py | 25 + .../aio/_operations/_operations.py | 158 ++ .../statuscoderange/aio/_operations/_patch.py | 20 + .../response/statuscoderange/aio/_patch.py | 20 + .../response/statuscoderange/aio/_vendor.py | 25 + .../statuscoderange/models/__init__.py | 33 + .../statuscoderange/models/_models.py | 143 ++ .../response/statuscoderange/models/_patch.py | 20 + .../response/statuscoderange/py.typed | 1 + .../response-status-code-range/setup.py | 67 + .../json/property/models/_models.py | 2 +- .../modelproperties/models/_models.py | 2 +- .../specialwords/models/models/_models.py | 66 +- .../typetest/array/models/_models.py | 6 +- .../typetest/dictionary/models/_models.py | 6 +- .../model/enumdiscriminator/models/_models.py | 12 +- .../nesteddiscriminator/models/_models.py | 18 +- .../model/notdiscriminated/models/_models.py | 6 +- .../model/recursive/models/_models.py | 6 +- .../singlediscriminator/models/_models.py | 22 +- .../typetest/model/usage/models/_models.py | 6 +- .../additionalproperties/models/_models.py | 118 +- .../property/nullable/models/_models.py | 58 +- .../property/optional/models/_models.py | 46 +- .../property/valuetypes/models/_models.py | 62 +- .../typetest/union/models/_models.py | 72 +- .../versioning/added/models/_models.py | 20 +- .../versioning/madeoptional/models/_models.py | 6 +- .../versioning/removed/models/_models.py | 16 +- .../versioning/renamedfrom/models/_models.py | 10 +- .../typechangedfrom/models/_models.py | 4 +- 260 files changed, 23153 insertions(+), 742 deletions(-) create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/CHANGELOG.md create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/LICENSE create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/MANIFEST.in create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/README.md create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/apiview-properties.json create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_client.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_configuration.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_model_base.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_operations/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_operations/_operations.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_operations/_patch.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_patch.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_serialization.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_vendor.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_version.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_client.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_configuration.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_operations/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_operations/_operations.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_operations/_patch.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_patch.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_vendor.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/py.typed create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/dev_requirements.txt create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/conftest.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/test_header.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/test_header_async.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/testpreparer.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/testpreparer_async.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/setup.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/CHANGELOG.md create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/LICENSE create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/MANIFEST.in create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/README.md create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/apiview-properties.json create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_client.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_configuration.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_model_base.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_operations/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_operations/_operations.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_operations/_patch.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_patch.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_serialization.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_vendor.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_version.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_client.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_configuration.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_operations/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_operations/_operations.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_operations/_patch.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_patch.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_vendor.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/py.typed create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/dev_requirements.txt create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/conftest.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/test_path.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/test_path_async.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/testpreparer.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/testpreparer_async.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/setup.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/CHANGELOG.md create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/LICENSE create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/MANIFEST.in create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/README.md create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/apiview-properties.json create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_client.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_configuration.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_model_base.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_operations/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_operations/_operations.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_operations/_patch.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_patch.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_serialization.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_vendor.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_version.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_client.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_configuration.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_operations/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_operations/_operations.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_operations/_patch.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_patch.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_vendor.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/py.typed create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/dev_requirements.txt create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/conftest.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/test_query.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/test_query_async.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/testpreparer.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/testpreparer_async.py create mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/setup.py create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/CHANGELOG.md create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/LICENSE create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/MANIFEST.in create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/README.md create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/apiview-properties.json create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/dev_requirements.txt create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/generated_tests/conftest.py create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/generated_tests/test_status_code_range.py create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/generated_tests/test_status_code_range_async.py create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/generated_tests/testpreparer.py create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/generated_tests/testpreparer_async.py create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/response/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_client.py create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_configuration.py create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_model_base.py create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_operations/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_operations/_patch.py create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_patch.py create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_serialization.py create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_vendor.py create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_version.py create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_client.py create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_configuration.py create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_operations/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_operations/_patch.py create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_patch.py create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_vendor.py create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/models/__init__.py create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/models/_models.py create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/models/_patch.py create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/py.typed create mode 100644 packages/typespec-python/test/azure/generated/response-status-code-range/setup.py create mode 100644 packages/typespec-python/test/unbranded/generated/response-status-code-range/CHANGELOG.md create mode 100644 packages/typespec-python/test/unbranded/generated/response-status-code-range/LICENSE create mode 100644 packages/typespec-python/test/unbranded/generated/response-status-code-range/MANIFEST.in create mode 100644 packages/typespec-python/test/unbranded/generated/response-status-code-range/README.md create mode 100644 packages/typespec-python/test/unbranded/generated/response-status-code-range/response/__init__.py create mode 100644 packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/__init__.py create mode 100644 packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_client.py create mode 100644 packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_configuration.py create mode 100644 packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_model_base.py create mode 100644 packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_operations/__init__.py create mode 100644 packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py create mode 100644 packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_operations/_patch.py create mode 100644 packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_patch.py create mode 100644 packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_serialization.py create mode 100644 packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_vendor.py create mode 100644 packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_version.py create mode 100644 packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/__init__.py create mode 100644 packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_client.py create mode 100644 packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_configuration.py create mode 100644 packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_operations/__init__.py create mode 100644 packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py create mode 100644 packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_operations/_patch.py create mode 100644 packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_patch.py create mode 100644 packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_vendor.py create mode 100644 packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/models/__init__.py create mode 100644 packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/models/_models.py create mode 100644 packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/models/_patch.py create mode 100644 packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/py.typed create mode 100644 packages/typespec-python/test/unbranded/generated/response-status-code-range/setup.py diff --git a/packages/typespec-python/test/azure/generated/authentication-api-key/authentication/apikey/models/_models.py b/packages/typespec-python/test/azure/generated/authentication-api-key/authentication/apikey/models/_models.py index c9f6c70366a..663d70a93cc 100644 --- a/packages/typespec-python/test/azure/generated/authentication-api-key/authentication/apikey/models/_models.py +++ b/packages/typespec-python/test/azure/generated/authentication-api-key/authentication/apikey/models/_models.py @@ -22,7 +22,7 @@ class InvalidAuth(_model_base.Model): :vartype error: str """ - error: str = rest_field() + error: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/authentication-http-custom/authentication/http/custom/models/_models.py b/packages/typespec-python/test/azure/generated/authentication-http-custom/authentication/http/custom/models/_models.py index c9f6c70366a..663d70a93cc 100644 --- a/packages/typespec-python/test/azure/generated/authentication-http-custom/authentication/http/custom/models/_models.py +++ b/packages/typespec-python/test/azure/generated/authentication-http-custom/authentication/http/custom/models/_models.py @@ -22,7 +22,7 @@ class InvalidAuth(_model_base.Model): :vartype error: str """ - error: str = rest_field() + error: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/authentication-oauth2/authentication/oauth2/models/_models.py b/packages/typespec-python/test/azure/generated/authentication-oauth2/authentication/oauth2/models/_models.py index c9f6c70366a..663d70a93cc 100644 --- a/packages/typespec-python/test/azure/generated/authentication-oauth2/authentication/oauth2/models/_models.py +++ b/packages/typespec-python/test/azure/generated/authentication-oauth2/authentication/oauth2/models/_models.py @@ -22,7 +22,7 @@ class InvalidAuth(_model_base.Model): :vartype error: str """ - error: str = rest_field() + error: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-access/specs/azure/clientgenerator/core/access/models/_models.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-access/specs/azure/clientgenerator/core/access/models/_models.py index 0506e0e6a3c..dd0e14c5e78 100644 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-access/specs/azure/clientgenerator/core/access/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-access/specs/azure/clientgenerator/core/access/models/_models.py @@ -32,7 +32,7 @@ class AbstractModel(_model_base.Model): __mapping__: Dict[str, _model_base.Model] = {} kind: str = rest_discriminator(name="kind") """Discriminator property for AbstractModel. Required. Default value is None.""" - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -62,7 +62,7 @@ class BaseModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -91,7 +91,7 @@ class InnerModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -120,7 +120,7 @@ class InternalDecoratorModelInInternal(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -149,7 +149,7 @@ class NoDecoratorModelInInternal(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -178,7 +178,7 @@ class NoDecoratorModelInPublic(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -209,7 +209,7 @@ class OuterModel(BaseModel): :vartype inner: ~specs.azure.clientgenerator.core.access.models._models.InnerModel """ - inner: "_models._models.InnerModel" = rest_field() + inner: "_models._models.InnerModel" = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -239,7 +239,7 @@ class PublicDecoratorModelInInternal(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -268,7 +268,7 @@ class PublicDecoratorModelInPublic(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -299,7 +299,7 @@ class RealModel(AbstractModel, discriminator="real"): :vartype kind: str """ - kind: Literal["real"] = rest_discriminator(name="kind") # type: ignore + kind: Literal["real"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long """Required. Default value is \"real\".""" @overload @@ -328,7 +328,7 @@ class SharedModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/CHANGELOG.md b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/CHANGELOG.md new file mode 100644 index 00000000000..628743d283a --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0b1 (1970-01-01) + +- Initial version diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/LICENSE b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/LICENSE new file mode 100644 index 00000000000..63447fd8bbb --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/LICENSE @@ -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. \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/MANIFEST.in b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/MANIFEST.in new file mode 100644 index 00000000000..0c8c941a444 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/MANIFEST.in @@ -0,0 +1,8 @@ +include *.md +include LICENSE +include client/alternateapiversion/service/header/py.typed +recursive-include tests *.py +recursive-include samples *.py *.md +include client/__init__.py +include client/alternateapiversion/__init__.py +include client/alternateapiversion/service/__init__.py \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/README.md b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/README.md new file mode 100644 index 00000000000..9cb0388f158 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/README.md @@ -0,0 +1,45 @@ + + +# Client Alternateapiversion Service Header client library for Python + + +## Getting started + +### Install the package + +```bash +python -m pip install client-alternateapiversion-service-header +``` + +#### 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 Client Alternateapiversion Service Header 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 opencode@microsoft.com with any +additional questions or comments. + + +[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/ + diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/apiview-properties.json b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/apiview-properties.json new file mode 100644 index 00000000000..59f18237883 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/apiview-properties.json @@ -0,0 +1,6 @@ +{ + "CrossLanguagePackageId": "Client.AlternateApiVersion.Service.Header", + "CrossLanguageDefinitionId": { + "client.alternateapiversion.service.header.HeaderClient.header_api_version": "Client.AlternateApiVersion.Service.Header.headerApiVersion" + } +} \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/__init__.py new file mode 100644 index 00000000000..d55ccad1f57 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/__init__.py new file mode 100644 index 00000000000..d55ccad1f57 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/__init__.py new file mode 100644 index 00000000000..d55ccad1f57 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/__init__.py new file mode 100644 index 00000000000..b4f101648cc --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/__init__.py @@ -0,0 +1,32 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import HeaderClient # type: ignore +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "HeaderClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore + +_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_client.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_client.py new file mode 100644 index 00000000000..c836af11b71 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_client.py @@ -0,0 +1,94 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any +from typing_extensions import Self + +from azure.core import PipelineClient +from azure.core.pipeline import policies +from azure.core.rest import HttpRequest, HttpResponse + +from ._configuration import HeaderClientConfiguration +from ._operations import HeaderClientOperationsMixin +from ._serialization import Deserializer, Serializer + + +class HeaderClient(HeaderClientOperationsMixin): + """HeaderClient. + + :keyword endpoint: Service host. Default value is "http://localhost:3000". + :paramtype endpoint: str + :keyword version: Default value is "2025-01-01". Note that overriding this default value may + result in unsupported behavior. + :paramtype version: str + """ + + def __init__( # pylint: disable=missing-client-constructor-parameter-credential + self, *, endpoint: str = "http://localhost:3000", **kwargs: Any + ) -> None: + _endpoint = "{endpoint}" + self._config = HeaderClientConfiguration(endpoint=endpoint, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> Self: + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_configuration.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_configuration.py new file mode 100644 index 00000000000..e0b34da732f --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_configuration.py @@ -0,0 +1,47 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any + +from azure.core.pipeline import policies + +from ._version import VERSION + + +class HeaderClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for HeaderClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: Service host. Default value is "http://localhost:3000". + :type endpoint: str + :keyword version: Default value is "2025-01-01". Note that overriding this default value may + result in unsupported behavior. + :paramtype version: str + """ + + def __init__(self, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None: + version: str = kwargs.pop("version", "2025-01-01") + + self.endpoint = endpoint + self.version = version + kwargs.setdefault("sdk_moniker", "client-alternateapiversion-service-header/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_model_base.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_model_base.py new file mode 100644 index 00000000000..3072ee252ed --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_model_base.py @@ -0,0 +1,1235 @@ +# pylint: disable=too-many-lines +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access, broad-except + +import copy +import calendar +import decimal +import functools +import sys +import logging +import base64 +import re +import typing +import enum +import email.utils +from datetime import datetime, date, time, timedelta, timezone +from json import JSONEncoder +import xml.etree.ElementTree as ET +from typing_extensions import Self +import isodate +from azure.core.exceptions import DeserializationError +from azure.core import CaseInsensitiveEnumMeta +from azure.core.pipeline import PipelineResponse +from azure.core.serialization import _Null + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping + +_LOGGER = logging.getLogger(__name__) + +__all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] + +TZ_UTC = timezone.utc +_T = typing.TypeVar("_T") + + +def _timedelta_as_isostr(td: timedelta) -> str: + """Converts a datetime.timedelta object into an ISO 8601 formatted string, e.g. 'P4DT12H30M05S' + + Function adapted from the Tin Can Python project: https://github.com/RusticiSoftware/TinCanPython + + :param timedelta td: The timedelta to convert + :rtype: str + :return: ISO8601 version of this timedelta + """ + + # Split seconds to larger units + seconds = td.total_seconds() + minutes, seconds = divmod(seconds, 60) + hours, minutes = divmod(minutes, 60) + days, hours = divmod(hours, 24) + + days, hours, minutes = list(map(int, (days, hours, minutes))) + seconds = round(seconds, 6) + + # Build date + date_str = "" + if days: + date_str = "%sD" % days + + if hours or minutes or seconds: + # Build time + time_str = "T" + + # Hours + bigger_exists = date_str or hours + if bigger_exists: + time_str += "{:02}H".format(hours) + + # Minutes + bigger_exists = bigger_exists or minutes + if bigger_exists: + time_str += "{:02}M".format(minutes) + + # Seconds + try: + if seconds.is_integer(): + seconds_string = "{:02}".format(int(seconds)) + else: + # 9 chars long w/ leading 0, 6 digits after decimal + seconds_string = "%09.6f" % seconds + # Remove trailing zeros + seconds_string = seconds_string.rstrip("0") + except AttributeError: # int.is_integer() raises + seconds_string = "{:02}".format(seconds) + + time_str += "{}S".format(seconds_string) + else: + time_str = "" + + return "P" + date_str + time_str + + +def _serialize_bytes(o, format: typing.Optional[str] = None) -> str: + encoded = base64.b64encode(o).decode() + if format == "base64url": + return encoded.strip("=").replace("+", "-").replace("/", "_") + return encoded + + +def _serialize_datetime(o, format: typing.Optional[str] = None): + if hasattr(o, "year") and hasattr(o, "hour"): + if format == "rfc7231": + return email.utils.format_datetime(o, usegmt=True) + if format == "unix-timestamp": + return int(calendar.timegm(o.utctimetuple())) + + # astimezone() fails for naive times in Python 2.7, so make make sure o is aware (tzinfo is set) + if not o.tzinfo: + iso_formatted = o.replace(tzinfo=TZ_UTC).isoformat() + else: + iso_formatted = o.astimezone(TZ_UTC).isoformat() + # Replace the trailing "+00:00" UTC offset with "Z" (RFC 3339: https://www.ietf.org/rfc/rfc3339.txt) + return iso_formatted.replace("+00:00", "Z") + # Next try datetime.date or datetime.time + return o.isoformat() + + +def _is_readonly(p): + try: + return p._visibility == ["read"] + except AttributeError: + return False + + +class SdkJSONEncoder(JSONEncoder): + """A JSON encoder that's capable of serializing datetime objects and bytes.""" + + def __init__(self, *args, exclude_readonly: bool = False, format: typing.Optional[str] = None, **kwargs): + super().__init__(*args, **kwargs) + self.exclude_readonly = exclude_readonly + self.format = format + + def default(self, o): # pylint: disable=too-many-return-statements + if _is_model(o): + if self.exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + return {k: v for k, v in o.items() if k not in readonly_props} + return dict(o.items()) + try: + return super(SdkJSONEncoder, self).default(o) + except TypeError: + if isinstance(o, _Null): + return None + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, self.format) + try: + # First try datetime.datetime + return _serialize_datetime(o, self.format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return super(SdkJSONEncoder, self).default(o) + + +_VALID_DATE = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" + r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") +_VALID_RFC7231 = re.compile( + r"(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s\d{2}\s" + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT" +) + + +def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + attr = attr.upper() + match = _VALID_DATE.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + return date_obj + + +def _deserialize_datetime_rfc7231(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize RFC7231 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + match = _VALID_RFC7231.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + return email.utils.parsedate_to_datetime(attr) + + +def _deserialize_datetime_unix_timestamp(attr: typing.Union[float, datetime]) -> datetime: + """Deserialize unix timestamp into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + return datetime.fromtimestamp(attr, TZ_UTC) + + +def _deserialize_date(attr: typing.Union[str, date]) -> date: + """Deserialize ISO-8601 formatted string into Date object. + :param str attr: response string to be deserialized. + :rtype: date + :returns: The date object from that input + """ + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + if isinstance(attr, date): + return attr + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) # type: ignore + + +def _deserialize_time(attr: typing.Union[str, time]) -> time: + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :returns: The time object from that input + """ + if isinstance(attr, time): + return attr + return isodate.parse_time(attr) + + +def _deserialize_bytes(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + return bytes(base64.b64decode(attr)) + + +def _deserialize_bytes_base64(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return bytes(base64.b64decode(encoded)) + + +def _deserialize_duration(attr): + if isinstance(attr, timedelta): + return attr + return isodate.parse_duration(attr) + + +def _deserialize_decimal(attr): + if isinstance(attr, decimal.Decimal): + return attr + return decimal.Decimal(str(attr)) + + +def _deserialize_int_as_str(attr): + if isinstance(attr, int): + return attr + return int(attr) + + +_DESERIALIZE_MAPPING = { + datetime: _deserialize_datetime, + date: _deserialize_date, + time: _deserialize_time, + bytes: _deserialize_bytes, + bytearray: _deserialize_bytes, + timedelta: _deserialize_duration, + typing.Any: lambda x: x, + decimal.Decimal: _deserialize_decimal, +} + +_DESERIALIZE_MAPPING_WITHFORMAT = { + "rfc3339": _deserialize_datetime, + "rfc7231": _deserialize_datetime_rfc7231, + "unix-timestamp": _deserialize_datetime_unix_timestamp, + "base64": _deserialize_bytes, + "base64url": _deserialize_bytes_base64, +} + + +def get_deserializer(annotation: typing.Any, rf: typing.Optional["_RestField"] = None): + if annotation is int and rf and rf._format == "str": + return _deserialize_int_as_str + if rf and rf._format: + return _DESERIALIZE_MAPPING_WITHFORMAT.get(rf._format) + return _DESERIALIZE_MAPPING.get(annotation) # pyright: ignore + + +def _get_type_alias_type(module_name: str, alias_name: str): + types = { + k: v + for k, v in sys.modules[module_name].__dict__.items() + if isinstance(v, typing._GenericAlias) # type: ignore + } + if alias_name not in types: + return alias_name + return types[alias_name] + + +def _get_model(module_name: str, model_name: str): + models = {k: v for k, v in sys.modules[module_name].__dict__.items() if isinstance(v, type)} + module_end = module_name.rsplit(".", 1)[0] + models.update({k: v for k, v in sys.modules[module_end].__dict__.items() if isinstance(v, type)}) + if isinstance(model_name, str): + model_name = model_name.split(".")[-1] + if model_name not in models: + return model_name + return models[model_name] + + +_UNSET = object() + + +class _MyMutableMapping(MutableMapping[str, typing.Any]): # pylint: disable=unsubscriptable-object + def __init__(self, data: typing.Dict[str, typing.Any]) -> None: + self._data = data + + def __contains__(self, key: typing.Any) -> bool: + return key in self._data + + def __getitem__(self, key: str) -> typing.Any: + return self._data.__getitem__(key) + + def __setitem__(self, key: str, value: typing.Any) -> None: + self._data.__setitem__(key, value) + + def __delitem__(self, key: str) -> None: + self._data.__delitem__(key) + + def __iter__(self) -> typing.Iterator[typing.Any]: + return self._data.__iter__() + + def __len__(self) -> int: + return self._data.__len__() + + def __ne__(self, other: typing.Any) -> bool: + return not self.__eq__(other) + + def keys(self) -> typing.KeysView[str]: + """ + :returns: a set-like object providing a view on D's keys + :rtype: ~typing.KeysView + """ + return self._data.keys() + + def values(self) -> typing.ValuesView[typing.Any]: + """ + :returns: an object providing a view on D's values + :rtype: ~typing.ValuesView + """ + return self._data.values() + + def items(self) -> typing.ItemsView[str, typing.Any]: + """ + :returns: set-like object providing a view on D's items + :rtype: ~typing.ItemsView + """ + return self._data.items() + + def get(self, key: str, default: typing.Any = None) -> typing.Any: + """ + Get the value for key if key is in the dictionary, else default. + :param str key: The key to look up. + :param any default: The value to return if key is not in the dictionary. Defaults to None + :returns: D[k] if k in D, else d. + :rtype: any + """ + try: + return self[key] + except KeyError: + return default + + @typing.overload + def pop(self, key: str) -> typing.Any: ... + + @typing.overload + def pop(self, key: str, default: _T) -> _T: ... + + @typing.overload + def pop(self, key: str, default: typing.Any) -> typing.Any: ... + + def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Removes specified key and return the corresponding value. + :param str key: The key to pop. + :param any default: The value to return if key is not in the dictionary + :returns: The value corresponding to the key. + :rtype: any + :raises KeyError: If key is not found and default is not given. + """ + if default is _UNSET: + return self._data.pop(key) + return self._data.pop(key, default) + + def popitem(self) -> typing.Tuple[str, typing.Any]: + """ + Removes and returns some (key, value) pair + :returns: The (key, value) pair. + :rtype: tuple + :raises KeyError: if D is empty. + """ + return self._data.popitem() + + def clear(self) -> None: + """ + Remove all items from D. + """ + self._data.clear() + + def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: + """ + Updates D from mapping/iterable E and F. + :param any args: Either a mapping object or an iterable of key-value pairs. + """ + self._data.update(*args, **kwargs) + + @typing.overload + def setdefault(self, key: str, default: None = None) -> None: ... + + @typing.overload + def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... + + def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Same as calling D.get(k, d), and setting D[k]=d if k not found + :param str key: The key to look up. + :param any default: The value to set if key is not in the dictionary + :returns: D[k] if k in D, else d. + :rtype: any + """ + if default is _UNSET: + return self._data.setdefault(key) + return self._data.setdefault(key, default) + + def __eq__(self, other: typing.Any) -> bool: + try: + other_model = self.__class__(other) + except Exception: + return False + return self._data == other_model._data + + def __repr__(self) -> str: + return str(self._data) + + +def _is_model(obj: typing.Any) -> bool: + return getattr(obj, "_is_model", False) + + +def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-many-return-statements + if isinstance(o, list): + return [_serialize(x, format) for x in o] + if isinstance(o, dict): + return {k: _serialize(v, format) for k, v in o.items()} + if isinstance(o, set): + return {_serialize(x, format) for x in o} + if isinstance(o, tuple): + return tuple(_serialize(x, format) for x in o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, format) + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, enum.Enum): + return o.value + if isinstance(o, int): + if format == "str": + return str(o) + return o + try: + # First try datetime.datetime + return _serialize_datetime(o, format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return o + + +def _get_rest_field( + attr_to_rest_field: typing.Dict[str, "_RestField"], rest_name: str +) -> typing.Optional["_RestField"]: + try: + return next(rf for rf in attr_to_rest_field.values() if rf._rest_name == rest_name) + except StopIteration: + return None + + +def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typing.Any: + if not rf: + return _serialize(value, None) + if rf._is_multipart_file_input: + return value + if rf._is_model: + return _deserialize(rf._type, value) + if isinstance(value, ET.Element): + value = _deserialize(rf._type, value) + return _serialize(value, rf._format) + + +class Model(_MyMutableMapping): + _is_model = True + # label whether current class's _attr_to_rest_field has been calculated + # could not see _attr_to_rest_field directly because subclass inherits it from parent class + _calculated: typing.Set[str] = set() + + def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: + class_name = self.__class__.__name__ + if len(args) > 1: + raise TypeError(f"{class_name}.__init__() takes 2 positional arguments but {len(args) + 1} were given") + dict_to_pass = { + rest_field._rest_name: rest_field._default + for rest_field in self._attr_to_rest_field.values() + if rest_field._default is not _UNSET + } + if args: # pylint: disable=too-many-nested-blocks + if isinstance(args[0], ET.Element): + existed_attr_keys = [] + model_meta = getattr(self, "_xml", {}) + + for rf in self._attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + # attribute + if prop_meta.get("attribute", False) and args[0].get(xml_name) is not None: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].get(xml_name)) + continue + + # unwrapped element is array + if prop_meta.get("unwrapped", False): + # unwrapped array could either use prop items meta/prop meta + if prop_meta.get("itemsName"): + xml_name = prop_meta.get("itemsName") + xml_ns = prop_meta.get("itemNs") + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + items = args[0].findall(xml_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, items) + continue + + # text element is primitive type + if prop_meta.get("text", False): + if args[0].text is not None: + dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].text) + continue + + # wrapped element could be normal property or array, it should only have one element + item = args[0].find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, item) + + # rest thing is additional properties + for e in args[0]: + if e.tag not in existed_attr_keys: + dict_to_pass[e.tag] = _convert_element(e) + else: + dict_to_pass.update( + {k: _create_value(_get_rest_field(self._attr_to_rest_field, k), v) for k, v in args[0].items()} + ) + else: + non_attr_kwargs = [k for k in kwargs if k not in self._attr_to_rest_field] + if non_attr_kwargs: + # actual type errors only throw the first wrong keyword arg they see, so following that. + raise TypeError(f"{class_name}.__init__() got an unexpected keyword argument '{non_attr_kwargs[0]}'") + dict_to_pass.update( + { + self._attr_to_rest_field[k]._rest_name: _create_value(self._attr_to_rest_field[k], v) + for k, v in kwargs.items() + if v is not None + } + ) + super().__init__(dict_to_pass) + + def copy(self) -> "Model": + return Model(self.__dict__) + + def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: + if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated: + # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', + # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' + mros = cls.__mro__[:-9][::-1] # ignore parents, and reverse the mro order + attr_to_rest_field: typing.Dict[str, _RestField] = { # map attribute name to rest_field property + k: v for mro_class in mros for k, v in mro_class.__dict__.items() if k[0] != "_" and hasattr(v, "_type") + } + annotations = { + k: v + for mro_class in mros + if hasattr(mro_class, "__annotations__") + for k, v in mro_class.__annotations__.items() + } + for attr, rf in attr_to_rest_field.items(): + rf._module = cls.__module__ + if not rf._type: + rf._type = rf._get_deserialize_callable_from_annotation(annotations.get(attr, None)) + if not rf._rest_name_input: + rf._rest_name_input = attr + cls._attr_to_rest_field: typing.Dict[str, _RestField] = dict(attr_to_rest_field.items()) + cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") + + return super().__new__(cls) # pylint: disable=no-value-for-parameter + + def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: + for base in cls.__bases__: + if hasattr(base, "__mapping__"): + base.__mapping__[discriminator or cls.__name__] = cls # type: ignore + + @classmethod + def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]: + for v in cls.__dict__.values(): + if isinstance(v, _RestField) and v._is_discriminator and v._rest_name not in exist_discriminators: + return v + return None + + @classmethod + def _deserialize(cls, data, exist_discriminators): + if not hasattr(cls, "__mapping__"): + return cls(data) + discriminator = cls._get_discriminator(exist_discriminators) + if discriminator is None: + return cls(data) + exist_discriminators.append(discriminator._rest_name) + if isinstance(data, ET.Element): + model_meta = getattr(cls, "_xml", {}) + prop_meta = getattr(discriminator, "_xml", {}) + xml_name = prop_meta.get("name", discriminator._rest_name) + xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + if data.get(xml_name) is not None: + discriminator_value = data.get(xml_name) + else: + discriminator_value = data.find(xml_name).text # pyright: ignore + else: + discriminator_value = data.get(discriminator._rest_name) + mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore + return mapped_cls._deserialize(data, exist_discriminators) + + def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.Any]: + """Return a dict that can be turned into json using json.dump. + + :keyword bool exclude_readonly: Whether to remove the readonly properties. + :returns: A dict JSON compatible object + :rtype: dict + """ + + result = {} + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in self._attr_to_rest_field.values() if _is_readonly(p)] + for k, v in self.items(): + if exclude_readonly and k in readonly_props: # pyright: ignore + continue + is_multipart_file_input = False + try: + is_multipart_file_input = next( + rf for rf in self._attr_to_rest_field.values() if rf._rest_name == k + )._is_multipart_file_input + except StopIteration: + pass + result[k] = v if is_multipart_file_input else Model._as_dict_value(v, exclude_readonly=exclude_readonly) + return result + + @staticmethod + def _as_dict_value(v: typing.Any, exclude_readonly: bool = False) -> typing.Any: + if v is None or isinstance(v, _Null): + return None + if isinstance(v, (list, tuple, set)): + return type(v)(Model._as_dict_value(x, exclude_readonly=exclude_readonly) for x in v) + if isinstance(v, dict): + return {dk: Model._as_dict_value(dv, exclude_readonly=exclude_readonly) for dk, dv in v.items()} + return v.as_dict(exclude_readonly=exclude_readonly) if hasattr(v, "as_dict") else v + + +def _deserialize_model(model_deserializer: typing.Optional[typing.Callable], obj): + if _is_model(obj): + return obj + return _deserialize(model_deserializer, obj) + + +def _deserialize_with_optional(if_obj_deserializer: typing.Optional[typing.Callable], obj): + if obj is None: + return obj + return _deserialize_with_callable(if_obj_deserializer, obj) + + +def _deserialize_with_union(deserializers, obj): + for deserializer in deserializers: + try: + return _deserialize(deserializer, obj) + except DeserializationError: + pass + raise DeserializationError() + + +def _deserialize_dict( + value_deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj: typing.Dict[typing.Any, typing.Any], +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = {child.tag: child for child in obj} + return {k: _deserialize(value_deserializer, v, module) for k, v in obj.items()} + + +def _deserialize_multiple_sequence( + entry_deserializers: typing.List[typing.Optional[typing.Callable]], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers)) + + +def _deserialize_sequence( + deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = list(obj) + return type(obj)(_deserialize(deserializer, entry, module) for entry in obj) + + +def _sorted_annotations(types: typing.List[typing.Any]) -> typing.List[typing.Any]: + return sorted( + types, + key=lambda x: hasattr(x, "__name__") and x.__name__.lower() in ("str", "float", "int", "bool"), + ) + + +def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-branches + annotation: typing.Any, + module: typing.Optional[str], + rf: typing.Optional["_RestField"] = None, +) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + if not annotation: + return None + + # is it a type alias? + if isinstance(annotation, str): + if module is not None: + annotation = _get_type_alias_type(module, annotation) + + # is it a forward ref / in quotes? + if isinstance(annotation, (str, typing.ForwardRef)): + try: + model_name = annotation.__forward_arg__ # type: ignore + except AttributeError: + model_name = annotation + if module is not None: + annotation = _get_model(module, model_name) # type: ignore + + try: + if module and _is_model(annotation): + if rf: + rf._is_model = True + + return functools.partial(_deserialize_model, annotation) # pyright: ignore + except Exception: + pass + + # is it a literal? + try: + if annotation.__origin__ is typing.Literal: # pyright: ignore + return None + except AttributeError: + pass + + # is it optional? + try: + if any(a for a in annotation.__args__ if a == type(None)): # pyright: ignore + if len(annotation.__args__) <= 2: # pyright: ignore + if_obj_deserializer = _get_deserialize_callable_from_annotation( + next(a for a in annotation.__args__ if a != type(None)), module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_with_optional, if_obj_deserializer) + # the type is Optional[Union[...]], we need to remove the None type from the Union + annotation_copy = copy.copy(annotation) + annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a != type(None)] # pyright: ignore + return _get_deserialize_callable_from_annotation(annotation_copy, module, rf) + except AttributeError: + pass + + # is it union? + if getattr(annotation, "__origin__", None) is typing.Union: + # initial ordering is we make `string` the last deserialization option, because it is often them most generic + deserializers = [ + _get_deserialize_callable_from_annotation(arg, module, rf) + for arg in _sorted_annotations(annotation.__args__) # pyright: ignore + ] + + return functools.partial(_deserialize_with_union, deserializers) + + try: + if annotation._name == "Dict": # pyright: ignore + value_deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[1], module, rf # pyright: ignore + ) + + return functools.partial( + _deserialize_dict, + value_deserializer, + module, + ) + except (AttributeError, IndexError): + pass + try: + if annotation._name in ["List", "Set", "Tuple", "Sequence"]: # pyright: ignore + if len(annotation.__args__) > 1: # pyright: ignore + entry_deserializers = [ + _get_deserialize_callable_from_annotation(dt, module, rf) + for dt in annotation.__args__ # pyright: ignore + ] + return functools.partial(_deserialize_multiple_sequence, entry_deserializers, module) + deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[0], module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_sequence, deserializer, module) + except (TypeError, IndexError, AttributeError, SyntaxError): + pass + + def _deserialize_default( + deserializer, + obj, + ): + if obj is None: + return obj + try: + return _deserialize_with_callable(deserializer, obj) + except Exception: + pass + return obj + + if get_deserializer(annotation, rf): + return functools.partial(_deserialize_default, get_deserializer(annotation, rf)) + + return functools.partial(_deserialize_default, annotation) + + +def _deserialize_with_callable( + deserializer: typing.Optional[typing.Callable[[typing.Any], typing.Any]], + value: typing.Any, +): # pylint: disable=too-many-return-statements + try: + if value is None or isinstance(value, _Null): + return None + if isinstance(value, ET.Element): + if deserializer is str: + return value.text or "" + if deserializer is int: + return int(value.text) if value.text else None + if deserializer is float: + return float(value.text) if value.text else None + if deserializer is bool: + return value.text == "true" if value.text else None + if deserializer is None: + return value + if deserializer in [int, float, bool]: + return deserializer(value) + if isinstance(deserializer, CaseInsensitiveEnumMeta): + try: + return deserializer(value) + except ValueError: + # for unknown value, return raw value + return value + if isinstance(deserializer, type) and issubclass(deserializer, Model): + return deserializer._deserialize(value, []) + return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value) + except Exception as e: + raise DeserializationError() from e + + +def _deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + if isinstance(value, PipelineResponse): + value = value.http_response.json() + if rf is None and format: + rf = _RestField(format=format) + if not isinstance(deserializer, functools.partial): + deserializer = _get_deserialize_callable_from_annotation(deserializer, module, rf) + return _deserialize_with_callable(deserializer, value) + + +def _failsafe_deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + try: + return _deserialize(deserializer, value, module, rf, format) + except DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +def _failsafe_deserialize_xml( + deserializer: typing.Any, + value: typing.Any, +) -> typing.Any: + try: + return _deserialize_xml(deserializer, value) + except DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +class _RestField: + def __init__( + self, + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + is_discriminator: bool = False, + visibility: typing.Optional[typing.List[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[typing.Dict[str, typing.Any]] = None, + ): + self._type = type + self._rest_name_input = name + self._module: typing.Optional[str] = None + self._is_discriminator = is_discriminator + self._visibility = visibility + self._is_model = False + self._default = default + self._format = format + self._is_multipart_file_input = is_multipart_file_input + self._xml = xml if xml is not None else {} + + @property + def _class_type(self) -> typing.Any: + return getattr(self._type, "args", [None])[0] + + @property + def _rest_name(self) -> str: + if self._rest_name_input is None: + raise ValueError("Rest name was never set") + return self._rest_name_input + + def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin + # by this point, type and rest_name will have a value bc we default + # them in __new__ of the Model class + item = obj.get(self._rest_name) + if item is None: + return item + if self._is_model: + return item + return _deserialize(self._type, _serialize(item, self._format), rf=self) + + def __set__(self, obj: Model, value) -> None: + if value is None: + # we want to wipe out entries if users set attr to None + try: + obj.__delitem__(self._rest_name) + except KeyError: + pass + return + if self._is_model: + if not _is_model(value): + value = _deserialize(self._type, value) + obj.__setitem__(self._rest_name, value) + return + obj.__setitem__(self._rest_name, _serialize(value, self._format)) + + def _get_deserialize_callable_from_annotation( + self, annotation: typing.Any + ) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + return _get_deserialize_callable_from_annotation(annotation, self._module, self) + + +def rest_field( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[typing.List[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[typing.Dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField( + name=name, + type=type, + visibility=visibility, + default=default, + format=format, + is_multipart_file_input=is_multipart_file_input, + xml=xml, + ) + + +def rest_discriminator( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[typing.List[str]] = None, + xml: typing.Optional[typing.Dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField(name=name, type=type, is_discriminator=True, visibility=visibility, xml=xml) + + +def serialize_xml(model: Model, exclude_readonly: bool = False) -> str: + """Serialize a model to XML. + + :param Model model: The model to serialize. + :param bool exclude_readonly: Whether to exclude readonly properties. + :returns: The XML representation of the model. + :rtype: str + """ + return ET.tostring(_get_element(model, exclude_readonly), encoding="unicode") # type: ignore + + +def _get_element( + o: typing.Any, + exclude_readonly: bool = False, + parent_meta: typing.Optional[typing.Dict[str, typing.Any]] = None, + wrapped_element: typing.Optional[ET.Element] = None, +) -> typing.Union[ET.Element, typing.List[ET.Element]]: + if _is_model(o): + model_meta = getattr(o, "_xml", {}) + + # if prop is a model, then use the prop element directly, else generate a wrapper of model + if wrapped_element is None: + wrapped_element = _create_xml_element( + model_meta.get("name", o.__class__.__name__), + model_meta.get("prefix"), + model_meta.get("ns"), + ) + + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + + for k, v in o.items(): + # do not serialize readonly properties + if exclude_readonly and k in readonly_props: + continue + + prop_rest_field = _get_rest_field(o._attr_to_rest_field, k) + if prop_rest_field: + prop_meta = getattr(prop_rest_field, "_xml").copy() + # use the wire name as xml name if no specific name is set + if prop_meta.get("name") is None: + prop_meta["name"] = k + else: + # additional properties will not have rest field, use the wire name as xml name + prop_meta = {"name": k} + + # if no ns for prop, use model's + if prop_meta.get("ns") is None and model_meta.get("ns"): + prop_meta["ns"] = model_meta.get("ns") + prop_meta["prefix"] = model_meta.get("prefix") + + if prop_meta.get("unwrapped", False): + # unwrapped could only set on array + wrapped_element.extend(_get_element(v, exclude_readonly, prop_meta)) + elif prop_meta.get("text", False): + # text could only set on primitive type + wrapped_element.text = _get_primitive_type_value(v) + elif prop_meta.get("attribute", False): + xml_name = prop_meta.get("name", k) + if prop_meta.get("ns"): + ET.register_namespace(prop_meta.get("prefix"), prop_meta.get("ns")) # pyright: ignore + xml_name = "{" + prop_meta.get("ns") + "}" + xml_name # pyright: ignore + # attribute should be primitive type + wrapped_element.set(xml_name, _get_primitive_type_value(v)) + else: + # other wrapped prop element + wrapped_element.append(_get_wrapped_element(v, exclude_readonly, prop_meta)) + return wrapped_element + if isinstance(o, list): + return [_get_element(x, exclude_readonly, parent_meta) for x in o] # type: ignore + if isinstance(o, dict): + result = [] + for k, v in o.items(): + result.append( + _get_wrapped_element( + v, + exclude_readonly, + { + "name": k, + "ns": parent_meta.get("ns") if parent_meta else None, + "prefix": parent_meta.get("prefix") if parent_meta else None, + }, + ) + ) + return result + + # primitive case need to create element based on parent_meta + if parent_meta: + return _get_wrapped_element( + o, + exclude_readonly, + { + "name": parent_meta.get("itemsName", parent_meta.get("name")), + "prefix": parent_meta.get("itemsPrefix", parent_meta.get("prefix")), + "ns": parent_meta.get("itemsNs", parent_meta.get("ns")), + }, + ) + + raise ValueError("Could not serialize value into xml: " + o) + + +def _get_wrapped_element( + v: typing.Any, + exclude_readonly: bool, + meta: typing.Optional[typing.Dict[str, typing.Any]], +) -> ET.Element: + wrapped_element = _create_xml_element( + meta.get("name") if meta else None, meta.get("prefix") if meta else None, meta.get("ns") if meta else None + ) + if isinstance(v, (dict, list)): + wrapped_element.extend(_get_element(v, exclude_readonly, meta)) + elif _is_model(v): + _get_element(v, exclude_readonly, meta, wrapped_element) + else: + wrapped_element.text = _get_primitive_type_value(v) + return wrapped_element + + +def _get_primitive_type_value(v) -> str: + if v is True: + return "true" + if v is False: + return "false" + if isinstance(v, _Null): + return "" + return str(v) + + +def _create_xml_element(tag, prefix=None, ns=None): + if prefix and ns: + ET.register_namespace(prefix, ns) + if ns: + return ET.Element("{" + ns + "}" + tag) + return ET.Element(tag) + + +def _deserialize_xml( + deserializer: typing.Any, + value: str, +) -> typing.Any: + element = ET.fromstring(value) # nosec + return _deserialize(deserializer, element) + + +def _convert_element(e: ET.Element): + # dict case + if len(e.attrib) > 0 or len({child.tag for child in e}) > 1: + dict_result: typing.Dict[str, typing.Any] = {} + for child in e: + if dict_result.get(child.tag) is not None: + if isinstance(dict_result[child.tag], list): + dict_result[child.tag].append(_convert_element(child)) + else: + dict_result[child.tag] = [dict_result[child.tag], _convert_element(child)] + else: + dict_result[child.tag] = _convert_element(child) + dict_result.update(e.attrib) + return dict_result + # array case + if len(e) > 0: + array_result: typing.List[typing.Any] = [] + for child in e: + array_result.append(_convert_element(child)) + return array_result + # primitive case + return e.text diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_operations/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_operations/__init__.py new file mode 100644 index 00000000000..f9c721d92b6 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_operations/__init__.py @@ -0,0 +1,25 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import HeaderClientOperationsMixin # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "HeaderClientOperationsMixin", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_operations/_operations.py new file mode 100644 index 00000000000..75e2cff2876 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_operations/_operations.py @@ -0,0 +1,96 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict + +from .._serialization import Serializer +from .._vendor import HeaderClientMixinABC + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_header_header_api_version_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + version: str = kwargs.pop("version", _headers.pop("x-ms-version", "2025-01-01")) + # Construct URL + _url = "/azure/client-generator-core/api-version/header" + + # Construct headers + _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") + + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + + +class HeaderClientOperationsMixin(HeaderClientMixinABC): + + @distributed_trace + def header_api_version(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """Header api version parameter. + + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_header_header_api_version_request( + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_operations/_patch.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_operations/_patch.py new file mode 100644 index 00000000000..f7dd3251033 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_patch.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_patch.py new file mode 100644 index 00000000000..f7dd3251033 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_serialization.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_serialization.py new file mode 100644 index 00000000000..a066e16a64d --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_serialization.py @@ -0,0 +1,2050 @@ +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# 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. +# +# -------------------------------------------------------------------------- + +# pyright: reportUnnecessaryTypeIgnoreComment=false + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +from typing import ( + Dict, + Any, + cast, + Optional, + Union, + AnyStr, + IO, + Mapping, + Callable, + MutableMapping, + List, +) + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote +import xml.etree.ElementTree as ET + +import isodate # type: ignore +from typing_extensions import Self + +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +JSON = MutableMapping[str, Any] + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + :return: The deserialized data. + :rtype: object + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) from err + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError as err: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str + raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + + :param bytes body_bytes: The body of the response. + :param dict headers: The headers of the response. + :returns: The deserialized data. + :rtype: object + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + +TZ_UTC = datetime.timezone.utc + +_FLATTEN = re.compile(r"(? None: + self.additional_properties: Optional[Dict[str, Any]] = {} + for k in kwargs: # pylint: disable=consider-using-dict-items + if k not in self._attribute_map: + _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) + elif k in self._validation and self._validation[k].get("readonly", False): + _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) + else: + setattr(self, k, kwargs[k]) + + def __eq__(self, other: Any) -> bool: + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are equal + :rtype: bool + """ + if isinstance(other, self.__class__): + return self.__dict__ == other.__dict__ + return False + + def __ne__(self, other: Any) -> bool: + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are not equal + :rtype: bool + """ + return not self.__eq__(other) + + def __str__(self) -> str: + return str(self.__dict__) + + @classmethod + def enable_additional_properties_sending(cls) -> None: + cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} + + @classmethod + def is_xml_model(cls) -> bool: + try: + cls._xml_map # type: ignore + except AttributeError: + return False + return True + + @classmethod + def _create_xml_node(cls): + """Create XML node. + + :returns: The XML node + :rtype: xml.etree.ElementTree.Element + """ + try: + xml_map = cls._xml_map # type: ignore + except AttributeError: + xml_map = {} + + return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) + + def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: + """Return the JSON that would be sent to server from this model. + + This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param bool keep_readonly: If you want to serialize the readonly attributes + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, keep_readonly=keep_readonly, **kwargs + ) + + def as_dict( + self, + keep_readonly: bool = True, + key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + **kwargs: Any + ) -> JSON: + """Return a dict that can be serialized using json.dump. + + Advanced usage might optionally use a callback as parameter: + + .. code::python + + def my_key_transformer(key, attr_desc, value): + return key + + Key is the attribute name used in Python. Attr_desc + is a dict of metadata. Currently contains 'type' with the + msrest type and 'key' with the RestAPI encoded key. + Value is the current value in this object. + + The string returned will be used to serialize the key. + If the return type is a list, this is considered hierarchical + result dict. + + See the three examples in this file: + + - attribute_transformer + - full_restapi_key_transformer + - last_restapi_key_transformer + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param bool keep_readonly: If you want to serialize the readonly attributes + :param function key_transformer: A key transformer function. + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs + ) + + @classmethod + def _infer_class_models(cls): + try: + str_models = cls.__module__.rsplit(".", 1)[0] + models = sys.modules[str_models] + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + if cls.__name__ not in client_models: + raise ValueError("Not Autorest generated code") + except Exception: # pylint: disable=broad-exception-caught + # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. + client_models = {cls.__name__: cls} + return client_models + + @classmethod + def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: + """Parse a str using the RestAPI syntax and return a model. + + :param str data: A str using RestAPI structure. JSON by default. + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises DeserializationError: if something went wrong + :rtype: Self + """ + deserializer = Deserializer(cls._infer_class_models()) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore + + @classmethod + def from_dict( + cls, + data: Any, + key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + content_type: Optional[str] = None, + ) -> Self: + """Parse a dict using given key extractor return a model. + + By default consider key + extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor + and last_rest_key_case_insensitive_extractor) + + :param dict data: A dict using RestAPI structure + :param function key_extractors: A key extractor function. + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises: DeserializationError if something went wrong + :rtype: Self + """ + deserializer = Deserializer(cls._infer_class_models()) + deserializer.key_extractors = ( # type: ignore + [ # type: ignore + attribute_key_case_insensitive_extractor, + rest_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + if key_extractors is None + else key_extractors + ) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore + + @classmethod + def _flatten_subtype(cls, key, objects): + if "_subtype_map" not in cls.__dict__: + return {} + result = dict(cls._subtype_map[key]) + for valuetype in cls._subtype_map[key].values(): + result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access + return result + + @classmethod + def _classify(cls, response, objects): + """Check the class _subtype_map for any child classes. + We want to ignore any inherited _subtype_maps. + + :param dict response: The initial data + :param dict objects: The class objects + :returns: The class to be used + :rtype: class + """ + for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): + subtype_value = None + + if not isinstance(response, ET.Element): + rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] + subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) + else: + subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) + if subtype_value: + # Try to match base class. Can be class name only + # (bug to fix in Autorest to support x-ms-discriminator-name) + if cls.__name__ == subtype_value: + return cls + flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) + try: + return objects[flatten_mapping_type[subtype_value]] # type: ignore + except KeyError: + _LOGGER.warning( + "Subtype value %s has no mapping, use base class %s.", + subtype_value, + cls.__name__, + ) + break + else: + _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) + break + return cls + + @classmethod + def _get_rest_key_parts(cls, attr_key): + """Get the RestAPI key of this attr, split it and decode part + :param str attr_key: Attribute key must be in attribute_map. + :returns: A list of RestAPI part + :rtype: list + """ + rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) + return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] + + +def _decode_attribute_map_key(key): + """This decode a key in an _attribute_map to the actual key we want to look at + inside the received data. + + :param str key: A key string from the generated code + :returns: The decoded key + :rtype: str + """ + return key.replace("\\.", ".") + + +class Serializer: # pylint: disable=too-many-public-methods + """Request object model serializer.""" + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} + days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} + months = { + 1: "Jan", + 2: "Feb", + 3: "Mar", + 4: "Apr", + 5: "May", + 6: "Jun", + 7: "Jul", + 8: "Aug", + 9: "Sep", + 10: "Oct", + 11: "Nov", + 12: "Dec", + } + validation = { + "min_length": lambda x, y: len(x) < y, + "max_length": lambda x, y: len(x) > y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals + self, target_obj, data_type=None, **kwargs + ): + """Serialize data into a string according to type. + + :param object target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises SerializationError: if serialization fails. + :returns: The serialized data. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() # pylint: disable=protected-access + try: + attributes = target_obj._attribute_map # pylint: disable=protected-access + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access + attr_name, {} + ).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) # type: ignore + continue + if xml_desc.get("text", False): + serialized.text = new_attr # type: ignore + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) # type: ignore + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, + # we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) # type: ignore + else: # That's a basic type + # Integrate namespace if necessary + local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) + local_node.text = str(new_attr) + serialized.append(local_node) # type: ignore + else: # JSON + for k in reversed(keys): # type: ignore + new_attr = {k: new_attr} + + _new_attr = new_attr + _serialized = serialized + for k in keys: # type: ignore + if k not in _serialized: + _serialized.update(_new_attr) # type: ignore + _new_attr = _new_attr[k] # type: ignore + _serialized = _serialized[k] + except ValueError as err: + if isinstance(err, SerializationError): + raise + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) + raise SerializationError(msg) from err + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises SerializationError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized request body + """ + + # Just in case this is a dict + internal_data_type_str = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type_str, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ # type: ignore + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access + except DeserializationError as err: + raise SerializationError("Unable to build a model: " + str(err)) from err + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param str name: The name of the URL path parameter. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :returns: The serialized URL path + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) + else: + output = quote(str(output), safe="") + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param str name: The name of the query parameter. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, list + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized query parameter + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + do_quote = not kwargs.get("skip_quote", False) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param str name: The name of the header. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized header + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :raises AttributeError: if required data is None. + :raises ValueError: if data is None + :raises SerializationError: if serialization fails. + :returns: The serialized data. + :rtype: str, int, float, bool, dict, list + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data is CoreNull: + return None + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + if data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise SerializationError(msg.format(data, data_type)) from err + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param obj data: Object to be serialized. + :param str data_type: Type of object in the iterable. + :rtype: str, int, float, bool + :return: serialized object + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == "str": + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec # pylint: disable=eval-used + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param str data: Object to be serialized. + :rtype: str + :return: serialized object + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): # type: ignore + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list data: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + Defaults to False. + :rtype: list, str + :return: serialized iterable + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError as err: + if isinstance(err, SerializationError): + raise + serialized.append(None) + + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + + if div: + serialized = ["" if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :rtype: dict + :return: serialized dictionary + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError as err: + if isinstance(err, SerializationError): + raise + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + :return: serialized object + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + if obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) # type: ignore + return result + except ValueError as exc: + for enum_value in enum_obj: # type: ignore + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) from exc + + @staticmethod + def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument + """Serialize bytearray into base-64 string. + + :param str attr: Object to be serialized. + :rtype: str + :return: serialized base64 + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument + """Serialize str into base-64 string. + + :param str attr: Object to be serialized. + :rtype: str + :return: serialized base64 + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Decimal object to float. + + :param decimal attr: Object to be serialized. + :rtype: float + :return: serialized decimal + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): # pylint: disable=unused-argument + """Serialize long (Py2) or int (Py3). + + :param int attr: Object to be serialized. + :rtype: int/long + :return: serialized long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + :return: serialized date + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + :return: serialized time + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + :return: serialized duration + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises TypeError: if format invalid. + :return: serialized rfc + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError as exc: + raise TypeError("RFC1123 object must be valid Datetime object.") from exc + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises SerializationError: if format invalid. + :return: serialized iso + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise SerializationError(msg) from err + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise TypeError(msg) from err + + @staticmethod + def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises SerializationError: if format invalid + :return: serialied unix + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError as exc: + raise TypeError("Unix time object must be valid Datetime object.") from exc + + +def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + key = attr_desc["key"] + working_data = data + + while "." in key: + # Need the cast, as for some reasons "split" is typed as list[str | Any] + dict_keys = cast(List[str], _FLATTEN.split(key)) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + return None + key = ".".join(dict_keys[1:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements + attr, attr_desc, data +): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + return None + key = ".".join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get("name", internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer: + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.key_extractors = [rest_key_extractor, xml_key_extractor] + # Additional properties only works if the "rest_key_extractor" is used to + # extract the keys. Making it to work whatever the key extractor is too much + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, str): + return self.deserialize_data(data, response) + if isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None or data is CoreNull: + return data + try: + attributes = response._attribute_map # type: ignore # pylint: disable=protected-access + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc["type"]) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name # type: ignore + raise DeserializationError(msg) from err + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + :return: The classified target object and its class name. + :rtype: tuple + """ + if target is None: + return None, None + + if isinstance(target, str): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ # type: ignore + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + :param str content_type: Swagger "produces" if available. + :return: Deserialized object. + :rtype: object + """ + try: + return self(target_obj, data, content_type=content_type) + except: # pylint: disable=bare-except + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param obj raw_data: Data to be processed. + :param str content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + :rtype: object + :return: Unpacked content. + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, "_content_consumed"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) + + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param Response response: The response model class. + :param dict attrs: The deserialized response attributes. + :param dict additional_properties: Additional properties to be set. + :rtype: Response + :return: The instantiated response model. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("readonly") + ] + const = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("constant") + ] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties # type: ignore + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore + raise DeserializationError(msg + str(err)) from err + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) from exp + + def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment + "object", + "[]", + r"{}", + ] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise DeserializationError(msg) from err + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :return: Deserialized iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :return: Deserialized dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :return: Deserialized object. + :rtype: dict + :raises TypeError: if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, str): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :return: Deserialized basic type. + :rtype: str, int, float or bool + :raises TypeError: if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + if isinstance(attr, str): + if attr.lower() in ["true", "1"]: + return True + if attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec # pylint: disable=eval-used + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :return: Deserialized string. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): # type: ignore + return data + except NameError: + return str(data) + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :return: Deserialized enum object. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + try: + return list(enum_obj.__members__.values())[data] + except IndexError as exc: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) from exc + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :return: Deserialized bytearray + :rtype: bytearray + :raises TypeError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) # type: ignore + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :return: Deserialized base64 string + :rtype: bytearray + :raises TypeError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :return: Deserialized decimal + :raises DeserializationError: if string format invalid. + :rtype: decimal + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(str(attr)) # type: ignore + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise DeserializationError(msg) from err + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :return: Deserialized int + :rtype: long or int + :raises ValueError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) # type: ignore + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :return: Deserialized duration + :rtype: TimeDelta + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise DeserializationError(msg) from err + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :return: Deserialized date + :rtype: Date + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :return: Deserialized time + :rtype: datetime.time + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :return: Deserialized RFC datetime + :rtype: Datetime + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) # type: ignore + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise DeserializationError(msg) from err + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :return: Deserialized ISO datetime + :rtype: Datetime + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() # type: ignore + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise DeserializationError(msg) from err + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :return: Deserialized datetime + :rtype: Datetime + :raises DeserializationError: if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) # type: ignore + try: + attr = int(attr) + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise DeserializationError(msg) from err + return date_obj diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_vendor.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_vendor.py new file mode 100644 index 00000000000..ef95074c5c9 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_vendor.py @@ -0,0 +1,25 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from ._configuration import HeaderClientConfiguration + +if TYPE_CHECKING: + from azure.core import PipelineClient + + from ._serialization import Deserializer, Serializer + + +class HeaderClientMixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "PipelineClient" + _config: HeaderClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_version.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_version.py new file mode 100644 index 00000000000..be71c81bd28 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_version.py @@ -0,0 +1,9 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/__init__.py new file mode 100644 index 00000000000..6107d5900e3 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/__init__.py @@ -0,0 +1,29 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import HeaderClient # type: ignore + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "HeaderClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore + +_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_client.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_client.py new file mode 100644 index 00000000000..1a9b26f9efe --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_client.py @@ -0,0 +1,96 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable +from typing_extensions import Self + +from azure.core import AsyncPipelineClient +from azure.core.pipeline import policies +from azure.core.rest import AsyncHttpResponse, HttpRequest + +from .._serialization import Deserializer, Serializer +from ._configuration import HeaderClientConfiguration +from ._operations import HeaderClientOperationsMixin + + +class HeaderClient(HeaderClientOperationsMixin): + """HeaderClient. + + :keyword endpoint: Service host. Default value is "http://localhost:3000". + :paramtype endpoint: str + :keyword version: Default value is "2025-01-01". Note that overriding this default value may + result in unsupported behavior. + :paramtype version: str + """ + + def __init__( # pylint: disable=missing-client-constructor-parameter-credential + self, *, endpoint: str = "http://localhost:3000", **kwargs: Any + ) -> None: + _endpoint = "{endpoint}" + self._config = HeaderClientConfiguration(endpoint=endpoint, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncPipelineClient = AsyncPipelineClient(base_url=_endpoint, policies=_policies, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + + def send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> Self: + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_configuration.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_configuration.py new file mode 100644 index 00000000000..e6dff658177 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_configuration.py @@ -0,0 +1,47 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any + +from azure.core.pipeline import policies + +from .._version import VERSION + + +class HeaderClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for HeaderClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: Service host. Default value is "http://localhost:3000". + :type endpoint: str + :keyword version: Default value is "2025-01-01". Note that overriding this default value may + result in unsupported behavior. + :paramtype version: str + """ + + def __init__(self, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None: + version: str = kwargs.pop("version", "2025-01-01") + + self.endpoint = endpoint + self.version = version + kwargs.setdefault("sdk_moniker", "client-alternateapiversion-service-header/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_operations/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_operations/__init__.py new file mode 100644 index 00000000000..f9c721d92b6 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_operations/__init__.py @@ -0,0 +1,25 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import HeaderClientOperationsMixin # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "HeaderClientOperationsMixin", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_operations/_operations.py new file mode 100644 index 00000000000..cb976363d03 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_operations/_operations.py @@ -0,0 +1,79 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async + +from ..._operations._operations import build_header_header_api_version_request +from .._vendor import HeaderClientMixinABC + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class HeaderClientOperationsMixin(HeaderClientMixinABC): + + @distributed_trace_async + async def header_api_version(self, **kwargs: Any) -> None: + """Header api version parameter. + + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_header_header_api_version_request( + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_operations/_patch.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_operations/_patch.py new file mode 100644 index 00000000000..f7dd3251033 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_patch.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_patch.py new file mode 100644 index 00000000000..f7dd3251033 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_vendor.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_vendor.py new file mode 100644 index 00000000000..5dabe25fe75 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_vendor.py @@ -0,0 +1,25 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from ._configuration import HeaderClientConfiguration + +if TYPE_CHECKING: + from azure.core import AsyncPipelineClient + + from .._serialization import Deserializer, Serializer + + +class HeaderClientMixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "AsyncPipelineClient" + _config: HeaderClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/py.typed b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/dev_requirements.txt b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/dev_requirements.txt new file mode 100644 index 00000000000..10548647144 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/dev_requirements.txt @@ -0,0 +1,3 @@ +-e ../../../tools/azure-sdk-tools +../../core/azure-core +aiohttp \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/conftest.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/conftest.py new file mode 100644 index 00000000000..e23f2f3a90f --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/conftest.py @@ -0,0 +1,35 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# For security, please avoid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + header_subscription_id = os.environ.get("HEADER_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + header_tenant_id = os.environ.get("HEADER_TENANT_ID", "00000000-0000-0000-0000-000000000000") + header_client_id = os.environ.get("HEADER_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + header_client_secret = os.environ.get("HEADER_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=header_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=header_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=header_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=header_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/test_header.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/test_header.py new file mode 100644 index 00000000000..1b1f4435135 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/test_header.py @@ -0,0 +1,22 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from devtools_testutils import recorded_by_proxy +from testpreparer import HeaderClientTestBase, HeaderPreparer + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestHeader(HeaderClientTestBase): + @HeaderPreparer() + @recorded_by_proxy + def test_header_api_version(self, header_endpoint): + client = self.create_client(endpoint=header_endpoint) + response = client.header_api_version() + + # please add some check logic here by yourself + # ... diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/test_header_async.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/test_header_async.py new file mode 100644 index 00000000000..617bceb8515 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/test_header_async.py @@ -0,0 +1,23 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from devtools_testutils.aio import recorded_by_proxy_async +from testpreparer import HeaderPreparer +from testpreparer_async import HeaderClientTestBaseAsync + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestHeaderAsync(HeaderClientTestBaseAsync): + @HeaderPreparer() + @recorded_by_proxy_async + async def test_header_api_version(self, header_endpoint): + client = self.create_async_client(endpoint=header_endpoint) + response = await client.header_api_version() + + # please add some check logic here by yourself + # ... diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/testpreparer.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/testpreparer.py new file mode 100644 index 00000000000..7d5c99b5138 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/testpreparer.py @@ -0,0 +1,24 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from client.alternateapiversion.service.header import HeaderClient +from devtools_testutils import AzureRecordedTestCase, PowerShellPreparer +import functools + + +class HeaderClientTestBase(AzureRecordedTestCase): + + def create_client(self, endpoint): + credential = self.get_credential(HeaderClient) + return self.create_client_from_credential( + HeaderClient, + credential=credential, + endpoint=endpoint, + ) + + +HeaderPreparer = functools.partial(PowerShellPreparer, "header", header_endpoint="https://fake_header_endpoint.com") diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/testpreparer_async.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/testpreparer_async.py new file mode 100644 index 00000000000..beb3a02c59a --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/testpreparer_async.py @@ -0,0 +1,20 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from client.alternateapiversion.service.header.aio import HeaderClient +from devtools_testutils import AzureRecordedTestCase + + +class HeaderClientTestBaseAsync(AzureRecordedTestCase): + + def create_async_client(self, endpoint): + credential = self.get_credential(HeaderClient, is_async=True) + return self.create_client_from_credential( + HeaderClient, + credential=credential, + endpoint=endpoint, + ) diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/setup.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/setup.py new file mode 100644 index 00000000000..78f636396b6 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/setup.py @@ -0,0 +1,72 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# coding: utf-8 + +import os +import re +from setuptools import setup, find_packages + + +PACKAGE_NAME = "client-alternateapiversion-service-header" +PACKAGE_PPRINT_NAME = "Client Alternateapiversion Service Header" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace("-", "/") + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, "_version.py"), "r") as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError("Cannot find version information") + + +setup( + name=PACKAGE_NAME, + version=version, + description="Microsoft {} Client Library for Python".format(PACKAGE_PPRINT_NAME), + long_description=open("README.md", "r").read(), + long_description_content_type="text/markdown", + license="MIT License", + author="Microsoft Corporation", + author_email="azpysdkhelp@microsoft.com", + url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk", + keywords="azure, azure sdk", + classifiers=[ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "License :: OSI Approved :: MIT License", + ], + zip_safe=False, + packages=find_packages( + exclude=[ + "tests", + # Exclude packages that will be covered by PEP420 or nspkg + "client", + "client.alternateapiversion", + "client.alternateapiversion.service", + ] + ), + include_package_data=True, + package_data={ + "client.alternateapiversion.service.header": ["py.typed"], + }, + install_requires=[ + "isodate>=0.6.1", + "azure-core>=1.30.0", + "typing-extensions>=4.6.0", + ], + python_requires=">=3.8", +) diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/CHANGELOG.md b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/CHANGELOG.md new file mode 100644 index 00000000000..628743d283a --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0b1 (1970-01-01) + +- Initial version diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/LICENSE b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/LICENSE new file mode 100644 index 00000000000..63447fd8bbb --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/LICENSE @@ -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. \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/MANIFEST.in b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/MANIFEST.in new file mode 100644 index 00000000000..5c683e9f9a3 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/MANIFEST.in @@ -0,0 +1,8 @@ +include *.md +include LICENSE +include client/alternateapiversion/service/path/py.typed +recursive-include tests *.py +recursive-include samples *.py *.md +include client/__init__.py +include client/alternateapiversion/__init__.py +include client/alternateapiversion/service/__init__.py \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/README.md b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/README.md new file mode 100644 index 00000000000..b25a7a5c82b --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/README.md @@ -0,0 +1,45 @@ + + +# Client Alternateapiversion Service Path client library for Python + + +## Getting started + +### Install the package + +```bash +python -m pip install client-alternateapiversion-service-path +``` + +#### 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 Client Alternateapiversion Service Path 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 opencode@microsoft.com with any +additional questions or comments. + + +[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/ + diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/apiview-properties.json b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/apiview-properties.json new file mode 100644 index 00000000000..342d9f29e28 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/apiview-properties.json @@ -0,0 +1,6 @@ +{ + "CrossLanguagePackageId": "Client.AlternateApiVersion.Service.Path", + "CrossLanguageDefinitionId": { + "client.alternateapiversion.service.path.PathClient.path_api_version": "Client.AlternateApiVersion.Service.Path.pathApiVersion" + } +} \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/__init__.py new file mode 100644 index 00000000000..d55ccad1f57 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/__init__.py new file mode 100644 index 00000000000..d55ccad1f57 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/__init__.py new file mode 100644 index 00000000000..d55ccad1f57 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/__init__.py new file mode 100644 index 00000000000..2b63a50720f --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/__init__.py @@ -0,0 +1,32 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import PathClient # type: ignore +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "PathClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore + +_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_client.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_client.py new file mode 100644 index 00000000000..cbbd2c51152 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_client.py @@ -0,0 +1,94 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any +from typing_extensions import Self + +from azure.core import PipelineClient +from azure.core.pipeline import policies +from azure.core.rest import HttpRequest, HttpResponse + +from ._configuration import PathClientConfiguration +from ._operations import PathClientOperationsMixin +from ._serialization import Deserializer, Serializer + + +class PathClient(PathClientOperationsMixin): + """PathClient. + + :keyword endpoint: Service host. Default value is "http://localhost:3000". + :paramtype endpoint: str + :keyword version: Default value is "2025-01-01". Note that overriding this default value may + result in unsupported behavior. + :paramtype version: str + """ + + def __init__( # pylint: disable=missing-client-constructor-parameter-credential + self, *, endpoint: str = "http://localhost:3000", **kwargs: Any + ) -> None: + _endpoint = "{endpoint}" + self._config = PathClientConfiguration(endpoint=endpoint, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> Self: + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_configuration.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_configuration.py new file mode 100644 index 00000000000..41b5eaf919b --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_configuration.py @@ -0,0 +1,47 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any + +from azure.core.pipeline import policies + +from ._version import VERSION + + +class PathClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for PathClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: Service host. Default value is "http://localhost:3000". + :type endpoint: str + :keyword version: Default value is "2025-01-01". Note that overriding this default value may + result in unsupported behavior. + :paramtype version: str + """ + + def __init__(self, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None: + version: str = kwargs.pop("version", "2025-01-01") + + self.endpoint = endpoint + self.version = version + kwargs.setdefault("sdk_moniker", "client-alternateapiversion-service-path/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_model_base.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_model_base.py new file mode 100644 index 00000000000..3072ee252ed --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_model_base.py @@ -0,0 +1,1235 @@ +# pylint: disable=too-many-lines +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access, broad-except + +import copy +import calendar +import decimal +import functools +import sys +import logging +import base64 +import re +import typing +import enum +import email.utils +from datetime import datetime, date, time, timedelta, timezone +from json import JSONEncoder +import xml.etree.ElementTree as ET +from typing_extensions import Self +import isodate +from azure.core.exceptions import DeserializationError +from azure.core import CaseInsensitiveEnumMeta +from azure.core.pipeline import PipelineResponse +from azure.core.serialization import _Null + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping + +_LOGGER = logging.getLogger(__name__) + +__all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] + +TZ_UTC = timezone.utc +_T = typing.TypeVar("_T") + + +def _timedelta_as_isostr(td: timedelta) -> str: + """Converts a datetime.timedelta object into an ISO 8601 formatted string, e.g. 'P4DT12H30M05S' + + Function adapted from the Tin Can Python project: https://github.com/RusticiSoftware/TinCanPython + + :param timedelta td: The timedelta to convert + :rtype: str + :return: ISO8601 version of this timedelta + """ + + # Split seconds to larger units + seconds = td.total_seconds() + minutes, seconds = divmod(seconds, 60) + hours, minutes = divmod(minutes, 60) + days, hours = divmod(hours, 24) + + days, hours, minutes = list(map(int, (days, hours, minutes))) + seconds = round(seconds, 6) + + # Build date + date_str = "" + if days: + date_str = "%sD" % days + + if hours or minutes or seconds: + # Build time + time_str = "T" + + # Hours + bigger_exists = date_str or hours + if bigger_exists: + time_str += "{:02}H".format(hours) + + # Minutes + bigger_exists = bigger_exists or minutes + if bigger_exists: + time_str += "{:02}M".format(minutes) + + # Seconds + try: + if seconds.is_integer(): + seconds_string = "{:02}".format(int(seconds)) + else: + # 9 chars long w/ leading 0, 6 digits after decimal + seconds_string = "%09.6f" % seconds + # Remove trailing zeros + seconds_string = seconds_string.rstrip("0") + except AttributeError: # int.is_integer() raises + seconds_string = "{:02}".format(seconds) + + time_str += "{}S".format(seconds_string) + else: + time_str = "" + + return "P" + date_str + time_str + + +def _serialize_bytes(o, format: typing.Optional[str] = None) -> str: + encoded = base64.b64encode(o).decode() + if format == "base64url": + return encoded.strip("=").replace("+", "-").replace("/", "_") + return encoded + + +def _serialize_datetime(o, format: typing.Optional[str] = None): + if hasattr(o, "year") and hasattr(o, "hour"): + if format == "rfc7231": + return email.utils.format_datetime(o, usegmt=True) + if format == "unix-timestamp": + return int(calendar.timegm(o.utctimetuple())) + + # astimezone() fails for naive times in Python 2.7, so make make sure o is aware (tzinfo is set) + if not o.tzinfo: + iso_formatted = o.replace(tzinfo=TZ_UTC).isoformat() + else: + iso_formatted = o.astimezone(TZ_UTC).isoformat() + # Replace the trailing "+00:00" UTC offset with "Z" (RFC 3339: https://www.ietf.org/rfc/rfc3339.txt) + return iso_formatted.replace("+00:00", "Z") + # Next try datetime.date or datetime.time + return o.isoformat() + + +def _is_readonly(p): + try: + return p._visibility == ["read"] + except AttributeError: + return False + + +class SdkJSONEncoder(JSONEncoder): + """A JSON encoder that's capable of serializing datetime objects and bytes.""" + + def __init__(self, *args, exclude_readonly: bool = False, format: typing.Optional[str] = None, **kwargs): + super().__init__(*args, **kwargs) + self.exclude_readonly = exclude_readonly + self.format = format + + def default(self, o): # pylint: disable=too-many-return-statements + if _is_model(o): + if self.exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + return {k: v for k, v in o.items() if k not in readonly_props} + return dict(o.items()) + try: + return super(SdkJSONEncoder, self).default(o) + except TypeError: + if isinstance(o, _Null): + return None + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, self.format) + try: + # First try datetime.datetime + return _serialize_datetime(o, self.format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return super(SdkJSONEncoder, self).default(o) + + +_VALID_DATE = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" + r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") +_VALID_RFC7231 = re.compile( + r"(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s\d{2}\s" + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT" +) + + +def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + attr = attr.upper() + match = _VALID_DATE.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + return date_obj + + +def _deserialize_datetime_rfc7231(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize RFC7231 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + match = _VALID_RFC7231.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + return email.utils.parsedate_to_datetime(attr) + + +def _deserialize_datetime_unix_timestamp(attr: typing.Union[float, datetime]) -> datetime: + """Deserialize unix timestamp into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + return datetime.fromtimestamp(attr, TZ_UTC) + + +def _deserialize_date(attr: typing.Union[str, date]) -> date: + """Deserialize ISO-8601 formatted string into Date object. + :param str attr: response string to be deserialized. + :rtype: date + :returns: The date object from that input + """ + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + if isinstance(attr, date): + return attr + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) # type: ignore + + +def _deserialize_time(attr: typing.Union[str, time]) -> time: + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :returns: The time object from that input + """ + if isinstance(attr, time): + return attr + return isodate.parse_time(attr) + + +def _deserialize_bytes(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + return bytes(base64.b64decode(attr)) + + +def _deserialize_bytes_base64(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return bytes(base64.b64decode(encoded)) + + +def _deserialize_duration(attr): + if isinstance(attr, timedelta): + return attr + return isodate.parse_duration(attr) + + +def _deserialize_decimal(attr): + if isinstance(attr, decimal.Decimal): + return attr + return decimal.Decimal(str(attr)) + + +def _deserialize_int_as_str(attr): + if isinstance(attr, int): + return attr + return int(attr) + + +_DESERIALIZE_MAPPING = { + datetime: _deserialize_datetime, + date: _deserialize_date, + time: _deserialize_time, + bytes: _deserialize_bytes, + bytearray: _deserialize_bytes, + timedelta: _deserialize_duration, + typing.Any: lambda x: x, + decimal.Decimal: _deserialize_decimal, +} + +_DESERIALIZE_MAPPING_WITHFORMAT = { + "rfc3339": _deserialize_datetime, + "rfc7231": _deserialize_datetime_rfc7231, + "unix-timestamp": _deserialize_datetime_unix_timestamp, + "base64": _deserialize_bytes, + "base64url": _deserialize_bytes_base64, +} + + +def get_deserializer(annotation: typing.Any, rf: typing.Optional["_RestField"] = None): + if annotation is int and rf and rf._format == "str": + return _deserialize_int_as_str + if rf and rf._format: + return _DESERIALIZE_MAPPING_WITHFORMAT.get(rf._format) + return _DESERIALIZE_MAPPING.get(annotation) # pyright: ignore + + +def _get_type_alias_type(module_name: str, alias_name: str): + types = { + k: v + for k, v in sys.modules[module_name].__dict__.items() + if isinstance(v, typing._GenericAlias) # type: ignore + } + if alias_name not in types: + return alias_name + return types[alias_name] + + +def _get_model(module_name: str, model_name: str): + models = {k: v for k, v in sys.modules[module_name].__dict__.items() if isinstance(v, type)} + module_end = module_name.rsplit(".", 1)[0] + models.update({k: v for k, v in sys.modules[module_end].__dict__.items() if isinstance(v, type)}) + if isinstance(model_name, str): + model_name = model_name.split(".")[-1] + if model_name not in models: + return model_name + return models[model_name] + + +_UNSET = object() + + +class _MyMutableMapping(MutableMapping[str, typing.Any]): # pylint: disable=unsubscriptable-object + def __init__(self, data: typing.Dict[str, typing.Any]) -> None: + self._data = data + + def __contains__(self, key: typing.Any) -> bool: + return key in self._data + + def __getitem__(self, key: str) -> typing.Any: + return self._data.__getitem__(key) + + def __setitem__(self, key: str, value: typing.Any) -> None: + self._data.__setitem__(key, value) + + def __delitem__(self, key: str) -> None: + self._data.__delitem__(key) + + def __iter__(self) -> typing.Iterator[typing.Any]: + return self._data.__iter__() + + def __len__(self) -> int: + return self._data.__len__() + + def __ne__(self, other: typing.Any) -> bool: + return not self.__eq__(other) + + def keys(self) -> typing.KeysView[str]: + """ + :returns: a set-like object providing a view on D's keys + :rtype: ~typing.KeysView + """ + return self._data.keys() + + def values(self) -> typing.ValuesView[typing.Any]: + """ + :returns: an object providing a view on D's values + :rtype: ~typing.ValuesView + """ + return self._data.values() + + def items(self) -> typing.ItemsView[str, typing.Any]: + """ + :returns: set-like object providing a view on D's items + :rtype: ~typing.ItemsView + """ + return self._data.items() + + def get(self, key: str, default: typing.Any = None) -> typing.Any: + """ + Get the value for key if key is in the dictionary, else default. + :param str key: The key to look up. + :param any default: The value to return if key is not in the dictionary. Defaults to None + :returns: D[k] if k in D, else d. + :rtype: any + """ + try: + return self[key] + except KeyError: + return default + + @typing.overload + def pop(self, key: str) -> typing.Any: ... + + @typing.overload + def pop(self, key: str, default: _T) -> _T: ... + + @typing.overload + def pop(self, key: str, default: typing.Any) -> typing.Any: ... + + def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Removes specified key and return the corresponding value. + :param str key: The key to pop. + :param any default: The value to return if key is not in the dictionary + :returns: The value corresponding to the key. + :rtype: any + :raises KeyError: If key is not found and default is not given. + """ + if default is _UNSET: + return self._data.pop(key) + return self._data.pop(key, default) + + def popitem(self) -> typing.Tuple[str, typing.Any]: + """ + Removes and returns some (key, value) pair + :returns: The (key, value) pair. + :rtype: tuple + :raises KeyError: if D is empty. + """ + return self._data.popitem() + + def clear(self) -> None: + """ + Remove all items from D. + """ + self._data.clear() + + def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: + """ + Updates D from mapping/iterable E and F. + :param any args: Either a mapping object or an iterable of key-value pairs. + """ + self._data.update(*args, **kwargs) + + @typing.overload + def setdefault(self, key: str, default: None = None) -> None: ... + + @typing.overload + def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... + + def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Same as calling D.get(k, d), and setting D[k]=d if k not found + :param str key: The key to look up. + :param any default: The value to set if key is not in the dictionary + :returns: D[k] if k in D, else d. + :rtype: any + """ + if default is _UNSET: + return self._data.setdefault(key) + return self._data.setdefault(key, default) + + def __eq__(self, other: typing.Any) -> bool: + try: + other_model = self.__class__(other) + except Exception: + return False + return self._data == other_model._data + + def __repr__(self) -> str: + return str(self._data) + + +def _is_model(obj: typing.Any) -> bool: + return getattr(obj, "_is_model", False) + + +def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-many-return-statements + if isinstance(o, list): + return [_serialize(x, format) for x in o] + if isinstance(o, dict): + return {k: _serialize(v, format) for k, v in o.items()} + if isinstance(o, set): + return {_serialize(x, format) for x in o} + if isinstance(o, tuple): + return tuple(_serialize(x, format) for x in o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, format) + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, enum.Enum): + return o.value + if isinstance(o, int): + if format == "str": + return str(o) + return o + try: + # First try datetime.datetime + return _serialize_datetime(o, format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return o + + +def _get_rest_field( + attr_to_rest_field: typing.Dict[str, "_RestField"], rest_name: str +) -> typing.Optional["_RestField"]: + try: + return next(rf for rf in attr_to_rest_field.values() if rf._rest_name == rest_name) + except StopIteration: + return None + + +def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typing.Any: + if not rf: + return _serialize(value, None) + if rf._is_multipart_file_input: + return value + if rf._is_model: + return _deserialize(rf._type, value) + if isinstance(value, ET.Element): + value = _deserialize(rf._type, value) + return _serialize(value, rf._format) + + +class Model(_MyMutableMapping): + _is_model = True + # label whether current class's _attr_to_rest_field has been calculated + # could not see _attr_to_rest_field directly because subclass inherits it from parent class + _calculated: typing.Set[str] = set() + + def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: + class_name = self.__class__.__name__ + if len(args) > 1: + raise TypeError(f"{class_name}.__init__() takes 2 positional arguments but {len(args) + 1} were given") + dict_to_pass = { + rest_field._rest_name: rest_field._default + for rest_field in self._attr_to_rest_field.values() + if rest_field._default is not _UNSET + } + if args: # pylint: disable=too-many-nested-blocks + if isinstance(args[0], ET.Element): + existed_attr_keys = [] + model_meta = getattr(self, "_xml", {}) + + for rf in self._attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + # attribute + if prop_meta.get("attribute", False) and args[0].get(xml_name) is not None: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].get(xml_name)) + continue + + # unwrapped element is array + if prop_meta.get("unwrapped", False): + # unwrapped array could either use prop items meta/prop meta + if prop_meta.get("itemsName"): + xml_name = prop_meta.get("itemsName") + xml_ns = prop_meta.get("itemNs") + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + items = args[0].findall(xml_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, items) + continue + + # text element is primitive type + if prop_meta.get("text", False): + if args[0].text is not None: + dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].text) + continue + + # wrapped element could be normal property or array, it should only have one element + item = args[0].find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, item) + + # rest thing is additional properties + for e in args[0]: + if e.tag not in existed_attr_keys: + dict_to_pass[e.tag] = _convert_element(e) + else: + dict_to_pass.update( + {k: _create_value(_get_rest_field(self._attr_to_rest_field, k), v) for k, v in args[0].items()} + ) + else: + non_attr_kwargs = [k for k in kwargs if k not in self._attr_to_rest_field] + if non_attr_kwargs: + # actual type errors only throw the first wrong keyword arg they see, so following that. + raise TypeError(f"{class_name}.__init__() got an unexpected keyword argument '{non_attr_kwargs[0]}'") + dict_to_pass.update( + { + self._attr_to_rest_field[k]._rest_name: _create_value(self._attr_to_rest_field[k], v) + for k, v in kwargs.items() + if v is not None + } + ) + super().__init__(dict_to_pass) + + def copy(self) -> "Model": + return Model(self.__dict__) + + def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: + if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated: + # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', + # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' + mros = cls.__mro__[:-9][::-1] # ignore parents, and reverse the mro order + attr_to_rest_field: typing.Dict[str, _RestField] = { # map attribute name to rest_field property + k: v for mro_class in mros for k, v in mro_class.__dict__.items() if k[0] != "_" and hasattr(v, "_type") + } + annotations = { + k: v + for mro_class in mros + if hasattr(mro_class, "__annotations__") + for k, v in mro_class.__annotations__.items() + } + for attr, rf in attr_to_rest_field.items(): + rf._module = cls.__module__ + if not rf._type: + rf._type = rf._get_deserialize_callable_from_annotation(annotations.get(attr, None)) + if not rf._rest_name_input: + rf._rest_name_input = attr + cls._attr_to_rest_field: typing.Dict[str, _RestField] = dict(attr_to_rest_field.items()) + cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") + + return super().__new__(cls) # pylint: disable=no-value-for-parameter + + def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: + for base in cls.__bases__: + if hasattr(base, "__mapping__"): + base.__mapping__[discriminator or cls.__name__] = cls # type: ignore + + @classmethod + def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]: + for v in cls.__dict__.values(): + if isinstance(v, _RestField) and v._is_discriminator and v._rest_name not in exist_discriminators: + return v + return None + + @classmethod + def _deserialize(cls, data, exist_discriminators): + if not hasattr(cls, "__mapping__"): + return cls(data) + discriminator = cls._get_discriminator(exist_discriminators) + if discriminator is None: + return cls(data) + exist_discriminators.append(discriminator._rest_name) + if isinstance(data, ET.Element): + model_meta = getattr(cls, "_xml", {}) + prop_meta = getattr(discriminator, "_xml", {}) + xml_name = prop_meta.get("name", discriminator._rest_name) + xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + if data.get(xml_name) is not None: + discriminator_value = data.get(xml_name) + else: + discriminator_value = data.find(xml_name).text # pyright: ignore + else: + discriminator_value = data.get(discriminator._rest_name) + mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore + return mapped_cls._deserialize(data, exist_discriminators) + + def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.Any]: + """Return a dict that can be turned into json using json.dump. + + :keyword bool exclude_readonly: Whether to remove the readonly properties. + :returns: A dict JSON compatible object + :rtype: dict + """ + + result = {} + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in self._attr_to_rest_field.values() if _is_readonly(p)] + for k, v in self.items(): + if exclude_readonly and k in readonly_props: # pyright: ignore + continue + is_multipart_file_input = False + try: + is_multipart_file_input = next( + rf for rf in self._attr_to_rest_field.values() if rf._rest_name == k + )._is_multipart_file_input + except StopIteration: + pass + result[k] = v if is_multipart_file_input else Model._as_dict_value(v, exclude_readonly=exclude_readonly) + return result + + @staticmethod + def _as_dict_value(v: typing.Any, exclude_readonly: bool = False) -> typing.Any: + if v is None or isinstance(v, _Null): + return None + if isinstance(v, (list, tuple, set)): + return type(v)(Model._as_dict_value(x, exclude_readonly=exclude_readonly) for x in v) + if isinstance(v, dict): + return {dk: Model._as_dict_value(dv, exclude_readonly=exclude_readonly) for dk, dv in v.items()} + return v.as_dict(exclude_readonly=exclude_readonly) if hasattr(v, "as_dict") else v + + +def _deserialize_model(model_deserializer: typing.Optional[typing.Callable], obj): + if _is_model(obj): + return obj + return _deserialize(model_deserializer, obj) + + +def _deserialize_with_optional(if_obj_deserializer: typing.Optional[typing.Callable], obj): + if obj is None: + return obj + return _deserialize_with_callable(if_obj_deserializer, obj) + + +def _deserialize_with_union(deserializers, obj): + for deserializer in deserializers: + try: + return _deserialize(deserializer, obj) + except DeserializationError: + pass + raise DeserializationError() + + +def _deserialize_dict( + value_deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj: typing.Dict[typing.Any, typing.Any], +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = {child.tag: child for child in obj} + return {k: _deserialize(value_deserializer, v, module) for k, v in obj.items()} + + +def _deserialize_multiple_sequence( + entry_deserializers: typing.List[typing.Optional[typing.Callable]], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers)) + + +def _deserialize_sequence( + deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = list(obj) + return type(obj)(_deserialize(deserializer, entry, module) for entry in obj) + + +def _sorted_annotations(types: typing.List[typing.Any]) -> typing.List[typing.Any]: + return sorted( + types, + key=lambda x: hasattr(x, "__name__") and x.__name__.lower() in ("str", "float", "int", "bool"), + ) + + +def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-branches + annotation: typing.Any, + module: typing.Optional[str], + rf: typing.Optional["_RestField"] = None, +) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + if not annotation: + return None + + # is it a type alias? + if isinstance(annotation, str): + if module is not None: + annotation = _get_type_alias_type(module, annotation) + + # is it a forward ref / in quotes? + if isinstance(annotation, (str, typing.ForwardRef)): + try: + model_name = annotation.__forward_arg__ # type: ignore + except AttributeError: + model_name = annotation + if module is not None: + annotation = _get_model(module, model_name) # type: ignore + + try: + if module and _is_model(annotation): + if rf: + rf._is_model = True + + return functools.partial(_deserialize_model, annotation) # pyright: ignore + except Exception: + pass + + # is it a literal? + try: + if annotation.__origin__ is typing.Literal: # pyright: ignore + return None + except AttributeError: + pass + + # is it optional? + try: + if any(a for a in annotation.__args__ if a == type(None)): # pyright: ignore + if len(annotation.__args__) <= 2: # pyright: ignore + if_obj_deserializer = _get_deserialize_callable_from_annotation( + next(a for a in annotation.__args__ if a != type(None)), module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_with_optional, if_obj_deserializer) + # the type is Optional[Union[...]], we need to remove the None type from the Union + annotation_copy = copy.copy(annotation) + annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a != type(None)] # pyright: ignore + return _get_deserialize_callable_from_annotation(annotation_copy, module, rf) + except AttributeError: + pass + + # is it union? + if getattr(annotation, "__origin__", None) is typing.Union: + # initial ordering is we make `string` the last deserialization option, because it is often them most generic + deserializers = [ + _get_deserialize_callable_from_annotation(arg, module, rf) + for arg in _sorted_annotations(annotation.__args__) # pyright: ignore + ] + + return functools.partial(_deserialize_with_union, deserializers) + + try: + if annotation._name == "Dict": # pyright: ignore + value_deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[1], module, rf # pyright: ignore + ) + + return functools.partial( + _deserialize_dict, + value_deserializer, + module, + ) + except (AttributeError, IndexError): + pass + try: + if annotation._name in ["List", "Set", "Tuple", "Sequence"]: # pyright: ignore + if len(annotation.__args__) > 1: # pyright: ignore + entry_deserializers = [ + _get_deserialize_callable_from_annotation(dt, module, rf) + for dt in annotation.__args__ # pyright: ignore + ] + return functools.partial(_deserialize_multiple_sequence, entry_deserializers, module) + deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[0], module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_sequence, deserializer, module) + except (TypeError, IndexError, AttributeError, SyntaxError): + pass + + def _deserialize_default( + deserializer, + obj, + ): + if obj is None: + return obj + try: + return _deserialize_with_callable(deserializer, obj) + except Exception: + pass + return obj + + if get_deserializer(annotation, rf): + return functools.partial(_deserialize_default, get_deserializer(annotation, rf)) + + return functools.partial(_deserialize_default, annotation) + + +def _deserialize_with_callable( + deserializer: typing.Optional[typing.Callable[[typing.Any], typing.Any]], + value: typing.Any, +): # pylint: disable=too-many-return-statements + try: + if value is None or isinstance(value, _Null): + return None + if isinstance(value, ET.Element): + if deserializer is str: + return value.text or "" + if deserializer is int: + return int(value.text) if value.text else None + if deserializer is float: + return float(value.text) if value.text else None + if deserializer is bool: + return value.text == "true" if value.text else None + if deserializer is None: + return value + if deserializer in [int, float, bool]: + return deserializer(value) + if isinstance(deserializer, CaseInsensitiveEnumMeta): + try: + return deserializer(value) + except ValueError: + # for unknown value, return raw value + return value + if isinstance(deserializer, type) and issubclass(deserializer, Model): + return deserializer._deserialize(value, []) + return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value) + except Exception as e: + raise DeserializationError() from e + + +def _deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + if isinstance(value, PipelineResponse): + value = value.http_response.json() + if rf is None and format: + rf = _RestField(format=format) + if not isinstance(deserializer, functools.partial): + deserializer = _get_deserialize_callable_from_annotation(deserializer, module, rf) + return _deserialize_with_callable(deserializer, value) + + +def _failsafe_deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + try: + return _deserialize(deserializer, value, module, rf, format) + except DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +def _failsafe_deserialize_xml( + deserializer: typing.Any, + value: typing.Any, +) -> typing.Any: + try: + return _deserialize_xml(deserializer, value) + except DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +class _RestField: + def __init__( + self, + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + is_discriminator: bool = False, + visibility: typing.Optional[typing.List[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[typing.Dict[str, typing.Any]] = None, + ): + self._type = type + self._rest_name_input = name + self._module: typing.Optional[str] = None + self._is_discriminator = is_discriminator + self._visibility = visibility + self._is_model = False + self._default = default + self._format = format + self._is_multipart_file_input = is_multipart_file_input + self._xml = xml if xml is not None else {} + + @property + def _class_type(self) -> typing.Any: + return getattr(self._type, "args", [None])[0] + + @property + def _rest_name(self) -> str: + if self._rest_name_input is None: + raise ValueError("Rest name was never set") + return self._rest_name_input + + def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin + # by this point, type and rest_name will have a value bc we default + # them in __new__ of the Model class + item = obj.get(self._rest_name) + if item is None: + return item + if self._is_model: + return item + return _deserialize(self._type, _serialize(item, self._format), rf=self) + + def __set__(self, obj: Model, value) -> None: + if value is None: + # we want to wipe out entries if users set attr to None + try: + obj.__delitem__(self._rest_name) + except KeyError: + pass + return + if self._is_model: + if not _is_model(value): + value = _deserialize(self._type, value) + obj.__setitem__(self._rest_name, value) + return + obj.__setitem__(self._rest_name, _serialize(value, self._format)) + + def _get_deserialize_callable_from_annotation( + self, annotation: typing.Any + ) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + return _get_deserialize_callable_from_annotation(annotation, self._module, self) + + +def rest_field( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[typing.List[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[typing.Dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField( + name=name, + type=type, + visibility=visibility, + default=default, + format=format, + is_multipart_file_input=is_multipart_file_input, + xml=xml, + ) + + +def rest_discriminator( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[typing.List[str]] = None, + xml: typing.Optional[typing.Dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField(name=name, type=type, is_discriminator=True, visibility=visibility, xml=xml) + + +def serialize_xml(model: Model, exclude_readonly: bool = False) -> str: + """Serialize a model to XML. + + :param Model model: The model to serialize. + :param bool exclude_readonly: Whether to exclude readonly properties. + :returns: The XML representation of the model. + :rtype: str + """ + return ET.tostring(_get_element(model, exclude_readonly), encoding="unicode") # type: ignore + + +def _get_element( + o: typing.Any, + exclude_readonly: bool = False, + parent_meta: typing.Optional[typing.Dict[str, typing.Any]] = None, + wrapped_element: typing.Optional[ET.Element] = None, +) -> typing.Union[ET.Element, typing.List[ET.Element]]: + if _is_model(o): + model_meta = getattr(o, "_xml", {}) + + # if prop is a model, then use the prop element directly, else generate a wrapper of model + if wrapped_element is None: + wrapped_element = _create_xml_element( + model_meta.get("name", o.__class__.__name__), + model_meta.get("prefix"), + model_meta.get("ns"), + ) + + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + + for k, v in o.items(): + # do not serialize readonly properties + if exclude_readonly and k in readonly_props: + continue + + prop_rest_field = _get_rest_field(o._attr_to_rest_field, k) + if prop_rest_field: + prop_meta = getattr(prop_rest_field, "_xml").copy() + # use the wire name as xml name if no specific name is set + if prop_meta.get("name") is None: + prop_meta["name"] = k + else: + # additional properties will not have rest field, use the wire name as xml name + prop_meta = {"name": k} + + # if no ns for prop, use model's + if prop_meta.get("ns") is None and model_meta.get("ns"): + prop_meta["ns"] = model_meta.get("ns") + prop_meta["prefix"] = model_meta.get("prefix") + + if prop_meta.get("unwrapped", False): + # unwrapped could only set on array + wrapped_element.extend(_get_element(v, exclude_readonly, prop_meta)) + elif prop_meta.get("text", False): + # text could only set on primitive type + wrapped_element.text = _get_primitive_type_value(v) + elif prop_meta.get("attribute", False): + xml_name = prop_meta.get("name", k) + if prop_meta.get("ns"): + ET.register_namespace(prop_meta.get("prefix"), prop_meta.get("ns")) # pyright: ignore + xml_name = "{" + prop_meta.get("ns") + "}" + xml_name # pyright: ignore + # attribute should be primitive type + wrapped_element.set(xml_name, _get_primitive_type_value(v)) + else: + # other wrapped prop element + wrapped_element.append(_get_wrapped_element(v, exclude_readonly, prop_meta)) + return wrapped_element + if isinstance(o, list): + return [_get_element(x, exclude_readonly, parent_meta) for x in o] # type: ignore + if isinstance(o, dict): + result = [] + for k, v in o.items(): + result.append( + _get_wrapped_element( + v, + exclude_readonly, + { + "name": k, + "ns": parent_meta.get("ns") if parent_meta else None, + "prefix": parent_meta.get("prefix") if parent_meta else None, + }, + ) + ) + return result + + # primitive case need to create element based on parent_meta + if parent_meta: + return _get_wrapped_element( + o, + exclude_readonly, + { + "name": parent_meta.get("itemsName", parent_meta.get("name")), + "prefix": parent_meta.get("itemsPrefix", parent_meta.get("prefix")), + "ns": parent_meta.get("itemsNs", parent_meta.get("ns")), + }, + ) + + raise ValueError("Could not serialize value into xml: " + o) + + +def _get_wrapped_element( + v: typing.Any, + exclude_readonly: bool, + meta: typing.Optional[typing.Dict[str, typing.Any]], +) -> ET.Element: + wrapped_element = _create_xml_element( + meta.get("name") if meta else None, meta.get("prefix") if meta else None, meta.get("ns") if meta else None + ) + if isinstance(v, (dict, list)): + wrapped_element.extend(_get_element(v, exclude_readonly, meta)) + elif _is_model(v): + _get_element(v, exclude_readonly, meta, wrapped_element) + else: + wrapped_element.text = _get_primitive_type_value(v) + return wrapped_element + + +def _get_primitive_type_value(v) -> str: + if v is True: + return "true" + if v is False: + return "false" + if isinstance(v, _Null): + return "" + return str(v) + + +def _create_xml_element(tag, prefix=None, ns=None): + if prefix and ns: + ET.register_namespace(prefix, ns) + if ns: + return ET.Element("{" + ns + "}" + tag) + return ET.Element(tag) + + +def _deserialize_xml( + deserializer: typing.Any, + value: str, +) -> typing.Any: + element = ET.fromstring(value) # nosec + return _deserialize(deserializer, element) + + +def _convert_element(e: ET.Element): + # dict case + if len(e.attrib) > 0 or len({child.tag for child in e}) > 1: + dict_result: typing.Dict[str, typing.Any] = {} + for child in e: + if dict_result.get(child.tag) is not None: + if isinstance(dict_result[child.tag], list): + dict_result[child.tag].append(_convert_element(child)) + else: + dict_result[child.tag] = [dict_result[child.tag], _convert_element(child)] + else: + dict_result[child.tag] = _convert_element(child) + dict_result.update(e.attrib) + return dict_result + # array case + if len(e) > 0: + array_result: typing.List[typing.Any] = [] + for child in e: + array_result.append(_convert_element(child)) + return array_result + # primitive case + return e.text diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_operations/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_operations/__init__.py new file mode 100644 index 00000000000..2674f45390d --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_operations/__init__.py @@ -0,0 +1,25 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import PathClientOperationsMixin # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "PathClientOperationsMixin", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_operations/_operations.py new file mode 100644 index 00000000000..b6825cddb2d --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_operations/_operations.py @@ -0,0 +1,95 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace + +from .._serialization import Serializer +from .._vendor import PathClientMixinABC + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_path_path_api_version_request(**kwargs: Any) -> HttpRequest: + version: str = kwargs.pop("version", "2025-01-01") + # Construct URL + _url = "/azure/client-generator-core/api-version/path/{version}" + path_format_arguments = { + "version": _SERIALIZER.url("version", version, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + return HttpRequest(method="POST", url=_url, **kwargs) + + +class PathClientOperationsMixin(PathClientMixinABC): + + @distributed_trace + def path_api_version(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """Path api version parameter. + + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_path_path_api_version_request( + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_operations/_patch.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_operations/_patch.py new file mode 100644 index 00000000000..f7dd3251033 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_patch.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_patch.py new file mode 100644 index 00000000000..f7dd3251033 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_serialization.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_serialization.py new file mode 100644 index 00000000000..a066e16a64d --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_serialization.py @@ -0,0 +1,2050 @@ +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# 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. +# +# -------------------------------------------------------------------------- + +# pyright: reportUnnecessaryTypeIgnoreComment=false + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +from typing import ( + Dict, + Any, + cast, + Optional, + Union, + AnyStr, + IO, + Mapping, + Callable, + MutableMapping, + List, +) + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote +import xml.etree.ElementTree as ET + +import isodate # type: ignore +from typing_extensions import Self + +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +JSON = MutableMapping[str, Any] + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + :return: The deserialized data. + :rtype: object + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) from err + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError as err: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str + raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + + :param bytes body_bytes: The body of the response. + :param dict headers: The headers of the response. + :returns: The deserialized data. + :rtype: object + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + +TZ_UTC = datetime.timezone.utc + +_FLATTEN = re.compile(r"(? None: + self.additional_properties: Optional[Dict[str, Any]] = {} + for k in kwargs: # pylint: disable=consider-using-dict-items + if k not in self._attribute_map: + _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) + elif k in self._validation and self._validation[k].get("readonly", False): + _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) + else: + setattr(self, k, kwargs[k]) + + def __eq__(self, other: Any) -> bool: + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are equal + :rtype: bool + """ + if isinstance(other, self.__class__): + return self.__dict__ == other.__dict__ + return False + + def __ne__(self, other: Any) -> bool: + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are not equal + :rtype: bool + """ + return not self.__eq__(other) + + def __str__(self) -> str: + return str(self.__dict__) + + @classmethod + def enable_additional_properties_sending(cls) -> None: + cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} + + @classmethod + def is_xml_model(cls) -> bool: + try: + cls._xml_map # type: ignore + except AttributeError: + return False + return True + + @classmethod + def _create_xml_node(cls): + """Create XML node. + + :returns: The XML node + :rtype: xml.etree.ElementTree.Element + """ + try: + xml_map = cls._xml_map # type: ignore + except AttributeError: + xml_map = {} + + return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) + + def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: + """Return the JSON that would be sent to server from this model. + + This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param bool keep_readonly: If you want to serialize the readonly attributes + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, keep_readonly=keep_readonly, **kwargs + ) + + def as_dict( + self, + keep_readonly: bool = True, + key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + **kwargs: Any + ) -> JSON: + """Return a dict that can be serialized using json.dump. + + Advanced usage might optionally use a callback as parameter: + + .. code::python + + def my_key_transformer(key, attr_desc, value): + return key + + Key is the attribute name used in Python. Attr_desc + is a dict of metadata. Currently contains 'type' with the + msrest type and 'key' with the RestAPI encoded key. + Value is the current value in this object. + + The string returned will be used to serialize the key. + If the return type is a list, this is considered hierarchical + result dict. + + See the three examples in this file: + + - attribute_transformer + - full_restapi_key_transformer + - last_restapi_key_transformer + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param bool keep_readonly: If you want to serialize the readonly attributes + :param function key_transformer: A key transformer function. + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs + ) + + @classmethod + def _infer_class_models(cls): + try: + str_models = cls.__module__.rsplit(".", 1)[0] + models = sys.modules[str_models] + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + if cls.__name__ not in client_models: + raise ValueError("Not Autorest generated code") + except Exception: # pylint: disable=broad-exception-caught + # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. + client_models = {cls.__name__: cls} + return client_models + + @classmethod + def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: + """Parse a str using the RestAPI syntax and return a model. + + :param str data: A str using RestAPI structure. JSON by default. + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises DeserializationError: if something went wrong + :rtype: Self + """ + deserializer = Deserializer(cls._infer_class_models()) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore + + @classmethod + def from_dict( + cls, + data: Any, + key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + content_type: Optional[str] = None, + ) -> Self: + """Parse a dict using given key extractor return a model. + + By default consider key + extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor + and last_rest_key_case_insensitive_extractor) + + :param dict data: A dict using RestAPI structure + :param function key_extractors: A key extractor function. + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises: DeserializationError if something went wrong + :rtype: Self + """ + deserializer = Deserializer(cls._infer_class_models()) + deserializer.key_extractors = ( # type: ignore + [ # type: ignore + attribute_key_case_insensitive_extractor, + rest_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + if key_extractors is None + else key_extractors + ) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore + + @classmethod + def _flatten_subtype(cls, key, objects): + if "_subtype_map" not in cls.__dict__: + return {} + result = dict(cls._subtype_map[key]) + for valuetype in cls._subtype_map[key].values(): + result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access + return result + + @classmethod + def _classify(cls, response, objects): + """Check the class _subtype_map for any child classes. + We want to ignore any inherited _subtype_maps. + + :param dict response: The initial data + :param dict objects: The class objects + :returns: The class to be used + :rtype: class + """ + for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): + subtype_value = None + + if not isinstance(response, ET.Element): + rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] + subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) + else: + subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) + if subtype_value: + # Try to match base class. Can be class name only + # (bug to fix in Autorest to support x-ms-discriminator-name) + if cls.__name__ == subtype_value: + return cls + flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) + try: + return objects[flatten_mapping_type[subtype_value]] # type: ignore + except KeyError: + _LOGGER.warning( + "Subtype value %s has no mapping, use base class %s.", + subtype_value, + cls.__name__, + ) + break + else: + _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) + break + return cls + + @classmethod + def _get_rest_key_parts(cls, attr_key): + """Get the RestAPI key of this attr, split it and decode part + :param str attr_key: Attribute key must be in attribute_map. + :returns: A list of RestAPI part + :rtype: list + """ + rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) + return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] + + +def _decode_attribute_map_key(key): + """This decode a key in an _attribute_map to the actual key we want to look at + inside the received data. + + :param str key: A key string from the generated code + :returns: The decoded key + :rtype: str + """ + return key.replace("\\.", ".") + + +class Serializer: # pylint: disable=too-many-public-methods + """Request object model serializer.""" + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} + days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} + months = { + 1: "Jan", + 2: "Feb", + 3: "Mar", + 4: "Apr", + 5: "May", + 6: "Jun", + 7: "Jul", + 8: "Aug", + 9: "Sep", + 10: "Oct", + 11: "Nov", + 12: "Dec", + } + validation = { + "min_length": lambda x, y: len(x) < y, + "max_length": lambda x, y: len(x) > y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals + self, target_obj, data_type=None, **kwargs + ): + """Serialize data into a string according to type. + + :param object target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises SerializationError: if serialization fails. + :returns: The serialized data. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() # pylint: disable=protected-access + try: + attributes = target_obj._attribute_map # pylint: disable=protected-access + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access + attr_name, {} + ).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) # type: ignore + continue + if xml_desc.get("text", False): + serialized.text = new_attr # type: ignore + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) # type: ignore + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, + # we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) # type: ignore + else: # That's a basic type + # Integrate namespace if necessary + local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) + local_node.text = str(new_attr) + serialized.append(local_node) # type: ignore + else: # JSON + for k in reversed(keys): # type: ignore + new_attr = {k: new_attr} + + _new_attr = new_attr + _serialized = serialized + for k in keys: # type: ignore + if k not in _serialized: + _serialized.update(_new_attr) # type: ignore + _new_attr = _new_attr[k] # type: ignore + _serialized = _serialized[k] + except ValueError as err: + if isinstance(err, SerializationError): + raise + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) + raise SerializationError(msg) from err + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises SerializationError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized request body + """ + + # Just in case this is a dict + internal_data_type_str = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type_str, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ # type: ignore + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access + except DeserializationError as err: + raise SerializationError("Unable to build a model: " + str(err)) from err + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param str name: The name of the URL path parameter. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :returns: The serialized URL path + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) + else: + output = quote(str(output), safe="") + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param str name: The name of the query parameter. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, list + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized query parameter + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + do_quote = not kwargs.get("skip_quote", False) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param str name: The name of the header. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized header + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :raises AttributeError: if required data is None. + :raises ValueError: if data is None + :raises SerializationError: if serialization fails. + :returns: The serialized data. + :rtype: str, int, float, bool, dict, list + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data is CoreNull: + return None + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + if data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise SerializationError(msg.format(data, data_type)) from err + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param obj data: Object to be serialized. + :param str data_type: Type of object in the iterable. + :rtype: str, int, float, bool + :return: serialized object + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == "str": + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec # pylint: disable=eval-used + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param str data: Object to be serialized. + :rtype: str + :return: serialized object + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): # type: ignore + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list data: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + Defaults to False. + :rtype: list, str + :return: serialized iterable + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError as err: + if isinstance(err, SerializationError): + raise + serialized.append(None) + + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + + if div: + serialized = ["" if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :rtype: dict + :return: serialized dictionary + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError as err: + if isinstance(err, SerializationError): + raise + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + :return: serialized object + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + if obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) # type: ignore + return result + except ValueError as exc: + for enum_value in enum_obj: # type: ignore + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) from exc + + @staticmethod + def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument + """Serialize bytearray into base-64 string. + + :param str attr: Object to be serialized. + :rtype: str + :return: serialized base64 + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument + """Serialize str into base-64 string. + + :param str attr: Object to be serialized. + :rtype: str + :return: serialized base64 + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Decimal object to float. + + :param decimal attr: Object to be serialized. + :rtype: float + :return: serialized decimal + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): # pylint: disable=unused-argument + """Serialize long (Py2) or int (Py3). + + :param int attr: Object to be serialized. + :rtype: int/long + :return: serialized long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + :return: serialized date + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + :return: serialized time + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + :return: serialized duration + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises TypeError: if format invalid. + :return: serialized rfc + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError as exc: + raise TypeError("RFC1123 object must be valid Datetime object.") from exc + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises SerializationError: if format invalid. + :return: serialized iso + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise SerializationError(msg) from err + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise TypeError(msg) from err + + @staticmethod + def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises SerializationError: if format invalid + :return: serialied unix + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError as exc: + raise TypeError("Unix time object must be valid Datetime object.") from exc + + +def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + key = attr_desc["key"] + working_data = data + + while "." in key: + # Need the cast, as for some reasons "split" is typed as list[str | Any] + dict_keys = cast(List[str], _FLATTEN.split(key)) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + return None + key = ".".join(dict_keys[1:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements + attr, attr_desc, data +): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + return None + key = ".".join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get("name", internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer: + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.key_extractors = [rest_key_extractor, xml_key_extractor] + # Additional properties only works if the "rest_key_extractor" is used to + # extract the keys. Making it to work whatever the key extractor is too much + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, str): + return self.deserialize_data(data, response) + if isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None or data is CoreNull: + return data + try: + attributes = response._attribute_map # type: ignore # pylint: disable=protected-access + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc["type"]) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name # type: ignore + raise DeserializationError(msg) from err + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + :return: The classified target object and its class name. + :rtype: tuple + """ + if target is None: + return None, None + + if isinstance(target, str): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ # type: ignore + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + :param str content_type: Swagger "produces" if available. + :return: Deserialized object. + :rtype: object + """ + try: + return self(target_obj, data, content_type=content_type) + except: # pylint: disable=bare-except + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param obj raw_data: Data to be processed. + :param str content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + :rtype: object + :return: Unpacked content. + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, "_content_consumed"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) + + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param Response response: The response model class. + :param dict attrs: The deserialized response attributes. + :param dict additional_properties: Additional properties to be set. + :rtype: Response + :return: The instantiated response model. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("readonly") + ] + const = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("constant") + ] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties # type: ignore + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore + raise DeserializationError(msg + str(err)) from err + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) from exp + + def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment + "object", + "[]", + r"{}", + ] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise DeserializationError(msg) from err + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :return: Deserialized iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :return: Deserialized dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :return: Deserialized object. + :rtype: dict + :raises TypeError: if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, str): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :return: Deserialized basic type. + :rtype: str, int, float or bool + :raises TypeError: if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + if isinstance(attr, str): + if attr.lower() in ["true", "1"]: + return True + if attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec # pylint: disable=eval-used + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :return: Deserialized string. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): # type: ignore + return data + except NameError: + return str(data) + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :return: Deserialized enum object. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + try: + return list(enum_obj.__members__.values())[data] + except IndexError as exc: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) from exc + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :return: Deserialized bytearray + :rtype: bytearray + :raises TypeError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) # type: ignore + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :return: Deserialized base64 string + :rtype: bytearray + :raises TypeError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :return: Deserialized decimal + :raises DeserializationError: if string format invalid. + :rtype: decimal + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(str(attr)) # type: ignore + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise DeserializationError(msg) from err + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :return: Deserialized int + :rtype: long or int + :raises ValueError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) # type: ignore + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :return: Deserialized duration + :rtype: TimeDelta + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise DeserializationError(msg) from err + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :return: Deserialized date + :rtype: Date + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :return: Deserialized time + :rtype: datetime.time + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :return: Deserialized RFC datetime + :rtype: Datetime + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) # type: ignore + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise DeserializationError(msg) from err + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :return: Deserialized ISO datetime + :rtype: Datetime + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() # type: ignore + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise DeserializationError(msg) from err + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :return: Deserialized datetime + :rtype: Datetime + :raises DeserializationError: if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) # type: ignore + try: + attr = int(attr) + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise DeserializationError(msg) from err + return date_obj diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_vendor.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_vendor.py new file mode 100644 index 00000000000..745b900e6f6 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_vendor.py @@ -0,0 +1,25 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from ._configuration import PathClientConfiguration + +if TYPE_CHECKING: + from azure.core import PipelineClient + + from ._serialization import Deserializer, Serializer + + +class PathClientMixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "PipelineClient" + _config: PathClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_version.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_version.py new file mode 100644 index 00000000000..be71c81bd28 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_version.py @@ -0,0 +1,9 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/__init__.py new file mode 100644 index 00000000000..c65d4008d6f --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/__init__.py @@ -0,0 +1,29 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import PathClient # type: ignore + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "PathClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore + +_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_client.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_client.py new file mode 100644 index 00000000000..0ab501cb659 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_client.py @@ -0,0 +1,96 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable +from typing_extensions import Self + +from azure.core import AsyncPipelineClient +from azure.core.pipeline import policies +from azure.core.rest import AsyncHttpResponse, HttpRequest + +from .._serialization import Deserializer, Serializer +from ._configuration import PathClientConfiguration +from ._operations import PathClientOperationsMixin + + +class PathClient(PathClientOperationsMixin): + """PathClient. + + :keyword endpoint: Service host. Default value is "http://localhost:3000". + :paramtype endpoint: str + :keyword version: Default value is "2025-01-01". Note that overriding this default value may + result in unsupported behavior. + :paramtype version: str + """ + + def __init__( # pylint: disable=missing-client-constructor-parameter-credential + self, *, endpoint: str = "http://localhost:3000", **kwargs: Any + ) -> None: + _endpoint = "{endpoint}" + self._config = PathClientConfiguration(endpoint=endpoint, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncPipelineClient = AsyncPipelineClient(base_url=_endpoint, policies=_policies, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + + def send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> Self: + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_configuration.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_configuration.py new file mode 100644 index 00000000000..6ee36588497 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_configuration.py @@ -0,0 +1,47 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any + +from azure.core.pipeline import policies + +from .._version import VERSION + + +class PathClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for PathClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: Service host. Default value is "http://localhost:3000". + :type endpoint: str + :keyword version: Default value is "2025-01-01". Note that overriding this default value may + result in unsupported behavior. + :paramtype version: str + """ + + def __init__(self, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None: + version: str = kwargs.pop("version", "2025-01-01") + + self.endpoint = endpoint + self.version = version + kwargs.setdefault("sdk_moniker", "client-alternateapiversion-service-path/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_operations/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_operations/__init__.py new file mode 100644 index 00000000000..2674f45390d --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_operations/__init__.py @@ -0,0 +1,25 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import PathClientOperationsMixin # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "PathClientOperationsMixin", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_operations/_operations.py new file mode 100644 index 00000000000..8cddfb0bb90 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_operations/_operations.py @@ -0,0 +1,79 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async + +from ..._operations._operations import build_path_path_api_version_request +from .._vendor import PathClientMixinABC + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PathClientOperationsMixin(PathClientMixinABC): + + @distributed_trace_async + async def path_api_version(self, **kwargs: Any) -> None: + """Path api version parameter. + + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_path_path_api_version_request( + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_operations/_patch.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_operations/_patch.py new file mode 100644 index 00000000000..f7dd3251033 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_patch.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_patch.py new file mode 100644 index 00000000000..f7dd3251033 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_vendor.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_vendor.py new file mode 100644 index 00000000000..1373fa6986b --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_vendor.py @@ -0,0 +1,25 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from ._configuration import PathClientConfiguration + +if TYPE_CHECKING: + from azure.core import AsyncPipelineClient + + from .._serialization import Deserializer, Serializer + + +class PathClientMixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "AsyncPipelineClient" + _config: PathClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/py.typed b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/dev_requirements.txt b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/dev_requirements.txt new file mode 100644 index 00000000000..10548647144 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/dev_requirements.txt @@ -0,0 +1,3 @@ +-e ../../../tools/azure-sdk-tools +../../core/azure-core +aiohttp \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/conftest.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/conftest.py new file mode 100644 index 00000000000..5776acd6a2d --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/conftest.py @@ -0,0 +1,35 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# For security, please avoid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + path_subscription_id = os.environ.get("PATH_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + path_tenant_id = os.environ.get("PATH_TENANT_ID", "00000000-0000-0000-0000-000000000000") + path_client_id = os.environ.get("PATH_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + path_client_secret = os.environ.get("PATH_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=path_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=path_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=path_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=path_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/test_path.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/test_path.py new file mode 100644 index 00000000000..51c1715e851 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/test_path.py @@ -0,0 +1,22 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from devtools_testutils import recorded_by_proxy +from testpreparer import PathClientTestBase, PathPreparer + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPath(PathClientTestBase): + @PathPreparer() + @recorded_by_proxy + def test_path_api_version(self, path_endpoint): + client = self.create_client(endpoint=path_endpoint) + response = client.path_api_version() + + # please add some check logic here by yourself + # ... diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/test_path_async.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/test_path_async.py new file mode 100644 index 00000000000..6b87fc650df --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/test_path_async.py @@ -0,0 +1,23 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from devtools_testutils.aio import recorded_by_proxy_async +from testpreparer import PathPreparer +from testpreparer_async import PathClientTestBaseAsync + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPathAsync(PathClientTestBaseAsync): + @PathPreparer() + @recorded_by_proxy_async + async def test_path_api_version(self, path_endpoint): + client = self.create_async_client(endpoint=path_endpoint) + response = await client.path_api_version() + + # please add some check logic here by yourself + # ... diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/testpreparer.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/testpreparer.py new file mode 100644 index 00000000000..a285609da20 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/testpreparer.py @@ -0,0 +1,24 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from client.alternateapiversion.service.path import PathClient +from devtools_testutils import AzureRecordedTestCase, PowerShellPreparer +import functools + + +class PathClientTestBase(AzureRecordedTestCase): + + def create_client(self, endpoint): + credential = self.get_credential(PathClient) + return self.create_client_from_credential( + PathClient, + credential=credential, + endpoint=endpoint, + ) + + +PathPreparer = functools.partial(PowerShellPreparer, "path", path_endpoint="https://fake_path_endpoint.com") diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/testpreparer_async.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/testpreparer_async.py new file mode 100644 index 00000000000..cd94b8373de --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/testpreparer_async.py @@ -0,0 +1,20 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from client.alternateapiversion.service.path.aio import PathClient +from devtools_testutils import AzureRecordedTestCase + + +class PathClientTestBaseAsync(AzureRecordedTestCase): + + def create_async_client(self, endpoint): + credential = self.get_credential(PathClient, is_async=True) + return self.create_client_from_credential( + PathClient, + credential=credential, + endpoint=endpoint, + ) diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/setup.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/setup.py new file mode 100644 index 00000000000..585696cb6f2 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/setup.py @@ -0,0 +1,72 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# coding: utf-8 + +import os +import re +from setuptools import setup, find_packages + + +PACKAGE_NAME = "client-alternateapiversion-service-path" +PACKAGE_PPRINT_NAME = "Client Alternateapiversion Service Path" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace("-", "/") + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, "_version.py"), "r") as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError("Cannot find version information") + + +setup( + name=PACKAGE_NAME, + version=version, + description="Microsoft {} Client Library for Python".format(PACKAGE_PPRINT_NAME), + long_description=open("README.md", "r").read(), + long_description_content_type="text/markdown", + license="MIT License", + author="Microsoft Corporation", + author_email="azpysdkhelp@microsoft.com", + url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk", + keywords="azure, azure sdk", + classifiers=[ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "License :: OSI Approved :: MIT License", + ], + zip_safe=False, + packages=find_packages( + exclude=[ + "tests", + # Exclude packages that will be covered by PEP420 or nspkg + "client", + "client.alternateapiversion", + "client.alternateapiversion.service", + ] + ), + include_package_data=True, + package_data={ + "client.alternateapiversion.service.path": ["py.typed"], + }, + install_requires=[ + "isodate>=0.6.1", + "azure-core>=1.30.0", + "typing-extensions>=4.6.0", + ], + python_requires=">=3.8", +) diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/CHANGELOG.md b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/CHANGELOG.md new file mode 100644 index 00000000000..628743d283a --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0b1 (1970-01-01) + +- Initial version diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/LICENSE b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/LICENSE new file mode 100644 index 00000000000..63447fd8bbb --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/LICENSE @@ -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. \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/MANIFEST.in b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/MANIFEST.in new file mode 100644 index 00000000000..69f8c2d2885 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/MANIFEST.in @@ -0,0 +1,8 @@ +include *.md +include LICENSE +include client/alternateapiversion/service/query/py.typed +recursive-include tests *.py +recursive-include samples *.py *.md +include client/__init__.py +include client/alternateapiversion/__init__.py +include client/alternateapiversion/service/__init__.py \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/README.md b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/README.md new file mode 100644 index 00000000000..c2d5a37df3b --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/README.md @@ -0,0 +1,45 @@ + + +# Client Alternateapiversion Service Query client library for Python + + +## Getting started + +### Install the package + +```bash +python -m pip install client-alternateapiversion-service-query +``` + +#### 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 Client Alternateapiversion Service Query 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 opencode@microsoft.com with any +additional questions or comments. + + +[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/ + diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/apiview-properties.json b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/apiview-properties.json new file mode 100644 index 00000000000..e451ff24fd3 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/apiview-properties.json @@ -0,0 +1,6 @@ +{ + "CrossLanguagePackageId": "Client.AlternateApiVersion.Service.Query", + "CrossLanguageDefinitionId": { + "client.alternateapiversion.service.query.QueryClient.query_api_version": "Client.AlternateApiVersion.Service.Query.queryApiVersion" + } +} \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/__init__.py new file mode 100644 index 00000000000..d55ccad1f57 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/__init__.py new file mode 100644 index 00000000000..d55ccad1f57 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/__init__.py new file mode 100644 index 00000000000..d55ccad1f57 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/__init__.py new file mode 100644 index 00000000000..56234fef3b6 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/__init__.py @@ -0,0 +1,32 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import QueryClient # type: ignore +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "QueryClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore + +_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_client.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_client.py new file mode 100644 index 00000000000..edb6298a458 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_client.py @@ -0,0 +1,94 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any +from typing_extensions import Self + +from azure.core import PipelineClient +from azure.core.pipeline import policies +from azure.core.rest import HttpRequest, HttpResponse + +from ._configuration import QueryClientConfiguration +from ._operations import QueryClientOperationsMixin +from ._serialization import Deserializer, Serializer + + +class QueryClient(QueryClientOperationsMixin): + """QueryClient. + + :keyword endpoint: Service host. Default value is "http://localhost:3000". + :paramtype endpoint: str + :keyword version: Default value is "2025-01-01". Note that overriding this default value may + result in unsupported behavior. + :paramtype version: str + """ + + def __init__( # pylint: disable=missing-client-constructor-parameter-credential + self, *, endpoint: str = "http://localhost:3000", **kwargs: Any + ) -> None: + _endpoint = "{endpoint}" + self._config = QueryClientConfiguration(endpoint=endpoint, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> Self: + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_configuration.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_configuration.py new file mode 100644 index 00000000000..d1f8b2e959c --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_configuration.py @@ -0,0 +1,47 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any + +from azure.core.pipeline import policies + +from ._version import VERSION + + +class QueryClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for QueryClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: Service host. Default value is "http://localhost:3000". + :type endpoint: str + :keyword version: Default value is "2025-01-01". Note that overriding this default value may + result in unsupported behavior. + :paramtype version: str + """ + + def __init__(self, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None: + version: str = kwargs.pop("version", "2025-01-01") + + self.endpoint = endpoint + self.version = version + kwargs.setdefault("sdk_moniker", "client-alternateapiversion-service-query/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_model_base.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_model_base.py new file mode 100644 index 00000000000..3072ee252ed --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_model_base.py @@ -0,0 +1,1235 @@ +# pylint: disable=too-many-lines +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access, broad-except + +import copy +import calendar +import decimal +import functools +import sys +import logging +import base64 +import re +import typing +import enum +import email.utils +from datetime import datetime, date, time, timedelta, timezone +from json import JSONEncoder +import xml.etree.ElementTree as ET +from typing_extensions import Self +import isodate +from azure.core.exceptions import DeserializationError +from azure.core import CaseInsensitiveEnumMeta +from azure.core.pipeline import PipelineResponse +from azure.core.serialization import _Null + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping + +_LOGGER = logging.getLogger(__name__) + +__all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] + +TZ_UTC = timezone.utc +_T = typing.TypeVar("_T") + + +def _timedelta_as_isostr(td: timedelta) -> str: + """Converts a datetime.timedelta object into an ISO 8601 formatted string, e.g. 'P4DT12H30M05S' + + Function adapted from the Tin Can Python project: https://github.com/RusticiSoftware/TinCanPython + + :param timedelta td: The timedelta to convert + :rtype: str + :return: ISO8601 version of this timedelta + """ + + # Split seconds to larger units + seconds = td.total_seconds() + minutes, seconds = divmod(seconds, 60) + hours, minutes = divmod(minutes, 60) + days, hours = divmod(hours, 24) + + days, hours, minutes = list(map(int, (days, hours, minutes))) + seconds = round(seconds, 6) + + # Build date + date_str = "" + if days: + date_str = "%sD" % days + + if hours or minutes or seconds: + # Build time + time_str = "T" + + # Hours + bigger_exists = date_str or hours + if bigger_exists: + time_str += "{:02}H".format(hours) + + # Minutes + bigger_exists = bigger_exists or minutes + if bigger_exists: + time_str += "{:02}M".format(minutes) + + # Seconds + try: + if seconds.is_integer(): + seconds_string = "{:02}".format(int(seconds)) + else: + # 9 chars long w/ leading 0, 6 digits after decimal + seconds_string = "%09.6f" % seconds + # Remove trailing zeros + seconds_string = seconds_string.rstrip("0") + except AttributeError: # int.is_integer() raises + seconds_string = "{:02}".format(seconds) + + time_str += "{}S".format(seconds_string) + else: + time_str = "" + + return "P" + date_str + time_str + + +def _serialize_bytes(o, format: typing.Optional[str] = None) -> str: + encoded = base64.b64encode(o).decode() + if format == "base64url": + return encoded.strip("=").replace("+", "-").replace("/", "_") + return encoded + + +def _serialize_datetime(o, format: typing.Optional[str] = None): + if hasattr(o, "year") and hasattr(o, "hour"): + if format == "rfc7231": + return email.utils.format_datetime(o, usegmt=True) + if format == "unix-timestamp": + return int(calendar.timegm(o.utctimetuple())) + + # astimezone() fails for naive times in Python 2.7, so make make sure o is aware (tzinfo is set) + if not o.tzinfo: + iso_formatted = o.replace(tzinfo=TZ_UTC).isoformat() + else: + iso_formatted = o.astimezone(TZ_UTC).isoformat() + # Replace the trailing "+00:00" UTC offset with "Z" (RFC 3339: https://www.ietf.org/rfc/rfc3339.txt) + return iso_formatted.replace("+00:00", "Z") + # Next try datetime.date or datetime.time + return o.isoformat() + + +def _is_readonly(p): + try: + return p._visibility == ["read"] + except AttributeError: + return False + + +class SdkJSONEncoder(JSONEncoder): + """A JSON encoder that's capable of serializing datetime objects and bytes.""" + + def __init__(self, *args, exclude_readonly: bool = False, format: typing.Optional[str] = None, **kwargs): + super().__init__(*args, **kwargs) + self.exclude_readonly = exclude_readonly + self.format = format + + def default(self, o): # pylint: disable=too-many-return-statements + if _is_model(o): + if self.exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + return {k: v for k, v in o.items() if k not in readonly_props} + return dict(o.items()) + try: + return super(SdkJSONEncoder, self).default(o) + except TypeError: + if isinstance(o, _Null): + return None + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, self.format) + try: + # First try datetime.datetime + return _serialize_datetime(o, self.format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return super(SdkJSONEncoder, self).default(o) + + +_VALID_DATE = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" + r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") +_VALID_RFC7231 = re.compile( + r"(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s\d{2}\s" + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT" +) + + +def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + attr = attr.upper() + match = _VALID_DATE.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + return date_obj + + +def _deserialize_datetime_rfc7231(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize RFC7231 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + match = _VALID_RFC7231.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + return email.utils.parsedate_to_datetime(attr) + + +def _deserialize_datetime_unix_timestamp(attr: typing.Union[float, datetime]) -> datetime: + """Deserialize unix timestamp into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + return datetime.fromtimestamp(attr, TZ_UTC) + + +def _deserialize_date(attr: typing.Union[str, date]) -> date: + """Deserialize ISO-8601 formatted string into Date object. + :param str attr: response string to be deserialized. + :rtype: date + :returns: The date object from that input + """ + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + if isinstance(attr, date): + return attr + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) # type: ignore + + +def _deserialize_time(attr: typing.Union[str, time]) -> time: + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :returns: The time object from that input + """ + if isinstance(attr, time): + return attr + return isodate.parse_time(attr) + + +def _deserialize_bytes(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + return bytes(base64.b64decode(attr)) + + +def _deserialize_bytes_base64(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return bytes(base64.b64decode(encoded)) + + +def _deserialize_duration(attr): + if isinstance(attr, timedelta): + return attr + return isodate.parse_duration(attr) + + +def _deserialize_decimal(attr): + if isinstance(attr, decimal.Decimal): + return attr + return decimal.Decimal(str(attr)) + + +def _deserialize_int_as_str(attr): + if isinstance(attr, int): + return attr + return int(attr) + + +_DESERIALIZE_MAPPING = { + datetime: _deserialize_datetime, + date: _deserialize_date, + time: _deserialize_time, + bytes: _deserialize_bytes, + bytearray: _deserialize_bytes, + timedelta: _deserialize_duration, + typing.Any: lambda x: x, + decimal.Decimal: _deserialize_decimal, +} + +_DESERIALIZE_MAPPING_WITHFORMAT = { + "rfc3339": _deserialize_datetime, + "rfc7231": _deserialize_datetime_rfc7231, + "unix-timestamp": _deserialize_datetime_unix_timestamp, + "base64": _deserialize_bytes, + "base64url": _deserialize_bytes_base64, +} + + +def get_deserializer(annotation: typing.Any, rf: typing.Optional["_RestField"] = None): + if annotation is int and rf and rf._format == "str": + return _deserialize_int_as_str + if rf and rf._format: + return _DESERIALIZE_MAPPING_WITHFORMAT.get(rf._format) + return _DESERIALIZE_MAPPING.get(annotation) # pyright: ignore + + +def _get_type_alias_type(module_name: str, alias_name: str): + types = { + k: v + for k, v in sys.modules[module_name].__dict__.items() + if isinstance(v, typing._GenericAlias) # type: ignore + } + if alias_name not in types: + return alias_name + return types[alias_name] + + +def _get_model(module_name: str, model_name: str): + models = {k: v for k, v in sys.modules[module_name].__dict__.items() if isinstance(v, type)} + module_end = module_name.rsplit(".", 1)[0] + models.update({k: v for k, v in sys.modules[module_end].__dict__.items() if isinstance(v, type)}) + if isinstance(model_name, str): + model_name = model_name.split(".")[-1] + if model_name not in models: + return model_name + return models[model_name] + + +_UNSET = object() + + +class _MyMutableMapping(MutableMapping[str, typing.Any]): # pylint: disable=unsubscriptable-object + def __init__(self, data: typing.Dict[str, typing.Any]) -> None: + self._data = data + + def __contains__(self, key: typing.Any) -> bool: + return key in self._data + + def __getitem__(self, key: str) -> typing.Any: + return self._data.__getitem__(key) + + def __setitem__(self, key: str, value: typing.Any) -> None: + self._data.__setitem__(key, value) + + def __delitem__(self, key: str) -> None: + self._data.__delitem__(key) + + def __iter__(self) -> typing.Iterator[typing.Any]: + return self._data.__iter__() + + def __len__(self) -> int: + return self._data.__len__() + + def __ne__(self, other: typing.Any) -> bool: + return not self.__eq__(other) + + def keys(self) -> typing.KeysView[str]: + """ + :returns: a set-like object providing a view on D's keys + :rtype: ~typing.KeysView + """ + return self._data.keys() + + def values(self) -> typing.ValuesView[typing.Any]: + """ + :returns: an object providing a view on D's values + :rtype: ~typing.ValuesView + """ + return self._data.values() + + def items(self) -> typing.ItemsView[str, typing.Any]: + """ + :returns: set-like object providing a view on D's items + :rtype: ~typing.ItemsView + """ + return self._data.items() + + def get(self, key: str, default: typing.Any = None) -> typing.Any: + """ + Get the value for key if key is in the dictionary, else default. + :param str key: The key to look up. + :param any default: The value to return if key is not in the dictionary. Defaults to None + :returns: D[k] if k in D, else d. + :rtype: any + """ + try: + return self[key] + except KeyError: + return default + + @typing.overload + def pop(self, key: str) -> typing.Any: ... + + @typing.overload + def pop(self, key: str, default: _T) -> _T: ... + + @typing.overload + def pop(self, key: str, default: typing.Any) -> typing.Any: ... + + def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Removes specified key and return the corresponding value. + :param str key: The key to pop. + :param any default: The value to return if key is not in the dictionary + :returns: The value corresponding to the key. + :rtype: any + :raises KeyError: If key is not found and default is not given. + """ + if default is _UNSET: + return self._data.pop(key) + return self._data.pop(key, default) + + def popitem(self) -> typing.Tuple[str, typing.Any]: + """ + Removes and returns some (key, value) pair + :returns: The (key, value) pair. + :rtype: tuple + :raises KeyError: if D is empty. + """ + return self._data.popitem() + + def clear(self) -> None: + """ + Remove all items from D. + """ + self._data.clear() + + def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: + """ + Updates D from mapping/iterable E and F. + :param any args: Either a mapping object or an iterable of key-value pairs. + """ + self._data.update(*args, **kwargs) + + @typing.overload + def setdefault(self, key: str, default: None = None) -> None: ... + + @typing.overload + def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... + + def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Same as calling D.get(k, d), and setting D[k]=d if k not found + :param str key: The key to look up. + :param any default: The value to set if key is not in the dictionary + :returns: D[k] if k in D, else d. + :rtype: any + """ + if default is _UNSET: + return self._data.setdefault(key) + return self._data.setdefault(key, default) + + def __eq__(self, other: typing.Any) -> bool: + try: + other_model = self.__class__(other) + except Exception: + return False + return self._data == other_model._data + + def __repr__(self) -> str: + return str(self._data) + + +def _is_model(obj: typing.Any) -> bool: + return getattr(obj, "_is_model", False) + + +def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-many-return-statements + if isinstance(o, list): + return [_serialize(x, format) for x in o] + if isinstance(o, dict): + return {k: _serialize(v, format) for k, v in o.items()} + if isinstance(o, set): + return {_serialize(x, format) for x in o} + if isinstance(o, tuple): + return tuple(_serialize(x, format) for x in o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, format) + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, enum.Enum): + return o.value + if isinstance(o, int): + if format == "str": + return str(o) + return o + try: + # First try datetime.datetime + return _serialize_datetime(o, format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return o + + +def _get_rest_field( + attr_to_rest_field: typing.Dict[str, "_RestField"], rest_name: str +) -> typing.Optional["_RestField"]: + try: + return next(rf for rf in attr_to_rest_field.values() if rf._rest_name == rest_name) + except StopIteration: + return None + + +def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typing.Any: + if not rf: + return _serialize(value, None) + if rf._is_multipart_file_input: + return value + if rf._is_model: + return _deserialize(rf._type, value) + if isinstance(value, ET.Element): + value = _deserialize(rf._type, value) + return _serialize(value, rf._format) + + +class Model(_MyMutableMapping): + _is_model = True + # label whether current class's _attr_to_rest_field has been calculated + # could not see _attr_to_rest_field directly because subclass inherits it from parent class + _calculated: typing.Set[str] = set() + + def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: + class_name = self.__class__.__name__ + if len(args) > 1: + raise TypeError(f"{class_name}.__init__() takes 2 positional arguments but {len(args) + 1} were given") + dict_to_pass = { + rest_field._rest_name: rest_field._default + for rest_field in self._attr_to_rest_field.values() + if rest_field._default is not _UNSET + } + if args: # pylint: disable=too-many-nested-blocks + if isinstance(args[0], ET.Element): + existed_attr_keys = [] + model_meta = getattr(self, "_xml", {}) + + for rf in self._attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + # attribute + if prop_meta.get("attribute", False) and args[0].get(xml_name) is not None: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].get(xml_name)) + continue + + # unwrapped element is array + if prop_meta.get("unwrapped", False): + # unwrapped array could either use prop items meta/prop meta + if prop_meta.get("itemsName"): + xml_name = prop_meta.get("itemsName") + xml_ns = prop_meta.get("itemNs") + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + items = args[0].findall(xml_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, items) + continue + + # text element is primitive type + if prop_meta.get("text", False): + if args[0].text is not None: + dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].text) + continue + + # wrapped element could be normal property or array, it should only have one element + item = args[0].find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, item) + + # rest thing is additional properties + for e in args[0]: + if e.tag not in existed_attr_keys: + dict_to_pass[e.tag] = _convert_element(e) + else: + dict_to_pass.update( + {k: _create_value(_get_rest_field(self._attr_to_rest_field, k), v) for k, v in args[0].items()} + ) + else: + non_attr_kwargs = [k for k in kwargs if k not in self._attr_to_rest_field] + if non_attr_kwargs: + # actual type errors only throw the first wrong keyword arg they see, so following that. + raise TypeError(f"{class_name}.__init__() got an unexpected keyword argument '{non_attr_kwargs[0]}'") + dict_to_pass.update( + { + self._attr_to_rest_field[k]._rest_name: _create_value(self._attr_to_rest_field[k], v) + for k, v in kwargs.items() + if v is not None + } + ) + super().__init__(dict_to_pass) + + def copy(self) -> "Model": + return Model(self.__dict__) + + def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: + if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated: + # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', + # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' + mros = cls.__mro__[:-9][::-1] # ignore parents, and reverse the mro order + attr_to_rest_field: typing.Dict[str, _RestField] = { # map attribute name to rest_field property + k: v for mro_class in mros for k, v in mro_class.__dict__.items() if k[0] != "_" and hasattr(v, "_type") + } + annotations = { + k: v + for mro_class in mros + if hasattr(mro_class, "__annotations__") + for k, v in mro_class.__annotations__.items() + } + for attr, rf in attr_to_rest_field.items(): + rf._module = cls.__module__ + if not rf._type: + rf._type = rf._get_deserialize_callable_from_annotation(annotations.get(attr, None)) + if not rf._rest_name_input: + rf._rest_name_input = attr + cls._attr_to_rest_field: typing.Dict[str, _RestField] = dict(attr_to_rest_field.items()) + cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") + + return super().__new__(cls) # pylint: disable=no-value-for-parameter + + def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: + for base in cls.__bases__: + if hasattr(base, "__mapping__"): + base.__mapping__[discriminator or cls.__name__] = cls # type: ignore + + @classmethod + def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]: + for v in cls.__dict__.values(): + if isinstance(v, _RestField) and v._is_discriminator and v._rest_name not in exist_discriminators: + return v + return None + + @classmethod + def _deserialize(cls, data, exist_discriminators): + if not hasattr(cls, "__mapping__"): + return cls(data) + discriminator = cls._get_discriminator(exist_discriminators) + if discriminator is None: + return cls(data) + exist_discriminators.append(discriminator._rest_name) + if isinstance(data, ET.Element): + model_meta = getattr(cls, "_xml", {}) + prop_meta = getattr(discriminator, "_xml", {}) + xml_name = prop_meta.get("name", discriminator._rest_name) + xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + if data.get(xml_name) is not None: + discriminator_value = data.get(xml_name) + else: + discriminator_value = data.find(xml_name).text # pyright: ignore + else: + discriminator_value = data.get(discriminator._rest_name) + mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore + return mapped_cls._deserialize(data, exist_discriminators) + + def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.Any]: + """Return a dict that can be turned into json using json.dump. + + :keyword bool exclude_readonly: Whether to remove the readonly properties. + :returns: A dict JSON compatible object + :rtype: dict + """ + + result = {} + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in self._attr_to_rest_field.values() if _is_readonly(p)] + for k, v in self.items(): + if exclude_readonly and k in readonly_props: # pyright: ignore + continue + is_multipart_file_input = False + try: + is_multipart_file_input = next( + rf for rf in self._attr_to_rest_field.values() if rf._rest_name == k + )._is_multipart_file_input + except StopIteration: + pass + result[k] = v if is_multipart_file_input else Model._as_dict_value(v, exclude_readonly=exclude_readonly) + return result + + @staticmethod + def _as_dict_value(v: typing.Any, exclude_readonly: bool = False) -> typing.Any: + if v is None or isinstance(v, _Null): + return None + if isinstance(v, (list, tuple, set)): + return type(v)(Model._as_dict_value(x, exclude_readonly=exclude_readonly) for x in v) + if isinstance(v, dict): + return {dk: Model._as_dict_value(dv, exclude_readonly=exclude_readonly) for dk, dv in v.items()} + return v.as_dict(exclude_readonly=exclude_readonly) if hasattr(v, "as_dict") else v + + +def _deserialize_model(model_deserializer: typing.Optional[typing.Callable], obj): + if _is_model(obj): + return obj + return _deserialize(model_deserializer, obj) + + +def _deserialize_with_optional(if_obj_deserializer: typing.Optional[typing.Callable], obj): + if obj is None: + return obj + return _deserialize_with_callable(if_obj_deserializer, obj) + + +def _deserialize_with_union(deserializers, obj): + for deserializer in deserializers: + try: + return _deserialize(deserializer, obj) + except DeserializationError: + pass + raise DeserializationError() + + +def _deserialize_dict( + value_deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj: typing.Dict[typing.Any, typing.Any], +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = {child.tag: child for child in obj} + return {k: _deserialize(value_deserializer, v, module) for k, v in obj.items()} + + +def _deserialize_multiple_sequence( + entry_deserializers: typing.List[typing.Optional[typing.Callable]], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers)) + + +def _deserialize_sequence( + deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = list(obj) + return type(obj)(_deserialize(deserializer, entry, module) for entry in obj) + + +def _sorted_annotations(types: typing.List[typing.Any]) -> typing.List[typing.Any]: + return sorted( + types, + key=lambda x: hasattr(x, "__name__") and x.__name__.lower() in ("str", "float", "int", "bool"), + ) + + +def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-branches + annotation: typing.Any, + module: typing.Optional[str], + rf: typing.Optional["_RestField"] = None, +) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + if not annotation: + return None + + # is it a type alias? + if isinstance(annotation, str): + if module is not None: + annotation = _get_type_alias_type(module, annotation) + + # is it a forward ref / in quotes? + if isinstance(annotation, (str, typing.ForwardRef)): + try: + model_name = annotation.__forward_arg__ # type: ignore + except AttributeError: + model_name = annotation + if module is not None: + annotation = _get_model(module, model_name) # type: ignore + + try: + if module and _is_model(annotation): + if rf: + rf._is_model = True + + return functools.partial(_deserialize_model, annotation) # pyright: ignore + except Exception: + pass + + # is it a literal? + try: + if annotation.__origin__ is typing.Literal: # pyright: ignore + return None + except AttributeError: + pass + + # is it optional? + try: + if any(a for a in annotation.__args__ if a == type(None)): # pyright: ignore + if len(annotation.__args__) <= 2: # pyright: ignore + if_obj_deserializer = _get_deserialize_callable_from_annotation( + next(a for a in annotation.__args__ if a != type(None)), module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_with_optional, if_obj_deserializer) + # the type is Optional[Union[...]], we need to remove the None type from the Union + annotation_copy = copy.copy(annotation) + annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a != type(None)] # pyright: ignore + return _get_deserialize_callable_from_annotation(annotation_copy, module, rf) + except AttributeError: + pass + + # is it union? + if getattr(annotation, "__origin__", None) is typing.Union: + # initial ordering is we make `string` the last deserialization option, because it is often them most generic + deserializers = [ + _get_deserialize_callable_from_annotation(arg, module, rf) + for arg in _sorted_annotations(annotation.__args__) # pyright: ignore + ] + + return functools.partial(_deserialize_with_union, deserializers) + + try: + if annotation._name == "Dict": # pyright: ignore + value_deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[1], module, rf # pyright: ignore + ) + + return functools.partial( + _deserialize_dict, + value_deserializer, + module, + ) + except (AttributeError, IndexError): + pass + try: + if annotation._name in ["List", "Set", "Tuple", "Sequence"]: # pyright: ignore + if len(annotation.__args__) > 1: # pyright: ignore + entry_deserializers = [ + _get_deserialize_callable_from_annotation(dt, module, rf) + for dt in annotation.__args__ # pyright: ignore + ] + return functools.partial(_deserialize_multiple_sequence, entry_deserializers, module) + deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[0], module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_sequence, deserializer, module) + except (TypeError, IndexError, AttributeError, SyntaxError): + pass + + def _deserialize_default( + deserializer, + obj, + ): + if obj is None: + return obj + try: + return _deserialize_with_callable(deserializer, obj) + except Exception: + pass + return obj + + if get_deserializer(annotation, rf): + return functools.partial(_deserialize_default, get_deserializer(annotation, rf)) + + return functools.partial(_deserialize_default, annotation) + + +def _deserialize_with_callable( + deserializer: typing.Optional[typing.Callable[[typing.Any], typing.Any]], + value: typing.Any, +): # pylint: disable=too-many-return-statements + try: + if value is None or isinstance(value, _Null): + return None + if isinstance(value, ET.Element): + if deserializer is str: + return value.text or "" + if deserializer is int: + return int(value.text) if value.text else None + if deserializer is float: + return float(value.text) if value.text else None + if deserializer is bool: + return value.text == "true" if value.text else None + if deserializer is None: + return value + if deserializer in [int, float, bool]: + return deserializer(value) + if isinstance(deserializer, CaseInsensitiveEnumMeta): + try: + return deserializer(value) + except ValueError: + # for unknown value, return raw value + return value + if isinstance(deserializer, type) and issubclass(deserializer, Model): + return deserializer._deserialize(value, []) + return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value) + except Exception as e: + raise DeserializationError() from e + + +def _deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + if isinstance(value, PipelineResponse): + value = value.http_response.json() + if rf is None and format: + rf = _RestField(format=format) + if not isinstance(deserializer, functools.partial): + deserializer = _get_deserialize_callable_from_annotation(deserializer, module, rf) + return _deserialize_with_callable(deserializer, value) + + +def _failsafe_deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + try: + return _deserialize(deserializer, value, module, rf, format) + except DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +def _failsafe_deserialize_xml( + deserializer: typing.Any, + value: typing.Any, +) -> typing.Any: + try: + return _deserialize_xml(deserializer, value) + except DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +class _RestField: + def __init__( + self, + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + is_discriminator: bool = False, + visibility: typing.Optional[typing.List[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[typing.Dict[str, typing.Any]] = None, + ): + self._type = type + self._rest_name_input = name + self._module: typing.Optional[str] = None + self._is_discriminator = is_discriminator + self._visibility = visibility + self._is_model = False + self._default = default + self._format = format + self._is_multipart_file_input = is_multipart_file_input + self._xml = xml if xml is not None else {} + + @property + def _class_type(self) -> typing.Any: + return getattr(self._type, "args", [None])[0] + + @property + def _rest_name(self) -> str: + if self._rest_name_input is None: + raise ValueError("Rest name was never set") + return self._rest_name_input + + def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin + # by this point, type and rest_name will have a value bc we default + # them in __new__ of the Model class + item = obj.get(self._rest_name) + if item is None: + return item + if self._is_model: + return item + return _deserialize(self._type, _serialize(item, self._format), rf=self) + + def __set__(self, obj: Model, value) -> None: + if value is None: + # we want to wipe out entries if users set attr to None + try: + obj.__delitem__(self._rest_name) + except KeyError: + pass + return + if self._is_model: + if not _is_model(value): + value = _deserialize(self._type, value) + obj.__setitem__(self._rest_name, value) + return + obj.__setitem__(self._rest_name, _serialize(value, self._format)) + + def _get_deserialize_callable_from_annotation( + self, annotation: typing.Any + ) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + return _get_deserialize_callable_from_annotation(annotation, self._module, self) + + +def rest_field( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[typing.List[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[typing.Dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField( + name=name, + type=type, + visibility=visibility, + default=default, + format=format, + is_multipart_file_input=is_multipart_file_input, + xml=xml, + ) + + +def rest_discriminator( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[typing.List[str]] = None, + xml: typing.Optional[typing.Dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField(name=name, type=type, is_discriminator=True, visibility=visibility, xml=xml) + + +def serialize_xml(model: Model, exclude_readonly: bool = False) -> str: + """Serialize a model to XML. + + :param Model model: The model to serialize. + :param bool exclude_readonly: Whether to exclude readonly properties. + :returns: The XML representation of the model. + :rtype: str + """ + return ET.tostring(_get_element(model, exclude_readonly), encoding="unicode") # type: ignore + + +def _get_element( + o: typing.Any, + exclude_readonly: bool = False, + parent_meta: typing.Optional[typing.Dict[str, typing.Any]] = None, + wrapped_element: typing.Optional[ET.Element] = None, +) -> typing.Union[ET.Element, typing.List[ET.Element]]: + if _is_model(o): + model_meta = getattr(o, "_xml", {}) + + # if prop is a model, then use the prop element directly, else generate a wrapper of model + if wrapped_element is None: + wrapped_element = _create_xml_element( + model_meta.get("name", o.__class__.__name__), + model_meta.get("prefix"), + model_meta.get("ns"), + ) + + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + + for k, v in o.items(): + # do not serialize readonly properties + if exclude_readonly and k in readonly_props: + continue + + prop_rest_field = _get_rest_field(o._attr_to_rest_field, k) + if prop_rest_field: + prop_meta = getattr(prop_rest_field, "_xml").copy() + # use the wire name as xml name if no specific name is set + if prop_meta.get("name") is None: + prop_meta["name"] = k + else: + # additional properties will not have rest field, use the wire name as xml name + prop_meta = {"name": k} + + # if no ns for prop, use model's + if prop_meta.get("ns") is None and model_meta.get("ns"): + prop_meta["ns"] = model_meta.get("ns") + prop_meta["prefix"] = model_meta.get("prefix") + + if prop_meta.get("unwrapped", False): + # unwrapped could only set on array + wrapped_element.extend(_get_element(v, exclude_readonly, prop_meta)) + elif prop_meta.get("text", False): + # text could only set on primitive type + wrapped_element.text = _get_primitive_type_value(v) + elif prop_meta.get("attribute", False): + xml_name = prop_meta.get("name", k) + if prop_meta.get("ns"): + ET.register_namespace(prop_meta.get("prefix"), prop_meta.get("ns")) # pyright: ignore + xml_name = "{" + prop_meta.get("ns") + "}" + xml_name # pyright: ignore + # attribute should be primitive type + wrapped_element.set(xml_name, _get_primitive_type_value(v)) + else: + # other wrapped prop element + wrapped_element.append(_get_wrapped_element(v, exclude_readonly, prop_meta)) + return wrapped_element + if isinstance(o, list): + return [_get_element(x, exclude_readonly, parent_meta) for x in o] # type: ignore + if isinstance(o, dict): + result = [] + for k, v in o.items(): + result.append( + _get_wrapped_element( + v, + exclude_readonly, + { + "name": k, + "ns": parent_meta.get("ns") if parent_meta else None, + "prefix": parent_meta.get("prefix") if parent_meta else None, + }, + ) + ) + return result + + # primitive case need to create element based on parent_meta + if parent_meta: + return _get_wrapped_element( + o, + exclude_readonly, + { + "name": parent_meta.get("itemsName", parent_meta.get("name")), + "prefix": parent_meta.get("itemsPrefix", parent_meta.get("prefix")), + "ns": parent_meta.get("itemsNs", parent_meta.get("ns")), + }, + ) + + raise ValueError("Could not serialize value into xml: " + o) + + +def _get_wrapped_element( + v: typing.Any, + exclude_readonly: bool, + meta: typing.Optional[typing.Dict[str, typing.Any]], +) -> ET.Element: + wrapped_element = _create_xml_element( + meta.get("name") if meta else None, meta.get("prefix") if meta else None, meta.get("ns") if meta else None + ) + if isinstance(v, (dict, list)): + wrapped_element.extend(_get_element(v, exclude_readonly, meta)) + elif _is_model(v): + _get_element(v, exclude_readonly, meta, wrapped_element) + else: + wrapped_element.text = _get_primitive_type_value(v) + return wrapped_element + + +def _get_primitive_type_value(v) -> str: + if v is True: + return "true" + if v is False: + return "false" + if isinstance(v, _Null): + return "" + return str(v) + + +def _create_xml_element(tag, prefix=None, ns=None): + if prefix and ns: + ET.register_namespace(prefix, ns) + if ns: + return ET.Element("{" + ns + "}" + tag) + return ET.Element(tag) + + +def _deserialize_xml( + deserializer: typing.Any, + value: str, +) -> typing.Any: + element = ET.fromstring(value) # nosec + return _deserialize(deserializer, element) + + +def _convert_element(e: ET.Element): + # dict case + if len(e.attrib) > 0 or len({child.tag for child in e}) > 1: + dict_result: typing.Dict[str, typing.Any] = {} + for child in e: + if dict_result.get(child.tag) is not None: + if isinstance(dict_result[child.tag], list): + dict_result[child.tag].append(_convert_element(child)) + else: + dict_result[child.tag] = [dict_result[child.tag], _convert_element(child)] + else: + dict_result[child.tag] = _convert_element(child) + dict_result.update(e.attrib) + return dict_result + # array case + if len(e) > 0: + array_result: typing.List[typing.Any] = [] + for child in e: + array_result.append(_convert_element(child)) + return array_result + # primitive case + return e.text diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_operations/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_operations/__init__.py new file mode 100644 index 00000000000..567607c23a2 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_operations/__init__.py @@ -0,0 +1,25 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import QueryClientOperationsMixin # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "QueryClientOperationsMixin", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_operations/_operations.py new file mode 100644 index 00000000000..3fa86121a30 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_operations/_operations.py @@ -0,0 +1,96 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict + +from .._serialization import Serializer +from .._vendor import QueryClientMixinABC + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_query_query_api_version_request(**kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + version: str = kwargs.pop("version", _params.pop("version", "2025-01-01")) + # Construct URL + _url = "/azure/client-generator-core/api-version/query" + + # Construct parameters + _params["version"] = _SERIALIZER.query("version", version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +class QueryClientOperationsMixin(QueryClientMixinABC): + + @distributed_trace + def query_api_version(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """Query api version parameter. + + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_query_query_api_version_request( + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_operations/_patch.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_operations/_patch.py new file mode 100644 index 00000000000..f7dd3251033 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_patch.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_patch.py new file mode 100644 index 00000000000..f7dd3251033 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_serialization.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_serialization.py new file mode 100644 index 00000000000..a066e16a64d --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_serialization.py @@ -0,0 +1,2050 @@ +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# 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. +# +# -------------------------------------------------------------------------- + +# pyright: reportUnnecessaryTypeIgnoreComment=false + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +from typing import ( + Dict, + Any, + cast, + Optional, + Union, + AnyStr, + IO, + Mapping, + Callable, + MutableMapping, + List, +) + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote +import xml.etree.ElementTree as ET + +import isodate # type: ignore +from typing_extensions import Self + +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +JSON = MutableMapping[str, Any] + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + :return: The deserialized data. + :rtype: object + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) from err + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError as err: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str + raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + + :param bytes body_bytes: The body of the response. + :param dict headers: The headers of the response. + :returns: The deserialized data. + :rtype: object + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + +TZ_UTC = datetime.timezone.utc + +_FLATTEN = re.compile(r"(? None: + self.additional_properties: Optional[Dict[str, Any]] = {} + for k in kwargs: # pylint: disable=consider-using-dict-items + if k not in self._attribute_map: + _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) + elif k in self._validation and self._validation[k].get("readonly", False): + _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) + else: + setattr(self, k, kwargs[k]) + + def __eq__(self, other: Any) -> bool: + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are equal + :rtype: bool + """ + if isinstance(other, self.__class__): + return self.__dict__ == other.__dict__ + return False + + def __ne__(self, other: Any) -> bool: + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are not equal + :rtype: bool + """ + return not self.__eq__(other) + + def __str__(self) -> str: + return str(self.__dict__) + + @classmethod + def enable_additional_properties_sending(cls) -> None: + cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} + + @classmethod + def is_xml_model(cls) -> bool: + try: + cls._xml_map # type: ignore + except AttributeError: + return False + return True + + @classmethod + def _create_xml_node(cls): + """Create XML node. + + :returns: The XML node + :rtype: xml.etree.ElementTree.Element + """ + try: + xml_map = cls._xml_map # type: ignore + except AttributeError: + xml_map = {} + + return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) + + def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: + """Return the JSON that would be sent to server from this model. + + This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param bool keep_readonly: If you want to serialize the readonly attributes + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, keep_readonly=keep_readonly, **kwargs + ) + + def as_dict( + self, + keep_readonly: bool = True, + key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + **kwargs: Any + ) -> JSON: + """Return a dict that can be serialized using json.dump. + + Advanced usage might optionally use a callback as parameter: + + .. code::python + + def my_key_transformer(key, attr_desc, value): + return key + + Key is the attribute name used in Python. Attr_desc + is a dict of metadata. Currently contains 'type' with the + msrest type and 'key' with the RestAPI encoded key. + Value is the current value in this object. + + The string returned will be used to serialize the key. + If the return type is a list, this is considered hierarchical + result dict. + + See the three examples in this file: + + - attribute_transformer + - full_restapi_key_transformer + - last_restapi_key_transformer + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param bool keep_readonly: If you want to serialize the readonly attributes + :param function key_transformer: A key transformer function. + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs + ) + + @classmethod + def _infer_class_models(cls): + try: + str_models = cls.__module__.rsplit(".", 1)[0] + models = sys.modules[str_models] + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + if cls.__name__ not in client_models: + raise ValueError("Not Autorest generated code") + except Exception: # pylint: disable=broad-exception-caught + # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. + client_models = {cls.__name__: cls} + return client_models + + @classmethod + def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: + """Parse a str using the RestAPI syntax and return a model. + + :param str data: A str using RestAPI structure. JSON by default. + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises DeserializationError: if something went wrong + :rtype: Self + """ + deserializer = Deserializer(cls._infer_class_models()) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore + + @classmethod + def from_dict( + cls, + data: Any, + key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + content_type: Optional[str] = None, + ) -> Self: + """Parse a dict using given key extractor return a model. + + By default consider key + extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor + and last_rest_key_case_insensitive_extractor) + + :param dict data: A dict using RestAPI structure + :param function key_extractors: A key extractor function. + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises: DeserializationError if something went wrong + :rtype: Self + """ + deserializer = Deserializer(cls._infer_class_models()) + deserializer.key_extractors = ( # type: ignore + [ # type: ignore + attribute_key_case_insensitive_extractor, + rest_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + if key_extractors is None + else key_extractors + ) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore + + @classmethod + def _flatten_subtype(cls, key, objects): + if "_subtype_map" not in cls.__dict__: + return {} + result = dict(cls._subtype_map[key]) + for valuetype in cls._subtype_map[key].values(): + result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access + return result + + @classmethod + def _classify(cls, response, objects): + """Check the class _subtype_map for any child classes. + We want to ignore any inherited _subtype_maps. + + :param dict response: The initial data + :param dict objects: The class objects + :returns: The class to be used + :rtype: class + """ + for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): + subtype_value = None + + if not isinstance(response, ET.Element): + rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] + subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) + else: + subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) + if subtype_value: + # Try to match base class. Can be class name only + # (bug to fix in Autorest to support x-ms-discriminator-name) + if cls.__name__ == subtype_value: + return cls + flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) + try: + return objects[flatten_mapping_type[subtype_value]] # type: ignore + except KeyError: + _LOGGER.warning( + "Subtype value %s has no mapping, use base class %s.", + subtype_value, + cls.__name__, + ) + break + else: + _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) + break + return cls + + @classmethod + def _get_rest_key_parts(cls, attr_key): + """Get the RestAPI key of this attr, split it and decode part + :param str attr_key: Attribute key must be in attribute_map. + :returns: A list of RestAPI part + :rtype: list + """ + rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) + return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] + + +def _decode_attribute_map_key(key): + """This decode a key in an _attribute_map to the actual key we want to look at + inside the received data. + + :param str key: A key string from the generated code + :returns: The decoded key + :rtype: str + """ + return key.replace("\\.", ".") + + +class Serializer: # pylint: disable=too-many-public-methods + """Request object model serializer.""" + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} + days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} + months = { + 1: "Jan", + 2: "Feb", + 3: "Mar", + 4: "Apr", + 5: "May", + 6: "Jun", + 7: "Jul", + 8: "Aug", + 9: "Sep", + 10: "Oct", + 11: "Nov", + 12: "Dec", + } + validation = { + "min_length": lambda x, y: len(x) < y, + "max_length": lambda x, y: len(x) > y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals + self, target_obj, data_type=None, **kwargs + ): + """Serialize data into a string according to type. + + :param object target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises SerializationError: if serialization fails. + :returns: The serialized data. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() # pylint: disable=protected-access + try: + attributes = target_obj._attribute_map # pylint: disable=protected-access + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access + attr_name, {} + ).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) # type: ignore + continue + if xml_desc.get("text", False): + serialized.text = new_attr # type: ignore + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) # type: ignore + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, + # we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) # type: ignore + else: # That's a basic type + # Integrate namespace if necessary + local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) + local_node.text = str(new_attr) + serialized.append(local_node) # type: ignore + else: # JSON + for k in reversed(keys): # type: ignore + new_attr = {k: new_attr} + + _new_attr = new_attr + _serialized = serialized + for k in keys: # type: ignore + if k not in _serialized: + _serialized.update(_new_attr) # type: ignore + _new_attr = _new_attr[k] # type: ignore + _serialized = _serialized[k] + except ValueError as err: + if isinstance(err, SerializationError): + raise + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) + raise SerializationError(msg) from err + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises SerializationError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized request body + """ + + # Just in case this is a dict + internal_data_type_str = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type_str, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ # type: ignore + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access + except DeserializationError as err: + raise SerializationError("Unable to build a model: " + str(err)) from err + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param str name: The name of the URL path parameter. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :returns: The serialized URL path + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) + else: + output = quote(str(output), safe="") + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param str name: The name of the query parameter. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, list + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized query parameter + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + do_quote = not kwargs.get("skip_quote", False) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param str name: The name of the header. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized header + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :raises AttributeError: if required data is None. + :raises ValueError: if data is None + :raises SerializationError: if serialization fails. + :returns: The serialized data. + :rtype: str, int, float, bool, dict, list + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data is CoreNull: + return None + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + if data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise SerializationError(msg.format(data, data_type)) from err + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param obj data: Object to be serialized. + :param str data_type: Type of object in the iterable. + :rtype: str, int, float, bool + :return: serialized object + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == "str": + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec # pylint: disable=eval-used + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param str data: Object to be serialized. + :rtype: str + :return: serialized object + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): # type: ignore + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list data: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + Defaults to False. + :rtype: list, str + :return: serialized iterable + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError as err: + if isinstance(err, SerializationError): + raise + serialized.append(None) + + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + + if div: + serialized = ["" if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :rtype: dict + :return: serialized dictionary + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError as err: + if isinstance(err, SerializationError): + raise + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + :return: serialized object + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + if obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) # type: ignore + return result + except ValueError as exc: + for enum_value in enum_obj: # type: ignore + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) from exc + + @staticmethod + def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument + """Serialize bytearray into base-64 string. + + :param str attr: Object to be serialized. + :rtype: str + :return: serialized base64 + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument + """Serialize str into base-64 string. + + :param str attr: Object to be serialized. + :rtype: str + :return: serialized base64 + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Decimal object to float. + + :param decimal attr: Object to be serialized. + :rtype: float + :return: serialized decimal + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): # pylint: disable=unused-argument + """Serialize long (Py2) or int (Py3). + + :param int attr: Object to be serialized. + :rtype: int/long + :return: serialized long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + :return: serialized date + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + :return: serialized time + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + :return: serialized duration + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises TypeError: if format invalid. + :return: serialized rfc + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError as exc: + raise TypeError("RFC1123 object must be valid Datetime object.") from exc + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises SerializationError: if format invalid. + :return: serialized iso + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise SerializationError(msg) from err + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise TypeError(msg) from err + + @staticmethod + def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises SerializationError: if format invalid + :return: serialied unix + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError as exc: + raise TypeError("Unix time object must be valid Datetime object.") from exc + + +def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + key = attr_desc["key"] + working_data = data + + while "." in key: + # Need the cast, as for some reasons "split" is typed as list[str | Any] + dict_keys = cast(List[str], _FLATTEN.split(key)) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + return None + key = ".".join(dict_keys[1:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements + attr, attr_desc, data +): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + return None + key = ".".join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get("name", internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer: + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.key_extractors = [rest_key_extractor, xml_key_extractor] + # Additional properties only works if the "rest_key_extractor" is used to + # extract the keys. Making it to work whatever the key extractor is too much + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, str): + return self.deserialize_data(data, response) + if isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None or data is CoreNull: + return data + try: + attributes = response._attribute_map # type: ignore # pylint: disable=protected-access + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc["type"]) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name # type: ignore + raise DeserializationError(msg) from err + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + :return: The classified target object and its class name. + :rtype: tuple + """ + if target is None: + return None, None + + if isinstance(target, str): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ # type: ignore + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + :param str content_type: Swagger "produces" if available. + :return: Deserialized object. + :rtype: object + """ + try: + return self(target_obj, data, content_type=content_type) + except: # pylint: disable=bare-except + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param obj raw_data: Data to be processed. + :param str content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + :rtype: object + :return: Unpacked content. + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, "_content_consumed"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) + + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param Response response: The response model class. + :param dict attrs: The deserialized response attributes. + :param dict additional_properties: Additional properties to be set. + :rtype: Response + :return: The instantiated response model. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("readonly") + ] + const = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("constant") + ] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties # type: ignore + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore + raise DeserializationError(msg + str(err)) from err + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) from exp + + def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment + "object", + "[]", + r"{}", + ] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise DeserializationError(msg) from err + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :return: Deserialized iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :return: Deserialized dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :return: Deserialized object. + :rtype: dict + :raises TypeError: if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, str): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :return: Deserialized basic type. + :rtype: str, int, float or bool + :raises TypeError: if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + if isinstance(attr, str): + if attr.lower() in ["true", "1"]: + return True + if attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec # pylint: disable=eval-used + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :return: Deserialized string. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): # type: ignore + return data + except NameError: + return str(data) + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :return: Deserialized enum object. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + try: + return list(enum_obj.__members__.values())[data] + except IndexError as exc: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) from exc + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :return: Deserialized bytearray + :rtype: bytearray + :raises TypeError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) # type: ignore + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :return: Deserialized base64 string + :rtype: bytearray + :raises TypeError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :return: Deserialized decimal + :raises DeserializationError: if string format invalid. + :rtype: decimal + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(str(attr)) # type: ignore + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise DeserializationError(msg) from err + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :return: Deserialized int + :rtype: long or int + :raises ValueError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) # type: ignore + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :return: Deserialized duration + :rtype: TimeDelta + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise DeserializationError(msg) from err + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :return: Deserialized date + :rtype: Date + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :return: Deserialized time + :rtype: datetime.time + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :return: Deserialized RFC datetime + :rtype: Datetime + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) # type: ignore + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise DeserializationError(msg) from err + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :return: Deserialized ISO datetime + :rtype: Datetime + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() # type: ignore + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise DeserializationError(msg) from err + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :return: Deserialized datetime + :rtype: Datetime + :raises DeserializationError: if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) # type: ignore + try: + attr = int(attr) + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise DeserializationError(msg) from err + return date_obj diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_vendor.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_vendor.py new file mode 100644 index 00000000000..da92612644d --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_vendor.py @@ -0,0 +1,25 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from ._configuration import QueryClientConfiguration + +if TYPE_CHECKING: + from azure.core import PipelineClient + + from ._serialization import Deserializer, Serializer + + +class QueryClientMixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "PipelineClient" + _config: QueryClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_version.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_version.py new file mode 100644 index 00000000000..be71c81bd28 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_version.py @@ -0,0 +1,9 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/__init__.py new file mode 100644 index 00000000000..6f02bd9751f --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/__init__.py @@ -0,0 +1,29 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import QueryClient # type: ignore + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "QueryClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore + +_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_client.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_client.py new file mode 100644 index 00000000000..6044ef167b5 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_client.py @@ -0,0 +1,96 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable +from typing_extensions import Self + +from azure.core import AsyncPipelineClient +from azure.core.pipeline import policies +from azure.core.rest import AsyncHttpResponse, HttpRequest + +from .._serialization import Deserializer, Serializer +from ._configuration import QueryClientConfiguration +from ._operations import QueryClientOperationsMixin + + +class QueryClient(QueryClientOperationsMixin): + """QueryClient. + + :keyword endpoint: Service host. Default value is "http://localhost:3000". + :paramtype endpoint: str + :keyword version: Default value is "2025-01-01". Note that overriding this default value may + result in unsupported behavior. + :paramtype version: str + """ + + def __init__( # pylint: disable=missing-client-constructor-parameter-credential + self, *, endpoint: str = "http://localhost:3000", **kwargs: Any + ) -> None: + _endpoint = "{endpoint}" + self._config = QueryClientConfiguration(endpoint=endpoint, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncPipelineClient = AsyncPipelineClient(base_url=_endpoint, policies=_policies, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + + def send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> Self: + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_configuration.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_configuration.py new file mode 100644 index 00000000000..21d105721de --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_configuration.py @@ -0,0 +1,47 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any + +from azure.core.pipeline import policies + +from .._version import VERSION + + +class QueryClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for QueryClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: Service host. Default value is "http://localhost:3000". + :type endpoint: str + :keyword version: Default value is "2025-01-01". Note that overriding this default value may + result in unsupported behavior. + :paramtype version: str + """ + + def __init__(self, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None: + version: str = kwargs.pop("version", "2025-01-01") + + self.endpoint = endpoint + self.version = version + kwargs.setdefault("sdk_moniker", "client-alternateapiversion-service-query/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_operations/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_operations/__init__.py new file mode 100644 index 00000000000..567607c23a2 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_operations/__init__.py @@ -0,0 +1,25 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import QueryClientOperationsMixin # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "QueryClientOperationsMixin", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_operations/_operations.py new file mode 100644 index 00000000000..6aa20c409f8 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_operations/_operations.py @@ -0,0 +1,79 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async + +from ..._operations._operations import build_query_query_api_version_request +from .._vendor import QueryClientMixinABC + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class QueryClientOperationsMixin(QueryClientMixinABC): + + @distributed_trace_async + async def query_api_version(self, **kwargs: Any) -> None: + """Query api version parameter. + + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_query_query_api_version_request( + version=self._config.version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_operations/_patch.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_operations/_patch.py new file mode 100644 index 00000000000..f7dd3251033 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_patch.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_patch.py new file mode 100644 index 00000000000..f7dd3251033 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_vendor.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_vendor.py new file mode 100644 index 00000000000..8d960bcfde1 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_vendor.py @@ -0,0 +1,25 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from ._configuration import QueryClientConfiguration + +if TYPE_CHECKING: + from azure.core import AsyncPipelineClient + + from .._serialization import Deserializer, Serializer + + +class QueryClientMixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "AsyncPipelineClient" + _config: QueryClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/py.typed b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/dev_requirements.txt b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/dev_requirements.txt new file mode 100644 index 00000000000..10548647144 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/dev_requirements.txt @@ -0,0 +1,3 @@ +-e ../../../tools/azure-sdk-tools +../../core/azure-core +aiohttp \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/conftest.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/conftest.py new file mode 100644 index 00000000000..d32ba91cfc6 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/conftest.py @@ -0,0 +1,35 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# For security, please avoid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + query_subscription_id = os.environ.get("QUERY_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + query_tenant_id = os.environ.get("QUERY_TENANT_ID", "00000000-0000-0000-0000-000000000000") + query_client_id = os.environ.get("QUERY_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + query_client_secret = os.environ.get("QUERY_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=query_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=query_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=query_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=query_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/test_query.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/test_query.py new file mode 100644 index 00000000000..c0f33e0ef31 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/test_query.py @@ -0,0 +1,22 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from devtools_testutils import recorded_by_proxy +from testpreparer import QueryClientTestBase, QueryPreparer + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestQuery(QueryClientTestBase): + @QueryPreparer() + @recorded_by_proxy + def test_query_api_version(self, query_endpoint): + client = self.create_client(endpoint=query_endpoint) + response = client.query_api_version() + + # please add some check logic here by yourself + # ... diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/test_query_async.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/test_query_async.py new file mode 100644 index 00000000000..55a81e5ce69 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/test_query_async.py @@ -0,0 +1,23 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from devtools_testutils.aio import recorded_by_proxy_async +from testpreparer import QueryPreparer +from testpreparer_async import QueryClientTestBaseAsync + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestQueryAsync(QueryClientTestBaseAsync): + @QueryPreparer() + @recorded_by_proxy_async + async def test_query_api_version(self, query_endpoint): + client = self.create_async_client(endpoint=query_endpoint) + response = await client.query_api_version() + + # please add some check logic here by yourself + # ... diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/testpreparer.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/testpreparer.py new file mode 100644 index 00000000000..7e19deda400 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/testpreparer.py @@ -0,0 +1,24 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from client.alternateapiversion.service.query import QueryClient +from devtools_testutils import AzureRecordedTestCase, PowerShellPreparer +import functools + + +class QueryClientTestBase(AzureRecordedTestCase): + + def create_client(self, endpoint): + credential = self.get_credential(QueryClient) + return self.create_client_from_credential( + QueryClient, + credential=credential, + endpoint=endpoint, + ) + + +QueryPreparer = functools.partial(PowerShellPreparer, "query", query_endpoint="https://fake_query_endpoint.com") diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/testpreparer_async.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/testpreparer_async.py new file mode 100644 index 00000000000..27fa3c9e341 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/testpreparer_async.py @@ -0,0 +1,20 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from client.alternateapiversion.service.query.aio import QueryClient +from devtools_testutils import AzureRecordedTestCase + + +class QueryClientTestBaseAsync(AzureRecordedTestCase): + + def create_async_client(self, endpoint): + credential = self.get_credential(QueryClient, is_async=True) + return self.create_client_from_credential( + QueryClient, + credential=credential, + endpoint=endpoint, + ) diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/setup.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/setup.py new file mode 100644 index 00000000000..0851e70a2bb --- /dev/null +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/setup.py @@ -0,0 +1,72 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# coding: utf-8 + +import os +import re +from setuptools import setup, find_packages + + +PACKAGE_NAME = "client-alternateapiversion-service-query" +PACKAGE_PPRINT_NAME = "Client Alternateapiversion Service Query" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace("-", "/") + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, "_version.py"), "r") as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError("Cannot find version information") + + +setup( + name=PACKAGE_NAME, + version=version, + description="Microsoft {} Client Library for Python".format(PACKAGE_PPRINT_NAME), + long_description=open("README.md", "r").read(), + long_description_content_type="text/markdown", + license="MIT License", + author="Microsoft Corporation", + author_email="azpysdkhelp@microsoft.com", + url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk", + keywords="azure, azure sdk", + classifiers=[ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "License :: OSI Approved :: MIT License", + ], + zip_safe=False, + packages=find_packages( + exclude=[ + "tests", + # Exclude packages that will be covered by PEP420 or nspkg + "client", + "client.alternateapiversion", + "client.alternateapiversion.service", + ] + ), + include_package_data=True, + package_data={ + "client.alternateapiversion.service.query": ["py.typed"], + }, + install_requires=[ + "isodate>=0.6.1", + "azure-core>=1.30.0", + "typing-extensions>=4.6.0", + ], + python_requires=">=3.8", +) diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-flatten-property/specs/azure/clientgenerator/core/flattenproperty/models/_models.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-flatten-property/specs/azure/clientgenerator/core/flattenproperty/models/_models.py index 4dc62eafbda..91759513031 100644 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-flatten-property/specs/azure/clientgenerator/core/flattenproperty/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-flatten-property/specs/azure/clientgenerator/core/flattenproperty/models/_models.py @@ -26,9 +26,9 @@ class ChildFlattenModel(_model_base.Model): :vartype properties: ~specs.azure.clientgenerator.core.flattenproperty.models.ChildModel """ - summary: str = rest_field() + summary: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - properties: "_models.ChildModel" = rest_field() + properties: "_models.ChildModel" = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" __flattened_items = ["description", "age"] @@ -80,9 +80,9 @@ class ChildModel(_model_base.Model): :vartype age: int """ - description: str = rest_field() + description: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - age: int = rest_field() + age: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -114,9 +114,9 @@ class FlattenModel(_model_base.Model): :vartype properties: ~specs.azure.clientgenerator.core.flattenproperty.models.ChildModel """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - properties: "_models.ChildModel" = rest_field() + properties: "_models.ChildModel" = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" __flattened_items = ["description", "age"] @@ -168,9 +168,9 @@ class NestedFlattenModel(_model_base.Model): :vartype properties: ~specs.azure.clientgenerator.core.flattenproperty.models.ChildFlattenModel """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - properties: "_models.ChildFlattenModel" = rest_field() + properties: "_models.ChildFlattenModel" = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/specs/azure/clientgenerator/core/usage/models/_models.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/specs/azure/clientgenerator/core/usage/models/_models.py index 6b26cd8076e..340476bcbae 100644 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/specs/azure/clientgenerator/core/usage/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/specs/azure/clientgenerator/core/usage/models/_models.py @@ -24,7 +24,7 @@ class InputModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -55,7 +55,7 @@ class OrphanModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -84,7 +84,7 @@ class OutputModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -113,7 +113,7 @@ class ResultModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/azure-core-basic/specs/azure/core/basic/models/_models.py b/packages/typespec-python/test/azure/generated/azure-core-basic/specs/azure/core/basic/models/_models.py index be82ef46db7..1584623698a 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-basic/specs/azure/core/basic/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azure-core-basic/specs/azure/core/basic/models/_models.py @@ -34,9 +34,9 @@ class User(_model_base.Model): id: int = rest_field(visibility=["read"]) """The user's id. Required.""" - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The user's name. Required.""" - orders: Optional[List["_models.UserOrder"]] = rest_field() + orders: Optional[List["_models.UserOrder"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The user's order list.""" etag: str = rest_field(visibility=["read"]) """The entity tag for this resource. Required.""" @@ -68,7 +68,7 @@ class UserList(_model_base.Model): :vartype users: list[~specs.azure.core.basic.models.User] """ - users: List["_models.User"] = rest_field() + users: List["_models.User"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -105,9 +105,9 @@ class UserOrder(_model_base.Model): id: int = rest_field(visibility=["read"]) """The user's id. Required.""" - user_id: int = rest_field(name="userId") + user_id: int = rest_field(name="userId", visibility=["read", "create", "update", "delete", "query"]) """The user's id. Required.""" - detail: str = rest_field() + detail: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The user's order detail. Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/azure-core-lro-standard/specs/azure/core/lro/standard/models/_models.py b/packages/typespec-python/test/azure/generated/azure-core-lro-standard/specs/azure/core/lro/standard/models/_models.py index 8cd4195ba67..a2b18c7aa46 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-lro-standard/specs/azure/core/lro/standard/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azure-core-lro-standard/specs/azure/core/lro/standard/models/_models.py @@ -23,9 +23,9 @@ class ExportedUser(_model_base.Model): :vartype resource_uri: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name of user. Required.""" - resource_uri: str = rest_field(name="resourceUri") + resource_uri: str = rest_field(name="resourceUri", visibility=["read", "create", "update", "delete", "query"]) """The exported URI. Required.""" @overload @@ -61,7 +61,7 @@ class User(_model_base.Model): name: str = rest_field(visibility=["read"]) """The name of user. Required.""" - role: str = rest_field() + role: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The role of user. Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/azure-core-model/specs/azure/core/model/models/_models.py b/packages/typespec-python/test/azure/generated/azure-core-model/specs/azure/core/model/models/_models.py index 862cd5a6aa3..6eed6c4fadf 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-model/specs/azure/core/model/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azure-core-model/specs/azure/core/model/models/_models.py @@ -21,7 +21,7 @@ class AzureEmbeddingModel(_model_base.Model): :vartype embedding: list[int] """ - embedding: List[int] = rest_field() + embedding: List[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/azure-core-page/specs/azure/core/page/models/_models.py b/packages/typespec-python/test/azure/generated/azure-core-page/specs/azure/core/page/models/_models.py index efa49e7a278..9b707c6928f 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-page/specs/azure/core/page/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azure-core-page/specs/azure/core/page/models/_models.py @@ -39,7 +39,7 @@ class ListItemInputBody(_model_base.Model): :vartype input_name: str """ - input_name: str = rest_field(name="inputName") + input_name: str = rest_field(name="inputName", visibility=["read", "create", "update", "delete", "query"]) """The name of the input. Required.""" @overload @@ -92,9 +92,9 @@ class User(_model_base.Model): id: int = rest_field(visibility=["read"]) """The user's id. Required.""" - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The user's name. Required.""" - orders: Optional[List["_models.UserOrder"]] = rest_field() + orders: Optional[List["_models.UserOrder"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The user's order list.""" etag: str = rest_field(visibility=["read"]) """The entity tag for this resource. Required.""" @@ -134,9 +134,9 @@ class UserOrder(_model_base.Model): id: int = rest_field(visibility=["read"]) """The user's id. Required.""" - user_id: int = rest_field(name="userId") + user_id: int = rest_field(name="userId", visibility=["read", "create", "update", "delete", "query"]) """The user's id. Required.""" - detail: str = rest_field() + detail: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The user's order detail. Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/azure-core-scalar/specs/azure/core/scalar/models/_models.py b/packages/typespec-python/test/azure/generated/azure-core-scalar/specs/azure/core/scalar/models/_models.py index a87ad21f18d..220989dab89 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-scalar/specs/azure/core/scalar/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azure-core-scalar/specs/azure/core/scalar/models/_models.py @@ -21,7 +21,7 @@ class AzureLocationModel(_model_base.Model): :vartype location: str """ - location: str = rest_field() + location: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/models/_models.py b/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/models/_models.py index a7549129593..da83da066df 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/models/_models.py @@ -27,7 +27,7 @@ class User(_model_base.Model): id: int = rest_field(visibility=["read"]) """The user's id. Required.""" - name: Optional[str] = rest_field() + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The user's name.""" @overload @@ -57,7 +57,9 @@ class UserActionParam(_model_base.Model): :vartype user_action_value: str """ - user_action_value: str = rest_field(name="userActionValue") + user_action_value: str = rest_field( + name="userActionValue", visibility=["read", "create", "update", "delete", "query"] + ) """User action value. Required.""" @overload @@ -86,7 +88,9 @@ class UserActionResponse(_model_base.Model): :vartype user_action_result: str """ - user_action_result: str = rest_field(name="userActionResult") + user_action_result: str = rest_field( + name="userActionResult", visibility=["read", "create", "update", "delete", "query"] + ) """User action result. Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/models/_models.py b/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/models/_models.py index 1a6da6692dc..75081a63549 100644 --- a/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/models/_models.py @@ -31,11 +31,17 @@ class ActionRequest(_model_base.Model): :vartype record_property: dict[str, str] """ - string_property: str = rest_field(name="stringProperty") + string_property: str = rest_field(name="stringProperty", visibility=["read", "create", "update", "delete", "query"]) """Required.""" - model_property: Optional["_models.Model"] = rest_field(name="modelProperty") - array_property: Optional[List[str]] = rest_field(name="arrayProperty") - record_property: Optional[Dict[str, str]] = rest_field(name="recordProperty") + model_property: Optional["_models.Model"] = rest_field( + name="modelProperty", visibility=["read", "create", "update", "delete", "query"] + ) + array_property: Optional[List[str]] = rest_field( + name="arrayProperty", visibility=["read", "create", "update", "delete", "query"] + ) + record_property: Optional[Dict[str, str]] = rest_field( + name="recordProperty", visibility=["read", "create", "update", "delete", "query"] + ) @overload def __init__( @@ -72,11 +78,17 @@ class ActionResponse(_model_base.Model): :vartype record_property: dict[str, str] """ - string_property: str = rest_field(name="stringProperty") + string_property: str = rest_field(name="stringProperty", visibility=["read", "create", "update", "delete", "query"]) """Required.""" - model_property: Optional["_models.Model"] = rest_field(name="modelProperty") - array_property: Optional[List[str]] = rest_field(name="arrayProperty") - record_property: Optional[Dict[str, str]] = rest_field(name="recordProperty") + model_property: Optional["_models.Model"] = rest_field( + name="modelProperty", visibility=["read", "create", "update", "delete", "query"] + ) + array_property: Optional[List[str]] = rest_field( + name="arrayProperty", visibility=["read", "create", "update", "delete", "query"] + ) + record_property: Optional[Dict[str, str]] = rest_field( + name="recordProperty", visibility=["read", "create", "update", "delete", "query"] + ) @overload def __init__( @@ -110,9 +122,15 @@ class Model(_model_base.Model): :vartype enum_property: str or ~specs.azure.example.basic.models.EnumEnum """ - int32_property: Optional[int] = rest_field(name="int32Property") - float32_property: Optional[float] = rest_field(name="float32Property") - enum_property: Optional[Union[str, "_models.EnumEnum"]] = rest_field(name="enumProperty") + int32_property: Optional[int] = rest_field( + name="int32Property", visibility=["read", "create", "update", "delete", "query"] + ) + float32_property: Optional[float] = rest_field( + name="float32Property", visibility=["read", "create", "update", "delete", "query"] + ) + enum_property: Optional[Union[str, "_models.EnumEnum"]] = rest_field( + name="enumProperty", visibility=["read", "create", "update", "delete", "query"] + ) """\"EnumValue1\"""" @overload diff --git a/packages/typespec-python/test/azure/generated/azure-payload-pageable/specs/azure/payload/pageable/models/_models.py b/packages/typespec-python/test/azure/generated/azure-payload-pageable/specs/azure/payload/pageable/models/_models.py index 0d0d1c180cb..fdff1eb60ea 100644 --- a/packages/typespec-python/test/azure/generated/azure-payload-pageable/specs/azure/payload/pageable/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azure-payload-pageable/specs/azure/payload/pageable/models/_models.py @@ -21,7 +21,7 @@ class User(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """User name. Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/models/_models.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/models/_models.py index 7c3532cd635..e7bf4351785 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/models/_models.py @@ -74,7 +74,7 @@ class ErrorResponse(_model_base.Model): :vartype error: ~azure.resourcemanager.commonproperties.models.ErrorDetail """ - error: Optional["_models.ErrorDetail"] = rest_field() + error: Optional["_models.ErrorDetail"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The error object.""" @overload @@ -149,7 +149,7 @@ class TrackedResource(Resource): :vartype location: str """ - tags: Optional[Dict[str, str]] = rest_field() + tags: Optional[Dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Resource tags.""" location: str = rest_field(visibility=["read", "create"]) """The geo-location where the resource lives. Required.""" @@ -202,9 +202,13 @@ class ManagedIdentityTrackedResource(TrackedResource): :vartype identity: ~azure.resourcemanager.commonproperties.models.ManagedServiceIdentity """ - properties: Optional["_models.ManagedIdentityTrackedResourceProperties"] = rest_field() + properties: Optional["_models.ManagedIdentityTrackedResourceProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The resource-specific properties for this resource.""" - identity: Optional["_models.ManagedServiceIdentity"] = rest_field() + identity: Optional["_models.ManagedServiceIdentity"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The managed service identities assigned to this resource.""" @overload @@ -268,11 +272,13 @@ class ManagedServiceIdentity(_model_base.Model): tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read"]) """The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity.""" - type: Union[str, "_models.ManagedServiceIdentityType"] = rest_field() + type: Union[str, "_models.ManagedServiceIdentityType"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The type of managed identity assigned to this resource. Required. Known values are: \"None\", \"SystemAssigned\", \"UserAssigned\", and \"SystemAssigned,UserAssigned\".""" user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = rest_field( - name="userAssignedIdentities" + name="userAssignedIdentities", visibility=["read", "create", "update", "delete", "query"] ) """The identities assigned to this resource by the user.""" @@ -315,19 +321,29 @@ class SystemData(_model_base.Model): :vartype last_modified_at: ~datetime.datetime """ - created_by: Optional[str] = rest_field(name="createdBy") + created_by: Optional[str] = rest_field(name="createdBy", visibility=["read", "create", "update", "delete", "query"]) """The identity that created the resource.""" - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field(name="createdByType") + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="createdByType", visibility=["read", "create", "update", "delete", "query"] + ) """The type of identity that created the resource. Known values are: \"User\", \"Application\", \"ManagedIdentity\", and \"Key\".""" - created_at: Optional[datetime.datetime] = rest_field(name="createdAt", format="rfc3339") + created_at: Optional[datetime.datetime] = rest_field( + name="createdAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) """The timestamp of resource creation (UTC).""" - last_modified_by: Optional[str] = rest_field(name="lastModifiedBy") + last_modified_by: Optional[str] = rest_field( + name="lastModifiedBy", visibility=["read", "create", "update", "delete", "query"] + ) """The identity that last modified the resource.""" - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field(name="lastModifiedByType") + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="lastModifiedByType", visibility=["read", "create", "update", "delete", "query"] + ) """The type of identity that last modified the resource. Known values are: \"User\", \"Application\", \"ManagedIdentity\", and \"Key\".""" - last_modified_at: Optional[datetime.datetime] = rest_field(name="lastModifiedAt", format="rfc3339") + last_modified_at: Optional[datetime.datetime] = rest_field( + name="lastModifiedAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) """The timestamp of resource last modification (UTC).""" @overload @@ -358,13 +374,13 @@ class UserAssignedIdentity(_model_base.Model): Readonly variables are only populated by the server, and will be ignored when sending a request. - :ivar principal_id: The principal ID of the assigned identity. - :vartype principal_id: str :ivar client_id: The client ID of the assigned identity. :vartype client_id: str + :ivar principal_id: The principal ID of the assigned identity. + :vartype principal_id: str """ - principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) - """The principal ID of the assigned identity.""" client_id: Optional[str] = rest_field(name="clientId", visibility=["read"]) """The client ID of the assigned identity.""" + principal_id: Optional[str] = rest_field(name="principalId", visibility=["read"]) + """The principal ID of the assigned identity.""" diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/models/_models.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/models/_models.py index cf2b30ca0ab..c39cf961f66 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/models/_models.py @@ -26,9 +26,9 @@ class CheckNameAvailabilityRequest(_model_base.Model): :vartype type: str """ - name: Optional[str] = rest_field() + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name of the resource for which availability needs to be checked.""" - type: Optional[str] = rest_field() + type: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The resource type.""" @overload @@ -63,12 +63,16 @@ class CheckNameAvailabilityResponse(_model_base.Model): :vartype message: str """ - name_available: Optional[bool] = rest_field(name="nameAvailable") + name_available: Optional[bool] = rest_field( + name="nameAvailable", visibility=["read", "create", "update", "delete", "query"] + ) """Indicates if the resource name is available.""" - reason: Optional[Union[str, "_models.CheckNameAvailabilityReason"]] = rest_field() + reason: Optional[Union[str, "_models.CheckNameAvailabilityReason"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The reason why the given name is not available. Known values are: \"Invalid\" and \"AlreadyExists\".""" - message: Optional[str] = rest_field() + message: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Detailed reason why the given name is not available.""" @overload @@ -148,7 +152,7 @@ class ErrorResponse(_model_base.Model): :vartype error: ~azure.resourcemanager.operationtemplates.models.ErrorDetail """ - error: Optional["_models.ErrorDetail"] = rest_field() + error: Optional["_models.ErrorDetail"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The error object.""" @overload @@ -178,7 +182,7 @@ class ExportRequest(_model_base.Model): :vartype format: str """ - format: str = rest_field() + format: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Format of the exported order. Required.""" @overload @@ -228,7 +232,9 @@ class Operation(_model_base.Model): is_data_action: Optional[bool] = rest_field(name="isDataAction", visibility=["read"]) """Whether the operation applies to data-plane. This is \"true\" for data-plane operations and \"false\" for Azure Resource Manager/control-plane operations.""" - display: Optional["_models.OperationDisplay"] = rest_field() + display: Optional["_models.OperationDisplay"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """Localized display information for this particular operation.""" origin: Optional[Union[str, "_models.Origin"]] = rest_field(visibility=["read"]) """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit @@ -343,7 +349,7 @@ class TrackedResource(Resource): :vartype location: str """ - tags: Optional[Dict[str, str]] = rest_field() + tags: Optional[Dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Resource tags.""" location: str = rest_field(visibility=["read", "create"]) """The geo-location where the resource lives. Required.""" @@ -393,7 +399,9 @@ class Order(TrackedResource): :vartype properties: ~azure.resourcemanager.operationtemplates.models.OrderProperties """ - properties: Optional["_models.OrderProperties"] = rest_field() + properties: Optional["_models.OrderProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The resource-specific properties for this resource.""" @overload @@ -430,9 +438,9 @@ class OrderProperties(_model_base.Model): :vartype provisioning_state: str """ - product_id: str = rest_field(name="productId") + product_id: str = rest_field(name="productId", visibility=["read", "create", "update", "delete", "query"]) """The product ID of the order. Required.""" - amount: int = rest_field() + amount: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Amount of the product. Required.""" provisioning_state: Optional[str] = rest_field(name="provisioningState", visibility=["read"]) """The provisioning state of the product.""" @@ -476,19 +484,29 @@ class SystemData(_model_base.Model): :vartype last_modified_at: ~datetime.datetime """ - created_by: Optional[str] = rest_field(name="createdBy") + created_by: Optional[str] = rest_field(name="createdBy", visibility=["read", "create", "update", "delete", "query"]) """The identity that created the resource.""" - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field(name="createdByType") + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="createdByType", visibility=["read", "create", "update", "delete", "query"] + ) """The type of identity that created the resource. Known values are: \"User\", \"Application\", \"ManagedIdentity\", and \"Key\".""" - created_at: Optional[datetime.datetime] = rest_field(name="createdAt", format="rfc3339") + created_at: Optional[datetime.datetime] = rest_field( + name="createdAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) """The timestamp of resource creation (UTC).""" - last_modified_by: Optional[str] = rest_field(name="lastModifiedBy") + last_modified_by: Optional[str] = rest_field( + name="lastModifiedBy", visibility=["read", "create", "update", "delete", "query"] + ) """The identity that last modified the resource.""" - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field(name="lastModifiedByType") + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="lastModifiedByType", visibility=["read", "create", "update", "delete", "query"] + ) """The type of identity that last modified the resource. Known values are: \"User\", \"Application\", \"ManagedIdentity\", and \"Key\".""" - last_modified_at: Optional[datetime.datetime] = rest_field(name="lastModifiedAt", format="rfc3339") + last_modified_at: Optional[datetime.datetime] = rest_field( + name="lastModifiedAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) """The timestamp of resource last modification (UTC).""" @overload diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/models/_models.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/models/_models.py index 2927a1501be..d57ad92bfc8 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/models/_models.py @@ -73,7 +73,7 @@ class ErrorResponse(_model_base.Model): :vartype error: ~azure.resourcemanager.resources.models.ErrorDetail """ - error: Optional["_models.ErrorDetail"] = rest_field() + error: Optional["_models.ErrorDetail"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The error object.""" @overload @@ -164,7 +164,9 @@ class ExtensionsResource(ExtensionResource): :vartype properties: ~azure.resourcemanager.resources.models.ExtensionsResourceProperties """ - properties: Optional["_models.ExtensionsResourceProperties"] = rest_field() + properties: Optional["_models.ExtensionsResourceProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The resource-specific properties for this resource.""" @overload @@ -197,7 +199,7 @@ class ExtensionsResourceProperties(_model_base.Model): :vartype provisioning_state: str or ~azure.resourcemanager.resources.models.ProvisioningState """ - description: Optional[str] = rest_field() + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The description of the resource.""" provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( name="provisioningState", visibility=["read"] @@ -264,7 +266,9 @@ class LocationResource(ProxyResource): :vartype properties: ~azure.resourcemanager.resources.models.LocationResourceProperties """ - properties: Optional["_models.LocationResourceProperties"] = rest_field() + properties: Optional["_models.LocationResourceProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The resource-specific properties for this resource.""" @overload @@ -297,7 +301,7 @@ class LocationResourceProperties(_model_base.Model): :vartype provisioning_state: str or ~azure.resourcemanager.resources.models.ProvisioningState """ - description: Optional[str] = rest_field() + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The description of the resource.""" provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( name="provisioningState", visibility=["read"] @@ -343,7 +347,9 @@ class NestedProxyResource(ProxyResource): :vartype properties: ~azure.resourcemanager.resources.models.NestedProxyResourceProperties """ - properties: Optional["_models.NestedProxyResourceProperties"] = rest_field() + properties: Optional["_models.NestedProxyResourceProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The resource-specific properties for this resource.""" @overload @@ -381,7 +387,7 @@ class NestedProxyResourceProperties(_model_base.Model): ) """Provisioning State of the nested child Resource. Known values are: \"Succeeded\", \"Failed\", \"Canceled\", \"Provisioning\", \"Updating\", \"Deleting\", and \"Accepted\".""" - description: Optional[str] = rest_field() + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Nested resource description.""" @overload @@ -413,9 +419,9 @@ class NotificationDetails(_model_base.Model): :vartype urgent: bool """ - message: str = rest_field() + message: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The notification message. Required.""" - urgent: bool = rest_field() + urgent: bool = rest_field(visibility=["read", "create", "update", "delete", "query"]) """If true, the notification is urgent. Required.""" @overload @@ -461,7 +467,7 @@ class TrackedResource(Resource): :vartype location: str """ - tags: Optional[Dict[str, str]] = rest_field() + tags: Optional[Dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Resource tags.""" location: str = rest_field(visibility=["read", "create"]) """The geo-location where the resource lives. Required.""" @@ -511,7 +517,9 @@ class SingletonTrackedResource(TrackedResource): :vartype properties: ~azure.resourcemanager.resources.models.SingletonTrackedResourceProperties """ - properties: Optional["_models.SingletonTrackedResourceProperties"] = rest_field() + properties: Optional["_models.SingletonTrackedResourceProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The resource-specific properties for this resource.""" @overload @@ -551,7 +559,7 @@ class SingletonTrackedResourceProperties(_model_base.Model): ) """The status of the last operation. Known values are: \"Succeeded\", \"Failed\", \"Canceled\", \"Provisioning\", \"Updating\", \"Deleting\", and \"Accepted\".""" - description: Optional[str] = rest_field() + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The description of the resource.""" @overload @@ -591,19 +599,29 @@ class SystemData(_model_base.Model): :vartype last_modified_at: ~datetime.datetime """ - created_by: Optional[str] = rest_field(name="createdBy") + created_by: Optional[str] = rest_field(name="createdBy", visibility=["read", "create", "update", "delete", "query"]) """The identity that created the resource.""" - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field(name="createdByType") + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="createdByType", visibility=["read", "create", "update", "delete", "query"] + ) """The type of identity that created the resource. Known values are: \"User\", \"Application\", \"ManagedIdentity\", and \"Key\".""" - created_at: Optional[datetime.datetime] = rest_field(name="createdAt", format="rfc3339") + created_at: Optional[datetime.datetime] = rest_field( + name="createdAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) """The timestamp of resource creation (UTC).""" - last_modified_by: Optional[str] = rest_field(name="lastModifiedBy") + last_modified_by: Optional[str] = rest_field( + name="lastModifiedBy", visibility=["read", "create", "update", "delete", "query"] + ) """The identity that last modified the resource.""" - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field(name="lastModifiedByType") + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="lastModifiedByType", visibility=["read", "create", "update", "delete", "query"] + ) """The type of identity that last modified the resource. Known values are: \"User\", \"Application\", \"ManagedIdentity\", and \"Key\".""" - last_modified_at: Optional[datetime.datetime] = rest_field(name="lastModifiedAt", format="rfc3339") + last_modified_at: Optional[datetime.datetime] = rest_field( + name="lastModifiedAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) """The timestamp of resource last modification (UTC).""" @overload @@ -655,7 +673,9 @@ class TopLevelTrackedResource(TrackedResource): :vartype properties: ~azure.resourcemanager.resources.models.TopLevelTrackedResourceProperties """ - properties: Optional["_models.TopLevelTrackedResourceProperties"] = rest_field() + properties: Optional["_models.TopLevelTrackedResourceProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """The resource-specific properties for this resource.""" @overload @@ -695,7 +715,7 @@ class TopLevelTrackedResourceProperties(_model_base.Model): ) """The status of the last operation. Known values are: \"Succeeded\", \"Failed\", \"Canceled\", \"Provisioning\", \"Updating\", \"Deleting\", and \"Accepted\".""" - description: Optional[str] = rest_field() + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The description of the resource.""" @overload diff --git a/packages/typespec-python/test/azure/generated/azurecore-lro-rpc/azurecore/lro/rpc/models/_models.py b/packages/typespec-python/test/azure/generated/azurecore-lro-rpc/azurecore/lro/rpc/models/_models.py index 0884bd78610..cd8108bd0eb 100644 --- a/packages/typespec-python/test/azure/generated/azurecore-lro-rpc/azurecore/lro/rpc/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azurecore-lro-rpc/azurecore/lro/rpc/models/_models.py @@ -22,7 +22,7 @@ class GenerationOptions(_model_base.Model): :vartype prompt: str """ - prompt: str = rest_field() + prompt: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Prompt. Required.""" @overload @@ -51,7 +51,7 @@ class GenerationResult(_model_base.Model): :vartype data: str """ - data: str = rest_field() + data: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The data. Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/client-namespace/client/clientnamespace/first/models/_models.py b/packages/typespec-python/test/azure/generated/client-namespace/client/clientnamespace/first/models/_models.py index bc33191d5e2..21a7659cb2e 100644 --- a/packages/typespec-python/test/azure/generated/client-namespace/client/clientnamespace/first/models/_models.py +++ b/packages/typespec-python/test/azure/generated/client-namespace/client/clientnamespace/first/models/_models.py @@ -21,7 +21,7 @@ class FirstClientResult(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/client-namespace/client/clientnamespace/second/models/_models.py b/packages/typespec-python/test/azure/generated/client-namespace/client/clientnamespace/second/models/_models.py index d4dc929b31f..e30b5d44c70 100644 --- a/packages/typespec-python/test/azure/generated/client-namespace/client/clientnamespace/second/models/_models.py +++ b/packages/typespec-python/test/azure/generated/client-namespace/client/clientnamespace/second/models/_models.py @@ -24,7 +24,9 @@ class SecondClientResult(_model_base.Model): :vartype type: str or ~client.clientnamespace.models.SecondClientEnumType """ - type: Union[str, "_sub_models2.SecondClientEnumType"] = rest_field() + type: Union[str, "_sub_models2.SecondClientEnumType"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """Required. \"second\"""" @overload diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/models/_models.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/models/_models.py index 721b91b4fd9..c9a57530570 100644 --- a/packages/typespec-python/test/azure/generated/client-naming/client/naming/models/_models.py +++ b/packages/typespec-python/test/azure/generated/client-naming/client/naming/models/_models.py @@ -22,7 +22,7 @@ class ClientModel(_model_base.Model): :vartype default_name: bool """ - default_name: bool = rest_field(name="defaultName") + default_name: bool = rest_field(name="defaultName", visibility=["read", "create", "update", "delete", "query"]) """Pass in true. Required.""" @overload @@ -52,7 +52,7 @@ class ClientNameAndJsonEncodedNameModel(_model_base.Model): :vartype client_name: bool """ - client_name: bool = rest_field(name="wireName") + client_name: bool = rest_field(name="wireName", visibility=["read", "create", "update", "delete", "query"]) """Pass in true. Required.""" @overload @@ -82,7 +82,7 @@ class ClientNameModel(_model_base.Model): :vartype client_name: bool """ - client_name: bool = rest_field(name="defaultName") + client_name: bool = rest_field(name="defaultName", visibility=["read", "create", "update", "delete", "query"]) """Pass in true. Required.""" @overload @@ -112,7 +112,7 @@ class LanguageClientNameModel(_model_base.Model): :vartype python_name: bool """ - python_name: bool = rest_field(name="defaultName") + python_name: bool = rest_field(name="defaultName", visibility=["read", "create", "update", "delete", "query"]) """Pass in true. Required.""" @overload @@ -142,7 +142,7 @@ class PythonModel(_model_base.Model): :vartype default_name: bool """ - default_name: bool = rest_field(name="defaultName") + default_name: bool = rest_field(name="defaultName", visibility=["read", "create", "update", "delete", "query"]) """Pass in true. Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/encode-bytes/encode/bytes/models/_models.py b/packages/typespec-python/test/azure/generated/encode-bytes/encode/bytes/models/_models.py index 6a3dd86429b..ab114ce0bd8 100644 --- a/packages/typespec-python/test/azure/generated/encode-bytes/encode/bytes/models/_models.py +++ b/packages/typespec-python/test/azure/generated/encode-bytes/encode/bytes/models/_models.py @@ -21,7 +21,7 @@ class Base64BytesProperty(_model_base.Model): :vartype value: bytes """ - value: bytes = rest_field(format="base64") + value: bytes = rest_field(visibility=["read", "create", "update", "delete", "query"], format="base64") """Required.""" @overload @@ -50,7 +50,7 @@ class Base64urlArrayBytesProperty(_model_base.Model): :vartype value: list[bytes] """ - value: List[bytes] = rest_field(format="base64url") + value: List[bytes] = rest_field(visibility=["read", "create", "update", "delete", "query"], format="base64url") """Required.""" @overload @@ -79,7 +79,7 @@ class Base64urlBytesProperty(_model_base.Model): :vartype value: bytes """ - value: bytes = rest_field(format="base64url") + value: bytes = rest_field(visibility=["read", "create", "update", "delete", "query"], format="base64url") """Required.""" @overload @@ -108,7 +108,7 @@ class DefaultBytesProperty(_model_base.Model): :vartype value: bytes """ - value: bytes = rest_field(format="base64") + value: bytes = rest_field(visibility=["read", "create", "update", "delete", "query"], format="base64") """Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/encode-datetime/encode/datetime/models/_models.py b/packages/typespec-python/test/azure/generated/encode-datetime/encode/datetime/models/_models.py index 14702585f7b..da2a9d47fff 100644 --- a/packages/typespec-python/test/azure/generated/encode-datetime/encode/datetime/models/_models.py +++ b/packages/typespec-python/test/azure/generated/encode-datetime/encode/datetime/models/_models.py @@ -22,7 +22,7 @@ class DefaultDatetimeProperty(_model_base.Model): :vartype value: ~datetime.datetime """ - value: datetime.datetime = rest_field(format="rfc3339") + value: datetime.datetime = rest_field(visibility=["read", "create", "update", "delete", "query"], format="rfc3339") """Required.""" @overload @@ -51,7 +51,7 @@ class Rfc3339DatetimeProperty(_model_base.Model): :vartype value: ~datetime.datetime """ - value: datetime.datetime = rest_field(format="rfc3339") + value: datetime.datetime = rest_field(visibility=["read", "create", "update", "delete", "query"], format="rfc3339") """Required.""" @overload @@ -80,7 +80,7 @@ class Rfc7231DatetimeProperty(_model_base.Model): :vartype value: ~datetime.datetime """ - value: datetime.datetime = rest_field(format="rfc7231") + value: datetime.datetime = rest_field(visibility=["read", "create", "update", "delete", "query"], format="rfc7231") """Required.""" @overload @@ -109,7 +109,9 @@ class UnixTimestampArrayDatetimeProperty(_model_base.Model): :vartype value: list[~datetime.datetime] """ - value: List[datetime.datetime] = rest_field(format="unix-timestamp") + value: List[datetime.datetime] = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="unix-timestamp" + ) """Required.""" @overload @@ -138,7 +140,9 @@ class UnixTimestampDatetimeProperty(_model_base.Model): :vartype value: ~datetime.datetime """ - value: datetime.datetime = rest_field(format="unix-timestamp") + value: datetime.datetime = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="unix-timestamp" + ) """Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/encode-duration/encode/duration/models/_models.py b/packages/typespec-python/test/azure/generated/encode-duration/encode/duration/models/_models.py index f14ce538d97..c25c5f486e4 100644 --- a/packages/typespec-python/test/azure/generated/encode-duration/encode/duration/models/_models.py +++ b/packages/typespec-python/test/azure/generated/encode-duration/encode/duration/models/_models.py @@ -22,7 +22,7 @@ class DefaultDurationProperty(_model_base.Model): :vartype value: ~datetime.timedelta """ - value: datetime.timedelta = rest_field() + value: datetime.timedelta = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -51,7 +51,7 @@ class Float64SecondsDurationProperty(_model_base.Model): :vartype value: float """ - value: float = rest_field() + value: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -80,7 +80,7 @@ class FloatSecondsDurationArrayProperty(_model_base.Model): :vartype value: list[float] """ - value: List[float] = rest_field() + value: List[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -109,7 +109,7 @@ class FloatSecondsDurationProperty(_model_base.Model): :vartype value: float """ - value: float = rest_field() + value: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -138,7 +138,7 @@ class Int32SecondsDurationProperty(_model_base.Model): :vartype value: int """ - value: int = rest_field() + value: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -167,7 +167,7 @@ class ISO8601DurationProperty(_model_base.Model): :vartype value: ~datetime.timedelta """ - value: datetime.timedelta = rest_field() + value: datetime.timedelta = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/encode-numeric/encode/numeric/models/_models.py b/packages/typespec-python/test/azure/generated/encode-numeric/encode/numeric/models/_models.py index ced081e8f86..d4be043156f 100644 --- a/packages/typespec-python/test/azure/generated/encode-numeric/encode/numeric/models/_models.py +++ b/packages/typespec-python/test/azure/generated/encode-numeric/encode/numeric/models/_models.py @@ -21,7 +21,7 @@ class SafeintAsStringProperty(_model_base.Model): :vartype value: int """ - value: int = rest_field(format="str") + value: int = rest_field(visibility=["read", "create", "update", "delete", "query"], format="str") """Required.""" @overload @@ -49,7 +49,7 @@ class Uint32AsStringProperty(_model_base.Model): :vartype value: int """ - value: Optional[int] = rest_field(format="str") + value: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"], format="str") @overload def __init__( @@ -77,7 +77,7 @@ class Uint8AsStringProperty(_model_base.Model): :vartype value: int """ - value: int = rest_field(format="str") + value: int = rest_field(visibility=["read", "create", "update", "delete", "query"], format="str") """Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/parameters-basic/parameters/basic/models/_models.py b/packages/typespec-python/test/azure/generated/parameters-basic/parameters/basic/models/_models.py index 1efff01d8aa..2041cdc608a 100644 --- a/packages/typespec-python/test/azure/generated/parameters-basic/parameters/basic/models/_models.py +++ b/packages/typespec-python/test/azure/generated/parameters-basic/parameters/basic/models/_models.py @@ -22,7 +22,7 @@ class User(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/parameters-body-optionality/parameters/bodyoptionality/models/_models.py b/packages/typespec-python/test/azure/generated/parameters-body-optionality/parameters/bodyoptionality/models/_models.py index 637ff936fbd..dea844ad41e 100644 --- a/packages/typespec-python/test/azure/generated/parameters-body-optionality/parameters/bodyoptionality/models/_models.py +++ b/packages/typespec-python/test/azure/generated/parameters-body-optionality/parameters/bodyoptionality/models/_models.py @@ -22,7 +22,7 @@ class BodyModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/parameters-spread/parameters/spread/models/_models.py b/packages/typespec-python/test/azure/generated/parameters-spread/parameters/spread/models/_models.py index dd2ce14f62c..ed9316a17cc 100644 --- a/packages/typespec-python/test/azure/generated/parameters-spread/parameters/spread/models/_models.py +++ b/packages/typespec-python/test/azure/generated/parameters-spread/parameters/spread/models/_models.py @@ -22,7 +22,7 @@ class BodyParameter(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/payload-content-negotiation/payload/contentnegotiation/models/_models.py b/packages/typespec-python/test/azure/generated/payload-content-negotiation/payload/contentnegotiation/models/_models.py index cc2fab232fb..c0b9321dfcd 100644 --- a/packages/typespec-python/test/azure/generated/payload-content-negotiation/payload/contentnegotiation/models/_models.py +++ b/packages/typespec-python/test/azure/generated/payload-content-negotiation/payload/contentnegotiation/models/_models.py @@ -21,7 +21,7 @@ class PngImageAsJson(_model_base.Model): :vartype content: bytes """ - content: bytes = rest_field(format="base64") + content: bytes = rest_field(visibility=["read", "create", "update", "delete", "query"], format="base64") """Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/payload-json-merge-patch/payload/jsonmergepatch/models/_models.py b/packages/typespec-python/test/azure/generated/payload-json-merge-patch/payload/jsonmergepatch/models/_models.py index 16bb2d20303..5a695012117 100644 --- a/packages/typespec-python/test/azure/generated/payload-json-merge-patch/payload/jsonmergepatch/models/_models.py +++ b/packages/typespec-python/test/azure/generated/payload-json-merge-patch/payload/jsonmergepatch/models/_models.py @@ -25,8 +25,8 @@ class InnerModel(_model_base.Model): :vartype description: str """ - name: Optional[str] = rest_field() - description: Optional[str] = rest_field() + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @overload def __init__( @@ -69,15 +69,23 @@ class Resource(_model_base.Model): :vartype int_array: list[int] """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - description: Optional[str] = rest_field() - map: Optional[Dict[str, "_models.InnerModel"]] = rest_field() - array: Optional[List["_models.InnerModel"]] = rest_field() - int_value: Optional[int] = rest_field(name="intValue") - float_value: Optional[float] = rest_field(name="floatValue") - inner_model: Optional["_models.InnerModel"] = rest_field(name="innerModel") - int_array: Optional[List[int]] = rest_field(name="intArray") + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + map: Optional[Dict[str, "_models.InnerModel"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + array: Optional[List["_models.InnerModel"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + int_value: Optional[int] = rest_field(name="intValue", visibility=["read", "create", "update", "delete", "query"]) + float_value: Optional[float] = rest_field( + name="floatValue", visibility=["read", "create", "update", "delete", "query"] + ) + inner_model: Optional["_models.InnerModel"] = rest_field( + name="innerModel", visibility=["read", "create", "update", "delete", "query"] + ) + int_array: Optional[List[int]] = rest_field( + name="intArray", visibility=["read", "create", "update", "delete", "query"] + ) @overload def __init__( @@ -123,13 +131,21 @@ class ResourcePatch(_model_base.Model): :vartype int_array: list[int] """ - description: Optional[str] = rest_field() - map: Optional[Dict[str, "_models.InnerModel"]] = rest_field() - array: Optional[List["_models.InnerModel"]] = rest_field() - int_value: Optional[int] = rest_field(name="intValue") - float_value: Optional[float] = rest_field(name="floatValue") - inner_model: Optional["_models.InnerModel"] = rest_field(name="innerModel") - int_array: Optional[List[int]] = rest_field(name="intArray") + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + map: Optional[Dict[str, "_models.InnerModel"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + array: Optional[List["_models.InnerModel"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + int_value: Optional[int] = rest_field(name="intValue", visibility=["read", "create", "update", "delete", "query"]) + float_value: Optional[float] = rest_field( + name="floatValue", visibility=["read", "create", "update", "delete", "query"] + ) + inner_model: Optional["_models.InnerModel"] = rest_field( + name="innerModel", visibility=["read", "create", "update", "delete", "query"] + ) + int_array: Optional[List[int]] = rest_field( + name="intArray", visibility=["read", "create", "update", "delete", "query"] + ) @overload def __init__( diff --git a/packages/typespec-python/test/azure/generated/payload-multipart/payload/multipart/models/_models.py b/packages/typespec-python/test/azure/generated/payload-multipart/payload/multipart/models/_models.py index b35844e2c39..83fb5e120d4 100644 --- a/packages/typespec-python/test/azure/generated/payload-multipart/payload/multipart/models/_models.py +++ b/packages/typespec-python/test/azure/generated/payload-multipart/payload/multipart/models/_models.py @@ -26,7 +26,7 @@ class Address(_model_base.Model): :vartype city: str """ - city: str = rest_field() + city: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -58,9 +58,11 @@ class BinaryArrayPartsRequest(_model_base.Model): :vartype pictures: list[~payload.multipart._vendor.FileType] """ - id: str = rest_field() + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - pictures: List[FileType] = rest_field(is_multipart_file_input=True) + pictures: List[FileType] = rest_field( + visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True + ) """Required.""" @overload @@ -99,15 +101,21 @@ class ComplexHttpPartsModelRequest(_model_base.Model): :vartype pictures: list[~payload.multipart._vendor.FileType] """ - id: str = rest_field() + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - address: "_models.Address" = rest_field() + address: "_models.Address" = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - profile_image: FileType = rest_field(name="profileImage", is_multipart_file_input=True) + profile_image: FileType = rest_field( + name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True + ) """Required.""" - previous_addresses: List["_models.Address"] = rest_field(name="previousAddresses") + previous_addresses: List["_models.Address"] = rest_field( + name="previousAddresses", visibility=["read", "create", "update", "delete", "query"] + ) """Required.""" - pictures: List[FileType] = rest_field(is_multipart_file_input=True) + pictures: List[FileType] = rest_field( + visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True + ) """Required.""" @overload @@ -147,13 +155,17 @@ class ComplexPartsRequest(_model_base.Model): :vartype pictures: list[~payload.multipart._vendor.FileType] """ - id: str = rest_field() + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - address: "_models.Address" = rest_field() + address: "_models.Address" = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - profile_image: FileType = rest_field(name="profileImage", is_multipart_file_input=True) + profile_image: FileType = rest_field( + name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True + ) """Required.""" - pictures: List[FileType] = rest_field(is_multipart_file_input=True) + pictures: List[FileType] = rest_field( + visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True + ) """Required.""" @overload @@ -186,7 +198,9 @@ class FileWithHttpPartOptionalContentTypeRequest(_model_base.Model): # pylint: :vartype profile_image: ~payload.multipart._vendor.FileType """ - profile_image: FileType = rest_field(name="profileImage", is_multipart_file_input=True) + profile_image: FileType = rest_field( + name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True + ) """Required.""" @overload @@ -216,7 +230,9 @@ class FileWithHttpPartRequiredContentTypeRequest(_model_base.Model): # pylint: :vartype profile_image: ~payload.multipart._vendor.FileType """ - profile_image: FileType = rest_field(name="profileImage", is_multipart_file_input=True) + profile_image: FileType = rest_field( + name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True + ) """Required.""" @overload @@ -246,7 +262,9 @@ class FileWithHttpPartSpecificContentTypeRequest(_model_base.Model): # pylint: :vartype profile_image: ~payload.multipart._vendor.FileType """ - profile_image: FileType = rest_field(name="profileImage", is_multipart_file_input=True) + profile_image: FileType = rest_field( + name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True + ) """Required.""" @overload @@ -276,7 +294,7 @@ class FloatRequest(_model_base.Model): :vartype temperature: float """ - temperature: float = rest_field() + temperature: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -308,9 +326,11 @@ class JsonPartRequest(_model_base.Model): :vartype profile_image: ~payload.multipart._vendor.FileType """ - address: "_models.Address" = rest_field() + address: "_models.Address" = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - profile_image: FileType = rest_field(name="profileImage", is_multipart_file_input=True) + profile_image: FileType = rest_field( + name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True + ) """Required.""" @overload @@ -343,9 +363,13 @@ class MultiBinaryPartsRequest(_model_base.Model): :vartype picture: ~payload.multipart._vendor.FileType """ - profile_image: FileType = rest_field(name="profileImage", is_multipart_file_input=True) + profile_image: FileType = rest_field( + name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True + ) """Required.""" - picture: Optional[FileType] = rest_field(is_multipart_file_input=True) + picture: Optional[FileType] = rest_field( + visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True + ) @overload def __init__( @@ -377,9 +401,11 @@ class MultiPartRequest(_model_base.Model): :vartype profile_image: ~payload.multipart._vendor.FileType """ - id: str = rest_field() + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - profile_image: FileType = rest_field(name="profileImage", is_multipart_file_input=True) + profile_image: FileType = rest_field( + name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True + ) """Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/models/_models.py b/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/models/_models.py index 8c1acf6a42b..5a96341e82b 100644 --- a/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/models/_models.py +++ b/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/models/_models.py @@ -23,9 +23,9 @@ class Pet(_model_base.Model): :vartype name: str """ - id: str = rest_field() + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/models/_models.py b/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/models/_models.py index a6cdfc9f24f..bd4c3b2aa6a 100644 --- a/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/models/_models.py +++ b/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/models/_models.py @@ -26,6 +26,7 @@ class ModelWithArrayOfModel(_model_base.Model): items_property: List["_models.SimpleModel"] = rest_field( name="items", + visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "SimpleModel", "name": "items", "text": False, "unwrapped": False}, ) """Required.""" @@ -62,11 +63,20 @@ class ModelWithAttributes(_model_base.Model): :vartype enabled: bool """ - id1: int = rest_field(xml={"attribute": True, "name": "id1", "text": False, "unwrapped": False}) + id1: int = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": True, "name": "id1", "text": False, "unwrapped": False}, + ) """Required.""" - id2: str = rest_field(xml={"attribute": True, "name": "id2", "text": False, "unwrapped": False}) + id2: str = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": True, "name": "id2", "text": False, "unwrapped": False}, + ) """Required.""" - enabled: bool = rest_field(xml={"attribute": False, "name": "enabled", "text": False, "unwrapped": False}) + enabled: bool = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "enabled", "text": False, "unwrapped": False}, + ) """Required.""" _xml = {"attribute": False, "name": "ModelWithAttributes", "text": False, "unwrapped": False} @@ -100,7 +110,8 @@ class ModelWithDictionary(_model_base.Model): """ metadata: Dict[str, str] = rest_field( - xml={"attribute": False, "name": "metadata", "text": False, "unwrapped": False} + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "metadata", "text": False, "unwrapped": False}, ) """Required.""" @@ -134,6 +145,7 @@ class ModelWithEmptyArray(_model_base.Model): items_property: List["_models.SimpleModel"] = rest_field( name="items", + visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "SimpleModel", "name": "items", "text": False, "unwrapped": False}, ) """Required.""" @@ -169,11 +181,14 @@ class ModelWithEncodedNames(_model_base.Model): """ model_data: "_models.SimpleModel" = rest_field( - name="modelData", xml={"attribute": False, "name": "SimpleModelData", "text": False, "unwrapped": False} + name="modelData", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "SimpleModelData", "text": False, "unwrapped": False}, ) """Required.""" colors: List[str] = rest_field( - xml={"attribute": False, "itemsName": "string", "name": "PossibleColors", "text": False, "unwrapped": False} + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "itemsName": "string", "name": "PossibleColors", "text": False, "unwrapped": False}, ) """Required.""" @@ -208,9 +223,15 @@ class ModelWithOptionalField(_model_base.Model): :vartype value: int """ - item: str = rest_field(xml={"attribute": False, "name": "item", "text": False, "unwrapped": False}) + item: str = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "item", "text": False, "unwrapped": False}, + ) """Required.""" - value: Optional[int] = rest_field(xml={"attribute": False, "name": "value", "text": False, "unwrapped": False}) + value: Optional[int] = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "value", "text": False, "unwrapped": False}, + ) _xml = {"attribute": False, "name": "ModelWithOptionalField", "text": False, "unwrapped": False} @@ -245,11 +266,13 @@ class ModelWithRenamedArrays(_model_base.Model): """ colors: List[str] = rest_field( - xml={"attribute": False, "itemsName": "Colors", "name": "Colors", "text": False, "unwrapped": True} + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "itemsName": "Colors", "name": "Colors", "text": False, "unwrapped": True}, ) """Required.""" counts: List[int] = rest_field( - xml={"attribute": False, "itemsName": "int32", "name": "Counts", "text": False, "unwrapped": False} + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "itemsName": "int32", "name": "Counts", "text": False, "unwrapped": False}, ) """Required.""" @@ -285,11 +308,15 @@ class ModelWithRenamedFields(_model_base.Model): """ input_data: "_models.SimpleModel" = rest_field( - name="inputData", xml={"attribute": False, "name": "InputData", "text": False, "unwrapped": False} + name="inputData", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "InputData", "text": False, "unwrapped": False}, ) """Required.""" output_data: "_models.SimpleModel" = rest_field( - name="outputData", xml={"attribute": False, "name": "OutputData", "text": False, "unwrapped": False} + name="outputData", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "OutputData", "text": False, "unwrapped": False}, ) """Required.""" @@ -325,11 +352,13 @@ class ModelWithSimpleArrays(_model_base.Model): """ colors: List[str] = rest_field( - xml={"attribute": False, "itemsName": "string", "name": "colors", "text": False, "unwrapped": False} + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "itemsName": "string", "name": "colors", "text": False, "unwrapped": False}, ) """Required.""" counts: List[int] = rest_field( - xml={"attribute": False, "itemsName": "int32", "name": "counts", "text": False, "unwrapped": False} + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "itemsName": "int32", "name": "counts", "text": False, "unwrapped": False}, ) """Required.""" @@ -364,9 +393,15 @@ class ModelWithText(_model_base.Model): :vartype content: str """ - language: str = rest_field(xml={"attribute": True, "name": "language", "text": False, "unwrapped": False}) + language: str = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": True, "name": "language", "text": False, "unwrapped": False}, + ) """Required.""" - content: str = rest_field(xml={"attribute": False, "name": "content", "text": True, "unwrapped": False}) + content: str = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "content", "text": True, "unwrapped": False}, + ) """Required.""" _xml = {"attribute": False, "name": "ModelWithText", "text": False, "unwrapped": False} @@ -401,11 +436,13 @@ class ModelWithUnwrappedArray(_model_base.Model): """ colors: List[str] = rest_field( - xml={"attribute": False, "itemsName": "colors", "name": "colors", "text": False, "unwrapped": True} + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "itemsName": "colors", "name": "colors", "text": False, "unwrapped": True}, ) """Required.""" counts: List[int] = rest_field( - xml={"attribute": False, "itemsName": "int32", "name": "counts", "text": False, "unwrapped": False} + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "itemsName": "int32", "name": "counts", "text": False, "unwrapped": False}, ) """Required.""" @@ -440,9 +477,15 @@ class SimpleModel(_model_base.Model): :vartype age: int """ - name: str = rest_field(xml={"attribute": False, "name": "name", "text": False, "unwrapped": False}) + name: str = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "name", "text": False, "unwrapped": False}, + ) """Required.""" - age: int = rest_field(xml={"attribute": False, "name": "age", "text": False, "unwrapped": False}) + age: int = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "age", "text": False, "unwrapped": False}, + ) """Required.""" _xml = {"attribute": False, "name": "SimpleModel", "text": False, "unwrapped": False} diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/CHANGELOG.md b/packages/typespec-python/test/azure/generated/response-status-code-range/CHANGELOG.md new file mode 100644 index 00000000000..628743d283a --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0b1 (1970-01-01) + +- Initial version diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/LICENSE b/packages/typespec-python/test/azure/generated/response-status-code-range/LICENSE new file mode 100644 index 00000000000..63447fd8bbb --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/LICENSE @@ -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. \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/MANIFEST.in b/packages/typespec-python/test/azure/generated/response-status-code-range/MANIFEST.in new file mode 100644 index 00000000000..87b2b3fe020 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/MANIFEST.in @@ -0,0 +1,6 @@ +include *.md +include LICENSE +include response/statuscoderange/py.typed +recursive-include tests *.py +recursive-include samples *.py *.md +include response/__init__.py \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/README.md b/packages/typespec-python/test/azure/generated/response-status-code-range/README.md new file mode 100644 index 00000000000..5e4613dfc2b --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/README.md @@ -0,0 +1,45 @@ + + +# Response Statuscoderange client library for Python + + +## Getting started + +### Install the package + +```bash +python -m pip install response-statuscoderange +``` + +#### 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 Response Statuscoderange 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 opencode@microsoft.com with any +additional questions or comments. + + +[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/ + diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/apiview-properties.json b/packages/typespec-python/test/azure/generated/response-status-code-range/apiview-properties.json new file mode 100644 index 00000000000..11d2cc5f91d --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/apiview-properties.json @@ -0,0 +1,11 @@ +{ + "CrossLanguagePackageId": "Response.StatusCodeRange", + "CrossLanguageDefinitionId": { + "response.statuscoderange.models.DefaultError": "Response.StatusCodeRange.DefaultError", + "response.statuscoderange.models.ErrorInRange": "Response.StatusCodeRange.ErrorInRange", + "response.statuscoderange.models.NotFoundError": "Response.StatusCodeRange.NotFoundError", + "response.statuscoderange.models.Standard4XXError": "Response.StatusCodeRange.Standard4XXError", + "response.statuscoderange.StatusCodeRangeClient.error_response_status_code_in_range": "Response.StatusCodeRange.errorResponseStatusCodeInRange", + "response.statuscoderange.StatusCodeRangeClient.error_response_status_code404": "Response.StatusCodeRange.errorResponseStatusCode404" + } +} \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/dev_requirements.txt b/packages/typespec-python/test/azure/generated/response-status-code-range/dev_requirements.txt new file mode 100644 index 00000000000..10548647144 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/dev_requirements.txt @@ -0,0 +1,3 @@ +-e ../../../tools/azure-sdk-tools +../../core/azure-core +aiohttp \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/generated_tests/conftest.py b/packages/typespec-python/test/azure/generated/response-status-code-range/generated_tests/conftest.py new file mode 100644 index 00000000000..b094f3e620d --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/generated_tests/conftest.py @@ -0,0 +1,39 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# For security, please avoid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + statuscoderange_subscription_id = os.environ.get( + "STATUSCODERANGE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000" + ) + statuscoderange_tenant_id = os.environ.get("STATUSCODERANGE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + statuscoderange_client_id = os.environ.get("STATUSCODERANGE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + statuscoderange_client_secret = os.environ.get( + "STATUSCODERANGE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer(regex=statuscoderange_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=statuscoderange_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=statuscoderange_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=statuscoderange_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/generated_tests/test_status_code_range.py b/packages/typespec-python/test/azure/generated/response-status-code-range/generated_tests/test_status_code_range.py new file mode 100644 index 00000000000..5214648aa20 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/generated_tests/test_status_code_range.py @@ -0,0 +1,31 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from devtools_testutils import recorded_by_proxy +from testpreparer import StatusCodeRangeClientTestBase, StatusCodeRangePreparer + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestStatusCodeRange(StatusCodeRangeClientTestBase): + @StatusCodeRangePreparer() + @recorded_by_proxy + def test_error_response_status_code_in_range(self, statuscoderange_endpoint): + client = self.create_client(endpoint=statuscoderange_endpoint) + response = client.error_response_status_code_in_range() + + # please add some check logic here by yourself + # ... + + @StatusCodeRangePreparer() + @recorded_by_proxy + def test_error_response_status_code404(self, statuscoderange_endpoint): + client = self.create_client(endpoint=statuscoderange_endpoint) + response = client.error_response_status_code404() + + # please add some check logic here by yourself + # ... diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/generated_tests/test_status_code_range_async.py b/packages/typespec-python/test/azure/generated/response-status-code-range/generated_tests/test_status_code_range_async.py new file mode 100644 index 00000000000..360b151bc21 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/generated_tests/test_status_code_range_async.py @@ -0,0 +1,32 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from devtools_testutils.aio import recorded_by_proxy_async +from testpreparer import StatusCodeRangePreparer +from testpreparer_async import StatusCodeRangeClientTestBaseAsync + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestStatusCodeRangeAsync(StatusCodeRangeClientTestBaseAsync): + @StatusCodeRangePreparer() + @recorded_by_proxy_async + async def test_error_response_status_code_in_range(self, statuscoderange_endpoint): + client = self.create_async_client(endpoint=statuscoderange_endpoint) + response = await client.error_response_status_code_in_range() + + # please add some check logic here by yourself + # ... + + @StatusCodeRangePreparer() + @recorded_by_proxy_async + async def test_error_response_status_code404(self, statuscoderange_endpoint): + client = self.create_async_client(endpoint=statuscoderange_endpoint) + response = await client.error_response_status_code404() + + # please add some check logic here by yourself + # ... diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/generated_tests/testpreparer.py b/packages/typespec-python/test/azure/generated/response-status-code-range/generated_tests/testpreparer.py new file mode 100644 index 00000000000..caa3846fa25 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/generated_tests/testpreparer.py @@ -0,0 +1,26 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from devtools_testutils import AzureRecordedTestCase, PowerShellPreparer +import functools +from response.statuscoderange import StatusCodeRangeClient + + +class StatusCodeRangeClientTestBase(AzureRecordedTestCase): + + def create_client(self, endpoint): + credential = self.get_credential(StatusCodeRangeClient) + return self.create_client_from_credential( + StatusCodeRangeClient, + credential=credential, + endpoint=endpoint, + ) + + +StatusCodeRangePreparer = functools.partial( + PowerShellPreparer, "statuscoderange", statuscoderange_endpoint="https://fake_statuscoderange_endpoint.com" +) diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/generated_tests/testpreparer_async.py b/packages/typespec-python/test/azure/generated/response-status-code-range/generated_tests/testpreparer_async.py new file mode 100644 index 00000000000..de32b98d031 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/generated_tests/testpreparer_async.py @@ -0,0 +1,20 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from devtools_testutils import AzureRecordedTestCase +from response.statuscoderange.aio import StatusCodeRangeClient + + +class StatusCodeRangeClientTestBaseAsync(AzureRecordedTestCase): + + def create_async_client(self, endpoint): + credential = self.get_credential(StatusCodeRangeClient, is_async=True) + return self.create_client_from_credential( + StatusCodeRangeClient, + credential=credential, + endpoint=endpoint, + ) diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/response/__init__.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/__init__.py new file mode 100644 index 00000000000..d55ccad1f57 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/__init__.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/__init__.py new file mode 100644 index 00000000000..16e389f9da2 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/__init__.py @@ -0,0 +1,32 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import StatusCodeRangeClient # type: ignore +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "StatusCodeRangeClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore + +_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_client.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_client.py new file mode 100644 index 00000000000..4ad9a78ba62 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_client.py @@ -0,0 +1,91 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any +from typing_extensions import Self + +from azure.core import PipelineClient +from azure.core.pipeline import policies +from azure.core.rest import HttpRequest, HttpResponse + +from ._configuration import StatusCodeRangeClientConfiguration +from ._operations import StatusCodeRangeClientOperationsMixin +from ._serialization import Deserializer, Serializer + + +class StatusCodeRangeClient(StatusCodeRangeClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword + """Test for range of status code. + + :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: + _endpoint = "{endpoint}" + self._config = StatusCodeRangeClientConfiguration(endpoint=endpoint, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> Self: + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_configuration.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_configuration.py new file mode 100644 index 00000000000..7189db724b4 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_configuration.py @@ -0,0 +1,42 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any + +from azure.core.pipeline import policies + +from ._version import VERSION + + +class StatusCodeRangeClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for StatusCodeRangeClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: Service host. Default value is "http://localhost:3000". + :type endpoint: str + """ + + def __init__(self, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None: + + self.endpoint = endpoint + kwargs.setdefault("sdk_moniker", "response-statuscoderange/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_model_base.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_model_base.py new file mode 100644 index 00000000000..3072ee252ed --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_model_base.py @@ -0,0 +1,1235 @@ +# pylint: disable=too-many-lines +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access, broad-except + +import copy +import calendar +import decimal +import functools +import sys +import logging +import base64 +import re +import typing +import enum +import email.utils +from datetime import datetime, date, time, timedelta, timezone +from json import JSONEncoder +import xml.etree.ElementTree as ET +from typing_extensions import Self +import isodate +from azure.core.exceptions import DeserializationError +from azure.core import CaseInsensitiveEnumMeta +from azure.core.pipeline import PipelineResponse +from azure.core.serialization import _Null + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping + +_LOGGER = logging.getLogger(__name__) + +__all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] + +TZ_UTC = timezone.utc +_T = typing.TypeVar("_T") + + +def _timedelta_as_isostr(td: timedelta) -> str: + """Converts a datetime.timedelta object into an ISO 8601 formatted string, e.g. 'P4DT12H30M05S' + + Function adapted from the Tin Can Python project: https://github.com/RusticiSoftware/TinCanPython + + :param timedelta td: The timedelta to convert + :rtype: str + :return: ISO8601 version of this timedelta + """ + + # Split seconds to larger units + seconds = td.total_seconds() + minutes, seconds = divmod(seconds, 60) + hours, minutes = divmod(minutes, 60) + days, hours = divmod(hours, 24) + + days, hours, minutes = list(map(int, (days, hours, minutes))) + seconds = round(seconds, 6) + + # Build date + date_str = "" + if days: + date_str = "%sD" % days + + if hours or minutes or seconds: + # Build time + time_str = "T" + + # Hours + bigger_exists = date_str or hours + if bigger_exists: + time_str += "{:02}H".format(hours) + + # Minutes + bigger_exists = bigger_exists or minutes + if bigger_exists: + time_str += "{:02}M".format(minutes) + + # Seconds + try: + if seconds.is_integer(): + seconds_string = "{:02}".format(int(seconds)) + else: + # 9 chars long w/ leading 0, 6 digits after decimal + seconds_string = "%09.6f" % seconds + # Remove trailing zeros + seconds_string = seconds_string.rstrip("0") + except AttributeError: # int.is_integer() raises + seconds_string = "{:02}".format(seconds) + + time_str += "{}S".format(seconds_string) + else: + time_str = "" + + return "P" + date_str + time_str + + +def _serialize_bytes(o, format: typing.Optional[str] = None) -> str: + encoded = base64.b64encode(o).decode() + if format == "base64url": + return encoded.strip("=").replace("+", "-").replace("/", "_") + return encoded + + +def _serialize_datetime(o, format: typing.Optional[str] = None): + if hasattr(o, "year") and hasattr(o, "hour"): + if format == "rfc7231": + return email.utils.format_datetime(o, usegmt=True) + if format == "unix-timestamp": + return int(calendar.timegm(o.utctimetuple())) + + # astimezone() fails for naive times in Python 2.7, so make make sure o is aware (tzinfo is set) + if not o.tzinfo: + iso_formatted = o.replace(tzinfo=TZ_UTC).isoformat() + else: + iso_formatted = o.astimezone(TZ_UTC).isoformat() + # Replace the trailing "+00:00" UTC offset with "Z" (RFC 3339: https://www.ietf.org/rfc/rfc3339.txt) + return iso_formatted.replace("+00:00", "Z") + # Next try datetime.date or datetime.time + return o.isoformat() + + +def _is_readonly(p): + try: + return p._visibility == ["read"] + except AttributeError: + return False + + +class SdkJSONEncoder(JSONEncoder): + """A JSON encoder that's capable of serializing datetime objects and bytes.""" + + def __init__(self, *args, exclude_readonly: bool = False, format: typing.Optional[str] = None, **kwargs): + super().__init__(*args, **kwargs) + self.exclude_readonly = exclude_readonly + self.format = format + + def default(self, o): # pylint: disable=too-many-return-statements + if _is_model(o): + if self.exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + return {k: v for k, v in o.items() if k not in readonly_props} + return dict(o.items()) + try: + return super(SdkJSONEncoder, self).default(o) + except TypeError: + if isinstance(o, _Null): + return None + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, self.format) + try: + # First try datetime.datetime + return _serialize_datetime(o, self.format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return super(SdkJSONEncoder, self).default(o) + + +_VALID_DATE = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" + r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") +_VALID_RFC7231 = re.compile( + r"(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s\d{2}\s" + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT" +) + + +def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + attr = attr.upper() + match = _VALID_DATE.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + return date_obj + + +def _deserialize_datetime_rfc7231(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize RFC7231 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + match = _VALID_RFC7231.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + return email.utils.parsedate_to_datetime(attr) + + +def _deserialize_datetime_unix_timestamp(attr: typing.Union[float, datetime]) -> datetime: + """Deserialize unix timestamp into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + return datetime.fromtimestamp(attr, TZ_UTC) + + +def _deserialize_date(attr: typing.Union[str, date]) -> date: + """Deserialize ISO-8601 formatted string into Date object. + :param str attr: response string to be deserialized. + :rtype: date + :returns: The date object from that input + """ + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + if isinstance(attr, date): + return attr + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) # type: ignore + + +def _deserialize_time(attr: typing.Union[str, time]) -> time: + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :returns: The time object from that input + """ + if isinstance(attr, time): + return attr + return isodate.parse_time(attr) + + +def _deserialize_bytes(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + return bytes(base64.b64decode(attr)) + + +def _deserialize_bytes_base64(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return bytes(base64.b64decode(encoded)) + + +def _deserialize_duration(attr): + if isinstance(attr, timedelta): + return attr + return isodate.parse_duration(attr) + + +def _deserialize_decimal(attr): + if isinstance(attr, decimal.Decimal): + return attr + return decimal.Decimal(str(attr)) + + +def _deserialize_int_as_str(attr): + if isinstance(attr, int): + return attr + return int(attr) + + +_DESERIALIZE_MAPPING = { + datetime: _deserialize_datetime, + date: _deserialize_date, + time: _deserialize_time, + bytes: _deserialize_bytes, + bytearray: _deserialize_bytes, + timedelta: _deserialize_duration, + typing.Any: lambda x: x, + decimal.Decimal: _deserialize_decimal, +} + +_DESERIALIZE_MAPPING_WITHFORMAT = { + "rfc3339": _deserialize_datetime, + "rfc7231": _deserialize_datetime_rfc7231, + "unix-timestamp": _deserialize_datetime_unix_timestamp, + "base64": _deserialize_bytes, + "base64url": _deserialize_bytes_base64, +} + + +def get_deserializer(annotation: typing.Any, rf: typing.Optional["_RestField"] = None): + if annotation is int and rf and rf._format == "str": + return _deserialize_int_as_str + if rf and rf._format: + return _DESERIALIZE_MAPPING_WITHFORMAT.get(rf._format) + return _DESERIALIZE_MAPPING.get(annotation) # pyright: ignore + + +def _get_type_alias_type(module_name: str, alias_name: str): + types = { + k: v + for k, v in sys.modules[module_name].__dict__.items() + if isinstance(v, typing._GenericAlias) # type: ignore + } + if alias_name not in types: + return alias_name + return types[alias_name] + + +def _get_model(module_name: str, model_name: str): + models = {k: v for k, v in sys.modules[module_name].__dict__.items() if isinstance(v, type)} + module_end = module_name.rsplit(".", 1)[0] + models.update({k: v for k, v in sys.modules[module_end].__dict__.items() if isinstance(v, type)}) + if isinstance(model_name, str): + model_name = model_name.split(".")[-1] + if model_name not in models: + return model_name + return models[model_name] + + +_UNSET = object() + + +class _MyMutableMapping(MutableMapping[str, typing.Any]): # pylint: disable=unsubscriptable-object + def __init__(self, data: typing.Dict[str, typing.Any]) -> None: + self._data = data + + def __contains__(self, key: typing.Any) -> bool: + return key in self._data + + def __getitem__(self, key: str) -> typing.Any: + return self._data.__getitem__(key) + + def __setitem__(self, key: str, value: typing.Any) -> None: + self._data.__setitem__(key, value) + + def __delitem__(self, key: str) -> None: + self._data.__delitem__(key) + + def __iter__(self) -> typing.Iterator[typing.Any]: + return self._data.__iter__() + + def __len__(self) -> int: + return self._data.__len__() + + def __ne__(self, other: typing.Any) -> bool: + return not self.__eq__(other) + + def keys(self) -> typing.KeysView[str]: + """ + :returns: a set-like object providing a view on D's keys + :rtype: ~typing.KeysView + """ + return self._data.keys() + + def values(self) -> typing.ValuesView[typing.Any]: + """ + :returns: an object providing a view on D's values + :rtype: ~typing.ValuesView + """ + return self._data.values() + + def items(self) -> typing.ItemsView[str, typing.Any]: + """ + :returns: set-like object providing a view on D's items + :rtype: ~typing.ItemsView + """ + return self._data.items() + + def get(self, key: str, default: typing.Any = None) -> typing.Any: + """ + Get the value for key if key is in the dictionary, else default. + :param str key: The key to look up. + :param any default: The value to return if key is not in the dictionary. Defaults to None + :returns: D[k] if k in D, else d. + :rtype: any + """ + try: + return self[key] + except KeyError: + return default + + @typing.overload + def pop(self, key: str) -> typing.Any: ... + + @typing.overload + def pop(self, key: str, default: _T) -> _T: ... + + @typing.overload + def pop(self, key: str, default: typing.Any) -> typing.Any: ... + + def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Removes specified key and return the corresponding value. + :param str key: The key to pop. + :param any default: The value to return if key is not in the dictionary + :returns: The value corresponding to the key. + :rtype: any + :raises KeyError: If key is not found and default is not given. + """ + if default is _UNSET: + return self._data.pop(key) + return self._data.pop(key, default) + + def popitem(self) -> typing.Tuple[str, typing.Any]: + """ + Removes and returns some (key, value) pair + :returns: The (key, value) pair. + :rtype: tuple + :raises KeyError: if D is empty. + """ + return self._data.popitem() + + def clear(self) -> None: + """ + Remove all items from D. + """ + self._data.clear() + + def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: + """ + Updates D from mapping/iterable E and F. + :param any args: Either a mapping object or an iterable of key-value pairs. + """ + self._data.update(*args, **kwargs) + + @typing.overload + def setdefault(self, key: str, default: None = None) -> None: ... + + @typing.overload + def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... + + def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Same as calling D.get(k, d), and setting D[k]=d if k not found + :param str key: The key to look up. + :param any default: The value to set if key is not in the dictionary + :returns: D[k] if k in D, else d. + :rtype: any + """ + if default is _UNSET: + return self._data.setdefault(key) + return self._data.setdefault(key, default) + + def __eq__(self, other: typing.Any) -> bool: + try: + other_model = self.__class__(other) + except Exception: + return False + return self._data == other_model._data + + def __repr__(self) -> str: + return str(self._data) + + +def _is_model(obj: typing.Any) -> bool: + return getattr(obj, "_is_model", False) + + +def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-many-return-statements + if isinstance(o, list): + return [_serialize(x, format) for x in o] + if isinstance(o, dict): + return {k: _serialize(v, format) for k, v in o.items()} + if isinstance(o, set): + return {_serialize(x, format) for x in o} + if isinstance(o, tuple): + return tuple(_serialize(x, format) for x in o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, format) + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, enum.Enum): + return o.value + if isinstance(o, int): + if format == "str": + return str(o) + return o + try: + # First try datetime.datetime + return _serialize_datetime(o, format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return o + + +def _get_rest_field( + attr_to_rest_field: typing.Dict[str, "_RestField"], rest_name: str +) -> typing.Optional["_RestField"]: + try: + return next(rf for rf in attr_to_rest_field.values() if rf._rest_name == rest_name) + except StopIteration: + return None + + +def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typing.Any: + if not rf: + return _serialize(value, None) + if rf._is_multipart_file_input: + return value + if rf._is_model: + return _deserialize(rf._type, value) + if isinstance(value, ET.Element): + value = _deserialize(rf._type, value) + return _serialize(value, rf._format) + + +class Model(_MyMutableMapping): + _is_model = True + # label whether current class's _attr_to_rest_field has been calculated + # could not see _attr_to_rest_field directly because subclass inherits it from parent class + _calculated: typing.Set[str] = set() + + def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: + class_name = self.__class__.__name__ + if len(args) > 1: + raise TypeError(f"{class_name}.__init__() takes 2 positional arguments but {len(args) + 1} were given") + dict_to_pass = { + rest_field._rest_name: rest_field._default + for rest_field in self._attr_to_rest_field.values() + if rest_field._default is not _UNSET + } + if args: # pylint: disable=too-many-nested-blocks + if isinstance(args[0], ET.Element): + existed_attr_keys = [] + model_meta = getattr(self, "_xml", {}) + + for rf in self._attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + # attribute + if prop_meta.get("attribute", False) and args[0].get(xml_name) is not None: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].get(xml_name)) + continue + + # unwrapped element is array + if prop_meta.get("unwrapped", False): + # unwrapped array could either use prop items meta/prop meta + if prop_meta.get("itemsName"): + xml_name = prop_meta.get("itemsName") + xml_ns = prop_meta.get("itemNs") + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + items = args[0].findall(xml_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, items) + continue + + # text element is primitive type + if prop_meta.get("text", False): + if args[0].text is not None: + dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].text) + continue + + # wrapped element could be normal property or array, it should only have one element + item = args[0].find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, item) + + # rest thing is additional properties + for e in args[0]: + if e.tag not in existed_attr_keys: + dict_to_pass[e.tag] = _convert_element(e) + else: + dict_to_pass.update( + {k: _create_value(_get_rest_field(self._attr_to_rest_field, k), v) for k, v in args[0].items()} + ) + else: + non_attr_kwargs = [k for k in kwargs if k not in self._attr_to_rest_field] + if non_attr_kwargs: + # actual type errors only throw the first wrong keyword arg they see, so following that. + raise TypeError(f"{class_name}.__init__() got an unexpected keyword argument '{non_attr_kwargs[0]}'") + dict_to_pass.update( + { + self._attr_to_rest_field[k]._rest_name: _create_value(self._attr_to_rest_field[k], v) + for k, v in kwargs.items() + if v is not None + } + ) + super().__init__(dict_to_pass) + + def copy(self) -> "Model": + return Model(self.__dict__) + + def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: + if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated: + # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', + # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' + mros = cls.__mro__[:-9][::-1] # ignore parents, and reverse the mro order + attr_to_rest_field: typing.Dict[str, _RestField] = { # map attribute name to rest_field property + k: v for mro_class in mros for k, v in mro_class.__dict__.items() if k[0] != "_" and hasattr(v, "_type") + } + annotations = { + k: v + for mro_class in mros + if hasattr(mro_class, "__annotations__") + for k, v in mro_class.__annotations__.items() + } + for attr, rf in attr_to_rest_field.items(): + rf._module = cls.__module__ + if not rf._type: + rf._type = rf._get_deserialize_callable_from_annotation(annotations.get(attr, None)) + if not rf._rest_name_input: + rf._rest_name_input = attr + cls._attr_to_rest_field: typing.Dict[str, _RestField] = dict(attr_to_rest_field.items()) + cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") + + return super().__new__(cls) # pylint: disable=no-value-for-parameter + + def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: + for base in cls.__bases__: + if hasattr(base, "__mapping__"): + base.__mapping__[discriminator or cls.__name__] = cls # type: ignore + + @classmethod + def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]: + for v in cls.__dict__.values(): + if isinstance(v, _RestField) and v._is_discriminator and v._rest_name not in exist_discriminators: + return v + return None + + @classmethod + def _deserialize(cls, data, exist_discriminators): + if not hasattr(cls, "__mapping__"): + return cls(data) + discriminator = cls._get_discriminator(exist_discriminators) + if discriminator is None: + return cls(data) + exist_discriminators.append(discriminator._rest_name) + if isinstance(data, ET.Element): + model_meta = getattr(cls, "_xml", {}) + prop_meta = getattr(discriminator, "_xml", {}) + xml_name = prop_meta.get("name", discriminator._rest_name) + xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + if data.get(xml_name) is not None: + discriminator_value = data.get(xml_name) + else: + discriminator_value = data.find(xml_name).text # pyright: ignore + else: + discriminator_value = data.get(discriminator._rest_name) + mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore + return mapped_cls._deserialize(data, exist_discriminators) + + def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.Any]: + """Return a dict that can be turned into json using json.dump. + + :keyword bool exclude_readonly: Whether to remove the readonly properties. + :returns: A dict JSON compatible object + :rtype: dict + """ + + result = {} + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in self._attr_to_rest_field.values() if _is_readonly(p)] + for k, v in self.items(): + if exclude_readonly and k in readonly_props: # pyright: ignore + continue + is_multipart_file_input = False + try: + is_multipart_file_input = next( + rf for rf in self._attr_to_rest_field.values() if rf._rest_name == k + )._is_multipart_file_input + except StopIteration: + pass + result[k] = v if is_multipart_file_input else Model._as_dict_value(v, exclude_readonly=exclude_readonly) + return result + + @staticmethod + def _as_dict_value(v: typing.Any, exclude_readonly: bool = False) -> typing.Any: + if v is None or isinstance(v, _Null): + return None + if isinstance(v, (list, tuple, set)): + return type(v)(Model._as_dict_value(x, exclude_readonly=exclude_readonly) for x in v) + if isinstance(v, dict): + return {dk: Model._as_dict_value(dv, exclude_readonly=exclude_readonly) for dk, dv in v.items()} + return v.as_dict(exclude_readonly=exclude_readonly) if hasattr(v, "as_dict") else v + + +def _deserialize_model(model_deserializer: typing.Optional[typing.Callable], obj): + if _is_model(obj): + return obj + return _deserialize(model_deserializer, obj) + + +def _deserialize_with_optional(if_obj_deserializer: typing.Optional[typing.Callable], obj): + if obj is None: + return obj + return _deserialize_with_callable(if_obj_deserializer, obj) + + +def _deserialize_with_union(deserializers, obj): + for deserializer in deserializers: + try: + return _deserialize(deserializer, obj) + except DeserializationError: + pass + raise DeserializationError() + + +def _deserialize_dict( + value_deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj: typing.Dict[typing.Any, typing.Any], +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = {child.tag: child for child in obj} + return {k: _deserialize(value_deserializer, v, module) for k, v in obj.items()} + + +def _deserialize_multiple_sequence( + entry_deserializers: typing.List[typing.Optional[typing.Callable]], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers)) + + +def _deserialize_sequence( + deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = list(obj) + return type(obj)(_deserialize(deserializer, entry, module) for entry in obj) + + +def _sorted_annotations(types: typing.List[typing.Any]) -> typing.List[typing.Any]: + return sorted( + types, + key=lambda x: hasattr(x, "__name__") and x.__name__.lower() in ("str", "float", "int", "bool"), + ) + + +def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-branches + annotation: typing.Any, + module: typing.Optional[str], + rf: typing.Optional["_RestField"] = None, +) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + if not annotation: + return None + + # is it a type alias? + if isinstance(annotation, str): + if module is not None: + annotation = _get_type_alias_type(module, annotation) + + # is it a forward ref / in quotes? + if isinstance(annotation, (str, typing.ForwardRef)): + try: + model_name = annotation.__forward_arg__ # type: ignore + except AttributeError: + model_name = annotation + if module is not None: + annotation = _get_model(module, model_name) # type: ignore + + try: + if module and _is_model(annotation): + if rf: + rf._is_model = True + + return functools.partial(_deserialize_model, annotation) # pyright: ignore + except Exception: + pass + + # is it a literal? + try: + if annotation.__origin__ is typing.Literal: # pyright: ignore + return None + except AttributeError: + pass + + # is it optional? + try: + if any(a for a in annotation.__args__ if a == type(None)): # pyright: ignore + if len(annotation.__args__) <= 2: # pyright: ignore + if_obj_deserializer = _get_deserialize_callable_from_annotation( + next(a for a in annotation.__args__ if a != type(None)), module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_with_optional, if_obj_deserializer) + # the type is Optional[Union[...]], we need to remove the None type from the Union + annotation_copy = copy.copy(annotation) + annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a != type(None)] # pyright: ignore + return _get_deserialize_callable_from_annotation(annotation_copy, module, rf) + except AttributeError: + pass + + # is it union? + if getattr(annotation, "__origin__", None) is typing.Union: + # initial ordering is we make `string` the last deserialization option, because it is often them most generic + deserializers = [ + _get_deserialize_callable_from_annotation(arg, module, rf) + for arg in _sorted_annotations(annotation.__args__) # pyright: ignore + ] + + return functools.partial(_deserialize_with_union, deserializers) + + try: + if annotation._name == "Dict": # pyright: ignore + value_deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[1], module, rf # pyright: ignore + ) + + return functools.partial( + _deserialize_dict, + value_deserializer, + module, + ) + except (AttributeError, IndexError): + pass + try: + if annotation._name in ["List", "Set", "Tuple", "Sequence"]: # pyright: ignore + if len(annotation.__args__) > 1: # pyright: ignore + entry_deserializers = [ + _get_deserialize_callable_from_annotation(dt, module, rf) + for dt in annotation.__args__ # pyright: ignore + ] + return functools.partial(_deserialize_multiple_sequence, entry_deserializers, module) + deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[0], module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_sequence, deserializer, module) + except (TypeError, IndexError, AttributeError, SyntaxError): + pass + + def _deserialize_default( + deserializer, + obj, + ): + if obj is None: + return obj + try: + return _deserialize_with_callable(deserializer, obj) + except Exception: + pass + return obj + + if get_deserializer(annotation, rf): + return functools.partial(_deserialize_default, get_deserializer(annotation, rf)) + + return functools.partial(_deserialize_default, annotation) + + +def _deserialize_with_callable( + deserializer: typing.Optional[typing.Callable[[typing.Any], typing.Any]], + value: typing.Any, +): # pylint: disable=too-many-return-statements + try: + if value is None or isinstance(value, _Null): + return None + if isinstance(value, ET.Element): + if deserializer is str: + return value.text or "" + if deserializer is int: + return int(value.text) if value.text else None + if deserializer is float: + return float(value.text) if value.text else None + if deserializer is bool: + return value.text == "true" if value.text else None + if deserializer is None: + return value + if deserializer in [int, float, bool]: + return deserializer(value) + if isinstance(deserializer, CaseInsensitiveEnumMeta): + try: + return deserializer(value) + except ValueError: + # for unknown value, return raw value + return value + if isinstance(deserializer, type) and issubclass(deserializer, Model): + return deserializer._deserialize(value, []) + return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value) + except Exception as e: + raise DeserializationError() from e + + +def _deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + if isinstance(value, PipelineResponse): + value = value.http_response.json() + if rf is None and format: + rf = _RestField(format=format) + if not isinstance(deserializer, functools.partial): + deserializer = _get_deserialize_callable_from_annotation(deserializer, module, rf) + return _deserialize_with_callable(deserializer, value) + + +def _failsafe_deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + try: + return _deserialize(deserializer, value, module, rf, format) + except DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +def _failsafe_deserialize_xml( + deserializer: typing.Any, + value: typing.Any, +) -> typing.Any: + try: + return _deserialize_xml(deserializer, value) + except DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +class _RestField: + def __init__( + self, + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + is_discriminator: bool = False, + visibility: typing.Optional[typing.List[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[typing.Dict[str, typing.Any]] = None, + ): + self._type = type + self._rest_name_input = name + self._module: typing.Optional[str] = None + self._is_discriminator = is_discriminator + self._visibility = visibility + self._is_model = False + self._default = default + self._format = format + self._is_multipart_file_input = is_multipart_file_input + self._xml = xml if xml is not None else {} + + @property + def _class_type(self) -> typing.Any: + return getattr(self._type, "args", [None])[0] + + @property + def _rest_name(self) -> str: + if self._rest_name_input is None: + raise ValueError("Rest name was never set") + return self._rest_name_input + + def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin + # by this point, type and rest_name will have a value bc we default + # them in __new__ of the Model class + item = obj.get(self._rest_name) + if item is None: + return item + if self._is_model: + return item + return _deserialize(self._type, _serialize(item, self._format), rf=self) + + def __set__(self, obj: Model, value) -> None: + if value is None: + # we want to wipe out entries if users set attr to None + try: + obj.__delitem__(self._rest_name) + except KeyError: + pass + return + if self._is_model: + if not _is_model(value): + value = _deserialize(self._type, value) + obj.__setitem__(self._rest_name, value) + return + obj.__setitem__(self._rest_name, _serialize(value, self._format)) + + def _get_deserialize_callable_from_annotation( + self, annotation: typing.Any + ) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + return _get_deserialize_callable_from_annotation(annotation, self._module, self) + + +def rest_field( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[typing.List[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[typing.Dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField( + name=name, + type=type, + visibility=visibility, + default=default, + format=format, + is_multipart_file_input=is_multipart_file_input, + xml=xml, + ) + + +def rest_discriminator( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[typing.List[str]] = None, + xml: typing.Optional[typing.Dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField(name=name, type=type, is_discriminator=True, visibility=visibility, xml=xml) + + +def serialize_xml(model: Model, exclude_readonly: bool = False) -> str: + """Serialize a model to XML. + + :param Model model: The model to serialize. + :param bool exclude_readonly: Whether to exclude readonly properties. + :returns: The XML representation of the model. + :rtype: str + """ + return ET.tostring(_get_element(model, exclude_readonly), encoding="unicode") # type: ignore + + +def _get_element( + o: typing.Any, + exclude_readonly: bool = False, + parent_meta: typing.Optional[typing.Dict[str, typing.Any]] = None, + wrapped_element: typing.Optional[ET.Element] = None, +) -> typing.Union[ET.Element, typing.List[ET.Element]]: + if _is_model(o): + model_meta = getattr(o, "_xml", {}) + + # if prop is a model, then use the prop element directly, else generate a wrapper of model + if wrapped_element is None: + wrapped_element = _create_xml_element( + model_meta.get("name", o.__class__.__name__), + model_meta.get("prefix"), + model_meta.get("ns"), + ) + + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + + for k, v in o.items(): + # do not serialize readonly properties + if exclude_readonly and k in readonly_props: + continue + + prop_rest_field = _get_rest_field(o._attr_to_rest_field, k) + if prop_rest_field: + prop_meta = getattr(prop_rest_field, "_xml").copy() + # use the wire name as xml name if no specific name is set + if prop_meta.get("name") is None: + prop_meta["name"] = k + else: + # additional properties will not have rest field, use the wire name as xml name + prop_meta = {"name": k} + + # if no ns for prop, use model's + if prop_meta.get("ns") is None and model_meta.get("ns"): + prop_meta["ns"] = model_meta.get("ns") + prop_meta["prefix"] = model_meta.get("prefix") + + if prop_meta.get("unwrapped", False): + # unwrapped could only set on array + wrapped_element.extend(_get_element(v, exclude_readonly, prop_meta)) + elif prop_meta.get("text", False): + # text could only set on primitive type + wrapped_element.text = _get_primitive_type_value(v) + elif prop_meta.get("attribute", False): + xml_name = prop_meta.get("name", k) + if prop_meta.get("ns"): + ET.register_namespace(prop_meta.get("prefix"), prop_meta.get("ns")) # pyright: ignore + xml_name = "{" + prop_meta.get("ns") + "}" + xml_name # pyright: ignore + # attribute should be primitive type + wrapped_element.set(xml_name, _get_primitive_type_value(v)) + else: + # other wrapped prop element + wrapped_element.append(_get_wrapped_element(v, exclude_readonly, prop_meta)) + return wrapped_element + if isinstance(o, list): + return [_get_element(x, exclude_readonly, parent_meta) for x in o] # type: ignore + if isinstance(o, dict): + result = [] + for k, v in o.items(): + result.append( + _get_wrapped_element( + v, + exclude_readonly, + { + "name": k, + "ns": parent_meta.get("ns") if parent_meta else None, + "prefix": parent_meta.get("prefix") if parent_meta else None, + }, + ) + ) + return result + + # primitive case need to create element based on parent_meta + if parent_meta: + return _get_wrapped_element( + o, + exclude_readonly, + { + "name": parent_meta.get("itemsName", parent_meta.get("name")), + "prefix": parent_meta.get("itemsPrefix", parent_meta.get("prefix")), + "ns": parent_meta.get("itemsNs", parent_meta.get("ns")), + }, + ) + + raise ValueError("Could not serialize value into xml: " + o) + + +def _get_wrapped_element( + v: typing.Any, + exclude_readonly: bool, + meta: typing.Optional[typing.Dict[str, typing.Any]], +) -> ET.Element: + wrapped_element = _create_xml_element( + meta.get("name") if meta else None, meta.get("prefix") if meta else None, meta.get("ns") if meta else None + ) + if isinstance(v, (dict, list)): + wrapped_element.extend(_get_element(v, exclude_readonly, meta)) + elif _is_model(v): + _get_element(v, exclude_readonly, meta, wrapped_element) + else: + wrapped_element.text = _get_primitive_type_value(v) + return wrapped_element + + +def _get_primitive_type_value(v) -> str: + if v is True: + return "true" + if v is False: + return "false" + if isinstance(v, _Null): + return "" + return str(v) + + +def _create_xml_element(tag, prefix=None, ns=None): + if prefix and ns: + ET.register_namespace(prefix, ns) + if ns: + return ET.Element("{" + ns + "}" + tag) + return ET.Element(tag) + + +def _deserialize_xml( + deserializer: typing.Any, + value: str, +) -> typing.Any: + element = ET.fromstring(value) # nosec + return _deserialize(deserializer, element) + + +def _convert_element(e: ET.Element): + # dict case + if len(e.attrib) > 0 or len({child.tag for child in e}) > 1: + dict_result: typing.Dict[str, typing.Any] = {} + for child in e: + if dict_result.get(child.tag) is not None: + if isinstance(dict_result[child.tag], list): + dict_result[child.tag].append(_convert_element(child)) + else: + dict_result[child.tag] = [dict_result[child.tag], _convert_element(child)] + else: + dict_result[child.tag] = _convert_element(child) + dict_result.update(e.attrib) + return dict_result + # array case + if len(e) > 0: + array_result: typing.List[typing.Any] = [] + for child in e: + array_result.append(_convert_element(child)) + return array_result + # primitive case + return e.text diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_operations/__init__.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_operations/__init__.py new file mode 100644 index 00000000000..6fdc2a0dad5 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_operations/__init__.py @@ -0,0 +1,25 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import StatusCodeRangeClientOperationsMixin # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "StatusCodeRangeClientOperationsMixin", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py new file mode 100644 index 00000000000..517abd62f19 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py @@ -0,0 +1,194 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Literal, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict + +from .. import models as _models +from .._model_base import _deserialize, _failsafe_deserialize +from .._serialization import Serializer +from .._vendor import StatusCodeRangeClientMixinABC + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_status_code_range_error_response_status_code_in_range_request( # pylint: disable=name-too-long + **kwargs: Any, +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/response/status-code-range/error-response-status-code-in-range" + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + +def build_status_code_range_error_response_status_code404_request( # pylint: disable=name-too-long + **kwargs: Any, +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/response/status-code-range/error-response-status-code-404" + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + +class StatusCodeRangeClientOperationsMixin(StatusCodeRangeClientMixinABC): + + @distributed_trace + def error_response_status_code_in_range(self, **kwargs: Any) -> Literal[204]: + """error_response_status_code_in_range. + + :return: constant + :rtype: int + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Literal[204]] = kwargs.pop("cls", None) + + _request = build_status_code_range_error_response_status_code_in_range_request( + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = None + if 494 <= response.status_code <= 499: + error = _failsafe_deserialize(_models.ErrorInRange, response.json()) + else: + error = _failsafe_deserialize(_models.DefaultError, response.json()) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(Literal[204], response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def error_response_status_code404(self, **kwargs: Any) -> Literal[204]: + """error_response_status_code404. + + :return: constant + :rtype: int + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Literal[204]] = kwargs.pop("cls", None) + + _request = build_status_code_range_error_response_status_code404_request( + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = None + if response.status_code == 404: + error = _failsafe_deserialize(_models.NotFoundError, response.json()) + raise ResourceNotFoundError(response=response, model=error) + elif 400 <= response.status_code <= 499: + error = _failsafe_deserialize(_models.Standard4XXError, response.json()) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(Literal[204], response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_operations/_patch.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_operations/_patch.py new file mode 100644 index 00000000000..f7dd3251033 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_patch.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_patch.py new file mode 100644 index 00000000000..f7dd3251033 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_serialization.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_serialization.py new file mode 100644 index 00000000000..a066e16a64d --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_serialization.py @@ -0,0 +1,2050 @@ +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# 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. +# +# -------------------------------------------------------------------------- + +# pyright: reportUnnecessaryTypeIgnoreComment=false + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +from typing import ( + Dict, + Any, + cast, + Optional, + Union, + AnyStr, + IO, + Mapping, + Callable, + MutableMapping, + List, +) + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote +import xml.etree.ElementTree as ET + +import isodate # type: ignore +from typing_extensions import Self + +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +JSON = MutableMapping[str, Any] + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + :return: The deserialized data. + :rtype: object + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) from err + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError as err: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str + raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + + :param bytes body_bytes: The body of the response. + :param dict headers: The headers of the response. + :returns: The deserialized data. + :rtype: object + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + +TZ_UTC = datetime.timezone.utc + +_FLATTEN = re.compile(r"(? None: + self.additional_properties: Optional[Dict[str, Any]] = {} + for k in kwargs: # pylint: disable=consider-using-dict-items + if k not in self._attribute_map: + _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) + elif k in self._validation and self._validation[k].get("readonly", False): + _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) + else: + setattr(self, k, kwargs[k]) + + def __eq__(self, other: Any) -> bool: + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are equal + :rtype: bool + """ + if isinstance(other, self.__class__): + return self.__dict__ == other.__dict__ + return False + + def __ne__(self, other: Any) -> bool: + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are not equal + :rtype: bool + """ + return not self.__eq__(other) + + def __str__(self) -> str: + return str(self.__dict__) + + @classmethod + def enable_additional_properties_sending(cls) -> None: + cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} + + @classmethod + def is_xml_model(cls) -> bool: + try: + cls._xml_map # type: ignore + except AttributeError: + return False + return True + + @classmethod + def _create_xml_node(cls): + """Create XML node. + + :returns: The XML node + :rtype: xml.etree.ElementTree.Element + """ + try: + xml_map = cls._xml_map # type: ignore + except AttributeError: + xml_map = {} + + return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) + + def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: + """Return the JSON that would be sent to server from this model. + + This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param bool keep_readonly: If you want to serialize the readonly attributes + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, keep_readonly=keep_readonly, **kwargs + ) + + def as_dict( + self, + keep_readonly: bool = True, + key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + **kwargs: Any + ) -> JSON: + """Return a dict that can be serialized using json.dump. + + Advanced usage might optionally use a callback as parameter: + + .. code::python + + def my_key_transformer(key, attr_desc, value): + return key + + Key is the attribute name used in Python. Attr_desc + is a dict of metadata. Currently contains 'type' with the + msrest type and 'key' with the RestAPI encoded key. + Value is the current value in this object. + + The string returned will be used to serialize the key. + If the return type is a list, this is considered hierarchical + result dict. + + See the three examples in this file: + + - attribute_transformer + - full_restapi_key_transformer + - last_restapi_key_transformer + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param bool keep_readonly: If you want to serialize the readonly attributes + :param function key_transformer: A key transformer function. + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs + ) + + @classmethod + def _infer_class_models(cls): + try: + str_models = cls.__module__.rsplit(".", 1)[0] + models = sys.modules[str_models] + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + if cls.__name__ not in client_models: + raise ValueError("Not Autorest generated code") + except Exception: # pylint: disable=broad-exception-caught + # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. + client_models = {cls.__name__: cls} + return client_models + + @classmethod + def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: + """Parse a str using the RestAPI syntax and return a model. + + :param str data: A str using RestAPI structure. JSON by default. + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises DeserializationError: if something went wrong + :rtype: Self + """ + deserializer = Deserializer(cls._infer_class_models()) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore + + @classmethod + def from_dict( + cls, + data: Any, + key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + content_type: Optional[str] = None, + ) -> Self: + """Parse a dict using given key extractor return a model. + + By default consider key + extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor + and last_rest_key_case_insensitive_extractor) + + :param dict data: A dict using RestAPI structure + :param function key_extractors: A key extractor function. + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises: DeserializationError if something went wrong + :rtype: Self + """ + deserializer = Deserializer(cls._infer_class_models()) + deserializer.key_extractors = ( # type: ignore + [ # type: ignore + attribute_key_case_insensitive_extractor, + rest_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + if key_extractors is None + else key_extractors + ) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore + + @classmethod + def _flatten_subtype(cls, key, objects): + if "_subtype_map" not in cls.__dict__: + return {} + result = dict(cls._subtype_map[key]) + for valuetype in cls._subtype_map[key].values(): + result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access + return result + + @classmethod + def _classify(cls, response, objects): + """Check the class _subtype_map for any child classes. + We want to ignore any inherited _subtype_maps. + + :param dict response: The initial data + :param dict objects: The class objects + :returns: The class to be used + :rtype: class + """ + for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): + subtype_value = None + + if not isinstance(response, ET.Element): + rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] + subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) + else: + subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) + if subtype_value: + # Try to match base class. Can be class name only + # (bug to fix in Autorest to support x-ms-discriminator-name) + if cls.__name__ == subtype_value: + return cls + flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) + try: + return objects[flatten_mapping_type[subtype_value]] # type: ignore + except KeyError: + _LOGGER.warning( + "Subtype value %s has no mapping, use base class %s.", + subtype_value, + cls.__name__, + ) + break + else: + _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) + break + return cls + + @classmethod + def _get_rest_key_parts(cls, attr_key): + """Get the RestAPI key of this attr, split it and decode part + :param str attr_key: Attribute key must be in attribute_map. + :returns: A list of RestAPI part + :rtype: list + """ + rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) + return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] + + +def _decode_attribute_map_key(key): + """This decode a key in an _attribute_map to the actual key we want to look at + inside the received data. + + :param str key: A key string from the generated code + :returns: The decoded key + :rtype: str + """ + return key.replace("\\.", ".") + + +class Serializer: # pylint: disable=too-many-public-methods + """Request object model serializer.""" + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} + days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} + months = { + 1: "Jan", + 2: "Feb", + 3: "Mar", + 4: "Apr", + 5: "May", + 6: "Jun", + 7: "Jul", + 8: "Aug", + 9: "Sep", + 10: "Oct", + 11: "Nov", + 12: "Dec", + } + validation = { + "min_length": lambda x, y: len(x) < y, + "max_length": lambda x, y: len(x) > y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals + self, target_obj, data_type=None, **kwargs + ): + """Serialize data into a string according to type. + + :param object target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises SerializationError: if serialization fails. + :returns: The serialized data. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() # pylint: disable=protected-access + try: + attributes = target_obj._attribute_map # pylint: disable=protected-access + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access + attr_name, {} + ).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) # type: ignore + continue + if xml_desc.get("text", False): + serialized.text = new_attr # type: ignore + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) # type: ignore + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, + # we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) # type: ignore + else: # That's a basic type + # Integrate namespace if necessary + local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) + local_node.text = str(new_attr) + serialized.append(local_node) # type: ignore + else: # JSON + for k in reversed(keys): # type: ignore + new_attr = {k: new_attr} + + _new_attr = new_attr + _serialized = serialized + for k in keys: # type: ignore + if k not in _serialized: + _serialized.update(_new_attr) # type: ignore + _new_attr = _new_attr[k] # type: ignore + _serialized = _serialized[k] + except ValueError as err: + if isinstance(err, SerializationError): + raise + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) + raise SerializationError(msg) from err + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises SerializationError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized request body + """ + + # Just in case this is a dict + internal_data_type_str = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type_str, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ # type: ignore + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access + except DeserializationError as err: + raise SerializationError("Unable to build a model: " + str(err)) from err + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param str name: The name of the URL path parameter. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :returns: The serialized URL path + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) + else: + output = quote(str(output), safe="") + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param str name: The name of the query parameter. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, list + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized query parameter + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + do_quote = not kwargs.get("skip_quote", False) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param str name: The name of the header. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized header + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :raises AttributeError: if required data is None. + :raises ValueError: if data is None + :raises SerializationError: if serialization fails. + :returns: The serialized data. + :rtype: str, int, float, bool, dict, list + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data is CoreNull: + return None + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + if data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise SerializationError(msg.format(data, data_type)) from err + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param obj data: Object to be serialized. + :param str data_type: Type of object in the iterable. + :rtype: str, int, float, bool + :return: serialized object + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == "str": + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec # pylint: disable=eval-used + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param str data: Object to be serialized. + :rtype: str + :return: serialized object + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): # type: ignore + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list data: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + Defaults to False. + :rtype: list, str + :return: serialized iterable + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError as err: + if isinstance(err, SerializationError): + raise + serialized.append(None) + + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + + if div: + serialized = ["" if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :rtype: dict + :return: serialized dictionary + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError as err: + if isinstance(err, SerializationError): + raise + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + :return: serialized object + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + if obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) # type: ignore + return result + except ValueError as exc: + for enum_value in enum_obj: # type: ignore + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) from exc + + @staticmethod + def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument + """Serialize bytearray into base-64 string. + + :param str attr: Object to be serialized. + :rtype: str + :return: serialized base64 + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument + """Serialize str into base-64 string. + + :param str attr: Object to be serialized. + :rtype: str + :return: serialized base64 + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Decimal object to float. + + :param decimal attr: Object to be serialized. + :rtype: float + :return: serialized decimal + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): # pylint: disable=unused-argument + """Serialize long (Py2) or int (Py3). + + :param int attr: Object to be serialized. + :rtype: int/long + :return: serialized long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + :return: serialized date + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + :return: serialized time + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + :return: serialized duration + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises TypeError: if format invalid. + :return: serialized rfc + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError as exc: + raise TypeError("RFC1123 object must be valid Datetime object.") from exc + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises SerializationError: if format invalid. + :return: serialized iso + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise SerializationError(msg) from err + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise TypeError(msg) from err + + @staticmethod + def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises SerializationError: if format invalid + :return: serialied unix + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError as exc: + raise TypeError("Unix time object must be valid Datetime object.") from exc + + +def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + key = attr_desc["key"] + working_data = data + + while "." in key: + # Need the cast, as for some reasons "split" is typed as list[str | Any] + dict_keys = cast(List[str], _FLATTEN.split(key)) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + return None + key = ".".join(dict_keys[1:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements + attr, attr_desc, data +): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + return None + key = ".".join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get("name", internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer: + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.key_extractors = [rest_key_extractor, xml_key_extractor] + # Additional properties only works if the "rest_key_extractor" is used to + # extract the keys. Making it to work whatever the key extractor is too much + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, str): + return self.deserialize_data(data, response) + if isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None or data is CoreNull: + return data + try: + attributes = response._attribute_map # type: ignore # pylint: disable=protected-access + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc["type"]) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name # type: ignore + raise DeserializationError(msg) from err + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + :return: The classified target object and its class name. + :rtype: tuple + """ + if target is None: + return None, None + + if isinstance(target, str): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ # type: ignore + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + :param str content_type: Swagger "produces" if available. + :return: Deserialized object. + :rtype: object + """ + try: + return self(target_obj, data, content_type=content_type) + except: # pylint: disable=bare-except + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param obj raw_data: Data to be processed. + :param str content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + :rtype: object + :return: Unpacked content. + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, "_content_consumed"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) + + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param Response response: The response model class. + :param dict attrs: The deserialized response attributes. + :param dict additional_properties: Additional properties to be set. + :rtype: Response + :return: The instantiated response model. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("readonly") + ] + const = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("constant") + ] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties # type: ignore + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore + raise DeserializationError(msg + str(err)) from err + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) from exp + + def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment + "object", + "[]", + r"{}", + ] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise DeserializationError(msg) from err + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :return: Deserialized iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :return: Deserialized dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :return: Deserialized object. + :rtype: dict + :raises TypeError: if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, str): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :return: Deserialized basic type. + :rtype: str, int, float or bool + :raises TypeError: if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + if isinstance(attr, str): + if attr.lower() in ["true", "1"]: + return True + if attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec # pylint: disable=eval-used + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :return: Deserialized string. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): # type: ignore + return data + except NameError: + return str(data) + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :return: Deserialized enum object. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + try: + return list(enum_obj.__members__.values())[data] + except IndexError as exc: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) from exc + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :return: Deserialized bytearray + :rtype: bytearray + :raises TypeError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) # type: ignore + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :return: Deserialized base64 string + :rtype: bytearray + :raises TypeError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :return: Deserialized decimal + :raises DeserializationError: if string format invalid. + :rtype: decimal + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(str(attr)) # type: ignore + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise DeserializationError(msg) from err + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :return: Deserialized int + :rtype: long or int + :raises ValueError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) # type: ignore + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :return: Deserialized duration + :rtype: TimeDelta + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise DeserializationError(msg) from err + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :return: Deserialized date + :rtype: Date + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :return: Deserialized time + :rtype: datetime.time + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :return: Deserialized RFC datetime + :rtype: Datetime + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) # type: ignore + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise DeserializationError(msg) from err + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :return: Deserialized ISO datetime + :rtype: Datetime + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() # type: ignore + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise DeserializationError(msg) from err + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :return: Deserialized datetime + :rtype: Datetime + :raises DeserializationError: if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) # type: ignore + try: + attr = int(attr) + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise DeserializationError(msg) from err + return date_obj diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_vendor.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_vendor.py new file mode 100644 index 00000000000..41dc5fa69db --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_vendor.py @@ -0,0 +1,25 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from ._configuration import StatusCodeRangeClientConfiguration + +if TYPE_CHECKING: + from azure.core import PipelineClient + + from ._serialization import Deserializer, Serializer + + +class StatusCodeRangeClientMixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "PipelineClient" + _config: StatusCodeRangeClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_version.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_version.py new file mode 100644 index 00000000000..be71c81bd28 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_version.py @@ -0,0 +1,9 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/__init__.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/__init__.py new file mode 100644 index 00000000000..593da0d6872 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/__init__.py @@ -0,0 +1,29 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import StatusCodeRangeClient # type: ignore + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "StatusCodeRangeClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore + +_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_client.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_client.py new file mode 100644 index 00000000000..7d3a968dc9b --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_client.py @@ -0,0 +1,93 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable +from typing_extensions import Self + +from azure.core import AsyncPipelineClient +from azure.core.pipeline import policies +from azure.core.rest import AsyncHttpResponse, HttpRequest + +from .._serialization import Deserializer, Serializer +from ._configuration import StatusCodeRangeClientConfiguration +from ._operations import StatusCodeRangeClientOperationsMixin + + +class StatusCodeRangeClient(StatusCodeRangeClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword + """Test for range of status code. + + :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: + _endpoint = "{endpoint}" + self._config = StatusCodeRangeClientConfiguration(endpoint=endpoint, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncPipelineClient = AsyncPipelineClient(base_url=_endpoint, policies=_policies, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + + def send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> Self: + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_configuration.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_configuration.py new file mode 100644 index 00000000000..91b9773fec3 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_configuration.py @@ -0,0 +1,42 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any + +from azure.core.pipeline import policies + +from .._version import VERSION + + +class StatusCodeRangeClientConfiguration: # pylint: disable=too-many-instance-attributes + """Configuration for StatusCodeRangeClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: Service host. Default value is "http://localhost:3000". + :type endpoint: str + """ + + def __init__(self, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None: + + self.endpoint = endpoint + kwargs.setdefault("sdk_moniker", "response-statuscoderange/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_operations/__init__.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_operations/__init__.py new file mode 100644 index 00000000000..6fdc2a0dad5 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_operations/__init__.py @@ -0,0 +1,25 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import StatusCodeRangeClientOperationsMixin # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "StatusCodeRangeClientOperationsMixin", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py new file mode 100644 index 00000000000..025309501bb --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py @@ -0,0 +1,161 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Literal, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async + +from ... import models as _models +from ..._model_base import _deserialize, _failsafe_deserialize +from ..._operations._operations import ( + build_status_code_range_error_response_status_code404_request, + build_status_code_range_error_response_status_code_in_range_request, +) +from .._vendor import StatusCodeRangeClientMixinABC + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class StatusCodeRangeClientOperationsMixin(StatusCodeRangeClientMixinABC): + + @distributed_trace_async + async def error_response_status_code_in_range(self, **kwargs: Any) -> Literal[204]: + """error_response_status_code_in_range. + + :return: constant + :rtype: int + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Literal[204]] = kwargs.pop("cls", None) + + _request = build_status_code_range_error_response_status_code_in_range_request( + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = None + if 494 <= response.status_code <= 499: + error = _failsafe_deserialize(_models.ErrorInRange, response.json()) + else: + error = _failsafe_deserialize(_models.DefaultError, response.json()) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(Literal[204], response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def error_response_status_code404(self, **kwargs: Any) -> Literal[204]: + """error_response_status_code404. + + :return: constant + :rtype: int + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Literal[204]] = kwargs.pop("cls", None) + + _request = build_status_code_range_error_response_status_code404_request( + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = None + if response.status_code == 404: + error = _failsafe_deserialize(_models.NotFoundError, response.json()) + raise ResourceNotFoundError(response=response, model=error) + elif 400 <= response.status_code <= 499: + error = _failsafe_deserialize(_models.Standard4XXError, response.json()) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(Literal[204], response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_operations/_patch.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_operations/_patch.py new file mode 100644 index 00000000000..f7dd3251033 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_patch.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_patch.py new file mode 100644 index 00000000000..f7dd3251033 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_vendor.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_vendor.py new file mode 100644 index 00000000000..263cd4a4f72 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_vendor.py @@ -0,0 +1,25 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from ._configuration import StatusCodeRangeClientConfiguration + +if TYPE_CHECKING: + from azure.core import AsyncPipelineClient + + from .._serialization import Deserializer, Serializer + + +class StatusCodeRangeClientMixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "AsyncPipelineClient" + _config: StatusCodeRangeClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/models/__init__.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/models/__init__.py new file mode 100644 index 00000000000..f77e6db26dd --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/models/__init__.py @@ -0,0 +1,33 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models import ( # type: ignore + DefaultError, + ErrorInRange, + NotFoundError, + Standard4XXError, +) +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DefaultError", + "ErrorInRange", + "NotFoundError", + "Standard4XXError", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/models/_models.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/models/_models.py new file mode 100644 index 00000000000..d177fa29452 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/models/_models.py @@ -0,0 +1,143 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=useless-super-delegation + +from typing import Any, Mapping, overload + +from .. import _model_base +from .._model_base import rest_field + + +class DefaultError(_model_base.Model): + """DefaultError. + + All required parameters must be populated in order to send to server. + + :ivar code: Required. + :vartype code: str + """ + + code: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + code: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ErrorInRange(_model_base.Model): + """ErrorInRange. + + All required parameters must be populated in order to send to server. + + :ivar code: Required. + :vartype code: str + :ivar message: Required. + :vartype message: str + """ + + code: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + message: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + code: str, + message: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NotFoundError(_model_base.Model): + """NotFoundError. + + All required parameters must be populated in order to send to server. + + :ivar code: Required. + :vartype code: str + :ivar resource_id: Required. + :vartype resource_id: str + """ + + code: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + resource_id: str = rest_field(name="resourceId", visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + code: str, + resource_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Standard4XXError(_model_base.Model): + """Standard4XXError. + + All required parameters must be populated in order to send to server. + + :ivar code: Required. + :vartype code: str + """ + + code: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + code: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/models/_patch.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/models/_patch.py new file mode 100644 index 00000000000..f7dd3251033 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/py.typed b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/setup.py b/packages/typespec-python/test/azure/generated/response-status-code-range/setup.py new file mode 100644 index 00000000000..08d9d67db36 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/setup.py @@ -0,0 +1,70 @@ +# 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. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# coding: utf-8 + +import os +import re +from setuptools import setup, find_packages + + +PACKAGE_NAME = "response-statuscoderange" +PACKAGE_PPRINT_NAME = "Response Statuscoderange" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace("-", "/") + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, "_version.py"), "r") as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError("Cannot find version information") + + +setup( + name=PACKAGE_NAME, + version=version, + description="Microsoft {} Client Library for Python".format(PACKAGE_PPRINT_NAME), + long_description=open("README.md", "r").read(), + long_description_content_type="text/markdown", + license="MIT License", + author="Microsoft Corporation", + author_email="azpysdkhelp@microsoft.com", + url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk", + keywords="azure, azure sdk", + classifiers=[ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "License :: OSI Approved :: MIT License", + ], + zip_safe=False, + packages=find_packages( + exclude=[ + "tests", + # Exclude packages that will be covered by PEP420 or nspkg + "response", + ] + ), + include_package_data=True, + package_data={ + "response.statuscoderange": ["py.typed"], + }, + install_requires=[ + "isodate>=0.6.1", + "azure-core>=1.30.0", + "typing-extensions>=4.6.0", + ], + python_requires=">=3.8", +) diff --git a/packages/typespec-python/test/azure/generated/serialization-encoded-name-json/serialization/encodedname/json/models/_models.py b/packages/typespec-python/test/azure/generated/serialization-encoded-name-json/serialization/encodedname/json/models/_models.py index a347aedce6e..44e3161acf1 100644 --- a/packages/typespec-python/test/azure/generated/serialization-encoded-name-json/serialization/encodedname/json/models/_models.py +++ b/packages/typespec-python/test/azure/generated/serialization-encoded-name-json/serialization/encodedname/json/models/_models.py @@ -21,7 +21,7 @@ class JsonEncodedNameModel(_model_base.Model): :vartype default_name: bool """ - default_name: bool = rest_field(name="wireName") + default_name: bool = rest_field(name="wireName", visibility=["read", "create", "update", "delete", "query"]) """Pass in true. Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/special-words/specialwords/models/_models.py b/packages/typespec-python/test/azure/generated/special-words/specialwords/models/_models.py index df42bb08e57..7d4c9090782 100644 --- a/packages/typespec-python/test/azure/generated/special-words/specialwords/models/_models.py +++ b/packages/typespec-python/test/azure/generated/special-words/specialwords/models/_models.py @@ -23,7 +23,7 @@ class AndModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -53,7 +53,7 @@ class AsModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -83,7 +83,7 @@ class AssertModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -113,7 +113,7 @@ class AsyncModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -143,7 +143,7 @@ class AwaitModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -173,7 +173,7 @@ class BreakModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -203,7 +203,7 @@ class ClassModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -233,7 +233,7 @@ class Constructor(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -263,7 +263,7 @@ class ContinueModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -293,7 +293,7 @@ class DefModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -323,7 +323,7 @@ class DelModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -353,7 +353,7 @@ class ElifModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -383,7 +383,7 @@ class ElseModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -413,7 +413,7 @@ class ExceptModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -443,7 +443,7 @@ class ExecModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -473,7 +473,7 @@ class FinallyModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -503,7 +503,7 @@ class ForModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -533,7 +533,7 @@ class FromModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -563,7 +563,7 @@ class GlobalModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -593,7 +593,7 @@ class IfModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -623,7 +623,7 @@ class ImportModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -653,7 +653,7 @@ class InModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -683,7 +683,7 @@ class IsModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -713,7 +713,7 @@ class LambdaModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -743,7 +743,7 @@ class NotModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -773,7 +773,7 @@ class OrModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -803,7 +803,7 @@ class PassModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -833,7 +833,7 @@ class RaiseModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -863,7 +863,7 @@ class ReturnModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -893,7 +893,7 @@ class SameAsModel(_model_base.Model): :vartype same_as_model: str """ - same_as_model: str = rest_field(name="SameAsModel") + same_as_model: str = rest_field(name="SameAsModel", visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -923,7 +923,7 @@ class TryModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -953,7 +953,7 @@ class WhileModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -983,7 +983,7 @@ class WithModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -1013,7 +1013,7 @@ class YieldModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/typetest-array/typetest/array/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-array/typetest/array/models/_models.py index 7a7f7fe80f4..3102e45483a 100644 --- a/packages/typespec-python/test/azure/generated/typetest-array/typetest/array/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-array/typetest/array/models/_models.py @@ -26,9 +26,11 @@ class InnerModel(_model_base.Model): :vartype children: list[~typetest.array.models.InnerModel] """ - property: str = rest_field() + property: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required string property. Required.""" - children: Optional[List["_models.InnerModel"]] = rest_field() + children: Optional[List["_models.InnerModel"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) @overload def __init__( diff --git a/packages/typespec-python/test/azure/generated/typetest-dictionary/typetest/dictionary/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-dictionary/typetest/dictionary/models/_models.py index af6aa8a00d3..92decb06661 100644 --- a/packages/typespec-python/test/azure/generated/typetest-dictionary/typetest/dictionary/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-dictionary/typetest/dictionary/models/_models.py @@ -26,9 +26,11 @@ class InnerModel(_model_base.Model): :vartype children: dict[str, ~typetest.dictionary.models.InnerModel] """ - property: str = rest_field() + property: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required string property. Required.""" - children: Optional[Dict[str, "_models.InnerModel"]] = rest_field() + children: Optional[Dict[str, "_models.InnerModel"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) @overload def __init__( diff --git a/packages/typespec-python/test/azure/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/models/_models.py index 17b4b89d6ce..c37e84c979c 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/models/_models.py @@ -28,9 +28,9 @@ class Snake(_model_base.Model): """ __mapping__: Dict[str, _model_base.Model] = {} - kind: str = rest_discriminator(name="kind") + kind: str = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) """discriminator property. Required. \"cobra\"""" - length: int = rest_field() + length: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Length of the snake. Required.""" @overload @@ -62,7 +62,7 @@ class Cobra(Snake, discriminator="cobra"): :vartype kind: str or ~typetest.model.enumdiscriminator.models.COBRA """ - kind: Literal[SnakeKind.COBRA] = rest_discriminator(name="kind") # type: ignore + kind: Literal[SnakeKind.COBRA] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """discriminator property. Required. Species cobra""" @overload @@ -97,9 +97,9 @@ class Dog(_model_base.Model): """ __mapping__: Dict[str, _model_base.Model] = {} - kind: str = rest_discriminator(name="kind") + kind: str = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) """discriminator property. Required. \"golden\"""" - weight: int = rest_field() + weight: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Weight of the dog. Required.""" @overload @@ -131,7 +131,7 @@ class Golden(Dog, discriminator="golden"): :vartype kind: str or ~typetest.model.enumdiscriminator.models.GOLDEN """ - kind: Literal[DogKind.GOLDEN] = rest_discriminator(name="kind") # type: ignore + kind: Literal[DogKind.GOLDEN] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """discriminator property. Required. Species golden""" @overload diff --git a/packages/typespec-python/test/azure/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/models/_models.py index b21661b78f5..2dbdcf1abfb 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/models/_models.py @@ -32,7 +32,7 @@ class Fish(_model_base.Model): __mapping__: Dict[str, _model_base.Model] = {} kind: str = rest_discriminator(name="kind") """Discriminator property for Fish. Required. Default value is None.""" - age: int = rest_field() + age: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -71,9 +71,9 @@ class Shark(Fish, discriminator="shark"): """ __mapping__: Dict[str, _model_base.Model] = {} - kind: Literal["shark"] = rest_discriminator(name="kind") # type: ignore + kind: Literal["shark"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long """Required. Default value is \"shark\".""" - sharktype: str = rest_discriminator(name="sharktype") + sharktype: str = rest_discriminator(name="sharktype", visibility=["read", "create", "update", "delete", "query"]) """Required. Default value is None.""" @overload @@ -108,7 +108,7 @@ class GoblinShark(Shark, discriminator="goblin"): """ __mapping__: Dict[str, _model_base.Model] = {} - sharktype: Literal["goblin"] = rest_discriminator(name="sharktype") # type: ignore + sharktype: Literal["goblin"] = rest_discriminator(name="sharktype", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"goblin\".""" @overload @@ -146,11 +146,11 @@ class Salmon(Fish, discriminator="salmon"): :vartype partner: ~typetest.model.nesteddiscriminator.models.Fish """ - kind: Literal["salmon"] = rest_discriminator(name="kind") # type: ignore + kind: Literal["salmon"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"salmon\".""" - friends: Optional[List["_models.Fish"]] = rest_field() - hate: Optional[Dict[str, "_models.Fish"]] = rest_field() - partner: Optional["_models.Fish"] = rest_field() + friends: Optional[List["_models.Fish"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + hate: Optional[Dict[str, "_models.Fish"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + partner: Optional["_models.Fish"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @overload def __init__( @@ -186,7 +186,7 @@ class SawShark(Shark, discriminator="saw"): """ __mapping__: Dict[str, _model_base.Model] = {} - sharktype: Literal["saw"] = rest_discriminator(name="sharktype") # type: ignore + sharktype: Literal["saw"] = rest_discriminator(name="sharktype", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"saw\".""" @overload diff --git a/packages/typespec-python/test/azure/generated/typetest-model-notdiscriminated/typetest/model/notdiscriminated/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-model-notdiscriminated/typetest/model/notdiscriminated/models/_models.py index df5f86e9aec..18164a50480 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-notdiscriminated/typetest/model/notdiscriminated/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-notdiscriminated/typetest/model/notdiscriminated/models/_models.py @@ -21,7 +21,7 @@ class Pet(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -52,7 +52,7 @@ class Cat(Pet): :vartype age: int """ - age: int = rest_field() + age: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -86,7 +86,7 @@ class Siamese(Cat): :vartype smart: bool """ - smart: bool = rest_field() + smart: bool = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/typetest-model-recursive/typetest/model/recursive/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-model-recursive/typetest/model/recursive/models/_models.py index 92ebe5cf2be..0910dc67bd5 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-recursive/typetest/model/recursive/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-recursive/typetest/model/recursive/models/_models.py @@ -23,7 +23,9 @@ class Element(_model_base.Model): :vartype extension: list[~typetest.model.recursive.models.Extension] """ - extension: Optional[List["_models.Extension"]] = rest_field() + extension: Optional[List["_models.Extension"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) @overload def __init__( @@ -53,7 +55,7 @@ class Extension(Element): :vartype level: int """ - level: int = rest_field() + level: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/models/_models.py index cedb85cb279..9f9e9a9a572 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/models/_models.py @@ -30,9 +30,9 @@ class Bird(_model_base.Model): """ __mapping__: Dict[str, _model_base.Model] = {} - kind: str = rest_discriminator(name="kind") + kind: str = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) """Required. Default value is None.""" - wingspan: int = rest_field() + wingspan: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -71,7 +71,7 @@ class Dinosaur(_model_base.Model): __mapping__: Dict[str, _model_base.Model] = {} kind: str = rest_discriminator(name="kind") """Discriminator property for Dinosaur. Required. Default value is None.""" - size: int = rest_field() + size: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -110,11 +110,11 @@ class Eagle(Bird, discriminator="eagle"): :vartype partner: ~typetest.model.singlediscriminator.models.Bird """ - kind: Literal["eagle"] = rest_discriminator(name="kind") # type: ignore + kind: Literal["eagle"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long """Required. Default value is \"eagle\".""" - friends: Optional[List["_models.Bird"]] = rest_field() - hate: Optional[Dict[str, "_models.Bird"]] = rest_field() - partner: Optional["_models.Bird"] = rest_field() + friends: Optional[List["_models.Bird"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + hate: Optional[Dict[str, "_models.Bird"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + partner: Optional["_models.Bird"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @overload def __init__( @@ -147,7 +147,7 @@ class Goose(Bird, discriminator="goose"): :vartype kind: str """ - kind: Literal["goose"] = rest_discriminator(name="kind") # type: ignore + kind: Literal["goose"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long """Required. Default value is \"goose\".""" @overload @@ -178,7 +178,7 @@ class SeaGull(Bird, discriminator="seagull"): :vartype kind: str """ - kind: Literal["seagull"] = rest_discriminator(name="kind") # type: ignore + kind: Literal["seagull"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"seagull\".""" @overload @@ -209,7 +209,7 @@ class Sparrow(Bird, discriminator="sparrow"): :vartype kind: str """ - kind: Literal["sparrow"] = rest_discriminator(name="kind") # type: ignore + kind: Literal["sparrow"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"sparrow\".""" @overload @@ -240,7 +240,7 @@ class TRex(Dinosaur, discriminator="t-rex"): :vartype kind: str """ - kind: Literal["t-rex"] = rest_discriminator(name="kind") # type: ignore + kind: Literal["t-rex"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long """Required. Default value is \"t-rex\".""" @overload diff --git a/packages/typespec-python/test/azure/generated/typetest-model-usage/typetest/model/usage/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-model-usage/typetest/model/usage/models/_models.py index 68b3926731a..f8134e8b9be 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-usage/typetest/model/usage/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-usage/typetest/model/usage/models/_models.py @@ -21,7 +21,7 @@ class InputOutputRecord(_model_base.Model): :vartype required_prop: str """ - required_prop: str = rest_field(name="requiredProp") + required_prop: str = rest_field(name="requiredProp", visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -51,7 +51,7 @@ class InputRecord(_model_base.Model): :vartype required_prop: str """ - required_prop: str = rest_field(name="requiredProp") + required_prop: str = rest_field(name="requiredProp", visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -80,7 +80,7 @@ class OutputRecord(_model_base.Model): :vartype required_prop: str """ - required_prop: str = rest_field(name="requiredProp") + required_prop: str = rest_field(name="requiredProp", visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py index 656ca40d421..68682ec7936 100644 --- a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py @@ -26,7 +26,7 @@ class DifferentSpreadFloatRecord(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The id property. Required.""" @overload @@ -58,7 +58,7 @@ class DifferentSpreadFloatDerived(DifferentSpreadFloatRecord): :vartype derived_prop: float """ - derived_prop: float = rest_field(name="derivedProp") + derived_prop: float = rest_field(name="derivedProp", visibility=["read", "create", "update", "delete", "query"]) """The index property. Required.""" @overload @@ -88,7 +88,7 @@ class DifferentSpreadModelArrayRecord(_model_base.Model): :vartype known_prop: str """ - known_prop: str = rest_field(name="knownProp") + known_prop: str = rest_field(name="knownProp", visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -120,7 +120,9 @@ class DifferentSpreadModelArrayDerived(DifferentSpreadModelArrayRecord): :vartype derived_prop: list[~typetest.property.additionalproperties.models.ModelForRecord] """ - derived_prop: List["_models.ModelForRecord"] = rest_field(name="derivedProp") + derived_prop: List["_models.ModelForRecord"] = rest_field( + name="derivedProp", visibility=["read", "create", "update", "delete", "query"] + ) """The index property. Required.""" @overload @@ -150,7 +152,7 @@ class DifferentSpreadModelRecord(_model_base.Model): :vartype known_prop: str """ - known_prop: str = rest_field(name="knownProp") + known_prop: str = rest_field(name="knownProp", visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -182,7 +184,9 @@ class DifferentSpreadModelDerived(DifferentSpreadModelRecord): :vartype derived_prop: ~typetest.property.additionalproperties.models.ModelForRecord """ - derived_prop: "_models.ModelForRecord" = rest_field(name="derivedProp") + derived_prop: "_models.ModelForRecord" = rest_field( + name="derivedProp", visibility=["read", "create", "update", "delete", "query"] + ) """The index property. Required.""" @overload @@ -212,7 +216,7 @@ class DifferentSpreadStringRecord(_model_base.Model): :vartype id: float """ - id: float = rest_field() + id: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name property. Required.""" @overload @@ -244,7 +248,7 @@ class DifferentSpreadStringDerived(DifferentSpreadStringRecord): :vartype derived_prop: str """ - derived_prop: str = rest_field(name="derivedProp") + derived_prop: str = rest_field(name="derivedProp", visibility=["read", "create", "update", "delete", "query"]) """The index property. Required.""" @overload @@ -274,7 +278,7 @@ class ExtendsFloatAdditionalProperties(_model_base.Model): :vartype id: float """ - id: float = rest_field() + id: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The id property. Required.""" @overload @@ -303,7 +307,9 @@ class ExtendsModelAdditionalProperties(_model_base.Model): :vartype known_prop: ~typetest.property.additionalproperties.models.ModelForRecord """ - known_prop: "_models.ModelForRecord" = rest_field(name="knownProp") + known_prop: "_models.ModelForRecord" = rest_field( + name="knownProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required.""" @overload @@ -332,7 +338,9 @@ class ExtendsModelArrayAdditionalProperties(_model_base.Model): :vartype known_prop: list[~typetest.property.additionalproperties.models.ModelForRecord] """ - known_prop: List["_models.ModelForRecord"] = rest_field(name="knownProp") + known_prop: List["_models.ModelForRecord"] = rest_field( + name="knownProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required.""" @overload @@ -361,7 +369,7 @@ class ExtendsStringAdditionalProperties(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name property. Required.""" @overload @@ -390,7 +398,7 @@ class ExtendsUnknownAdditionalProperties(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name property. Required.""" @overload @@ -423,9 +431,9 @@ class ExtendsUnknownAdditionalPropertiesDerived(ExtendsUnknownAdditionalProperti :vartype age: float """ - index: int = rest_field() + index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The index property. Required.""" - age: Optional[float] = rest_field() + age: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The age property.""" @overload @@ -462,9 +470,9 @@ class ExtendsUnknownAdditionalPropertiesDiscriminated(_model_base.Model): # pyl """ __mapping__: Dict[str, _model_base.Model] = {} - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name property. Required.""" - kind: str = rest_discriminator(name="kind") + kind: str = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) """The discriminator. Required. Default value is None.""" @overload @@ -502,11 +510,11 @@ class ExtendsUnknownAdditionalPropertiesDiscriminatedDerived( :vartype age: float """ - kind: Literal["derived"] = rest_discriminator(name="kind") # type: ignore + kind: Literal["derived"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"derived\".""" - index: int = rest_field() + index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The index property. Required.""" - age: Optional[float] = rest_field() + age: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The age property.""" @overload @@ -537,7 +545,7 @@ class IsFloatAdditionalProperties(_model_base.Model): :vartype id: float """ - id: float = rest_field() + id: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The id property. Required.""" @overload @@ -566,7 +574,9 @@ class IsModelAdditionalProperties(_model_base.Model): :vartype known_prop: ~typetest.property.additionalproperties.models.ModelForRecord """ - known_prop: "_models.ModelForRecord" = rest_field(name="knownProp") + known_prop: "_models.ModelForRecord" = rest_field( + name="knownProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required.""" @overload @@ -595,7 +605,9 @@ class IsModelArrayAdditionalProperties(_model_base.Model): :vartype known_prop: list[~typetest.property.additionalproperties.models.ModelForRecord] """ - known_prop: List["_models.ModelForRecord"] = rest_field(name="knownProp") + known_prop: List["_models.ModelForRecord"] = rest_field( + name="knownProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required.""" @overload @@ -624,7 +636,7 @@ class IsStringAdditionalProperties(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name property. Required.""" @overload @@ -653,7 +665,7 @@ class IsUnknownAdditionalProperties(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name property. Required.""" @overload @@ -686,9 +698,9 @@ class IsUnknownAdditionalPropertiesDerived(IsUnknownAdditionalProperties): :vartype age: float """ - index: int = rest_field() + index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The index property. Required.""" - age: Optional[float] = rest_field() + age: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The age property.""" @overload @@ -725,9 +737,9 @@ class IsUnknownAdditionalPropertiesDiscriminated(_model_base.Model): # pylint: """ __mapping__: Dict[str, _model_base.Model] = {} - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name property. Required.""" - kind: str = rest_discriminator(name="kind") + kind: str = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) """The discriminator. Required. Default value is None.""" @overload @@ -765,11 +777,11 @@ class IsUnknownAdditionalPropertiesDiscriminatedDerived( :vartype age: float """ - kind: Literal["derived"] = rest_discriminator(name="kind") # type: ignore + kind: Literal["derived"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"derived\".""" - index: int = rest_field() + index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The index property. Required.""" - age: Optional[float] = rest_field() + age: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The age property.""" @overload @@ -800,7 +812,7 @@ class ModelForRecord(_model_base.Model): :vartype state: str """ - state: str = rest_field() + state: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The state property. Required.""" @overload @@ -829,7 +841,7 @@ class MultipleSpreadRecord(_model_base.Model): :vartype flag: bool """ - flag: bool = rest_field() + flag: bool = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name property. Required.""" @overload @@ -858,7 +870,7 @@ class SpreadFloatRecord(_model_base.Model): :vartype id: float """ - id: float = rest_field() + id: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The id property. Required.""" @overload @@ -887,7 +899,9 @@ class SpreadModelArrayRecord(_model_base.Model): :vartype known_prop: list[~typetest.property.additionalproperties.models.ModelForRecord] """ - known_prop: List["_models.ModelForRecord"] = rest_field(name="knownProp") + known_prop: List["_models.ModelForRecord"] = rest_field( + name="knownProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required.""" @overload @@ -916,7 +930,9 @@ class SpreadModelRecord(_model_base.Model): :vartype known_prop: ~typetest.property.additionalproperties.models.ModelForRecord """ - known_prop: "_models.ModelForRecord" = rest_field(name="knownProp") + known_prop: "_models.ModelForRecord" = rest_field( + name="knownProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required.""" @overload @@ -945,7 +961,7 @@ class SpreadRecordForDiscriminatedUnion(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name property. Required.""" @overload @@ -974,7 +990,7 @@ class SpreadRecordForNonDiscriminatedUnion(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name property. Required.""" @overload @@ -1003,7 +1019,7 @@ class SpreadRecordForNonDiscriminatedUnion2(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name property. Required.""" @overload @@ -1032,7 +1048,7 @@ class SpreadRecordForNonDiscriminatedUnion3(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name property. Required.""" @overload @@ -1061,7 +1077,7 @@ class SpreadRecordForUnion(_model_base.Model): :vartype flag: bool """ - flag: bool = rest_field() + flag: bool = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name property. Required.""" @overload @@ -1090,7 +1106,7 @@ class SpreadStringRecord(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name property. Required.""" @overload @@ -1123,9 +1139,9 @@ class WidgetData0(_model_base.Model): :vartype foo_prop: str """ - kind: Literal["kind0"] = rest_field() + kind: Literal["kind0"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required. Default value is \"kind0\".""" - foo_prop: str = rest_field(name="fooProp") + foo_prop: str = rest_field(name="fooProp", visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -1161,11 +1177,13 @@ class WidgetData1(_model_base.Model): :vartype end: ~datetime.datetime """ - kind: Literal["kind1"] = rest_field() + kind: Literal["kind1"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required. Default value is \"kind1\".""" - start: datetime.datetime = rest_field(format="rfc3339") + start: datetime.datetime = rest_field(visibility=["read", "create", "update", "delete", "query"], format="rfc3339") """Required.""" - end: Optional[datetime.datetime] = rest_field(format="rfc3339") + end: Optional[datetime.datetime] = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) @overload def __init__( @@ -1199,9 +1217,9 @@ class WidgetData2(_model_base.Model): :vartype start: str """ - kind: Literal["kind1"] = rest_field() + kind: Literal["kind1"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required. Default value is \"kind1\".""" - start: str = rest_field() + start: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/typetest-property-nullable/typetest/property/nullable/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-property-nullable/typetest/property/nullable/models/_models.py index db03201b6d9..75617a41bac 100644 --- a/packages/typespec-python/test/azure/generated/typetest-property-nullable/typetest/property/nullable/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-property-nullable/typetest/property/nullable/models/_models.py @@ -28,9 +28,13 @@ class BytesProperty(_model_base.Model): :vartype nullable_property: bytes """ - required_property: str = rest_field(name="requiredProperty") + required_property: str = rest_field( + name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] + ) """Required property. Required.""" - nullable_property: bytes = rest_field(name="nullableProperty", format="base64") + nullable_property: bytes = rest_field( + name="nullableProperty", visibility=["read", "create", "update", "delete", "query"], format="base64" + ) """Property. Required.""" @overload @@ -62,9 +66,13 @@ class CollectionsByteProperty(_model_base.Model): :vartype nullable_property: list[bytes] """ - required_property: str = rest_field(name="requiredProperty") + required_property: str = rest_field( + name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] + ) """Required property. Required.""" - nullable_property: List[bytes] = rest_field(name="nullableProperty", format="base64") + nullable_property: List[bytes] = rest_field( + name="nullableProperty", visibility=["read", "create", "update", "delete", "query"], format="base64" + ) """Property. Required.""" @overload @@ -96,9 +104,13 @@ class CollectionsModelProperty(_model_base.Model): :vartype nullable_property: list[~typetest.property.nullable.models.InnerModel] """ - required_property: str = rest_field(name="requiredProperty") + required_property: str = rest_field( + name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] + ) """Required property. Required.""" - nullable_property: List["_models.InnerModel"] = rest_field(name="nullableProperty") + nullable_property: List["_models.InnerModel"] = rest_field( + name="nullableProperty", visibility=["read", "create", "update", "delete", "query"] + ) """Property. Required.""" @overload @@ -130,9 +142,13 @@ class CollectionsStringProperty(_model_base.Model): :vartype nullable_property: list[str] """ - required_property: str = rest_field(name="requiredProperty") + required_property: str = rest_field( + name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] + ) """Required property. Required.""" - nullable_property: List[str] = rest_field(name="nullableProperty") + nullable_property: List[str] = rest_field( + name="nullableProperty", visibility=["read", "create", "update", "delete", "query"] + ) """Property. Required.""" @overload @@ -164,9 +180,13 @@ class DatetimeProperty(_model_base.Model): :vartype nullable_property: ~datetime.datetime """ - required_property: str = rest_field(name="requiredProperty") + required_property: str = rest_field( + name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] + ) """Required property. Required.""" - nullable_property: datetime.datetime = rest_field(name="nullableProperty", format="rfc3339") + nullable_property: datetime.datetime = rest_field( + name="nullableProperty", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) """Property. Required.""" @overload @@ -198,9 +218,13 @@ class DurationProperty(_model_base.Model): :vartype nullable_property: ~datetime.timedelta """ - required_property: str = rest_field(name="requiredProperty") + required_property: str = rest_field( + name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] + ) """Required property. Required.""" - nullable_property: datetime.timedelta = rest_field(name="nullableProperty") + nullable_property: datetime.timedelta = rest_field( + name="nullableProperty", visibility=["read", "create", "update", "delete", "query"] + ) """Property. Required.""" @overload @@ -230,7 +254,7 @@ class InnerModel(_model_base.Model): :vartype property: str """ - property: str = rest_field() + property: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Inner model property. Required.""" @overload @@ -262,9 +286,13 @@ class StringProperty(_model_base.Model): :vartype nullable_property: str """ - required_property: str = rest_field(name="requiredProperty") + required_property: str = rest_field( + name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] + ) """Required property. Required.""" - nullable_property: str = rest_field(name="nullableProperty") + nullable_property: str = rest_field( + name="nullableProperty", visibility=["read", "create", "update", "delete", "query"] + ) """Property. Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/typetest-property-optional/typetest/property/optional/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-property-optional/typetest/property/optional/models/_models.py index b859e21ccb5..5e8dbdad678 100644 --- a/packages/typespec-python/test/azure/generated/typetest-property-optional/typetest/property/optional/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-property-optional/typetest/property/optional/models/_models.py @@ -24,7 +24,7 @@ class BooleanLiteralProperty(_model_base.Model): :vartype property: bool """ - property: Optional[Literal[True]] = rest_field() + property: Optional[Literal[True]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Default value is True.""" @overload @@ -53,7 +53,7 @@ class BytesProperty(_model_base.Model): :vartype property: bytes """ - property: Optional[bytes] = rest_field(format="base64") + property: Optional[bytes] = rest_field(visibility=["read", "create", "update", "delete", "query"], format="base64") """Property.""" @overload @@ -81,7 +81,9 @@ class CollectionsByteProperty(_model_base.Model): :vartype property: list[bytes] """ - property: Optional[List[bytes]] = rest_field(format="base64") + property: Optional[List[bytes]] = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="base64" + ) """Property.""" @overload @@ -109,7 +111,9 @@ class CollectionsModelProperty(_model_base.Model): :vartype property: list[~typetest.property.optional.models.StringProperty] """ - property: Optional[List["_models.StringProperty"]] = rest_field() + property: Optional[List["_models.StringProperty"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """Property.""" @overload @@ -137,7 +141,9 @@ class DatetimeProperty(_model_base.Model): :vartype property: ~datetime.datetime """ - property: Optional[datetime.datetime] = rest_field(format="rfc3339") + property: Optional[datetime.datetime] = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) """Property.""" @overload @@ -165,7 +171,7 @@ class DurationProperty(_model_base.Model): :vartype property: ~datetime.timedelta """ - property: Optional[datetime.timedelta] = rest_field() + property: Optional[datetime.timedelta] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property.""" @overload @@ -193,7 +199,7 @@ class FloatLiteralProperty(_model_base.Model): :vartype property: float """ - property: Optional[float] = rest_field() + property: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Default value is 1.25.""" @overload @@ -221,7 +227,7 @@ class IntLiteralProperty(_model_base.Model): :vartype property: int """ - property: Optional[Literal[1]] = rest_field() + property: Optional[Literal[1]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Default value is 1.""" @overload @@ -249,7 +255,7 @@ class PlainDateProperty(_model_base.Model): :vartype property: ~datetime.date """ - property: Optional[datetime.date] = rest_field() + property: Optional[datetime.date] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property.""" @overload @@ -277,7 +283,7 @@ class PlainTimeProperty(_model_base.Model): :vartype property: ~datetime.time """ - property: Optional[datetime.time] = rest_field() + property: Optional[datetime.time] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property.""" @overload @@ -308,9 +314,13 @@ class RequiredAndOptionalProperty(_model_base.Model): :vartype required_property: int """ - optional_property: Optional[str] = rest_field(name="optionalProperty") + optional_property: Optional[str] = rest_field( + name="optionalProperty", visibility=["read", "create", "update", "delete", "query"] + ) """optional string property.""" - required_property: int = rest_field(name="requiredProperty") + required_property: int = rest_field( + name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] + ) """required int property. Required.""" @overload @@ -339,7 +349,7 @@ class StringLiteralProperty(_model_base.Model): :vartype property: str """ - property: Optional[Literal["hello"]] = rest_field() + property: Optional[Literal["hello"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Default value is \"hello\".""" @overload @@ -368,7 +378,7 @@ class StringProperty(_model_base.Model): :vartype property: str """ - property: Optional[str] = rest_field() + property: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property.""" @overload @@ -396,7 +406,7 @@ class UnionFloatLiteralProperty(_model_base.Model): :vartype property: float or float """ - property: Optional[float] = rest_field() + property: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Is one of the following types: float""" @overload @@ -424,7 +434,7 @@ class UnionIntLiteralProperty(_model_base.Model): :vartype property: int or int """ - property: Optional[Literal[1, 2]] = rest_field() + property: Optional[Literal[1, 2]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Is either a Literal[1] type or a Literal[2] type.""" @overload @@ -452,7 +462,9 @@ class UnionStringLiteralProperty(_model_base.Model): :vartype property: str or str """ - property: Optional[Literal["hello", "world"]] = rest_field() + property: Optional[Literal["hello", "world"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """Property. Is either a Literal[\"hello\"] type or a Literal[\"world\"] type.""" @overload diff --git a/packages/typespec-python/test/azure/generated/typetest-property-valuetypes/typetest/property/valuetypes/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-property-valuetypes/typetest/property/valuetypes/models/_models.py index d312cb68842..e436012c81d 100644 --- a/packages/typespec-python/test/azure/generated/typetest-property-valuetypes/typetest/property/valuetypes/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-property-valuetypes/typetest/property/valuetypes/models/_models.py @@ -29,7 +29,7 @@ class BooleanLiteralProperty(_model_base.Model): :vartype property: bool """ - property: Literal[True] = rest_field() + property: Literal[True] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required. Default value is True.""" def __init__(self, *args: Any, **kwargs: Any) -> None: @@ -45,7 +45,7 @@ class BooleanProperty(_model_base.Model): :vartype property: bool """ - property: bool = rest_field() + property: bool = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -74,7 +74,7 @@ class BytesProperty(_model_base.Model): :vartype property: bytes """ - property: bytes = rest_field(format="base64") + property: bytes = rest_field(visibility=["read", "create", "update", "delete", "query"], format="base64") """Property. Required.""" @overload @@ -103,7 +103,7 @@ class CollectionsIntProperty(_model_base.Model): :vartype property: list[int] """ - property: List[int] = rest_field() + property: List[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -132,7 +132,7 @@ class CollectionsModelProperty(_model_base.Model): :vartype property: list[~typetest.property.valuetypes.models.InnerModel] """ - property: List["_models.InnerModel"] = rest_field() + property: List["_models.InnerModel"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -161,7 +161,7 @@ class CollectionsStringProperty(_model_base.Model): :vartype property: list[str] """ - property: List[str] = rest_field() + property: List[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -190,7 +190,9 @@ class DatetimeProperty(_model_base.Model): :vartype property: ~datetime.datetime """ - property: datetime.datetime = rest_field(format="rfc3339") + property: datetime.datetime = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) """Property. Required.""" @overload @@ -219,7 +221,7 @@ class Decimal128Property(_model_base.Model): :vartype property: ~decimal.Decimal """ - property: decimal.Decimal = rest_field() + property: decimal.Decimal = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -248,7 +250,7 @@ class DecimalProperty(_model_base.Model): :vartype property: ~decimal.Decimal """ - property: decimal.Decimal = rest_field() + property: decimal.Decimal = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -277,7 +279,7 @@ class DictionaryStringProperty(_model_base.Model): :vartype property: dict[str, str] """ - property: Dict[str, str] = rest_field() + property: Dict[str, str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -306,7 +308,7 @@ class DurationProperty(_model_base.Model): :vartype property: ~datetime.timedelta """ - property: datetime.timedelta = rest_field() + property: datetime.timedelta = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -335,7 +337,9 @@ class EnumProperty(_model_base.Model): :vartype property: str or ~typetest.property.valuetypes.models.FixedInnerEnum """ - property: Union[str, "_models.FixedInnerEnum"] = rest_field() + property: Union[str, "_models.FixedInnerEnum"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """Property. Required. Known values are: \"ValueOne\" and \"ValueTwo\".""" @overload @@ -364,7 +368,7 @@ class ExtensibleEnumProperty(_model_base.Model): :vartype property: str or ~typetest.property.valuetypes.models.InnerEnum """ - property: Union[str, "_models.InnerEnum"] = rest_field() + property: Union[str, "_models.InnerEnum"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required. Known values are: \"ValueOne\" and \"ValueTwo\".""" @overload @@ -395,7 +399,7 @@ class FloatLiteralProperty(_model_base.Model): :vartype property: float """ - property: float = rest_field() + property: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required. Default value is 43.125.""" def __init__(self, *args: Any, **kwargs: Any) -> None: @@ -411,7 +415,7 @@ class FloatProperty(_model_base.Model): :vartype property: float """ - property: float = rest_field() + property: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -440,7 +444,7 @@ class InnerModel(_model_base.Model): :vartype property: str """ - property: str = rest_field() + property: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required string property. Required.""" @overload @@ -471,7 +475,7 @@ class IntLiteralProperty(_model_base.Model): :vartype property: int """ - property: Literal[42] = rest_field() + property: Literal[42] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required. Default value is 42.""" def __init__(self, *args: Any, **kwargs: Any) -> None: @@ -487,7 +491,7 @@ class IntProperty(_model_base.Model): :vartype property: int """ - property: int = rest_field() + property: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -516,7 +520,7 @@ class ModelProperty(_model_base.Model): :vartype property: ~typetest.property.valuetypes.models.InnerModel """ - property: "_models.InnerModel" = rest_field() + property: "_models.InnerModel" = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -551,7 +555,7 @@ class StringLiteralProperty(_model_base.Model): :vartype property: str """ - property: Literal["hello"] = rest_field() + property: Literal["hello"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required. Default value is \"hello\".""" def __init__(self, *args: Any, **kwargs: Any) -> None: @@ -567,7 +571,7 @@ class StringProperty(_model_base.Model): :vartype property: str """ - property: str = rest_field() + property: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -597,7 +601,7 @@ class UnionEnumValueProperty(_model_base.Model): :vartype property: str or ~typetest.property.valuetypes.models.ENUM_VALUE2 """ - property: Literal[ExtendedEnum.ENUM_VALUE2] = rest_field() + property: Literal[ExtendedEnum.ENUM_VALUE2] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -626,7 +630,7 @@ class UnionFloatLiteralProperty(_model_base.Model): :vartype property: float or float """ - property: float = rest_field() + property: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required. Is one of the following types: float""" @overload @@ -655,7 +659,7 @@ class UnionIntLiteralProperty(_model_base.Model): :vartype property: int or int """ - property: Literal[42, 43] = rest_field() + property: Literal[42, 43] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required. Is either a Literal[42] type or a Literal[43] type.""" @overload @@ -685,7 +689,7 @@ class UnionStringLiteralProperty(_model_base.Model): :vartype property: str or str """ - property: Literal["hello", "world"] = rest_field() + property: Literal["hello", "world"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required. Is either a Literal[\"hello\"] type or a Literal[\"world\"] type.""" @overload @@ -714,7 +718,7 @@ class UnknownArrayProperty(_model_base.Model): :vartype property: any """ - property: Any = rest_field() + property: Any = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -743,7 +747,7 @@ class UnknownDictProperty(_model_base.Model): :vartype property: any """ - property: Any = rest_field() + property: Any = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -772,7 +776,7 @@ class UnknownIntProperty(_model_base.Model): :vartype property: any """ - property: Any = rest_field() + property: Any = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -801,7 +805,7 @@ class UnknownStringProperty(_model_base.Model): :vartype property: any """ - property: Any = rest_field() + property: Any = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/typetest-union/typetest/union/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-union/typetest/union/models/_models.py index 6b4a00e3274..82507a82c34 100644 --- a/packages/typespec-python/test/azure/generated/typetest-union/typetest/union/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-union/typetest/union/models/_models.py @@ -24,7 +24,7 @@ class Cat(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -53,7 +53,7 @@ class Dog(_model_base.Model): :vartype bark: str """ - bark: str = rest_field() + bark: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -86,10 +86,10 @@ class EnumsOnlyCases(_model_base.Model): :vartype ud: str or str """ - lr: Literal["left", "right", "up", "down"] = rest_field() + lr: Literal["left", "right", "up", "down"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """This should be receive/send the left variant. Required. Is one of the following types: Literal[\"left\"], Literal[\"right\"], Literal[\"up\"], Literal[\"down\"]""" - ud: Literal["up", "down"] = rest_field() + ud: Literal["up", "down"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """This should be receive/send the up variant. Required. Is either a Literal[\"up\"] type or a Literal[\"down\"] type.""" @@ -120,7 +120,7 @@ class GetResponse(_model_base.Model): :vartype prop: ~typetest.union.models.MixedTypesCases """ - prop: "_models.MixedTypesCases" = rest_field() + prop: "_models.MixedTypesCases" = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -149,7 +149,7 @@ class GetResponse1(_model_base.Model): :vartype prop: ~typetest.union.models.MixedLiteralsCases """ - prop: "_models.MixedLiteralsCases" = rest_field() + prop: "_models.MixedLiteralsCases" = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -178,7 +178,7 @@ class GetResponse2(_model_base.Model): :vartype prop: ~typetest.union.models.StringAndArrayCases """ - prop: "_models.StringAndArrayCases" = rest_field() + prop: "_models.StringAndArrayCases" = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -207,7 +207,7 @@ class GetResponse3(_model_base.Model): :vartype prop: ~typetest.union.models.EnumsOnlyCases """ - prop: "_models.EnumsOnlyCases" = rest_field() + prop: "_models.EnumsOnlyCases" = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -236,7 +236,7 @@ class GetResponse4(_model_base.Model): :vartype prop: ~typetest.union.models.Cat or ~typetest.union.models.Dog """ - prop: Union["_models.Cat", "_models.Dog"] = rest_field() + prop: Union["_models.Cat", "_models.Dog"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required. Is either a Cat type or a Dog type.""" @overload @@ -265,7 +265,7 @@ class GetResponse5(_model_base.Model): :vartype prop: float or float or float """ - prop: float = rest_field() + prop: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required. Is one of the following types: float""" @overload @@ -294,7 +294,7 @@ class GetResponse6(_model_base.Model): :vartype prop: int or int or int """ - prop: Literal[1, 2, 3] = rest_field() + prop: Literal[1, 2, 3] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required. Is one of the following types: Literal[1], Literal[2], Literal[3]""" @overload @@ -323,7 +323,9 @@ class GetResponse7(_model_base.Model): :vartype prop: str or ~typetest.union.models.StringExtensibleNamedUnion """ - prop: Union[str, "_models.StringExtensibleNamedUnion"] = rest_field() + prop: Union[str, "_models.StringExtensibleNamedUnion"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """Required. Known values are: \"b\" and \"c\".""" @overload @@ -352,7 +354,9 @@ class GetResponse8(_model_base.Model): :vartype prop: str or str or str """ - prop: Union[Literal["b"], Literal["c"], str] = rest_field() + prop: Union[Literal["b"], Literal["c"], str] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """Required. Is one of the following types: Literal[\"b\"], Literal[\"c\"], str""" @overload @@ -381,7 +385,7 @@ class GetResponse9(_model_base.Model): :vartype prop: str or str or str """ - prop: Literal["a", "b", "c"] = rest_field() + prop: Literal["a", "b", "c"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required. Is one of the following types: Literal[\"a\"], Literal[\"b\"], Literal[\"c\"]""" @overload @@ -420,16 +424,24 @@ class MixedLiteralsCases(_model_base.Model): :vartype boolean_literal: str or int or float or bool """ - string_literal: Literal["a", 2, True] = rest_field(name="stringLiteral") + string_literal: Literal["a", 2, True] = rest_field( + name="stringLiteral", visibility=["read", "create", "update", "delete", "query"] + ) """This should be receive/send the \"a\" variant. Required. Is one of the following types: Literal[\"a\"], Literal[2], float, Literal[True]""" - int_literal: Literal["a", 2, True] = rest_field(name="intLiteral") + int_literal: Literal["a", 2, True] = rest_field( + name="intLiteral", visibility=["read", "create", "update", "delete", "query"] + ) """This should be receive/send the 2 variant. Required. Is one of the following types: Literal[\"a\"], Literal[2], float, Literal[True]""" - float_literal: Literal["a", 2, True] = rest_field(name="floatLiteral") + float_literal: Literal["a", 2, True] = rest_field( + name="floatLiteral", visibility=["read", "create", "update", "delete", "query"] + ) """This should be receive/send the 3.3 variant. Required. Is one of the following types: Literal[\"a\"], Literal[2], float, Literal[True]""" - boolean_literal: Literal["a", 2, True] = rest_field(name="booleanLiteral") + boolean_literal: Literal["a", 2, True] = rest_field( + name="booleanLiteral", visibility=["read", "create", "update", "delete", "query"] + ) """This should be receive/send the true variant. Required. Is one of the following types: Literal[\"a\"], Literal[2], float, Literal[True]""" @@ -474,19 +486,29 @@ class MixedTypesCases(_model_base.Model): :vartype array: list[~typetest.union.models.Cat or str or int or bool] """ - model: Union["_models.Cat", Literal["a"], int, bool] = rest_field() + model: Union["_models.Cat", Literal["a"], int, bool] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """This should be receive/send the Cat variant. Required. Is one of the following types: Cat, Literal[\"a\"], int, bool""" - literal: Union["_models.Cat", Literal["a"], int, bool] = rest_field() + literal: Union["_models.Cat", Literal["a"], int, bool] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """This should be receive/send the \"a\" variant. Required. Is one of the following types: Cat, Literal[\"a\"], int, bool""" - int_property: Union["_models.Cat", Literal["a"], int, bool] = rest_field(name="int") + int_property: Union["_models.Cat", Literal["a"], int, bool] = rest_field( + name="int", visibility=["read", "create", "update", "delete", "query"] + ) """This should be receive/send the int variant. Required. Is one of the following types: Cat, Literal[\"a\"], int, bool""" - boolean: Union["_models.Cat", Literal["a"], int, bool] = rest_field() + boolean: Union["_models.Cat", Literal["a"], int, bool] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """This should be receive/send the boolean variant. Required. Is one of the following types: Cat, Literal[\"a\"], int, bool""" - array: List[Union["_models.Cat", Literal["a"], int, bool]] = rest_field() + array: List[Union["_models.Cat", Literal["a"], int, bool]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """This should be receive/send 4 element with Cat, \"a\", int, and boolean. Required.""" @overload @@ -523,9 +545,9 @@ class StringAndArrayCases(_model_base.Model): :vartype array: str or list[str] """ - string: Union[str, List[str]] = rest_field() + string: Union[str, List[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """This should be receive/send the string variant. Required. Is either a str type or a [str] type.""" - array: Union[str, List[str]] = rest_field() + array: Union[str, List[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """This should be receive/send the array variant. Required. Is either a str type or a [str] type.""" @overload diff --git a/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/models/_models.py b/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/models/_models.py index 33b151e4615..4723f9db5b8 100644 --- a/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/models/_models.py +++ b/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/models/_models.py @@ -28,11 +28,15 @@ class ModelV1(_model_base.Model): :vartype union_prop: str or int """ - prop: str = rest_field() + prop: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - enum_prop: Union[str, "_models.EnumV1"] = rest_field(name="enumProp") + enum_prop: Union[str, "_models.EnumV1"] = rest_field( + name="enumProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required. Known values are: \"enumMemberV1\" and \"enumMemberV2\".""" - union_prop: "_types.UnionV1" = rest_field(name="unionProp") + union_prop: "_types.UnionV1" = rest_field( + name="unionProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required. Is either a str type or a int type.""" @overload @@ -67,11 +71,15 @@ class ModelV2(_model_base.Model): :vartype union_prop: str or int """ - prop: str = rest_field() + prop: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - enum_prop: Union[str, "_models.EnumV2"] = rest_field(name="enumProp") + enum_prop: Union[str, "_models.EnumV2"] = rest_field( + name="enumProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required. \"enumMember\"""" - union_prop: "_types.UnionV2" = rest_field(name="unionProp") + union_prop: "_types.UnionV2" = rest_field( + name="unionProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required. Is either a str type or a int type.""" @overload diff --git a/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/models/_models.py b/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/models/_models.py index 35fe5bf01c7..4f831a94814 100644 --- a/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/models/_models.py +++ b/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/models/_models.py @@ -23,9 +23,11 @@ class TestModel(_model_base.Model): :vartype changed_prop: str """ - prop: str = rest_field() + prop: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - changed_prop: Optional[str] = rest_field(name="changedProp") + changed_prop: Optional[str] = rest_field( + name="changedProp", visibility=["read", "create", "update", "delete", "query"] + ) @overload def __init__( diff --git a/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/models/_models.py b/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/models/_models.py index b776fe9c739..ac6c82b5f41 100644 --- a/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/models/_models.py +++ b/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/models/_models.py @@ -28,11 +28,15 @@ class ModelV2(_model_base.Model): :vartype union_prop: str or float """ - prop: str = rest_field() + prop: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - enum_prop: Union[str, "_models.EnumV2"] = rest_field(name="enumProp") + enum_prop: Union[str, "_models.EnumV2"] = rest_field( + name="enumProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required. \"enumMemberV2\"""" - union_prop: "_types.UnionV2" = rest_field(name="unionProp") + union_prop: "_types.UnionV2" = rest_field( + name="unionProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required. Is either a str type or a float type.""" @overload @@ -65,9 +69,11 @@ class ModelV3(_model_base.Model): :vartype enum_prop: str or ~versioning.removed.models.EnumV3 """ - id: str = rest_field() + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - enum_prop: Union[str, "_models.EnumV3"] = rest_field(name="enumProp") + enum_prop: Union[str, "_models.EnumV3"] = rest_field( + name="enumProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required. Known values are: \"enumMemberV1\" and \"enumMemberV2Preview\".""" @overload diff --git a/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/models/_models.py b/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/models/_models.py index 4a85917a382..4e8e36ed08b 100644 --- a/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/models/_models.py +++ b/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/models/_models.py @@ -28,11 +28,15 @@ class NewModel(_model_base.Model): :vartype union_prop: str or int """ - new_prop: str = rest_field(name="newProp") + new_prop: str = rest_field(name="newProp", visibility=["read", "create", "update", "delete", "query"]) """Required.""" - enum_prop: Union[str, "_models.NewEnum"] = rest_field(name="enumProp") + enum_prop: Union[str, "_models.NewEnum"] = rest_field( + name="enumProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required. \"newEnumMember\"""" - union_prop: "_types.NewUnion" = rest_field(name="unionProp") + union_prop: "_types.NewUnion" = rest_field( + name="unionProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required. Is either a str type or a int type.""" @overload diff --git a/packages/typespec-python/test/azure/generated/versioning-typechangedfrom/versioning/typechangedfrom/models/_models.py b/packages/typespec-python/test/azure/generated/versioning-typechangedfrom/versioning/typechangedfrom/models/_models.py index 9ca5e519e6d..98eabdebad9 100644 --- a/packages/typespec-python/test/azure/generated/versioning-typechangedfrom/versioning/typechangedfrom/models/_models.py +++ b/packages/typespec-python/test/azure/generated/versioning-typechangedfrom/versioning/typechangedfrom/models/_models.py @@ -23,9 +23,9 @@ class TestModel(_model_base.Model): :vartype changed_prop: str """ - prop: str = rest_field() + prop: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - changed_prop: str = rest_field(name="changedProp") + changed_prop: str = rest_field(name="changedProp", visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/authentication-api-key/authentication/apikey/models/_models.py b/packages/typespec-python/test/unbranded/generated/authentication-api-key/authentication/apikey/models/_models.py index 89f206a7df2..f1ca3dc4e67 100644 --- a/packages/typespec-python/test/unbranded/generated/authentication-api-key/authentication/apikey/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/authentication-api-key/authentication/apikey/models/_models.py @@ -22,7 +22,7 @@ class InvalidAuth(_model_base.Model): :vartype error: str """ - error: str = rest_field() + error: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/authentication-http-custom/authentication/http/custom/models/_models.py b/packages/typespec-python/test/unbranded/generated/authentication-http-custom/authentication/http/custom/models/_models.py index 89f206a7df2..f1ca3dc4e67 100644 --- a/packages/typespec-python/test/unbranded/generated/authentication-http-custom/authentication/http/custom/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/authentication-http-custom/authentication/http/custom/models/_models.py @@ -22,7 +22,7 @@ class InvalidAuth(_model_base.Model): :vartype error: str """ - error: str = rest_field() + error: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/authentication-oauth2/authentication/oauth2/models/_models.py b/packages/typespec-python/test/unbranded/generated/authentication-oauth2/authentication/oauth2/models/_models.py index 89f206a7df2..f1ca3dc4e67 100644 --- a/packages/typespec-python/test/unbranded/generated/authentication-oauth2/authentication/oauth2/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/authentication-oauth2/authentication/oauth2/models/_models.py @@ -22,7 +22,7 @@ class InvalidAuth(_model_base.Model): :vartype error: str """ - error: str = rest_field() + error: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/models/_models.py b/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/models/_models.py index 54690a7348d..1818508887e 100644 --- a/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/models/_models.py @@ -21,7 +21,7 @@ class Base64BytesProperty(_model_base.Model): :vartype value: bytes """ - value: bytes = rest_field(format="base64") + value: bytes = rest_field(visibility=["read", "create", "update", "delete", "query"], format="base64") """Required.""" @overload @@ -50,7 +50,7 @@ class Base64urlArrayBytesProperty(_model_base.Model): :vartype value: list[bytes] """ - value: List[bytes] = rest_field(format="base64url") + value: List[bytes] = rest_field(visibility=["read", "create", "update", "delete", "query"], format="base64url") """Required.""" @overload @@ -79,7 +79,7 @@ class Base64urlBytesProperty(_model_base.Model): :vartype value: bytes """ - value: bytes = rest_field(format="base64url") + value: bytes = rest_field(visibility=["read", "create", "update", "delete", "query"], format="base64url") """Required.""" @overload @@ -108,7 +108,7 @@ class DefaultBytesProperty(_model_base.Model): :vartype value: bytes """ - value: bytes = rest_field(format="base64") + value: bytes = rest_field(visibility=["read", "create", "update", "delete", "query"], format="base64") """Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/encode-datetime/encode/datetime/models/_models.py b/packages/typespec-python/test/unbranded/generated/encode-datetime/encode/datetime/models/_models.py index 510429222d5..f68996e2385 100644 --- a/packages/typespec-python/test/unbranded/generated/encode-datetime/encode/datetime/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/encode-datetime/encode/datetime/models/_models.py @@ -22,7 +22,7 @@ class DefaultDatetimeProperty(_model_base.Model): :vartype value: ~datetime.datetime """ - value: datetime.datetime = rest_field(format="rfc3339") + value: datetime.datetime = rest_field(visibility=["read", "create", "update", "delete", "query"], format="rfc3339") """Required.""" @overload @@ -51,7 +51,7 @@ class Rfc3339DatetimeProperty(_model_base.Model): :vartype value: ~datetime.datetime """ - value: datetime.datetime = rest_field(format="rfc3339") + value: datetime.datetime = rest_field(visibility=["read", "create", "update", "delete", "query"], format="rfc3339") """Required.""" @overload @@ -80,7 +80,7 @@ class Rfc7231DatetimeProperty(_model_base.Model): :vartype value: ~datetime.datetime """ - value: datetime.datetime = rest_field(format="rfc7231") + value: datetime.datetime = rest_field(visibility=["read", "create", "update", "delete", "query"], format="rfc7231") """Required.""" @overload @@ -109,7 +109,9 @@ class UnixTimestampArrayDatetimeProperty(_model_base.Model): :vartype value: list[~datetime.datetime] """ - value: List[datetime.datetime] = rest_field(format="unix-timestamp") + value: List[datetime.datetime] = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="unix-timestamp" + ) """Required.""" @overload @@ -138,7 +140,9 @@ class UnixTimestampDatetimeProperty(_model_base.Model): :vartype value: ~datetime.datetime """ - value: datetime.datetime = rest_field(format="unix-timestamp") + value: datetime.datetime = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="unix-timestamp" + ) """Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/encode-duration/encode/duration/property/models/_models.py b/packages/typespec-python/test/unbranded/generated/encode-duration/encode/duration/property/models/_models.py index e8d09a90539..e3787e2bfe4 100644 --- a/packages/typespec-python/test/unbranded/generated/encode-duration/encode/duration/property/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/encode-duration/encode/duration/property/models/_models.py @@ -22,7 +22,7 @@ class DefaultDurationProperty(_model_base.Model): :vartype value: ~datetime.timedelta """ - value: datetime.timedelta = rest_field() + value: datetime.timedelta = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -51,7 +51,7 @@ class Float64SecondsDurationProperty(_model_base.Model): :vartype value: float """ - value: float = rest_field() + value: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -80,7 +80,7 @@ class FloatSecondsDurationArrayProperty(_model_base.Model): :vartype value: list[float] """ - value: List[float] = rest_field() + value: List[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -109,7 +109,7 @@ class FloatSecondsDurationProperty(_model_base.Model): :vartype value: float """ - value: float = rest_field() + value: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -138,7 +138,7 @@ class Int32SecondsDurationProperty(_model_base.Model): :vartype value: int """ - value: int = rest_field() + value: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -167,7 +167,7 @@ class ISO8601DurationProperty(_model_base.Model): :vartype value: ~datetime.timedelta """ - value: datetime.timedelta = rest_field() + value: datetime.timedelta = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/encode-numeric/encode/numeric/property/models/_models.py b/packages/typespec-python/test/unbranded/generated/encode-numeric/encode/numeric/property/models/_models.py index 6b630883835..ab0b220495b 100644 --- a/packages/typespec-python/test/unbranded/generated/encode-numeric/encode/numeric/property/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/encode-numeric/encode/numeric/property/models/_models.py @@ -21,7 +21,7 @@ class SafeintAsStringProperty(_model_base.Model): :vartype value: int """ - value: int = rest_field(format="str") + value: int = rest_field(visibility=["read", "create", "update", "delete", "query"], format="str") """Required.""" @overload @@ -49,7 +49,7 @@ class Uint32AsStringProperty(_model_base.Model): :vartype value: int """ - value: Optional[int] = rest_field(format="str") + value: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"], format="str") @overload def __init__( @@ -77,7 +77,7 @@ class Uint8AsStringProperty(_model_base.Model): :vartype value: int """ - value: int = rest_field(format="str") + value: int = rest_field(visibility=["read", "create", "update", "delete", "query"], format="str") """Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/parameters-basic/parameters/basic/explicitbody/models/_models.py b/packages/typespec-python/test/unbranded/generated/parameters-basic/parameters/basic/explicitbody/models/_models.py index dae6a71772e..8215aaf7ef2 100644 --- a/packages/typespec-python/test/unbranded/generated/parameters-basic/parameters/basic/explicitbody/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/parameters-basic/parameters/basic/explicitbody/models/_models.py @@ -22,7 +22,7 @@ class User(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/parameters-body-optionality/parameters/bodyoptionality/models/_models.py b/packages/typespec-python/test/unbranded/generated/parameters-body-optionality/parameters/bodyoptionality/models/_models.py index d06bef23290..60ec5c7ddf0 100644 --- a/packages/typespec-python/test/unbranded/generated/parameters-body-optionality/parameters/bodyoptionality/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/parameters-body-optionality/parameters/bodyoptionality/models/_models.py @@ -22,7 +22,7 @@ class BodyModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/parameters-spread/parameters/spread/model/models/_models.py b/packages/typespec-python/test/unbranded/generated/parameters-spread/parameters/spread/model/models/_models.py index ac496772bfd..e9d78e47f34 100644 --- a/packages/typespec-python/test/unbranded/generated/parameters-spread/parameters/spread/model/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/parameters-spread/parameters/spread/model/models/_models.py @@ -22,7 +22,7 @@ class BodyParameter(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/payload-content-negotiation/payload/contentnegotiation/differentbody/models/_models.py b/packages/typespec-python/test/unbranded/generated/payload-content-negotiation/payload/contentnegotiation/differentbody/models/_models.py index 881bd686c5e..2e7d1f34f73 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-content-negotiation/payload/contentnegotiation/differentbody/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/payload-content-negotiation/payload/contentnegotiation/differentbody/models/_models.py @@ -21,7 +21,7 @@ class PngImageAsJson(_model_base.Model): :vartype content: bytes """ - content: bytes = rest_field(format="base64") + content: bytes = rest_field(visibility=["read", "create", "update", "delete", "query"], format="base64") """Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/payload-json-merge-patch/payload/jsonmergepatch/models/_models.py b/packages/typespec-python/test/unbranded/generated/payload-json-merge-patch/payload/jsonmergepatch/models/_models.py index 8698d0ee743..8d8ec836387 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-json-merge-patch/payload/jsonmergepatch/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/payload-json-merge-patch/payload/jsonmergepatch/models/_models.py @@ -25,8 +25,8 @@ class InnerModel(_model_base.Model): :vartype description: str """ - name: Optional[str] = rest_field() - description: Optional[str] = rest_field() + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @overload def __init__( @@ -69,15 +69,23 @@ class Resource(_model_base.Model): :vartype int_array: list[int] """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - description: Optional[str] = rest_field() - map: Optional[Dict[str, "_models.InnerModel"]] = rest_field() - array: Optional[List["_models.InnerModel"]] = rest_field() - int_value: Optional[int] = rest_field(name="intValue") - float_value: Optional[float] = rest_field(name="floatValue") - inner_model: Optional["_models.InnerModel"] = rest_field(name="innerModel") - int_array: Optional[List[int]] = rest_field(name="intArray") + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + map: Optional[Dict[str, "_models.InnerModel"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + array: Optional[List["_models.InnerModel"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + int_value: Optional[int] = rest_field(name="intValue", visibility=["read", "create", "update", "delete", "query"]) + float_value: Optional[float] = rest_field( + name="floatValue", visibility=["read", "create", "update", "delete", "query"] + ) + inner_model: Optional["_models.InnerModel"] = rest_field( + name="innerModel", visibility=["read", "create", "update", "delete", "query"] + ) + int_array: Optional[List[int]] = rest_field( + name="intArray", visibility=["read", "create", "update", "delete", "query"] + ) @overload def __init__( @@ -123,13 +131,21 @@ class ResourcePatch(_model_base.Model): :vartype int_array: list[int] """ - description: Optional[str] = rest_field() - map: Optional[Dict[str, "_models.InnerModel"]] = rest_field() - array: Optional[List["_models.InnerModel"]] = rest_field() - int_value: Optional[int] = rest_field(name="intValue") - float_value: Optional[float] = rest_field(name="floatValue") - inner_model: Optional["_models.InnerModel"] = rest_field(name="innerModel") - int_array: Optional[List[int]] = rest_field(name="intArray") + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + map: Optional[Dict[str, "_models.InnerModel"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + array: Optional[List["_models.InnerModel"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + int_value: Optional[int] = rest_field(name="intValue", visibility=["read", "create", "update", "delete", "query"]) + float_value: Optional[float] = rest_field( + name="floatValue", visibility=["read", "create", "update", "delete", "query"] + ) + inner_model: Optional["_models.InnerModel"] = rest_field( + name="innerModel", visibility=["read", "create", "update", "delete", "query"] + ) + int_array: Optional[List[int]] = rest_field( + name="intArray", visibility=["read", "create", "update", "delete", "query"] + ) @overload def __init__( diff --git a/packages/typespec-python/test/unbranded/generated/payload-multipart/payload/multipart/formdata/httpparts/nonstring/models/_models.py b/packages/typespec-python/test/unbranded/generated/payload-multipart/payload/multipart/formdata/httpparts/nonstring/models/_models.py index 45035e7bf7e..0f38b5fb240 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-multipart/payload/multipart/formdata/httpparts/nonstring/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/payload-multipart/payload/multipart/formdata/httpparts/nonstring/models/_models.py @@ -22,7 +22,7 @@ class FloatRequest(_model_base.Model): :vartype temperature: float """ - temperature: float = rest_field() + temperature: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/payload-multipart/payload/multipart/models/_models.py b/packages/typespec-python/test/unbranded/generated/payload-multipart/payload/multipart/models/_models.py index 7c78f6a9849..dd9bdb318c7 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-multipart/payload/multipart/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/payload-multipart/payload/multipart/models/_models.py @@ -26,7 +26,7 @@ class Address(_model_base.Model): :vartype city: str """ - city: str = rest_field() + city: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -58,9 +58,11 @@ class BinaryArrayPartsRequest(_model_base.Model): :vartype pictures: list[~payload.multipart._vendor.FileType] """ - id: str = rest_field() + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - pictures: List[FileType] = rest_field(is_multipart_file_input=True) + pictures: List[FileType] = rest_field( + visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True + ) """Required.""" @overload @@ -99,15 +101,21 @@ class ComplexHttpPartsModelRequest(_model_base.Model): :vartype pictures: list[~payload.multipart._vendor.FileType] """ - id: str = rest_field() + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - address: "_models.Address" = rest_field() + address: "_models.Address" = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - profile_image: FileType = rest_field(name="profileImage", is_multipart_file_input=True) + profile_image: FileType = rest_field( + name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True + ) """Required.""" - previous_addresses: List["_models.Address"] = rest_field(name="previousAddresses") + previous_addresses: List["_models.Address"] = rest_field( + name="previousAddresses", visibility=["read", "create", "update", "delete", "query"] + ) """Required.""" - pictures: List[FileType] = rest_field(is_multipart_file_input=True) + pictures: List[FileType] = rest_field( + visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True + ) """Required.""" @overload @@ -147,13 +155,17 @@ class ComplexPartsRequest(_model_base.Model): :vartype pictures: list[~payload.multipart._vendor.FileType] """ - id: str = rest_field() + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - address: "_models.Address" = rest_field() + address: "_models.Address" = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - profile_image: FileType = rest_field(name="profileImage", is_multipart_file_input=True) + profile_image: FileType = rest_field( + name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True + ) """Required.""" - pictures: List[FileType] = rest_field(is_multipart_file_input=True) + pictures: List[FileType] = rest_field( + visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True + ) """Required.""" @overload @@ -186,7 +198,9 @@ class FileWithHttpPartOptionalContentTypeRequest(_model_base.Model): # pylint: :vartype profile_image: ~payload.multipart._vendor.FileType """ - profile_image: FileType = rest_field(name="profileImage", is_multipart_file_input=True) + profile_image: FileType = rest_field( + name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True + ) """Required.""" @overload @@ -216,7 +230,9 @@ class FileWithHttpPartRequiredContentTypeRequest(_model_base.Model): # pylint: :vartype profile_image: ~payload.multipart._vendor.FileType """ - profile_image: FileType = rest_field(name="profileImage", is_multipart_file_input=True) + profile_image: FileType = rest_field( + name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True + ) """Required.""" @overload @@ -246,7 +262,9 @@ class FileWithHttpPartSpecificContentTypeRequest(_model_base.Model): # pylint: :vartype profile_image: ~payload.multipart._vendor.FileType """ - profile_image: FileType = rest_field(name="profileImage", is_multipart_file_input=True) + profile_image: FileType = rest_field( + name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True + ) """Required.""" @overload @@ -278,9 +296,11 @@ class JsonPartRequest(_model_base.Model): :vartype profile_image: ~payload.multipart._vendor.FileType """ - address: "_models.Address" = rest_field() + address: "_models.Address" = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - profile_image: FileType = rest_field(name="profileImage", is_multipart_file_input=True) + profile_image: FileType = rest_field( + name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True + ) """Required.""" @overload @@ -313,9 +333,13 @@ class MultiBinaryPartsRequest(_model_base.Model): :vartype picture: ~payload.multipart._vendor.FileType """ - profile_image: FileType = rest_field(name="profileImage", is_multipart_file_input=True) + profile_image: FileType = rest_field( + name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True + ) """Required.""" - picture: Optional[FileType] = rest_field(is_multipart_file_input=True) + picture: Optional[FileType] = rest_field( + visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True + ) @overload def __init__( @@ -347,9 +371,11 @@ class MultiPartRequest(_model_base.Model): :vartype profile_image: ~payload.multipart._vendor.FileType """ - id: str = rest_field() + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - profile_image: FileType = rest_field(name="profileImage", is_multipart_file_input=True) + profile_image: FileType = rest_field( + name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True + ) """Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/models/_models.py b/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/models/_models.py index 16d755acd8b..d7e05ce8d0a 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/models/_models.py @@ -23,9 +23,9 @@ class Pet(_model_base.Model): :vartype name: str """ - id: str = rest_field() + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/models/_models.py b/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/models/_models.py index e920c25a2d7..3a624109b00 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/models/_models.py @@ -26,6 +26,7 @@ class ModelWithArrayOfModel(_model_base.Model): items_property: List["_models.SimpleModel"] = rest_field( name="items", + visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "SimpleModel", "name": "items", "text": False, "unwrapped": False}, ) """Required.""" @@ -62,11 +63,20 @@ class ModelWithAttributes(_model_base.Model): :vartype enabled: bool """ - id1: int = rest_field(xml={"attribute": True, "name": "id1", "text": False, "unwrapped": False}) + id1: int = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": True, "name": "id1", "text": False, "unwrapped": False}, + ) """Required.""" - id2: str = rest_field(xml={"attribute": True, "name": "id2", "text": False, "unwrapped": False}) + id2: str = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": True, "name": "id2", "text": False, "unwrapped": False}, + ) """Required.""" - enabled: bool = rest_field(xml={"attribute": False, "name": "enabled", "text": False, "unwrapped": False}) + enabled: bool = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "enabled", "text": False, "unwrapped": False}, + ) """Required.""" _xml = {"attribute": False, "name": "ModelWithAttributes", "text": False, "unwrapped": False} @@ -100,7 +110,8 @@ class ModelWithDictionary(_model_base.Model): """ metadata: Dict[str, str] = rest_field( - xml={"attribute": False, "name": "metadata", "text": False, "unwrapped": False} + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "metadata", "text": False, "unwrapped": False}, ) """Required.""" @@ -134,6 +145,7 @@ class ModelWithEmptyArray(_model_base.Model): items_property: List["_models.SimpleModel"] = rest_field( name="items", + visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "SimpleModel", "name": "items", "text": False, "unwrapped": False}, ) """Required.""" @@ -169,11 +181,14 @@ class ModelWithEncodedNames(_model_base.Model): """ model_data: "_models.SimpleModel" = rest_field( - name="modelData", xml={"attribute": False, "name": "SimpleModelData", "text": False, "unwrapped": False} + name="modelData", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "SimpleModelData", "text": False, "unwrapped": False}, ) """Required.""" colors: List[str] = rest_field( - xml={"attribute": False, "itemsName": "string", "name": "PossibleColors", "text": False, "unwrapped": False} + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "itemsName": "string", "name": "PossibleColors", "text": False, "unwrapped": False}, ) """Required.""" @@ -208,9 +223,15 @@ class ModelWithOptionalField(_model_base.Model): :vartype value: int """ - item: str = rest_field(xml={"attribute": False, "name": "item", "text": False, "unwrapped": False}) + item: str = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "item", "text": False, "unwrapped": False}, + ) """Required.""" - value: Optional[int] = rest_field(xml={"attribute": False, "name": "value", "text": False, "unwrapped": False}) + value: Optional[int] = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "value", "text": False, "unwrapped": False}, + ) _xml = {"attribute": False, "name": "ModelWithOptionalField", "text": False, "unwrapped": False} @@ -245,11 +266,13 @@ class ModelWithRenamedArrays(_model_base.Model): """ colors: List[str] = rest_field( - xml={"attribute": False, "itemsName": "Colors", "name": "Colors", "text": False, "unwrapped": True} + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "itemsName": "Colors", "name": "Colors", "text": False, "unwrapped": True}, ) """Required.""" counts: List[int] = rest_field( - xml={"attribute": False, "itemsName": "int32", "name": "Counts", "text": False, "unwrapped": False} + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "itemsName": "int32", "name": "Counts", "text": False, "unwrapped": False}, ) """Required.""" @@ -285,11 +308,15 @@ class ModelWithRenamedFields(_model_base.Model): """ input_data: "_models.SimpleModel" = rest_field( - name="inputData", xml={"attribute": False, "name": "InputData", "text": False, "unwrapped": False} + name="inputData", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "InputData", "text": False, "unwrapped": False}, ) """Required.""" output_data: "_models.SimpleModel" = rest_field( - name="outputData", xml={"attribute": False, "name": "OutputData", "text": False, "unwrapped": False} + name="outputData", + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "OutputData", "text": False, "unwrapped": False}, ) """Required.""" @@ -325,11 +352,13 @@ class ModelWithSimpleArrays(_model_base.Model): """ colors: List[str] = rest_field( - xml={"attribute": False, "itemsName": "string", "name": "colors", "text": False, "unwrapped": False} + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "itemsName": "string", "name": "colors", "text": False, "unwrapped": False}, ) """Required.""" counts: List[int] = rest_field( - xml={"attribute": False, "itemsName": "int32", "name": "counts", "text": False, "unwrapped": False} + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "itemsName": "int32", "name": "counts", "text": False, "unwrapped": False}, ) """Required.""" @@ -364,9 +393,15 @@ class ModelWithText(_model_base.Model): :vartype content: str """ - language: str = rest_field(xml={"attribute": True, "name": "language", "text": False, "unwrapped": False}) + language: str = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": True, "name": "language", "text": False, "unwrapped": False}, + ) """Required.""" - content: str = rest_field(xml={"attribute": False, "name": "content", "text": True, "unwrapped": False}) + content: str = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "content", "text": True, "unwrapped": False}, + ) """Required.""" _xml = {"attribute": False, "name": "ModelWithText", "text": False, "unwrapped": False} @@ -401,11 +436,13 @@ class ModelWithUnwrappedArray(_model_base.Model): """ colors: List[str] = rest_field( - xml={"attribute": False, "itemsName": "colors", "name": "colors", "text": False, "unwrapped": True} + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "itemsName": "colors", "name": "colors", "text": False, "unwrapped": True}, ) """Required.""" counts: List[int] = rest_field( - xml={"attribute": False, "itemsName": "int32", "name": "counts", "text": False, "unwrapped": False} + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "itemsName": "int32", "name": "counts", "text": False, "unwrapped": False}, ) """Required.""" @@ -440,9 +477,15 @@ class SimpleModel(_model_base.Model): :vartype age: int """ - name: str = rest_field(xml={"attribute": False, "name": "name", "text": False, "unwrapped": False}) + name: str = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "name", "text": False, "unwrapped": False}, + ) """Required.""" - age: int = rest_field(xml={"attribute": False, "name": "age", "text": False, "unwrapped": False}) + age: int = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "age", "text": False, "unwrapped": False}, + ) """Required.""" _xml = {"attribute": False, "name": "SimpleModel", "text": False, "unwrapped": False} diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/CHANGELOG.md b/packages/typespec-python/test/unbranded/generated/response-status-code-range/CHANGELOG.md new file mode 100644 index 00000000000..628743d283a --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0b1 (1970-01-01) + +- Initial version diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/LICENSE b/packages/typespec-python/test/unbranded/generated/response-status-code-range/LICENSE new file mode 100644 index 00000000000..edd3f78edcc --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) Unbranded 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. \ No newline at end of file diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/MANIFEST.in b/packages/typespec-python/test/unbranded/generated/response-status-code-range/MANIFEST.in new file mode 100644 index 00000000000..87b2b3fe020 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/MANIFEST.in @@ -0,0 +1,6 @@ +include *.md +include LICENSE +include response/statuscoderange/py.typed +recursive-include tests *.py +recursive-include samples *.py *.md +include response/__init__.py \ No newline at end of file diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/README.md b/packages/typespec-python/test/unbranded/generated/response-status-code-range/README.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/__init__.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/__init__.py new file mode 100644 index 00000000000..d55ccad1f57 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/__init__.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/__init__.py new file mode 100644 index 00000000000..698c2bae7f3 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/__init__.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Unbranded (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import StatusCodeRangeClient # type: ignore +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "StatusCodeRangeClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore + +_patch_sdk() diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_client.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_client.py new file mode 100644 index 00000000000..e24c0a594c1 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_client.py @@ -0,0 +1,84 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Unbranded (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any +from typing_extensions import Self + +from corehttp.rest import HttpRequest, HttpResponse +from corehttp.runtime import PipelineClient, policies + +from ._configuration import StatusCodeRangeClientConfiguration +from ._operations import StatusCodeRangeClientOperationsMixin +from ._serialization import Deserializer, Serializer + + +class StatusCodeRangeClient(StatusCodeRangeClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword + """Test for range of status code. + + :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: + _endpoint = "{endpoint}" + self._config = StatusCodeRangeClientConfiguration(endpoint=endpoint, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + self._config.retry_policy, + self._config.authentication_policy, + self._config.logging_policy, + ] + self._client: PipelineClient = PipelineClient(endpoint=_endpoint, policies=_policies, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from corehttp.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~corehttp.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~corehttp.rest.HttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> Self: + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_configuration.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_configuration.py new file mode 100644 index 00000000000..f7c2cf06adc --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_configuration.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Unbranded (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any + +from corehttp.runtime import policies + +from ._version import VERSION + + +class StatusCodeRangeClientConfiguration: + """Configuration for StatusCodeRangeClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: Service host. Default value is "http://localhost:3000". + :type endpoint: str + """ + + def __init__(self, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None: + + self.endpoint = endpoint + kwargs.setdefault("sdk_moniker", "response-statuscoderange/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_model_base.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_model_base.py new file mode 100644 index 00000000000..86f9838e356 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_model_base.py @@ -0,0 +1,1235 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access, broad-except + +import copy +import calendar +import decimal +import functools +import sys +import logging +import base64 +import re +import typing +import enum +import email.utils +from datetime import datetime, date, time, timedelta, timezone +from json import JSONEncoder +import xml.etree.ElementTree as ET +from typing_extensions import Self +import isodate +from corehttp.exceptions import DeserializationError +from corehttp.utils import CaseInsensitiveEnumMeta +from corehttp.runtime.pipeline import PipelineResponse +from corehttp.serialization import _Null + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping + +_LOGGER = logging.getLogger(__name__) + +__all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] + +TZ_UTC = timezone.utc +_T = typing.TypeVar("_T") + + +def _timedelta_as_isostr(td: timedelta) -> str: + """Converts a datetime.timedelta object into an ISO 8601 formatted string, e.g. 'P4DT12H30M05S' + + Function adapted from the Tin Can Python project: https://github.com/RusticiSoftware/TinCanPython + + :param timedelta td: The timedelta to convert + :rtype: str + :return: ISO8601 version of this timedelta + """ + + # Split seconds to larger units + seconds = td.total_seconds() + minutes, seconds = divmod(seconds, 60) + hours, minutes = divmod(minutes, 60) + days, hours = divmod(hours, 24) + + days, hours, minutes = list(map(int, (days, hours, minutes))) + seconds = round(seconds, 6) + + # Build date + date_str = "" + if days: + date_str = "%sD" % days + + if hours or minutes or seconds: + # Build time + time_str = "T" + + # Hours + bigger_exists = date_str or hours + if bigger_exists: + time_str += "{:02}H".format(hours) + + # Minutes + bigger_exists = bigger_exists or minutes + if bigger_exists: + time_str += "{:02}M".format(minutes) + + # Seconds + try: + if seconds.is_integer(): + seconds_string = "{:02}".format(int(seconds)) + else: + # 9 chars long w/ leading 0, 6 digits after decimal + seconds_string = "%09.6f" % seconds + # Remove trailing zeros + seconds_string = seconds_string.rstrip("0") + except AttributeError: # int.is_integer() raises + seconds_string = "{:02}".format(seconds) + + time_str += "{}S".format(seconds_string) + else: + time_str = "" + + return "P" + date_str + time_str + + +def _serialize_bytes(o, format: typing.Optional[str] = None) -> str: + encoded = base64.b64encode(o).decode() + if format == "base64url": + return encoded.strip("=").replace("+", "-").replace("/", "_") + return encoded + + +def _serialize_datetime(o, format: typing.Optional[str] = None): + if hasattr(o, "year") and hasattr(o, "hour"): + if format == "rfc7231": + return email.utils.format_datetime(o, usegmt=True) + if format == "unix-timestamp": + return int(calendar.timegm(o.utctimetuple())) + + # astimezone() fails for naive times in Python 2.7, so make make sure o is aware (tzinfo is set) + if not o.tzinfo: + iso_formatted = o.replace(tzinfo=TZ_UTC).isoformat() + else: + iso_formatted = o.astimezone(TZ_UTC).isoformat() + # Replace the trailing "+00:00" UTC offset with "Z" (RFC 3339: https://www.ietf.org/rfc/rfc3339.txt) + return iso_formatted.replace("+00:00", "Z") + # Next try datetime.date or datetime.time + return o.isoformat() + + +def _is_readonly(p): + try: + return p._visibility == ["read"] + except AttributeError: + return False + + +class SdkJSONEncoder(JSONEncoder): + """A JSON encoder that's capable of serializing datetime objects and bytes.""" + + def __init__(self, *args, exclude_readonly: bool = False, format: typing.Optional[str] = None, **kwargs): + super().__init__(*args, **kwargs) + self.exclude_readonly = exclude_readonly + self.format = format + + def default(self, o): # pylint: disable=too-many-return-statements + if _is_model(o): + if self.exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + return {k: v for k, v in o.items() if k not in readonly_props} + return dict(o.items()) + try: + return super(SdkJSONEncoder, self).default(o) + except TypeError: + if isinstance(o, _Null): + return None + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, self.format) + try: + # First try datetime.datetime + return _serialize_datetime(o, self.format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return super(SdkJSONEncoder, self).default(o) + + +_VALID_DATE = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" + r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") +_VALID_RFC7231 = re.compile( + r"(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s\d{2}\s" + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT" +) + + +def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + attr = attr.upper() + match = _VALID_DATE.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + return date_obj + + +def _deserialize_datetime_rfc7231(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize RFC7231 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + match = _VALID_RFC7231.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + return email.utils.parsedate_to_datetime(attr) + + +def _deserialize_datetime_unix_timestamp(attr: typing.Union[float, datetime]) -> datetime: + """Deserialize unix timestamp into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + return datetime.fromtimestamp(attr, TZ_UTC) + + +def _deserialize_date(attr: typing.Union[str, date]) -> date: + """Deserialize ISO-8601 formatted string into Date object. + :param str attr: response string to be deserialized. + :rtype: date + :returns: The date object from that input + """ + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + if isinstance(attr, date): + return attr + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) # type: ignore + + +def _deserialize_time(attr: typing.Union[str, time]) -> time: + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :returns: The time object from that input + """ + if isinstance(attr, time): + return attr + return isodate.parse_time(attr) + + +def _deserialize_bytes(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + return bytes(base64.b64decode(attr)) + + +def _deserialize_bytes_base64(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return bytes(base64.b64decode(encoded)) + + +def _deserialize_duration(attr): + if isinstance(attr, timedelta): + return attr + return isodate.parse_duration(attr) + + +def _deserialize_decimal(attr): + if isinstance(attr, decimal.Decimal): + return attr + return decimal.Decimal(str(attr)) + + +def _deserialize_int_as_str(attr): + if isinstance(attr, int): + return attr + return int(attr) + + +_DESERIALIZE_MAPPING = { + datetime: _deserialize_datetime, + date: _deserialize_date, + time: _deserialize_time, + bytes: _deserialize_bytes, + bytearray: _deserialize_bytes, + timedelta: _deserialize_duration, + typing.Any: lambda x: x, + decimal.Decimal: _deserialize_decimal, +} + +_DESERIALIZE_MAPPING_WITHFORMAT = { + "rfc3339": _deserialize_datetime, + "rfc7231": _deserialize_datetime_rfc7231, + "unix-timestamp": _deserialize_datetime_unix_timestamp, + "base64": _deserialize_bytes, + "base64url": _deserialize_bytes_base64, +} + + +def get_deserializer(annotation: typing.Any, rf: typing.Optional["_RestField"] = None): + if annotation is int and rf and rf._format == "str": + return _deserialize_int_as_str + if rf and rf._format: + return _DESERIALIZE_MAPPING_WITHFORMAT.get(rf._format) + return _DESERIALIZE_MAPPING.get(annotation) # pyright: ignore + + +def _get_type_alias_type(module_name: str, alias_name: str): + types = { + k: v + for k, v in sys.modules[module_name].__dict__.items() + if isinstance(v, typing._GenericAlias) # type: ignore + } + if alias_name not in types: + return alias_name + return types[alias_name] + + +def _get_model(module_name: str, model_name: str): + models = {k: v for k, v in sys.modules[module_name].__dict__.items() if isinstance(v, type)} + module_end = module_name.rsplit(".", 1)[0] + models.update({k: v for k, v in sys.modules[module_end].__dict__.items() if isinstance(v, type)}) + if isinstance(model_name, str): + model_name = model_name.split(".")[-1] + if model_name not in models: + return model_name + return models[model_name] + + +_UNSET = object() + + +class _MyMutableMapping(MutableMapping[str, typing.Any]): # pylint: disable=unsubscriptable-object + def __init__(self, data: typing.Dict[str, typing.Any]) -> None: + self._data = data + + def __contains__(self, key: typing.Any) -> bool: + return key in self._data + + def __getitem__(self, key: str) -> typing.Any: + return self._data.__getitem__(key) + + def __setitem__(self, key: str, value: typing.Any) -> None: + self._data.__setitem__(key, value) + + def __delitem__(self, key: str) -> None: + self._data.__delitem__(key) + + def __iter__(self) -> typing.Iterator[typing.Any]: + return self._data.__iter__() + + def __len__(self) -> int: + return self._data.__len__() + + def __ne__(self, other: typing.Any) -> bool: + return not self.__eq__(other) + + def keys(self) -> typing.KeysView[str]: + """ + :returns: a set-like object providing a view on D's keys + :rtype: ~typing.KeysView + """ + return self._data.keys() + + def values(self) -> typing.ValuesView[typing.Any]: + """ + :returns: an object providing a view on D's values + :rtype: ~typing.ValuesView + """ + return self._data.values() + + def items(self) -> typing.ItemsView[str, typing.Any]: + """ + :returns: set-like object providing a view on D's items + :rtype: ~typing.ItemsView + """ + return self._data.items() + + def get(self, key: str, default: typing.Any = None) -> typing.Any: + """ + Get the value for key if key is in the dictionary, else default. + :param str key: The key to look up. + :param any default: The value to return if key is not in the dictionary. Defaults to None + :returns: D[k] if k in D, else d. + :rtype: any + """ + try: + return self[key] + except KeyError: + return default + + @typing.overload + def pop(self, key: str) -> typing.Any: ... + + @typing.overload + def pop(self, key: str, default: _T) -> _T: ... + + @typing.overload + def pop(self, key: str, default: typing.Any) -> typing.Any: ... + + def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Removes specified key and return the corresponding value. + :param str key: The key to pop. + :param any default: The value to return if key is not in the dictionary + :returns: The value corresponding to the key. + :rtype: any + :raises KeyError: If key is not found and default is not given. + """ + if default is _UNSET: + return self._data.pop(key) + return self._data.pop(key, default) + + def popitem(self) -> typing.Tuple[str, typing.Any]: + """ + Removes and returns some (key, value) pair + :returns: The (key, value) pair. + :rtype: tuple + :raises KeyError: if D is empty. + """ + return self._data.popitem() + + def clear(self) -> None: + """ + Remove all items from D. + """ + self._data.clear() + + def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: + """ + Updates D from mapping/iterable E and F. + :param any args: Either a mapping object or an iterable of key-value pairs. + """ + self._data.update(*args, **kwargs) + + @typing.overload + def setdefault(self, key: str, default: None = None) -> None: ... + + @typing.overload + def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... + + def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Same as calling D.get(k, d), and setting D[k]=d if k not found + :param str key: The key to look up. + :param any default: The value to set if key is not in the dictionary + :returns: D[k] if k in D, else d. + :rtype: any + """ + if default is _UNSET: + return self._data.setdefault(key) + return self._data.setdefault(key, default) + + def __eq__(self, other: typing.Any) -> bool: + try: + other_model = self.__class__(other) + except Exception: + return False + return self._data == other_model._data + + def __repr__(self) -> str: + return str(self._data) + + +def _is_model(obj: typing.Any) -> bool: + return getattr(obj, "_is_model", False) + + +def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-many-return-statements + if isinstance(o, list): + return [_serialize(x, format) for x in o] + if isinstance(o, dict): + return {k: _serialize(v, format) for k, v in o.items()} + if isinstance(o, set): + return {_serialize(x, format) for x in o} + if isinstance(o, tuple): + return tuple(_serialize(x, format) for x in o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, format) + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, enum.Enum): + return o.value + if isinstance(o, int): + if format == "str": + return str(o) + return o + try: + # First try datetime.datetime + return _serialize_datetime(o, format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return o + + +def _get_rest_field( + attr_to_rest_field: typing.Dict[str, "_RestField"], rest_name: str +) -> typing.Optional["_RestField"]: + try: + return next(rf for rf in attr_to_rest_field.values() if rf._rest_name == rest_name) + except StopIteration: + return None + + +def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typing.Any: + if not rf: + return _serialize(value, None) + if rf._is_multipart_file_input: + return value + if rf._is_model: + return _deserialize(rf._type, value) + if isinstance(value, ET.Element): + value = _deserialize(rf._type, value) + return _serialize(value, rf._format) + + +class Model(_MyMutableMapping): + _is_model = True + # label whether current class's _attr_to_rest_field has been calculated + # could not see _attr_to_rest_field directly because subclass inherits it from parent class + _calculated: typing.Set[str] = set() + + def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: + class_name = self.__class__.__name__ + if len(args) > 1: + raise TypeError(f"{class_name}.__init__() takes 2 positional arguments but {len(args) + 1} were given") + dict_to_pass = { + rest_field._rest_name: rest_field._default + for rest_field in self._attr_to_rest_field.values() + if rest_field._default is not _UNSET + } + if args: # pylint: disable=too-many-nested-blocks + if isinstance(args[0], ET.Element): + existed_attr_keys = [] + model_meta = getattr(self, "_xml", {}) + + for rf in self._attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + # attribute + if prop_meta.get("attribute", False) and args[0].get(xml_name) is not None: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].get(xml_name)) + continue + + # unwrapped element is array + if prop_meta.get("unwrapped", False): + # unwrapped array could either use prop items meta/prop meta + if prop_meta.get("itemsName"): + xml_name = prop_meta.get("itemsName") + xml_ns = prop_meta.get("itemNs") + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + items = args[0].findall(xml_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, items) + continue + + # text element is primitive type + if prop_meta.get("text", False): + if args[0].text is not None: + dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].text) + continue + + # wrapped element could be normal property or array, it should only have one element + item = args[0].find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + dict_to_pass[rf._rest_name] = _deserialize(rf._type, item) + + # rest thing is additional properties + for e in args[0]: + if e.tag not in existed_attr_keys: + dict_to_pass[e.tag] = _convert_element(e) + else: + dict_to_pass.update( + {k: _create_value(_get_rest_field(self._attr_to_rest_field, k), v) for k, v in args[0].items()} + ) + else: + non_attr_kwargs = [k for k in kwargs if k not in self._attr_to_rest_field] + if non_attr_kwargs: + # actual type errors only throw the first wrong keyword arg they see, so following that. + raise TypeError(f"{class_name}.__init__() got an unexpected keyword argument '{non_attr_kwargs[0]}'") + dict_to_pass.update( + { + self._attr_to_rest_field[k]._rest_name: _create_value(self._attr_to_rest_field[k], v) + for k, v in kwargs.items() + if v is not None + } + ) + super().__init__(dict_to_pass) + + def copy(self) -> "Model": + return Model(self.__dict__) + + def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: + if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated: + # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', + # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' + mros = cls.__mro__[:-9][::-1] # ignore parents, and reverse the mro order + attr_to_rest_field: typing.Dict[str, _RestField] = { # map attribute name to rest_field property + k: v for mro_class in mros for k, v in mro_class.__dict__.items() if k[0] != "_" and hasattr(v, "_type") + } + annotations = { + k: v + for mro_class in mros + if hasattr(mro_class, "__annotations__") + for k, v in mro_class.__annotations__.items() + } + for attr, rf in attr_to_rest_field.items(): + rf._module = cls.__module__ + if not rf._type: + rf._type = rf._get_deserialize_callable_from_annotation(annotations.get(attr, None)) + if not rf._rest_name_input: + rf._rest_name_input = attr + cls._attr_to_rest_field: typing.Dict[str, _RestField] = dict(attr_to_rest_field.items()) + cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") + + return super().__new__(cls) # pylint: disable=no-value-for-parameter + + def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: + for base in cls.__bases__: + if hasattr(base, "__mapping__"): + base.__mapping__[discriminator or cls.__name__] = cls # type: ignore + + @classmethod + def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]: + for v in cls.__dict__.values(): + if isinstance(v, _RestField) and v._is_discriminator and v._rest_name not in exist_discriminators: + return v + return None + + @classmethod + def _deserialize(cls, data, exist_discriminators): + if not hasattr(cls, "__mapping__"): + return cls(data) + discriminator = cls._get_discriminator(exist_discriminators) + if discriminator is None: + return cls(data) + exist_discriminators.append(discriminator._rest_name) + if isinstance(data, ET.Element): + model_meta = getattr(cls, "_xml", {}) + prop_meta = getattr(discriminator, "_xml", {}) + xml_name = prop_meta.get("name", discriminator._rest_name) + xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + if data.get(xml_name) is not None: + discriminator_value = data.get(xml_name) + else: + discriminator_value = data.find(xml_name).text # pyright: ignore + else: + discriminator_value = data.get(discriminator._rest_name) + mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore + return mapped_cls._deserialize(data, exist_discriminators) + + def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.Any]: + """Return a dict that can be turned into json using json.dump. + + :keyword bool exclude_readonly: Whether to remove the readonly properties. + :returns: A dict JSON compatible object + :rtype: dict + """ + + result = {} + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in self._attr_to_rest_field.values() if _is_readonly(p)] + for k, v in self.items(): + if exclude_readonly and k in readonly_props: # pyright: ignore + continue + is_multipart_file_input = False + try: + is_multipart_file_input = next( + rf for rf in self._attr_to_rest_field.values() if rf._rest_name == k + )._is_multipart_file_input + except StopIteration: + pass + result[k] = v if is_multipart_file_input else Model._as_dict_value(v, exclude_readonly=exclude_readonly) + return result + + @staticmethod + def _as_dict_value(v: typing.Any, exclude_readonly: bool = False) -> typing.Any: + if v is None or isinstance(v, _Null): + return None + if isinstance(v, (list, tuple, set)): + return type(v)(Model._as_dict_value(x, exclude_readonly=exclude_readonly) for x in v) + if isinstance(v, dict): + return {dk: Model._as_dict_value(dv, exclude_readonly=exclude_readonly) for dk, dv in v.items()} + return v.as_dict(exclude_readonly=exclude_readonly) if hasattr(v, "as_dict") else v + + +def _deserialize_model(model_deserializer: typing.Optional[typing.Callable], obj): + if _is_model(obj): + return obj + return _deserialize(model_deserializer, obj) + + +def _deserialize_with_optional(if_obj_deserializer: typing.Optional[typing.Callable], obj): + if obj is None: + return obj + return _deserialize_with_callable(if_obj_deserializer, obj) + + +def _deserialize_with_union(deserializers, obj): + for deserializer in deserializers: + try: + return _deserialize(deserializer, obj) + except DeserializationError: + pass + raise DeserializationError() + + +def _deserialize_dict( + value_deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj: typing.Dict[typing.Any, typing.Any], +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = {child.tag: child for child in obj} + return {k: _deserialize(value_deserializer, v, module) for k, v in obj.items()} + + +def _deserialize_multiple_sequence( + entry_deserializers: typing.List[typing.Optional[typing.Callable]], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers)) + + +def _deserialize_sequence( + deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = list(obj) + return type(obj)(_deserialize(deserializer, entry, module) for entry in obj) + + +def _sorted_annotations(types: typing.List[typing.Any]) -> typing.List[typing.Any]: + return sorted( + types, + key=lambda x: hasattr(x, "__name__") and x.__name__.lower() in ("str", "float", "int", "bool"), + ) + + +def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-branches + annotation: typing.Any, + module: typing.Optional[str], + rf: typing.Optional["_RestField"] = None, +) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + if not annotation: + return None + + # is it a type alias? + if isinstance(annotation, str): + if module is not None: + annotation = _get_type_alias_type(module, annotation) + + # is it a forward ref / in quotes? + if isinstance(annotation, (str, typing.ForwardRef)): + try: + model_name = annotation.__forward_arg__ # type: ignore + except AttributeError: + model_name = annotation + if module is not None: + annotation = _get_model(module, model_name) # type: ignore + + try: + if module and _is_model(annotation): + if rf: + rf._is_model = True + + return functools.partial(_deserialize_model, annotation) # pyright: ignore + except Exception: + pass + + # is it a literal? + try: + if annotation.__origin__ is typing.Literal: # pyright: ignore + return None + except AttributeError: + pass + + # is it optional? + try: + if any(a for a in annotation.__args__ if a == type(None)): # pyright: ignore + if len(annotation.__args__) <= 2: # pyright: ignore + if_obj_deserializer = _get_deserialize_callable_from_annotation( + next(a for a in annotation.__args__ if a != type(None)), module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_with_optional, if_obj_deserializer) + # the type is Optional[Union[...]], we need to remove the None type from the Union + annotation_copy = copy.copy(annotation) + annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a != type(None)] # pyright: ignore + return _get_deserialize_callable_from_annotation(annotation_copy, module, rf) + except AttributeError: + pass + + # is it union? + if getattr(annotation, "__origin__", None) is typing.Union: + # initial ordering is we make `string` the last deserialization option, because it is often them most generic + deserializers = [ + _get_deserialize_callable_from_annotation(arg, module, rf) + for arg in _sorted_annotations(annotation.__args__) # pyright: ignore + ] + + return functools.partial(_deserialize_with_union, deserializers) + + try: + if annotation._name == "Dict": # pyright: ignore + value_deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[1], module, rf # pyright: ignore + ) + + return functools.partial( + _deserialize_dict, + value_deserializer, + module, + ) + except (AttributeError, IndexError): + pass + try: + if annotation._name in ["List", "Set", "Tuple", "Sequence"]: # pyright: ignore + if len(annotation.__args__) > 1: # pyright: ignore + entry_deserializers = [ + _get_deserialize_callable_from_annotation(dt, module, rf) + for dt in annotation.__args__ # pyright: ignore + ] + return functools.partial(_deserialize_multiple_sequence, entry_deserializers, module) + deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[0], module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_sequence, deserializer, module) + except (TypeError, IndexError, AttributeError, SyntaxError): + pass + + def _deserialize_default( + deserializer, + obj, + ): + if obj is None: + return obj + try: + return _deserialize_with_callable(deserializer, obj) + except Exception: + pass + return obj + + if get_deserializer(annotation, rf): + return functools.partial(_deserialize_default, get_deserializer(annotation, rf)) + + return functools.partial(_deserialize_default, annotation) + + +def _deserialize_with_callable( + deserializer: typing.Optional[typing.Callable[[typing.Any], typing.Any]], + value: typing.Any, +): # pylint: disable=too-many-return-statements + try: + if value is None or isinstance(value, _Null): + return None + if isinstance(value, ET.Element): + if deserializer is str: + return value.text or "" + if deserializer is int: + return int(value.text) if value.text else None + if deserializer is float: + return float(value.text) if value.text else None + if deserializer is bool: + return value.text == "true" if value.text else None + if deserializer is None: + return value + if deserializer in [int, float, bool]: + return deserializer(value) + if isinstance(deserializer, CaseInsensitiveEnumMeta): + try: + return deserializer(value) + except ValueError: + # for unknown value, return raw value + return value + if isinstance(deserializer, type) and issubclass(deserializer, Model): + return deserializer._deserialize(value, []) + return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value) + except Exception as e: + raise DeserializationError() from e + + +def _deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + if isinstance(value, PipelineResponse): + value = value.http_response.json() + if rf is None and format: + rf = _RestField(format=format) + if not isinstance(deserializer, functools.partial): + deserializer = _get_deserialize_callable_from_annotation(deserializer, module, rf) + return _deserialize_with_callable(deserializer, value) + + +def _failsafe_deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + try: + return _deserialize(deserializer, value, module, rf, format) + except DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +def _failsafe_deserialize_xml( + deserializer: typing.Any, + value: typing.Any, +) -> typing.Any: + try: + return _deserialize_xml(deserializer, value) + except DeserializationError: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +class _RestField: + def __init__( + self, + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + is_discriminator: bool = False, + visibility: typing.Optional[typing.List[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[typing.Dict[str, typing.Any]] = None, + ): + self._type = type + self._rest_name_input = name + self._module: typing.Optional[str] = None + self._is_discriminator = is_discriminator + self._visibility = visibility + self._is_model = False + self._default = default + self._format = format + self._is_multipart_file_input = is_multipart_file_input + self._xml = xml if xml is not None else {} + + @property + def _class_type(self) -> typing.Any: + return getattr(self._type, "args", [None])[0] + + @property + def _rest_name(self) -> str: + if self._rest_name_input is None: + raise ValueError("Rest name was never set") + return self._rest_name_input + + def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin + # by this point, type and rest_name will have a value bc we default + # them in __new__ of the Model class + item = obj.get(self._rest_name) + if item is None: + return item + if self._is_model: + return item + return _deserialize(self._type, _serialize(item, self._format), rf=self) + + def __set__(self, obj: Model, value) -> None: + if value is None: + # we want to wipe out entries if users set attr to None + try: + obj.__delitem__(self._rest_name) + except KeyError: + pass + return + if self._is_model: + if not _is_model(value): + value = _deserialize(self._type, value) + obj.__setitem__(self._rest_name, value) + return + obj.__setitem__(self._rest_name, _serialize(value, self._format)) + + def _get_deserialize_callable_from_annotation( + self, annotation: typing.Any + ) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + return _get_deserialize_callable_from_annotation(annotation, self._module, self) + + +def rest_field( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[typing.List[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[typing.Dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField( + name=name, + type=type, + visibility=visibility, + default=default, + format=format, + is_multipart_file_input=is_multipart_file_input, + xml=xml, + ) + + +def rest_discriminator( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[typing.List[str]] = None, + xml: typing.Optional[typing.Dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField(name=name, type=type, is_discriminator=True, visibility=visibility, xml=xml) + + +def serialize_xml(model: Model, exclude_readonly: bool = False) -> str: + """Serialize a model to XML. + + :param Model model: The model to serialize. + :param bool exclude_readonly: Whether to exclude readonly properties. + :returns: The XML representation of the model. + :rtype: str + """ + return ET.tostring(_get_element(model, exclude_readonly), encoding="unicode") # type: ignore + + +def _get_element( + o: typing.Any, + exclude_readonly: bool = False, + parent_meta: typing.Optional[typing.Dict[str, typing.Any]] = None, + wrapped_element: typing.Optional[ET.Element] = None, +) -> typing.Union[ET.Element, typing.List[ET.Element]]: + if _is_model(o): + model_meta = getattr(o, "_xml", {}) + + # if prop is a model, then use the prop element directly, else generate a wrapper of model + if wrapped_element is None: + wrapped_element = _create_xml_element( + model_meta.get("name", o.__class__.__name__), + model_meta.get("prefix"), + model_meta.get("ns"), + ) + + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + + for k, v in o.items(): + # do not serialize readonly properties + if exclude_readonly and k in readonly_props: + continue + + prop_rest_field = _get_rest_field(o._attr_to_rest_field, k) + if prop_rest_field: + prop_meta = getattr(prop_rest_field, "_xml").copy() + # use the wire name as xml name if no specific name is set + if prop_meta.get("name") is None: + prop_meta["name"] = k + else: + # additional properties will not have rest field, use the wire name as xml name + prop_meta = {"name": k} + + # if no ns for prop, use model's + if prop_meta.get("ns") is None and model_meta.get("ns"): + prop_meta["ns"] = model_meta.get("ns") + prop_meta["prefix"] = model_meta.get("prefix") + + if prop_meta.get("unwrapped", False): + # unwrapped could only set on array + wrapped_element.extend(_get_element(v, exclude_readonly, prop_meta)) + elif prop_meta.get("text", False): + # text could only set on primitive type + wrapped_element.text = _get_primitive_type_value(v) + elif prop_meta.get("attribute", False): + xml_name = prop_meta.get("name", k) + if prop_meta.get("ns"): + ET.register_namespace(prop_meta.get("prefix"), prop_meta.get("ns")) # pyright: ignore + xml_name = "{" + prop_meta.get("ns") + "}" + xml_name # pyright: ignore + # attribute should be primitive type + wrapped_element.set(xml_name, _get_primitive_type_value(v)) + else: + # other wrapped prop element + wrapped_element.append(_get_wrapped_element(v, exclude_readonly, prop_meta)) + return wrapped_element + if isinstance(o, list): + return [_get_element(x, exclude_readonly, parent_meta) for x in o] # type: ignore + if isinstance(o, dict): + result = [] + for k, v in o.items(): + result.append( + _get_wrapped_element( + v, + exclude_readonly, + { + "name": k, + "ns": parent_meta.get("ns") if parent_meta else None, + "prefix": parent_meta.get("prefix") if parent_meta else None, + }, + ) + ) + return result + + # primitive case need to create element based on parent_meta + if parent_meta: + return _get_wrapped_element( + o, + exclude_readonly, + { + "name": parent_meta.get("itemsName", parent_meta.get("name")), + "prefix": parent_meta.get("itemsPrefix", parent_meta.get("prefix")), + "ns": parent_meta.get("itemsNs", parent_meta.get("ns")), + }, + ) + + raise ValueError("Could not serialize value into xml: " + o) + + +def _get_wrapped_element( + v: typing.Any, + exclude_readonly: bool, + meta: typing.Optional[typing.Dict[str, typing.Any]], +) -> ET.Element: + wrapped_element = _create_xml_element( + meta.get("name") if meta else None, meta.get("prefix") if meta else None, meta.get("ns") if meta else None + ) + if isinstance(v, (dict, list)): + wrapped_element.extend(_get_element(v, exclude_readonly, meta)) + elif _is_model(v): + _get_element(v, exclude_readonly, meta, wrapped_element) + else: + wrapped_element.text = _get_primitive_type_value(v) + return wrapped_element + + +def _get_primitive_type_value(v) -> str: + if v is True: + return "true" + if v is False: + return "false" + if isinstance(v, _Null): + return "" + return str(v) + + +def _create_xml_element(tag, prefix=None, ns=None): + if prefix and ns: + ET.register_namespace(prefix, ns) + if ns: + return ET.Element("{" + ns + "}" + tag) + return ET.Element(tag) + + +def _deserialize_xml( + deserializer: typing.Any, + value: str, +) -> typing.Any: + element = ET.fromstring(value) # nosec + return _deserialize(deserializer, element) + + +def _convert_element(e: ET.Element): + # dict case + if len(e.attrib) > 0 or len({child.tag for child in e}) > 1: + dict_result: typing.Dict[str, typing.Any] = {} + for child in e: + if dict_result.get(child.tag) is not None: + if isinstance(dict_result[child.tag], list): + dict_result[child.tag].append(_convert_element(child)) + else: + dict_result[child.tag] = [dict_result[child.tag], _convert_element(child)] + else: + dict_result[child.tag] = _convert_element(child) + dict_result.update(e.attrib) + return dict_result + # array case + if len(e) > 0: + array_result: typing.List[typing.Any] = [] + for child in e: + array_result.append(_convert_element(child)) + return array_result + # primitive case + return e.text diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_operations/__init__.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_operations/__init__.py new file mode 100644 index 00000000000..5dd3cd1a25e --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_operations/__init__.py @@ -0,0 +1,25 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Unbranded (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import StatusCodeRangeClientOperationsMixin # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "StatusCodeRangeClientOperationsMixin", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py new file mode 100644 index 00000000000..eab51d7c9d6 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py @@ -0,0 +1,187 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Unbranded (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Literal, Optional, TypeVar + +from corehttp.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from corehttp.rest import HttpRequest, HttpResponse +from corehttp.runtime.pipeline import PipelineResponse +from corehttp.utils import case_insensitive_dict + +from .. import models as _models +from .._model_base import _deserialize, _failsafe_deserialize +from .._serialization import Serializer +from .._vendor import StatusCodeRangeClientMixinABC + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_status_code_range_error_response_status_code_in_range_request( # pylint: disable=name-too-long + **kwargs: Any, +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/response/status-code-range/error-response-status-code-in-range" + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + +def build_status_code_range_error_response_status_code404_request( # pylint: disable=name-too-long + **kwargs: Any, +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/response/status-code-range/error-response-status-code-404" + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + +class StatusCodeRangeClientOperationsMixin(StatusCodeRangeClientMixinABC): + + def error_response_status_code_in_range(self, **kwargs: Any) -> Literal[204]: + """error_response_status_code_in_range. + + :return: constant + :rtype: int + :raises ~corehttp.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Literal[204]] = kwargs.pop("cls", None) + + _request = build_status_code_range_error_response_status_code_in_range_request( + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client.pipeline.run(_request, stream=_stream, **kwargs) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = None + if 494 <= response.status_code <= 499: + error = _failsafe_deserialize(_models.ErrorInRange, response.json()) + else: + error = _failsafe_deserialize(_models.DefaultError, response.json()) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(Literal[204], response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def error_response_status_code404(self, **kwargs: Any) -> Literal[204]: + """error_response_status_code404. + + :return: constant + :rtype: int + :raises ~corehttp.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Literal[204]] = kwargs.pop("cls", None) + + _request = build_status_code_range_error_response_status_code404_request( + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client.pipeline.run(_request, stream=_stream, **kwargs) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = None + if response.status_code == 404: + error = _failsafe_deserialize(_models.NotFoundError, response.json()) + raise ResourceNotFoundError(response=response, model=error) + elif 400 <= response.status_code <= 499: + error = _failsafe_deserialize(_models.Standard4XXError, response.json()) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(Literal[204], response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_operations/_patch.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_operations/_patch.py new file mode 100644 index 00000000000..cc9d8be1c50 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Unbranded Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_patch.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_patch.py new file mode 100644 index 00000000000..cc9d8be1c50 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Unbranded Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_serialization.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_serialization.py new file mode 100644 index 00000000000..00075c6255e --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_serialization.py @@ -0,0 +1,2050 @@ +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# +# Copyright (c) Unbranded Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# 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. +# +# -------------------------------------------------------------------------- + +# pyright: reportUnnecessaryTypeIgnoreComment=false + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +from typing import ( + Dict, + Any, + cast, + Optional, + Union, + AnyStr, + IO, + Mapping, + Callable, + MutableMapping, + List, +) + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote +import xml.etree.ElementTree as ET + +import isodate # type: ignore +from typing_extensions import Self + +from corehttp.exceptions import DeserializationError, SerializationError +from corehttp.serialization import NULL as CoreNull + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +JSON = MutableMapping[str, Any] + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + :return: The deserialized data. + :rtype: object + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) from err + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError as err: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str + raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + + :param bytes body_bytes: The body of the response. + :param dict headers: The headers of the response. + :returns: The deserialized data. + :rtype: object + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + +TZ_UTC = datetime.timezone.utc + +_FLATTEN = re.compile(r"(? None: + self.additional_properties: Optional[Dict[str, Any]] = {} + for k in kwargs: # pylint: disable=consider-using-dict-items + if k not in self._attribute_map: + _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) + elif k in self._validation and self._validation[k].get("readonly", False): + _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) + else: + setattr(self, k, kwargs[k]) + + def __eq__(self, other: Any) -> bool: + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are equal + :rtype: bool + """ + if isinstance(other, self.__class__): + return self.__dict__ == other.__dict__ + return False + + def __ne__(self, other: Any) -> bool: + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are not equal + :rtype: bool + """ + return not self.__eq__(other) + + def __str__(self) -> str: + return str(self.__dict__) + + @classmethod + def enable_additional_properties_sending(cls) -> None: + cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} + + @classmethod + def is_xml_model(cls) -> bool: + try: + cls._xml_map # type: ignore + except AttributeError: + return False + return True + + @classmethod + def _create_xml_node(cls): + """Create XML node. + + :returns: The XML node + :rtype: xml.etree.ElementTree.Element + """ + try: + xml_map = cls._xml_map # type: ignore + except AttributeError: + xml_map = {} + + return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) + + def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: + """Return the JSON that would be sent to server from this model. + + This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param bool keep_readonly: If you want to serialize the readonly attributes + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, keep_readonly=keep_readonly, **kwargs + ) + + def as_dict( + self, + keep_readonly: bool = True, + key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + **kwargs: Any + ) -> JSON: + """Return a dict that can be serialized using json.dump. + + Advanced usage might optionally use a callback as parameter: + + .. code::python + + def my_key_transformer(key, attr_desc, value): + return key + + Key is the attribute name used in Python. Attr_desc + is a dict of metadata. Currently contains 'type' with the + msrest type and 'key' with the RestAPI encoded key. + Value is the current value in this object. + + The string returned will be used to serialize the key. + If the return type is a list, this is considered hierarchical + result dict. + + See the three examples in this file: + + - attribute_transformer + - full_restapi_key_transformer + - last_restapi_key_transformer + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param bool keep_readonly: If you want to serialize the readonly attributes + :param function key_transformer: A key transformer function. + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs + ) + + @classmethod + def _infer_class_models(cls): + try: + str_models = cls.__module__.rsplit(".", 1)[0] + models = sys.modules[str_models] + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + if cls.__name__ not in client_models: + raise ValueError("Not Autorest generated code") + except Exception: # pylint: disable=broad-exception-caught + # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. + client_models = {cls.__name__: cls} + return client_models + + @classmethod + def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: + """Parse a str using the RestAPI syntax and return a model. + + :param str data: A str using RestAPI structure. JSON by default. + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises DeserializationError: if something went wrong + :rtype: Self + """ + deserializer = Deserializer(cls._infer_class_models()) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore + + @classmethod + def from_dict( + cls, + data: Any, + key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + content_type: Optional[str] = None, + ) -> Self: + """Parse a dict using given key extractor return a model. + + By default consider key + extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor + and last_rest_key_case_insensitive_extractor) + + :param dict data: A dict using RestAPI structure + :param function key_extractors: A key extractor function. + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises: DeserializationError if something went wrong + :rtype: Self + """ + deserializer = Deserializer(cls._infer_class_models()) + deserializer.key_extractors = ( # type: ignore + [ # type: ignore + attribute_key_case_insensitive_extractor, + rest_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + if key_extractors is None + else key_extractors + ) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore + + @classmethod + def _flatten_subtype(cls, key, objects): + if "_subtype_map" not in cls.__dict__: + return {} + result = dict(cls._subtype_map[key]) + for valuetype in cls._subtype_map[key].values(): + result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access + return result + + @classmethod + def _classify(cls, response, objects): + """Check the class _subtype_map for any child classes. + We want to ignore any inherited _subtype_maps. + + :param dict response: The initial data + :param dict objects: The class objects + :returns: The class to be used + :rtype: class + """ + for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): + subtype_value = None + + if not isinstance(response, ET.Element): + rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] + subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) + else: + subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) + if subtype_value: + # Try to match base class. Can be class name only + # (bug to fix in Autorest to support x-ms-discriminator-name) + if cls.__name__ == subtype_value: + return cls + flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) + try: + return objects[flatten_mapping_type[subtype_value]] # type: ignore + except KeyError: + _LOGGER.warning( + "Subtype value %s has no mapping, use base class %s.", + subtype_value, + cls.__name__, + ) + break + else: + _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) + break + return cls + + @classmethod + def _get_rest_key_parts(cls, attr_key): + """Get the RestAPI key of this attr, split it and decode part + :param str attr_key: Attribute key must be in attribute_map. + :returns: A list of RestAPI part + :rtype: list + """ + rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) + return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] + + +def _decode_attribute_map_key(key): + """This decode a key in an _attribute_map to the actual key we want to look at + inside the received data. + + :param str key: A key string from the generated code + :returns: The decoded key + :rtype: str + """ + return key.replace("\\.", ".") + + +class Serializer: # pylint: disable=too-many-public-methods + """Request object model serializer.""" + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} + days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} + months = { + 1: "Jan", + 2: "Feb", + 3: "Mar", + 4: "Apr", + 5: "May", + 6: "Jun", + 7: "Jul", + 8: "Aug", + 9: "Sep", + 10: "Oct", + 11: "Nov", + 12: "Dec", + } + validation = { + "min_length": lambda x, y: len(x) < y, + "max_length": lambda x, y: len(x) > y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals + self, target_obj, data_type=None, **kwargs + ): + """Serialize data into a string according to type. + + :param object target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises SerializationError: if serialization fails. + :returns: The serialized data. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() # pylint: disable=protected-access + try: + attributes = target_obj._attribute_map # pylint: disable=protected-access + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access + attr_name, {} + ).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) # type: ignore + continue + if xml_desc.get("text", False): + serialized.text = new_attr # type: ignore + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) # type: ignore + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, + # we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) # type: ignore + else: # That's a basic type + # Integrate namespace if necessary + local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) + local_node.text = str(new_attr) + serialized.append(local_node) # type: ignore + else: # JSON + for k in reversed(keys): # type: ignore + new_attr = {k: new_attr} + + _new_attr = new_attr + _serialized = serialized + for k in keys: # type: ignore + if k not in _serialized: + _serialized.update(_new_attr) # type: ignore + _new_attr = _new_attr[k] # type: ignore + _serialized = _serialized[k] + except ValueError as err: + if isinstance(err, SerializationError): + raise + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) + raise SerializationError(msg) from err + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises SerializationError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized request body + """ + + # Just in case this is a dict + internal_data_type_str = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type_str, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ # type: ignore + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access + except DeserializationError as err: + raise SerializationError("Unable to build a model: " + str(err)) from err + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param str name: The name of the URL path parameter. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :returns: The serialized URL path + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) + else: + output = quote(str(output), safe="") + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param str name: The name of the query parameter. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, list + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized query parameter + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + do_quote = not kwargs.get("skip_quote", False) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param str name: The name of the header. + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized header + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param object data: The data to be serialized. + :param str data_type: The type to be serialized from. + :raises AttributeError: if required data is None. + :raises ValueError: if data is None + :raises SerializationError: if serialization fails. + :returns: The serialized data. + :rtype: str, int, float, bool, dict, list + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data is CoreNull: + return None + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + if data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise SerializationError(msg.format(data, data_type)) from err + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param obj data: Object to be serialized. + :param str data_type: Type of object in the iterable. + :rtype: str, int, float, bool + :return: serialized object + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == "str": + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec # pylint: disable=eval-used + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param str data: Object to be serialized. + :rtype: str + :return: serialized object + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): # type: ignore + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list data: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + Defaults to False. + :rtype: list, str + :return: serialized iterable + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError as err: + if isinstance(err, SerializationError): + raise + serialized.append(None) + + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + + if div: + serialized = ["" if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :rtype: dict + :return: serialized dictionary + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError as err: + if isinstance(err, SerializationError): + raise + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + :return: serialized object + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + if obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) # type: ignore + return result + except ValueError as exc: + for enum_value in enum_obj: # type: ignore + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) from exc + + @staticmethod + def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument + """Serialize bytearray into base-64 string. + + :param str attr: Object to be serialized. + :rtype: str + :return: serialized base64 + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument + """Serialize str into base-64 string. + + :param str attr: Object to be serialized. + :rtype: str + :return: serialized base64 + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Decimal object to float. + + :param decimal attr: Object to be serialized. + :rtype: float + :return: serialized decimal + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): # pylint: disable=unused-argument + """Serialize long (Py2) or int (Py3). + + :param int attr: Object to be serialized. + :rtype: int/long + :return: serialized long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + :return: serialized date + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + :return: serialized time + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + :return: serialized duration + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises TypeError: if format invalid. + :return: serialized rfc + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError as exc: + raise TypeError("RFC1123 object must be valid Datetime object.") from exc + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises SerializationError: if format invalid. + :return: serialized iso + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise SerializationError(msg) from err + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise TypeError(msg) from err + + @staticmethod + def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises SerializationError: if format invalid + :return: serialied unix + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError as exc: + raise TypeError("Unix time object must be valid Datetime object.") from exc + + +def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + key = attr_desc["key"] + working_data = data + + while "." in key: + # Need the cast, as for some reasons "split" is typed as list[str | Any] + dict_keys = cast(List[str], _FLATTEN.split(key)) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + return None + key = ".".join(dict_keys[1:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements + attr, attr_desc, data +): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + return None + key = ".".join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get("name", internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer: + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.key_extractors = [rest_key_extractor, xml_key_extractor] + # Additional properties only works if the "rest_key_extractor" is used to + # extract the keys. Making it to work whatever the key extractor is too much + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, str): + return self.deserialize_data(data, response) + if isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None or data is CoreNull: + return data + try: + attributes = response._attribute_map # type: ignore # pylint: disable=protected-access + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc["type"]) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name # type: ignore + raise DeserializationError(msg) from err + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + :return: The classified target object and its class name. + :rtype: tuple + """ + if target is None: + return None, None + + if isinstance(target, str): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ # type: ignore + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + :param str content_type: Swagger "produces" if available. + :return: Deserialized object. + :rtype: object + """ + try: + return self(target_obj, data, content_type=content_type) + except: # pylint: disable=bare-except + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param obj raw_data: Data to be processed. + :param str content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + :rtype: object + :return: Unpacked content. + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, "_content_consumed"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) + + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param Response response: The response model class. + :param dict attrs: The deserialized response attributes. + :param dict additional_properties: Additional properties to be set. + :rtype: Response + :return: The instantiated response model. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("readonly") + ] + const = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("constant") + ] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties # type: ignore + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore + raise DeserializationError(msg + str(err)) from err + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) from exp + + def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises DeserializationError: if deserialization fails. + :return: Deserialized object. + :rtype: object + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment + "object", + "[]", + r"{}", + ] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise DeserializationError(msg) from err + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :return: Deserialized iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :return: Deserialized dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :return: Deserialized object. + :rtype: dict + :raises TypeError: if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, str): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :return: Deserialized basic type. + :rtype: str, int, float or bool + :raises TypeError: if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + if isinstance(attr, str): + if attr.lower() in ["true", "1"]: + return True + if attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec # pylint: disable=eval-used + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :return: Deserialized string. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): # type: ignore + return data + except NameError: + return str(data) + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :return: Deserialized enum object. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + try: + return list(enum_obj.__members__.values())[data] + except IndexError as exc: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) from exc + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :return: Deserialized bytearray + :rtype: bytearray + :raises TypeError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) # type: ignore + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :return: Deserialized base64 string + :rtype: bytearray + :raises TypeError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :return: Deserialized decimal + :raises DeserializationError: if string format invalid. + :rtype: decimal + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(str(attr)) # type: ignore + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise DeserializationError(msg) from err + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :return: Deserialized int + :rtype: long or int + :raises ValueError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) # type: ignore + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :return: Deserialized duration + :rtype: TimeDelta + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise DeserializationError(msg) from err + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :return: Deserialized date + :rtype: Date + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :return: Deserialized time + :rtype: datetime.time + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :return: Deserialized RFC datetime + :rtype: Datetime + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) # type: ignore + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise DeserializationError(msg) from err + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :return: Deserialized ISO datetime + :rtype: Datetime + :raises DeserializationError: if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() # type: ignore + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise DeserializationError(msg) from err + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :return: Deserialized datetime + :rtype: Datetime + :raises DeserializationError: if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) # type: ignore + try: + attr = int(attr) + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise DeserializationError(msg) from err + return date_obj diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_vendor.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_vendor.py new file mode 100644 index 00000000000..2d3bd26cfdf --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_vendor.py @@ -0,0 +1,25 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Unbranded (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from ._configuration import StatusCodeRangeClientConfiguration + +if TYPE_CHECKING: + from corehttp.runtime import PipelineClient + + from ._serialization import Deserializer, Serializer + + +class StatusCodeRangeClientMixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "PipelineClient" + _config: StatusCodeRangeClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_version.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_version.py new file mode 100644 index 00000000000..2a6e487ad06 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Unbranded (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/__init__.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/__init__.py new file mode 100644 index 00000000000..bace18b4382 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/__init__.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Unbranded (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._client import StatusCodeRangeClient # type: ignore + +try: + from ._patch import __all__ as _patch_all + from ._patch import * +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "StatusCodeRangeClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore + +_patch_sdk() diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_client.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_client.py new file mode 100644 index 00000000000..7a0ad731287 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_client.py @@ -0,0 +1,86 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Unbranded (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable +from typing_extensions import Self + +from corehttp.rest import AsyncHttpResponse, HttpRequest +from corehttp.runtime import AsyncPipelineClient, policies + +from .._serialization import Deserializer, Serializer +from ._configuration import StatusCodeRangeClientConfiguration +from ._operations import StatusCodeRangeClientOperationsMixin + + +class StatusCodeRangeClient(StatusCodeRangeClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword + """Test for range of status code. + + :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: + _endpoint = "{endpoint}" + self._config = StatusCodeRangeClientConfiguration(endpoint=endpoint, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + self._config.retry_policy, + self._config.authentication_policy, + self._config.logging_policy, + ] + self._client: AsyncPipelineClient = AsyncPipelineClient(endpoint=_endpoint, policies=_policies, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + + def send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from corehttp.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~corehttp.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~corehttp.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> Self: + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_configuration.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_configuration.py new file mode 100644 index 00000000000..44538955421 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_configuration.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Unbranded (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any + +from corehttp.runtime import policies + +from .._version import VERSION + + +class StatusCodeRangeClientConfiguration: + """Configuration for StatusCodeRangeClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: Service host. Default value is "http://localhost:3000". + :type endpoint: str + """ + + def __init__(self, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None: + + self.endpoint = endpoint + kwargs.setdefault("sdk_moniker", "response-statuscoderange/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_operations/__init__.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_operations/__init__.py new file mode 100644 index 00000000000..5dd3cd1a25e --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_operations/__init__.py @@ -0,0 +1,25 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Unbranded (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import StatusCodeRangeClientOperationsMixin # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "StatusCodeRangeClientOperationsMixin", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py new file mode 100644 index 00000000000..25932c2b754 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py @@ -0,0 +1,158 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Unbranded (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Literal, Optional, TypeVar + +from corehttp.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from corehttp.rest import AsyncHttpResponse, HttpRequest +from corehttp.runtime.pipeline import PipelineResponse + +from ... import models as _models +from ..._model_base import _deserialize, _failsafe_deserialize +from ..._operations._operations import ( + build_status_code_range_error_response_status_code404_request, + build_status_code_range_error_response_status_code_in_range_request, +) +from .._vendor import StatusCodeRangeClientMixinABC + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class StatusCodeRangeClientOperationsMixin(StatusCodeRangeClientMixinABC): + + async def error_response_status_code_in_range(self, **kwargs: Any) -> Literal[204]: + """error_response_status_code_in_range. + + :return: constant + :rtype: int + :raises ~corehttp.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Literal[204]] = kwargs.pop("cls", None) + + _request = build_status_code_range_error_response_status_code_in_range_request( + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client.pipeline.run( # type: ignore + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = None + if 494 <= response.status_code <= 499: + error = _failsafe_deserialize(_models.ErrorInRange, response.json()) + else: + error = _failsafe_deserialize(_models.DefaultError, response.json()) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(Literal[204], response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def error_response_status_code404(self, **kwargs: Any) -> Literal[204]: + """error_response_status_code404. + + :return: constant + :rtype: int + :raises ~corehttp.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Literal[204]] = kwargs.pop("cls", None) + + _request = build_status_code_range_error_response_status_code404_request( + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client.pipeline.run( # type: ignore + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = None + if response.status_code == 404: + error = _failsafe_deserialize(_models.NotFoundError, response.json()) + raise ResourceNotFoundError(response=response, model=error) + elif 400 <= response.status_code <= 499: + error = _failsafe_deserialize(_models.Standard4XXError, response.json()) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(Literal[204], response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_operations/_patch.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_operations/_patch.py new file mode 100644 index 00000000000..cc9d8be1c50 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Unbranded Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_patch.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_patch.py new file mode 100644 index 00000000000..cc9d8be1c50 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Unbranded Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_vendor.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_vendor.py new file mode 100644 index 00000000000..97a7c86260f --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_vendor.py @@ -0,0 +1,25 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Unbranded (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from abc import ABC +from typing import TYPE_CHECKING + +from ._configuration import StatusCodeRangeClientConfiguration + +if TYPE_CHECKING: + from corehttp.runtime import AsyncPipelineClient + + from .._serialization import Deserializer, Serializer + + +class StatusCodeRangeClientMixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + + _client: "AsyncPipelineClient" + _config: StatusCodeRangeClientConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/models/__init__.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/models/__init__.py new file mode 100644 index 00000000000..8999bca0bac --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/models/__init__.py @@ -0,0 +1,33 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Unbranded (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models import ( # type: ignore + DefaultError, + ErrorInRange, + NotFoundError, + Standard4XXError, +) +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "DefaultError", + "ErrorInRange", + "NotFoundError", + "Standard4XXError", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/models/_models.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/models/_models.py new file mode 100644 index 00000000000..a34eea253e4 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/models/_models.py @@ -0,0 +1,143 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Unbranded (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=useless-super-delegation + +from typing import Any, Mapping, overload + +from .. import _model_base +from .._model_base import rest_field + + +class DefaultError(_model_base.Model): + """DefaultError. + + All required parameters must be populated in order to send to server. + + :ivar code: Required. + :vartype code: str + """ + + code: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + code: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ErrorInRange(_model_base.Model): + """ErrorInRange. + + All required parameters must be populated in order to send to server. + + :ivar code: Required. + :vartype code: str + :ivar message: Required. + :vartype message: str + """ + + code: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + message: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + code: str, + message: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class NotFoundError(_model_base.Model): + """NotFoundError. + + All required parameters must be populated in order to send to server. + + :ivar code: Required. + :vartype code: str + :ivar resource_id: Required. + :vartype resource_id: str + """ + + code: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + resource_id: str = rest_field(name="resourceId", visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + code: str, + resource_id: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Standard4XXError(_model_base.Model): + """Standard4XXError. + + All required parameters must be populated in order to send to server. + + :ivar code: Required. + :vartype code: str + """ + + code: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + + @overload + def __init__( + self, + *, + code: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/models/_patch.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/models/_patch.py new file mode 100644 index 00000000000..cc9d8be1c50 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Unbranded Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__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/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/py.typed b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/setup.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/setup.py new file mode 100644 index 00000000000..34ab0f06afb --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/setup.py @@ -0,0 +1,67 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Unbranded Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Unbranded (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# coding: utf-8 + +import os +import re +from setuptools import setup, find_packages + + +PACKAGE_NAME = "response-statuscoderange" +PACKAGE_PPRINT_NAME = "Response Statuscoderange" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace("-", "/") + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, "_version.py"), "r") as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError("Cannot find version information") + + +setup( + name=PACKAGE_NAME, + version=version, + description="Unbranded {} Client Library for Python".format(PACKAGE_PPRINT_NAME), + long_description=open("README.md", "r").read(), + long_description_content_type="text/markdown", + license="MIT License", + author="Unbranded Corporation", + classifiers=[ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "License :: OSI Approved :: MIT License", + ], + zip_safe=False, + packages=find_packages( + exclude=[ + "tests", + # Exclude packages that will be covered by PEP420 or nspkg + "response", + ] + ), + include_package_data=True, + package_data={ + "response.statuscoderange": ["py.typed"], + }, + install_requires=[ + "isodate>=0.6.1", + "corehttp[requests]", + "typing-extensions>=4.6.0", + ], + python_requires=">=3.8", +) diff --git a/packages/typespec-python/test/unbranded/generated/serialization-encoded-name-json/serialization/encodedname/json/property/models/_models.py b/packages/typespec-python/test/unbranded/generated/serialization-encoded-name-json/serialization/encodedname/json/property/models/_models.py index e413b68f10a..0709df6fb3a 100644 --- a/packages/typespec-python/test/unbranded/generated/serialization-encoded-name-json/serialization/encodedname/json/property/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/serialization-encoded-name-json/serialization/encodedname/json/property/models/_models.py @@ -21,7 +21,7 @@ class JsonEncodedNameModel(_model_base.Model): :vartype default_name: bool """ - default_name: bool = rest_field(name="wireName") + default_name: bool = rest_field(name="wireName", visibility=["read", "create", "update", "delete", "query"]) """Pass in true. Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/special-words/specialwords/modelproperties/models/_models.py b/packages/typespec-python/test/unbranded/generated/special-words/specialwords/modelproperties/models/_models.py index 3be9088cd7d..fd8ae88ba4e 100644 --- a/packages/typespec-python/test/unbranded/generated/special-words/specialwords/modelproperties/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/special-words/specialwords/modelproperties/models/_models.py @@ -22,7 +22,7 @@ class SameAsModel(_model_base.Model): :vartype same_as_model: str """ - same_as_model: str = rest_field(name="SameAsModel") + same_as_model: str = rest_field(name="SameAsModel", visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/special-words/specialwords/models/models/_models.py b/packages/typespec-python/test/unbranded/generated/special-words/specialwords/models/models/_models.py index a1e22076922..d1ec40657e2 100644 --- a/packages/typespec-python/test/unbranded/generated/special-words/specialwords/models/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/special-words/specialwords/models/models/_models.py @@ -23,7 +23,7 @@ class AndModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -53,7 +53,7 @@ class AsModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -83,7 +83,7 @@ class AssertModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -113,7 +113,7 @@ class AsyncModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -143,7 +143,7 @@ class AwaitModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -173,7 +173,7 @@ class BreakModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -203,7 +203,7 @@ class ClassModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -233,7 +233,7 @@ class Constructor(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -263,7 +263,7 @@ class ContinueModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -293,7 +293,7 @@ class DefModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -323,7 +323,7 @@ class DelModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -353,7 +353,7 @@ class ElifModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -383,7 +383,7 @@ class ElseModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -413,7 +413,7 @@ class ExceptModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -443,7 +443,7 @@ class ExecModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -473,7 +473,7 @@ class FinallyModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -503,7 +503,7 @@ class ForModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -533,7 +533,7 @@ class FromModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -563,7 +563,7 @@ class GlobalModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -593,7 +593,7 @@ class IfModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -623,7 +623,7 @@ class ImportModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -653,7 +653,7 @@ class InModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -683,7 +683,7 @@ class IsModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -713,7 +713,7 @@ class LambdaModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -743,7 +743,7 @@ class NotModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -773,7 +773,7 @@ class OrModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -803,7 +803,7 @@ class PassModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -833,7 +833,7 @@ class RaiseModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -863,7 +863,7 @@ class ReturnModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -893,7 +893,7 @@ class TryModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -923,7 +923,7 @@ class WhileModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -953,7 +953,7 @@ class WithModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -983,7 +983,7 @@ class YieldModel(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/typetest-array/typetest/array/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-array/typetest/array/models/_models.py index c41793695a5..958abea9cf1 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-array/typetest/array/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-array/typetest/array/models/_models.py @@ -26,9 +26,11 @@ class InnerModel(_model_base.Model): :vartype children: list[~typetest.array.models.InnerModel] """ - property: str = rest_field() + property: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required string property. Required.""" - children: Optional[List["_models.InnerModel"]] = rest_field() + children: Optional[List["_models.InnerModel"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) @overload def __init__( diff --git a/packages/typespec-python/test/unbranded/generated/typetest-dictionary/typetest/dictionary/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-dictionary/typetest/dictionary/models/_models.py index dc37a299a4a..82822cb115c 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-dictionary/typetest/dictionary/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-dictionary/typetest/dictionary/models/_models.py @@ -26,9 +26,11 @@ class InnerModel(_model_base.Model): :vartype children: dict[str, ~typetest.dictionary.models.InnerModel] """ - property: str = rest_field() + property: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required string property. Required.""" - children: Optional[Dict[str, "_models.InnerModel"]] = rest_field() + children: Optional[Dict[str, "_models.InnerModel"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) @overload def __init__( diff --git a/packages/typespec-python/test/unbranded/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/models/_models.py index 6a5673d33ed..2af220ea8fa 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/models/_models.py @@ -28,9 +28,9 @@ class Snake(_model_base.Model): """ __mapping__: Dict[str, _model_base.Model] = {} - kind: str = rest_discriminator(name="kind") + kind: str = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) """discriminator property. Required. \"cobra\"""" - length: int = rest_field() + length: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Length of the snake. Required.""" @overload @@ -62,7 +62,7 @@ class Cobra(Snake, discriminator="cobra"): :vartype kind: str or ~typetest.model.enumdiscriminator.models.COBRA """ - kind: Literal[SnakeKind.COBRA] = rest_discriminator(name="kind") # type: ignore + kind: Literal[SnakeKind.COBRA] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """discriminator property. Required. Species cobra""" @overload @@ -97,9 +97,9 @@ class Dog(_model_base.Model): """ __mapping__: Dict[str, _model_base.Model] = {} - kind: str = rest_discriminator(name="kind") + kind: str = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) """discriminator property. Required. \"golden\"""" - weight: int = rest_field() + weight: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Weight of the dog. Required.""" @overload @@ -131,7 +131,7 @@ class Golden(Dog, discriminator="golden"): :vartype kind: str or ~typetest.model.enumdiscriminator.models.GOLDEN """ - kind: Literal[DogKind.GOLDEN] = rest_discriminator(name="kind") # type: ignore + kind: Literal[DogKind.GOLDEN] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """discriminator property. Required. Species golden""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/models/_models.py index 7c6e93b2b97..0edcd59542b 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/models/_models.py @@ -32,7 +32,7 @@ class Fish(_model_base.Model): __mapping__: Dict[str, _model_base.Model] = {} kind: str = rest_discriminator(name="kind") """Discriminator property for Fish. Required. Default value is None.""" - age: int = rest_field() + age: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -71,9 +71,9 @@ class Shark(Fish, discriminator="shark"): """ __mapping__: Dict[str, _model_base.Model] = {} - kind: Literal["shark"] = rest_discriminator(name="kind") # type: ignore + kind: Literal["shark"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long """Required. Default value is \"shark\".""" - sharktype: str = rest_discriminator(name="sharktype") + sharktype: str = rest_discriminator(name="sharktype", visibility=["read", "create", "update", "delete", "query"]) """Required. Default value is None.""" @overload @@ -108,7 +108,7 @@ class GoblinShark(Shark, discriminator="goblin"): """ __mapping__: Dict[str, _model_base.Model] = {} - sharktype: Literal["goblin"] = rest_discriminator(name="sharktype") # type: ignore + sharktype: Literal["goblin"] = rest_discriminator(name="sharktype", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"goblin\".""" @overload @@ -146,11 +146,11 @@ class Salmon(Fish, discriminator="salmon"): :vartype partner: ~typetest.model.nesteddiscriminator.models.Fish """ - kind: Literal["salmon"] = rest_discriminator(name="kind") # type: ignore + kind: Literal["salmon"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"salmon\".""" - friends: Optional[List["_models.Fish"]] = rest_field() - hate: Optional[Dict[str, "_models.Fish"]] = rest_field() - partner: Optional["_models.Fish"] = rest_field() + friends: Optional[List["_models.Fish"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + hate: Optional[Dict[str, "_models.Fish"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + partner: Optional["_models.Fish"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @overload def __init__( @@ -186,7 +186,7 @@ class SawShark(Shark, discriminator="saw"): """ __mapping__: Dict[str, _model_base.Model] = {} - sharktype: Literal["saw"] = rest_discriminator(name="sharktype") # type: ignore + sharktype: Literal["saw"] = rest_discriminator(name="sharktype", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"saw\".""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/typetest-model-notdiscriminated/typetest/model/notdiscriminated/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-model-notdiscriminated/typetest/model/notdiscriminated/models/_models.py index 8eaa01dd6cc..421d5963edd 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-model-notdiscriminated/typetest/model/notdiscriminated/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-model-notdiscriminated/typetest/model/notdiscriminated/models/_models.py @@ -21,7 +21,7 @@ class Pet(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -52,7 +52,7 @@ class Cat(Pet): :vartype age: int """ - age: int = rest_field() + age: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -86,7 +86,7 @@ class Siamese(Cat): :vartype smart: bool """ - smart: bool = rest_field() + smart: bool = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/typetest-model-recursive/typetest/model/recursive/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-model-recursive/typetest/model/recursive/models/_models.py index b2d04e9a81f..3df5e36bff5 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-model-recursive/typetest/model/recursive/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-model-recursive/typetest/model/recursive/models/_models.py @@ -23,7 +23,9 @@ class Element(_model_base.Model): :vartype extension: list[~typetest.model.recursive.models.Extension] """ - extension: Optional[List["_models.Extension"]] = rest_field() + extension: Optional[List["_models.Extension"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) @overload def __init__( @@ -53,7 +55,7 @@ class Extension(Element): :vartype level: int """ - level: int = rest_field() + level: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/models/_models.py index fc93ece0043..a83c1d64cf1 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/models/_models.py @@ -30,9 +30,9 @@ class Bird(_model_base.Model): """ __mapping__: Dict[str, _model_base.Model] = {} - kind: str = rest_discriminator(name="kind") + kind: str = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) """Required. Default value is None.""" - wingspan: int = rest_field() + wingspan: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -71,7 +71,7 @@ class Dinosaur(_model_base.Model): __mapping__: Dict[str, _model_base.Model] = {} kind: str = rest_discriminator(name="kind") """Discriminator property for Dinosaur. Required. Default value is None.""" - size: int = rest_field() + size: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -110,11 +110,11 @@ class Eagle(Bird, discriminator="eagle"): :vartype partner: ~typetest.model.singlediscriminator.models.Bird """ - kind: Literal["eagle"] = rest_discriminator(name="kind") # type: ignore + kind: Literal["eagle"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long """Required. Default value is \"eagle\".""" - friends: Optional[List["_models.Bird"]] = rest_field() - hate: Optional[Dict[str, "_models.Bird"]] = rest_field() - partner: Optional["_models.Bird"] = rest_field() + friends: Optional[List["_models.Bird"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + hate: Optional[Dict[str, "_models.Bird"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + partner: Optional["_models.Bird"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @overload def __init__( @@ -147,7 +147,7 @@ class Goose(Bird, discriminator="goose"): :vartype kind: str """ - kind: Literal["goose"] = rest_discriminator(name="kind") # type: ignore + kind: Literal["goose"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long """Required. Default value is \"goose\".""" @overload @@ -178,7 +178,7 @@ class SeaGull(Bird, discriminator="seagull"): :vartype kind: str """ - kind: Literal["seagull"] = rest_discriminator(name="kind") # type: ignore + kind: Literal["seagull"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"seagull\".""" @overload @@ -209,7 +209,7 @@ class Sparrow(Bird, discriminator="sparrow"): :vartype kind: str """ - kind: Literal["sparrow"] = rest_discriminator(name="kind") # type: ignore + kind: Literal["sparrow"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"sparrow\".""" @overload @@ -240,7 +240,7 @@ class TRex(Dinosaur, discriminator="t-rex"): :vartype kind: str """ - kind: Literal["t-rex"] = rest_discriminator(name="kind") # type: ignore + kind: Literal["t-rex"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long """Required. Default value is \"t-rex\".""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/typetest-model-usage/typetest/model/usage/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-model-usage/typetest/model/usage/models/_models.py index 3f1ace42aba..bed762c5fcb 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-model-usage/typetest/model/usage/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-model-usage/typetest/model/usage/models/_models.py @@ -21,7 +21,7 @@ class InputOutputRecord(_model_base.Model): :vartype required_prop: str """ - required_prop: str = rest_field(name="requiredProp") + required_prop: str = rest_field(name="requiredProp", visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -51,7 +51,7 @@ class InputRecord(_model_base.Model): :vartype required_prop: str """ - required_prop: str = rest_field(name="requiredProp") + required_prop: str = rest_field(name="requiredProp", visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -80,7 +80,7 @@ class OutputRecord(_model_base.Model): :vartype required_prop: str """ - required_prop: str = rest_field(name="requiredProp") + required_prop: str = rest_field(name="requiredProp", visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py index c9fb0f703c0..89fb6b1e101 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py @@ -26,7 +26,7 @@ class DifferentSpreadFloatRecord(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The id property. Required.""" @overload @@ -58,7 +58,7 @@ class DifferentSpreadFloatDerived(DifferentSpreadFloatRecord): :vartype derived_prop: float """ - derived_prop: float = rest_field(name="derivedProp") + derived_prop: float = rest_field(name="derivedProp", visibility=["read", "create", "update", "delete", "query"]) """The index property. Required.""" @overload @@ -88,7 +88,7 @@ class DifferentSpreadModelArrayRecord(_model_base.Model): :vartype known_prop: str """ - known_prop: str = rest_field(name="knownProp") + known_prop: str = rest_field(name="knownProp", visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -120,7 +120,9 @@ class DifferentSpreadModelArrayDerived(DifferentSpreadModelArrayRecord): :vartype derived_prop: list[~typetest.property.additionalproperties.models.ModelForRecord] """ - derived_prop: List["_models.ModelForRecord"] = rest_field(name="derivedProp") + derived_prop: List["_models.ModelForRecord"] = rest_field( + name="derivedProp", visibility=["read", "create", "update", "delete", "query"] + ) """The index property. Required.""" @overload @@ -150,7 +152,7 @@ class DifferentSpreadModelRecord(_model_base.Model): :vartype known_prop: str """ - known_prop: str = rest_field(name="knownProp") + known_prop: str = rest_field(name="knownProp", visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -182,7 +184,9 @@ class DifferentSpreadModelDerived(DifferentSpreadModelRecord): :vartype derived_prop: ~typetest.property.additionalproperties.models.ModelForRecord """ - derived_prop: "_models.ModelForRecord" = rest_field(name="derivedProp") + derived_prop: "_models.ModelForRecord" = rest_field( + name="derivedProp", visibility=["read", "create", "update", "delete", "query"] + ) """The index property. Required.""" @overload @@ -212,7 +216,7 @@ class DifferentSpreadStringRecord(_model_base.Model): :vartype id: float """ - id: float = rest_field() + id: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name property. Required.""" @overload @@ -244,7 +248,7 @@ class DifferentSpreadStringDerived(DifferentSpreadStringRecord): :vartype derived_prop: str """ - derived_prop: str = rest_field(name="derivedProp") + derived_prop: str = rest_field(name="derivedProp", visibility=["read", "create", "update", "delete", "query"]) """The index property. Required.""" @overload @@ -274,7 +278,7 @@ class ExtendsFloatAdditionalProperties(_model_base.Model): :vartype id: float """ - id: float = rest_field() + id: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The id property. Required.""" @overload @@ -303,7 +307,9 @@ class ExtendsModelAdditionalProperties(_model_base.Model): :vartype known_prop: ~typetest.property.additionalproperties.models.ModelForRecord """ - known_prop: "_models.ModelForRecord" = rest_field(name="knownProp") + known_prop: "_models.ModelForRecord" = rest_field( + name="knownProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required.""" @overload @@ -332,7 +338,9 @@ class ExtendsModelArrayAdditionalProperties(_model_base.Model): :vartype known_prop: list[~typetest.property.additionalproperties.models.ModelForRecord] """ - known_prop: List["_models.ModelForRecord"] = rest_field(name="knownProp") + known_prop: List["_models.ModelForRecord"] = rest_field( + name="knownProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required.""" @overload @@ -361,7 +369,7 @@ class ExtendsStringAdditionalProperties(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name property. Required.""" @overload @@ -390,7 +398,7 @@ class ExtendsUnknownAdditionalProperties(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name property. Required.""" @overload @@ -423,9 +431,9 @@ class ExtendsUnknownAdditionalPropertiesDerived(ExtendsUnknownAdditionalProperti :vartype age: float """ - index: int = rest_field() + index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The index property. Required.""" - age: Optional[float] = rest_field() + age: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The age property.""" @overload @@ -462,9 +470,9 @@ class ExtendsUnknownAdditionalPropertiesDiscriminated(_model_base.Model): # pyl """ __mapping__: Dict[str, _model_base.Model] = {} - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name property. Required.""" - kind: str = rest_discriminator(name="kind") + kind: str = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) """The discriminator. Required. Default value is None.""" @overload @@ -502,11 +510,11 @@ class ExtendsUnknownAdditionalPropertiesDiscriminatedDerived( :vartype age: float """ - kind: Literal["derived"] = rest_discriminator(name="kind") # type: ignore + kind: Literal["derived"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"derived\".""" - index: int = rest_field() + index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The index property. Required.""" - age: Optional[float] = rest_field() + age: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The age property.""" @overload @@ -537,7 +545,7 @@ class IsFloatAdditionalProperties(_model_base.Model): :vartype id: float """ - id: float = rest_field() + id: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The id property. Required.""" @overload @@ -566,7 +574,9 @@ class IsModelAdditionalProperties(_model_base.Model): :vartype known_prop: ~typetest.property.additionalproperties.models.ModelForRecord """ - known_prop: "_models.ModelForRecord" = rest_field(name="knownProp") + known_prop: "_models.ModelForRecord" = rest_field( + name="knownProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required.""" @overload @@ -595,7 +605,9 @@ class IsModelArrayAdditionalProperties(_model_base.Model): :vartype known_prop: list[~typetest.property.additionalproperties.models.ModelForRecord] """ - known_prop: List["_models.ModelForRecord"] = rest_field(name="knownProp") + known_prop: List["_models.ModelForRecord"] = rest_field( + name="knownProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required.""" @overload @@ -624,7 +636,7 @@ class IsStringAdditionalProperties(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name property. Required.""" @overload @@ -653,7 +665,7 @@ class IsUnknownAdditionalProperties(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name property. Required.""" @overload @@ -686,9 +698,9 @@ class IsUnknownAdditionalPropertiesDerived(IsUnknownAdditionalProperties): :vartype age: float """ - index: int = rest_field() + index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The index property. Required.""" - age: Optional[float] = rest_field() + age: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The age property.""" @overload @@ -725,9 +737,9 @@ class IsUnknownAdditionalPropertiesDiscriminated(_model_base.Model): # pylint: """ __mapping__: Dict[str, _model_base.Model] = {} - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name property. Required.""" - kind: str = rest_discriminator(name="kind") + kind: str = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) """The discriminator. Required. Default value is None.""" @overload @@ -765,11 +777,11 @@ class IsUnknownAdditionalPropertiesDiscriminatedDerived( :vartype age: float """ - kind: Literal["derived"] = rest_discriminator(name="kind") # type: ignore + kind: Literal["derived"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"derived\".""" - index: int = rest_field() + index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The index property. Required.""" - age: Optional[float] = rest_field() + age: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The age property.""" @overload @@ -800,7 +812,7 @@ class ModelForRecord(_model_base.Model): :vartype state: str """ - state: str = rest_field() + state: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The state property. Required.""" @overload @@ -829,7 +841,7 @@ class MultipleSpreadRecord(_model_base.Model): :vartype flag: bool """ - flag: bool = rest_field() + flag: bool = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name property. Required.""" @overload @@ -858,7 +870,7 @@ class SpreadFloatRecord(_model_base.Model): :vartype id: float """ - id: float = rest_field() + id: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The id property. Required.""" @overload @@ -887,7 +899,9 @@ class SpreadModelArrayRecord(_model_base.Model): :vartype known_prop: list[~typetest.property.additionalproperties.models.ModelForRecord] """ - known_prop: List["_models.ModelForRecord"] = rest_field(name="knownProp") + known_prop: List["_models.ModelForRecord"] = rest_field( + name="knownProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required.""" @overload @@ -916,7 +930,9 @@ class SpreadModelRecord(_model_base.Model): :vartype known_prop: ~typetest.property.additionalproperties.models.ModelForRecord """ - known_prop: "_models.ModelForRecord" = rest_field(name="knownProp") + known_prop: "_models.ModelForRecord" = rest_field( + name="knownProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required.""" @overload @@ -945,7 +961,7 @@ class SpreadRecordForDiscriminatedUnion(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name property. Required.""" @overload @@ -974,7 +990,7 @@ class SpreadRecordForNonDiscriminatedUnion(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name property. Required.""" @overload @@ -1003,7 +1019,7 @@ class SpreadRecordForNonDiscriminatedUnion2(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name property. Required.""" @overload @@ -1032,7 +1048,7 @@ class SpreadRecordForNonDiscriminatedUnion3(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name property. Required.""" @overload @@ -1061,7 +1077,7 @@ class SpreadRecordForUnion(_model_base.Model): :vartype flag: bool """ - flag: bool = rest_field() + flag: bool = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name property. Required.""" @overload @@ -1090,7 +1106,7 @@ class SpreadStringRecord(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name property. Required.""" @overload @@ -1123,9 +1139,9 @@ class WidgetData0(_model_base.Model): :vartype foo_prop: str """ - kind: Literal["kind0"] = rest_field() + kind: Literal["kind0"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required. Default value is \"kind0\".""" - foo_prop: str = rest_field(name="fooProp") + foo_prop: str = rest_field(name="fooProp", visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -1161,11 +1177,13 @@ class WidgetData1(_model_base.Model): :vartype end: ~datetime.datetime """ - kind: Literal["kind1"] = rest_field() + kind: Literal["kind1"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required. Default value is \"kind1\".""" - start: datetime.datetime = rest_field(format="rfc3339") + start: datetime.datetime = rest_field(visibility=["read", "create", "update", "delete", "query"], format="rfc3339") """Required.""" - end: Optional[datetime.datetime] = rest_field(format="rfc3339") + end: Optional[datetime.datetime] = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) @overload def __init__( @@ -1199,9 +1217,9 @@ class WidgetData2(_model_base.Model): :vartype start: str """ - kind: Literal["kind1"] = rest_field() + kind: Literal["kind1"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required. Default value is \"kind1\".""" - start: str = rest_field() + start: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/typetest-property-nullable/typetest/property/nullable/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-property-nullable/typetest/property/nullable/models/_models.py index 2daa2cdee8c..d0209bb7063 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-property-nullable/typetest/property/nullable/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-property-nullable/typetest/property/nullable/models/_models.py @@ -28,9 +28,13 @@ class BytesProperty(_model_base.Model): :vartype nullable_property: bytes """ - required_property: str = rest_field(name="requiredProperty") + required_property: str = rest_field( + name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] + ) """Required property. Required.""" - nullable_property: bytes = rest_field(name="nullableProperty", format="base64") + nullable_property: bytes = rest_field( + name="nullableProperty", visibility=["read", "create", "update", "delete", "query"], format="base64" + ) """Property. Required.""" @overload @@ -62,9 +66,13 @@ class CollectionsByteProperty(_model_base.Model): :vartype nullable_property: list[bytes] """ - required_property: str = rest_field(name="requiredProperty") + required_property: str = rest_field( + name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] + ) """Required property. Required.""" - nullable_property: List[bytes] = rest_field(name="nullableProperty", format="base64") + nullable_property: List[bytes] = rest_field( + name="nullableProperty", visibility=["read", "create", "update", "delete", "query"], format="base64" + ) """Property. Required.""" @overload @@ -96,9 +104,13 @@ class CollectionsModelProperty(_model_base.Model): :vartype nullable_property: list[~typetest.property.nullable.models.InnerModel] """ - required_property: str = rest_field(name="requiredProperty") + required_property: str = rest_field( + name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] + ) """Required property. Required.""" - nullable_property: List["_models.InnerModel"] = rest_field(name="nullableProperty") + nullable_property: List["_models.InnerModel"] = rest_field( + name="nullableProperty", visibility=["read", "create", "update", "delete", "query"] + ) """Property. Required.""" @overload @@ -130,9 +142,13 @@ class CollectionsStringProperty(_model_base.Model): :vartype nullable_property: list[str] """ - required_property: str = rest_field(name="requiredProperty") + required_property: str = rest_field( + name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] + ) """Required property. Required.""" - nullable_property: List[str] = rest_field(name="nullableProperty") + nullable_property: List[str] = rest_field( + name="nullableProperty", visibility=["read", "create", "update", "delete", "query"] + ) """Property. Required.""" @overload @@ -164,9 +180,13 @@ class DatetimeProperty(_model_base.Model): :vartype nullable_property: ~datetime.datetime """ - required_property: str = rest_field(name="requiredProperty") + required_property: str = rest_field( + name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] + ) """Required property. Required.""" - nullable_property: datetime.datetime = rest_field(name="nullableProperty", format="rfc3339") + nullable_property: datetime.datetime = rest_field( + name="nullableProperty", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) """Property. Required.""" @overload @@ -198,9 +218,13 @@ class DurationProperty(_model_base.Model): :vartype nullable_property: ~datetime.timedelta """ - required_property: str = rest_field(name="requiredProperty") + required_property: str = rest_field( + name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] + ) """Required property. Required.""" - nullable_property: datetime.timedelta = rest_field(name="nullableProperty") + nullable_property: datetime.timedelta = rest_field( + name="nullableProperty", visibility=["read", "create", "update", "delete", "query"] + ) """Property. Required.""" @overload @@ -230,7 +254,7 @@ class InnerModel(_model_base.Model): :vartype property: str """ - property: str = rest_field() + property: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Inner model property. Required.""" @overload @@ -262,9 +286,13 @@ class StringProperty(_model_base.Model): :vartype nullable_property: str """ - required_property: str = rest_field(name="requiredProperty") + required_property: str = rest_field( + name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] + ) """Required property. Required.""" - nullable_property: str = rest_field(name="nullableProperty") + nullable_property: str = rest_field( + name="nullableProperty", visibility=["read", "create", "update", "delete", "query"] + ) """Property. Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/typetest-property-optional/typetest/property/optional/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-property-optional/typetest/property/optional/models/_models.py index 647e97d2b33..7d20f98e842 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-property-optional/typetest/property/optional/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-property-optional/typetest/property/optional/models/_models.py @@ -24,7 +24,7 @@ class BooleanLiteralProperty(_model_base.Model): :vartype property: bool """ - property: Optional[Literal[True]] = rest_field() + property: Optional[Literal[True]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Default value is True.""" @overload @@ -53,7 +53,7 @@ class BytesProperty(_model_base.Model): :vartype property: bytes """ - property: Optional[bytes] = rest_field(format="base64") + property: Optional[bytes] = rest_field(visibility=["read", "create", "update", "delete", "query"], format="base64") """Property.""" @overload @@ -81,7 +81,9 @@ class CollectionsByteProperty(_model_base.Model): :vartype property: list[bytes] """ - property: Optional[List[bytes]] = rest_field(format="base64") + property: Optional[List[bytes]] = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="base64" + ) """Property.""" @overload @@ -109,7 +111,9 @@ class CollectionsModelProperty(_model_base.Model): :vartype property: list[~typetest.property.optional.models.StringProperty] """ - property: Optional[List["_models.StringProperty"]] = rest_field() + property: Optional[List["_models.StringProperty"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """Property.""" @overload @@ -137,7 +141,9 @@ class DatetimeProperty(_model_base.Model): :vartype property: ~datetime.datetime """ - property: Optional[datetime.datetime] = rest_field(format="rfc3339") + property: Optional[datetime.datetime] = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) """Property.""" @overload @@ -165,7 +171,7 @@ class DurationProperty(_model_base.Model): :vartype property: ~datetime.timedelta """ - property: Optional[datetime.timedelta] = rest_field() + property: Optional[datetime.timedelta] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property.""" @overload @@ -193,7 +199,7 @@ class FloatLiteralProperty(_model_base.Model): :vartype property: float """ - property: Optional[float] = rest_field() + property: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Default value is 1.25.""" @overload @@ -221,7 +227,7 @@ class IntLiteralProperty(_model_base.Model): :vartype property: int """ - property: Optional[Literal[1]] = rest_field() + property: Optional[Literal[1]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Default value is 1.""" @overload @@ -249,7 +255,7 @@ class PlainDateProperty(_model_base.Model): :vartype property: ~datetime.date """ - property: Optional[datetime.date] = rest_field() + property: Optional[datetime.date] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property.""" @overload @@ -277,7 +283,7 @@ class PlainTimeProperty(_model_base.Model): :vartype property: ~datetime.time """ - property: Optional[datetime.time] = rest_field() + property: Optional[datetime.time] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property.""" @overload @@ -308,9 +314,13 @@ class RequiredAndOptionalProperty(_model_base.Model): :vartype required_property: int """ - optional_property: Optional[str] = rest_field(name="optionalProperty") + optional_property: Optional[str] = rest_field( + name="optionalProperty", visibility=["read", "create", "update", "delete", "query"] + ) """optional string property.""" - required_property: int = rest_field(name="requiredProperty") + required_property: int = rest_field( + name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] + ) """required int property. Required.""" @overload @@ -339,7 +349,7 @@ class StringLiteralProperty(_model_base.Model): :vartype property: str """ - property: Optional[Literal["hello"]] = rest_field() + property: Optional[Literal["hello"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Default value is \"hello\".""" @overload @@ -368,7 +378,7 @@ class StringProperty(_model_base.Model): :vartype property: str """ - property: Optional[str] = rest_field() + property: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property.""" @overload @@ -396,7 +406,7 @@ class UnionFloatLiteralProperty(_model_base.Model): :vartype property: float or float """ - property: Optional[float] = rest_field() + property: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Is one of the following types: float""" @overload @@ -424,7 +434,7 @@ class UnionIntLiteralProperty(_model_base.Model): :vartype property: int or int """ - property: Optional[Literal[1, 2]] = rest_field() + property: Optional[Literal[1, 2]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Is either a Literal[1] type or a Literal[2] type.""" @overload @@ -452,7 +462,9 @@ class UnionStringLiteralProperty(_model_base.Model): :vartype property: str or str """ - property: Optional[Literal["hello", "world"]] = rest_field() + property: Optional[Literal["hello", "world"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """Property. Is either a Literal[\"hello\"] type or a Literal[\"world\"] type.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/typetest-property-valuetypes/typetest/property/valuetypes/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-property-valuetypes/typetest/property/valuetypes/models/_models.py index 24957532e8b..1834b01cf16 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-property-valuetypes/typetest/property/valuetypes/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-property-valuetypes/typetest/property/valuetypes/models/_models.py @@ -29,7 +29,7 @@ class BooleanLiteralProperty(_model_base.Model): :vartype property: bool """ - property: Literal[True] = rest_field() + property: Literal[True] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required. Default value is True.""" def __init__(self, *args: Any, **kwargs: Any) -> None: @@ -45,7 +45,7 @@ class BooleanProperty(_model_base.Model): :vartype property: bool """ - property: bool = rest_field() + property: bool = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -74,7 +74,7 @@ class BytesProperty(_model_base.Model): :vartype property: bytes """ - property: bytes = rest_field(format="base64") + property: bytes = rest_field(visibility=["read", "create", "update", "delete", "query"], format="base64") """Property. Required.""" @overload @@ -103,7 +103,7 @@ class CollectionsIntProperty(_model_base.Model): :vartype property: list[int] """ - property: List[int] = rest_field() + property: List[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -132,7 +132,7 @@ class CollectionsModelProperty(_model_base.Model): :vartype property: list[~typetest.property.valuetypes.models.InnerModel] """ - property: List["_models.InnerModel"] = rest_field() + property: List["_models.InnerModel"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -161,7 +161,7 @@ class CollectionsStringProperty(_model_base.Model): :vartype property: list[str] """ - property: List[str] = rest_field() + property: List[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -190,7 +190,9 @@ class DatetimeProperty(_model_base.Model): :vartype property: ~datetime.datetime """ - property: datetime.datetime = rest_field(format="rfc3339") + property: datetime.datetime = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) """Property. Required.""" @overload @@ -219,7 +221,7 @@ class Decimal128Property(_model_base.Model): :vartype property: ~decimal.Decimal """ - property: decimal.Decimal = rest_field() + property: decimal.Decimal = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -248,7 +250,7 @@ class DecimalProperty(_model_base.Model): :vartype property: ~decimal.Decimal """ - property: decimal.Decimal = rest_field() + property: decimal.Decimal = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -277,7 +279,7 @@ class DictionaryStringProperty(_model_base.Model): :vartype property: dict[str, str] """ - property: Dict[str, str] = rest_field() + property: Dict[str, str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -306,7 +308,7 @@ class DurationProperty(_model_base.Model): :vartype property: ~datetime.timedelta """ - property: datetime.timedelta = rest_field() + property: datetime.timedelta = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -335,7 +337,9 @@ class EnumProperty(_model_base.Model): :vartype property: str or ~typetest.property.valuetypes.models.FixedInnerEnum """ - property: Union[str, "_models.FixedInnerEnum"] = rest_field() + property: Union[str, "_models.FixedInnerEnum"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """Property. Required. Known values are: \"ValueOne\" and \"ValueTwo\".""" @overload @@ -364,7 +368,7 @@ class ExtensibleEnumProperty(_model_base.Model): :vartype property: str or ~typetest.property.valuetypes.models.InnerEnum """ - property: Union[str, "_models.InnerEnum"] = rest_field() + property: Union[str, "_models.InnerEnum"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required. Known values are: \"ValueOne\" and \"ValueTwo\".""" @overload @@ -395,7 +399,7 @@ class FloatLiteralProperty(_model_base.Model): :vartype property: float """ - property: float = rest_field() + property: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required. Default value is 43.125.""" def __init__(self, *args: Any, **kwargs: Any) -> None: @@ -411,7 +415,7 @@ class FloatProperty(_model_base.Model): :vartype property: float """ - property: float = rest_field() + property: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -440,7 +444,7 @@ class InnerModel(_model_base.Model): :vartype property: str """ - property: str = rest_field() + property: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required string property. Required.""" @overload @@ -471,7 +475,7 @@ class IntLiteralProperty(_model_base.Model): :vartype property: int """ - property: Literal[42] = rest_field() + property: Literal[42] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required. Default value is 42.""" def __init__(self, *args: Any, **kwargs: Any) -> None: @@ -487,7 +491,7 @@ class IntProperty(_model_base.Model): :vartype property: int """ - property: int = rest_field() + property: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -516,7 +520,7 @@ class ModelProperty(_model_base.Model): :vartype property: ~typetest.property.valuetypes.models.InnerModel """ - property: "_models.InnerModel" = rest_field() + property: "_models.InnerModel" = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -551,7 +555,7 @@ class StringLiteralProperty(_model_base.Model): :vartype property: str """ - property: Literal["hello"] = rest_field() + property: Literal["hello"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required. Default value is \"hello\".""" def __init__(self, *args: Any, **kwargs: Any) -> None: @@ -567,7 +571,7 @@ class StringProperty(_model_base.Model): :vartype property: str """ - property: str = rest_field() + property: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -597,7 +601,7 @@ class UnionEnumValueProperty(_model_base.Model): :vartype property: str or ~typetest.property.valuetypes.models.ENUM_VALUE2 """ - property: Literal[ExtendedEnum.ENUM_VALUE2] = rest_field() + property: Literal[ExtendedEnum.ENUM_VALUE2] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -626,7 +630,7 @@ class UnionFloatLiteralProperty(_model_base.Model): :vartype property: float or float """ - property: float = rest_field() + property: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required. Is one of the following types: float""" @overload @@ -655,7 +659,7 @@ class UnionIntLiteralProperty(_model_base.Model): :vartype property: int or int """ - property: Literal[42, 43] = rest_field() + property: Literal[42, 43] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required. Is either a Literal[42] type or a Literal[43] type.""" @overload @@ -685,7 +689,7 @@ class UnionStringLiteralProperty(_model_base.Model): :vartype property: str or str """ - property: Literal["hello", "world"] = rest_field() + property: Literal["hello", "world"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required. Is either a Literal[\"hello\"] type or a Literal[\"world\"] type.""" @overload @@ -714,7 +718,7 @@ class UnknownArrayProperty(_model_base.Model): :vartype property: any """ - property: Any = rest_field() + property: Any = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -743,7 +747,7 @@ class UnknownDictProperty(_model_base.Model): :vartype property: any """ - property: Any = rest_field() + property: Any = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -772,7 +776,7 @@ class UnknownIntProperty(_model_base.Model): :vartype property: any """ - property: Any = rest_field() + property: Any = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload @@ -801,7 +805,7 @@ class UnknownStringProperty(_model_base.Model): :vartype property: any """ - property: Any = rest_field() + property: Any = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Property. Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/typetest-union/typetest/union/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-union/typetest/union/models/_models.py index 9d71add06e4..3f1b2f6f514 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-union/typetest/union/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-union/typetest/union/models/_models.py @@ -24,7 +24,7 @@ class Cat(_model_base.Model): :vartype name: str """ - name: str = rest_field() + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -53,7 +53,7 @@ class Dog(_model_base.Model): :vartype bark: str """ - bark: str = rest_field() + bark: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -86,10 +86,10 @@ class EnumsOnlyCases(_model_base.Model): :vartype ud: str or str """ - lr: Literal["left", "right", "up", "down"] = rest_field() + lr: Literal["left", "right", "up", "down"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """This should be receive/send the left variant. Required. Is one of the following types: Literal[\"left\"], Literal[\"right\"], Literal[\"up\"], Literal[\"down\"]""" - ud: Literal["up", "down"] = rest_field() + ud: Literal["up", "down"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """This should be receive/send the up variant. Required. Is either a Literal[\"up\"] type or a Literal[\"down\"] type.""" @@ -120,7 +120,7 @@ class GetResponse(_model_base.Model): :vartype prop: ~typetest.union.models.MixedTypesCases """ - prop: "_models.MixedTypesCases" = rest_field() + prop: "_models.MixedTypesCases" = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -149,7 +149,7 @@ class GetResponse1(_model_base.Model): :vartype prop: ~typetest.union.models.MixedLiteralsCases """ - prop: "_models.MixedLiteralsCases" = rest_field() + prop: "_models.MixedLiteralsCases" = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -178,7 +178,7 @@ class GetResponse2(_model_base.Model): :vartype prop: ~typetest.union.models.StringAndArrayCases """ - prop: "_models.StringAndArrayCases" = rest_field() + prop: "_models.StringAndArrayCases" = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -207,7 +207,7 @@ class GetResponse3(_model_base.Model): :vartype prop: ~typetest.union.models.EnumsOnlyCases """ - prop: "_models.EnumsOnlyCases" = rest_field() + prop: "_models.EnumsOnlyCases" = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload @@ -236,7 +236,7 @@ class GetResponse4(_model_base.Model): :vartype prop: ~typetest.union.models.Cat or ~typetest.union.models.Dog """ - prop: Union["_models.Cat", "_models.Dog"] = rest_field() + prop: Union["_models.Cat", "_models.Dog"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required. Is either a Cat type or a Dog type.""" @overload @@ -265,7 +265,7 @@ class GetResponse5(_model_base.Model): :vartype prop: float or float or float """ - prop: float = rest_field() + prop: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required. Is one of the following types: float""" @overload @@ -294,7 +294,7 @@ class GetResponse6(_model_base.Model): :vartype prop: int or int or int """ - prop: Literal[1, 2, 3] = rest_field() + prop: Literal[1, 2, 3] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required. Is one of the following types: Literal[1], Literal[2], Literal[3]""" @overload @@ -323,7 +323,9 @@ class GetResponse7(_model_base.Model): :vartype prop: str or ~typetest.union.models.StringExtensibleNamedUnion """ - prop: Union[str, "_models.StringExtensibleNamedUnion"] = rest_field() + prop: Union[str, "_models.StringExtensibleNamedUnion"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """Required. Known values are: \"b\" and \"c\".""" @overload @@ -352,7 +354,9 @@ class GetResponse8(_model_base.Model): :vartype prop: str or str or str """ - prop: Union[Literal["b"], Literal["c"], str] = rest_field() + prop: Union[Literal["b"], Literal["c"], str] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """Required. Is one of the following types: Literal[\"b\"], Literal[\"c\"], str""" @overload @@ -381,7 +385,7 @@ class GetResponse9(_model_base.Model): :vartype prop: str or str or str """ - prop: Literal["a", "b", "c"] = rest_field() + prop: Literal["a", "b", "c"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required. Is one of the following types: Literal[\"a\"], Literal[\"b\"], Literal[\"c\"]""" @overload @@ -420,16 +424,24 @@ class MixedLiteralsCases(_model_base.Model): :vartype boolean_literal: str or int or float or bool """ - string_literal: Literal["a", 2, True] = rest_field(name="stringLiteral") + string_literal: Literal["a", 2, True] = rest_field( + name="stringLiteral", visibility=["read", "create", "update", "delete", "query"] + ) """This should be receive/send the \"a\" variant. Required. Is one of the following types: Literal[\"a\"], Literal[2], float, Literal[True]""" - int_literal: Literal["a", 2, True] = rest_field(name="intLiteral") + int_literal: Literal["a", 2, True] = rest_field( + name="intLiteral", visibility=["read", "create", "update", "delete", "query"] + ) """This should be receive/send the 2 variant. Required. Is one of the following types: Literal[\"a\"], Literal[2], float, Literal[True]""" - float_literal: Literal["a", 2, True] = rest_field(name="floatLiteral") + float_literal: Literal["a", 2, True] = rest_field( + name="floatLiteral", visibility=["read", "create", "update", "delete", "query"] + ) """This should be receive/send the 3.3 variant. Required. Is one of the following types: Literal[\"a\"], Literal[2], float, Literal[True]""" - boolean_literal: Literal["a", 2, True] = rest_field(name="booleanLiteral") + boolean_literal: Literal["a", 2, True] = rest_field( + name="booleanLiteral", visibility=["read", "create", "update", "delete", "query"] + ) """This should be receive/send the true variant. Required. Is one of the following types: Literal[\"a\"], Literal[2], float, Literal[True]""" @@ -474,19 +486,29 @@ class MixedTypesCases(_model_base.Model): :vartype array: list[~typetest.union.models.Cat or str or int or bool] """ - model: Union["_models.Cat", Literal["a"], int, bool] = rest_field() + model: Union["_models.Cat", Literal["a"], int, bool] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """This should be receive/send the Cat variant. Required. Is one of the following types: Cat, Literal[\"a\"], int, bool""" - literal: Union["_models.Cat", Literal["a"], int, bool] = rest_field() + literal: Union["_models.Cat", Literal["a"], int, bool] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """This should be receive/send the \"a\" variant. Required. Is one of the following types: Cat, Literal[\"a\"], int, bool""" - int_property: Union["_models.Cat", Literal["a"], int, bool] = rest_field(name="int") + int_property: Union["_models.Cat", Literal["a"], int, bool] = rest_field( + name="int", visibility=["read", "create", "update", "delete", "query"] + ) """This should be receive/send the int variant. Required. Is one of the following types: Cat, Literal[\"a\"], int, bool""" - boolean: Union["_models.Cat", Literal["a"], int, bool] = rest_field() + boolean: Union["_models.Cat", Literal["a"], int, bool] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """This should be receive/send the boolean variant. Required. Is one of the following types: Cat, Literal[\"a\"], int, bool""" - array: List[Union["_models.Cat", Literal["a"], int, bool]] = rest_field() + array: List[Union["_models.Cat", Literal["a"], int, bool]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """This should be receive/send 4 element with Cat, \"a\", int, and boolean. Required.""" @overload @@ -523,9 +545,9 @@ class StringAndArrayCases(_model_base.Model): :vartype array: str or list[str] """ - string: Union[str, List[str]] = rest_field() + string: Union[str, List[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """This should be receive/send the string variant. Required. Is either a str type or a [str] type.""" - array: Union[str, List[str]] = rest_field() + array: Union[str, List[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """This should be receive/send the array variant. Required. Is either a str type or a [str] type.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/models/_models.py b/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/models/_models.py index d228b887c26..a538788bef8 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/models/_models.py @@ -28,11 +28,15 @@ class ModelV1(_model_base.Model): :vartype union_prop: str or int """ - prop: str = rest_field() + prop: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - enum_prop: Union[str, "_models.EnumV1"] = rest_field(name="enumProp") + enum_prop: Union[str, "_models.EnumV1"] = rest_field( + name="enumProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required. Known values are: \"enumMemberV1\" and \"enumMemberV2\".""" - union_prop: "_types.UnionV1" = rest_field(name="unionProp") + union_prop: "_types.UnionV1" = rest_field( + name="unionProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required. Is either a str type or a int type.""" @overload @@ -67,11 +71,15 @@ class ModelV2(_model_base.Model): :vartype union_prop: str or int """ - prop: str = rest_field() + prop: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - enum_prop: Union[str, "_models.EnumV2"] = rest_field(name="enumProp") + enum_prop: Union[str, "_models.EnumV2"] = rest_field( + name="enumProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required. \"enumMember\"""" - union_prop: "_types.UnionV2" = rest_field(name="unionProp") + union_prop: "_types.UnionV2" = rest_field( + name="unionProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required. Is either a str type or a int type.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/models/_models.py b/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/models/_models.py index 2fda4c1e234..188fde629f2 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/models/_models.py @@ -23,9 +23,11 @@ class TestModel(_model_base.Model): :vartype changed_prop: str """ - prop: str = rest_field() + prop: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - changed_prop: Optional[str] = rest_field(name="changedProp") + changed_prop: Optional[str] = rest_field( + name="changedProp", visibility=["read", "create", "update", "delete", "query"] + ) @overload def __init__( diff --git a/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/models/_models.py b/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/models/_models.py index 3ef70c7e9c0..635034a6ba4 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/models/_models.py @@ -28,11 +28,15 @@ class ModelV2(_model_base.Model): :vartype union_prop: str or float """ - prop: str = rest_field() + prop: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - enum_prop: Union[str, "_models.EnumV2"] = rest_field(name="enumProp") + enum_prop: Union[str, "_models.EnumV2"] = rest_field( + name="enumProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required. \"enumMemberV2\"""" - union_prop: "_types.UnionV2" = rest_field(name="unionProp") + union_prop: "_types.UnionV2" = rest_field( + name="unionProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required. Is either a str type or a float type.""" @overload @@ -65,9 +69,11 @@ class ModelV3(_model_base.Model): :vartype enum_prop: str or ~versioning.removed.models.EnumV3 """ - id: str = rest_field() + id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - enum_prop: Union[str, "_models.EnumV3"] = rest_field(name="enumProp") + enum_prop: Union[str, "_models.EnumV3"] = rest_field( + name="enumProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required. Known values are: \"enumMemberV1\" and \"enumMemberV2Preview\".""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/models/_models.py b/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/models/_models.py index 92b90b05bde..e423bc9b009 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/models/_models.py @@ -28,11 +28,15 @@ class NewModel(_model_base.Model): :vartype union_prop: str or int """ - new_prop: str = rest_field(name="newProp") + new_prop: str = rest_field(name="newProp", visibility=["read", "create", "update", "delete", "query"]) """Required.""" - enum_prop: Union[str, "_models.NewEnum"] = rest_field(name="enumProp") + enum_prop: Union[str, "_models.NewEnum"] = rest_field( + name="enumProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required. \"newEnumMember\"""" - union_prop: "_types.NewUnion" = rest_field(name="unionProp") + union_prop: "_types.NewUnion" = rest_field( + name="unionProp", visibility=["read", "create", "update", "delete", "query"] + ) """Required. Is either a str type or a int type.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/versioning-typechangedfrom/versioning/typechangedfrom/models/_models.py b/packages/typespec-python/test/unbranded/generated/versioning-typechangedfrom/versioning/typechangedfrom/models/_models.py index c3ff394d0cd..83f129dc8c5 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-typechangedfrom/versioning/typechangedfrom/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-typechangedfrom/versioning/typechangedfrom/models/_models.py @@ -23,9 +23,9 @@ class TestModel(_model_base.Model): :vartype changed_prop: str """ - prop: str = rest_field() + prop: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - changed_prop: str = rest_field(name="changedProp") + changed_prop: str = rest_field(name="changedProp", visibility=["read", "create", "update", "delete", "query"]) """Required.""" @overload From 95be06a9588e444c3205a75f8a6d63c041890c17 Mon Sep 17 00:00:00 2001 From: AutoPrFromHttpClientPython Date: Thu, 13 Feb 2025 02:13:25 +0000 Subject: [PATCH 03/14] Update dependencies (2025-02-13 02:13:25) --- packages/autorest.python/package.json | 2 +- packages/typespec-python/package.json | 6 ++-- pnpm-lock.yaml | 46 +++++++++++++-------------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/packages/autorest.python/package.json b/packages/autorest.python/package.json index 08ddc36faa6..280ace6d922 100644 --- a/packages/autorest.python/package.json +++ b/packages/autorest.python/package.json @@ -29,7 +29,7 @@ }, "homepage": "https://github.com/Azure/autorest.python/blob/main/README.md", "dependencies": { - "@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1NTg1Ny9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz", + "@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1OTgyNS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz", "@autorest/system-requirements": "~1.0.2", "fs-extra": "~11.2.0", "tsx": "~4.19.1" diff --git a/packages/typespec-python/package.json b/packages/typespec-python/package.json index 682ab42158f..962f07cce80 100644 --- a/packages/typespec-python/package.json +++ b/packages/typespec-python/package.json @@ -54,13 +54,13 @@ "@azure-tools/typespec-azure-resource-manager": ">=0.51.0 <1.0.0", "@azure-tools/typespec-autorest": ">=0.51.0 <1.0.0", "@azure-tools/typespec-azure-rulesets": ">=0.51.0 <3.0.0", - "@azure-tools/typespec-client-generator-core": ">=0.51.0 <1.0.0" + "@azure-tools/typespec-client-generator-core": ">=0.51.1 <1.0.0" }, "dependencies": { "js-yaml": "~4.1.0", "semver": "~7.6.2", "tsx": "~4.19.1", - "@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1NTg1Ny9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz", + "@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1OTgyNS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz", "fs-extra": "~11.2.0" }, "devDependencies": { @@ -73,7 +73,7 @@ "@azure-tools/typespec-azure-core": "~0.51.0", "@azure-tools/typespec-azure-rulesets": "~0.51.0", "@azure-tools/typespec-autorest": "~0.51.0", - "@azure-tools/typespec-client-generator-core": "~0.51.0", + "@azure-tools/typespec-client-generator-core": "~0.51.1", "@azure-tools/azure-http-specs": "0.1.0-alpha.6", "@typespec/http-specs": "0.1.0-alpha.9", "@types/js-yaml": "~4.0.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4b5cf8aecbb..13fe991d2c4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -57,8 +57,8 @@ importers: specifier: ~1.0.2 version: 1.0.2 '@typespec/http-client-python': - specifier: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1NTg1Ny9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz - version: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1NTg1Ny9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz(pj75u6zo6obzdihzpwvg36i7j4) + specifier: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1OTgyNS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz + version: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1OTgyNS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz(5dspuyrtxidbihsk6ixub7kbfm) fs-extra: specifier: ~11.2.0 version: 11.2.0 @@ -79,8 +79,8 @@ importers: packages/typespec-python: dependencies: '@typespec/http-client-python': - specifier: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1NTg1Ny9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz - version: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1NTg1Ny9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz(pj75u6zo6obzdihzpwvg36i7j4) + specifier: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1OTgyNS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz + version: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1OTgyNS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz(5dspuyrtxidbihsk6ixub7kbfm) fs-extra: specifier: ~11.2.0 version: 11.2.0 @@ -99,7 +99,7 @@ importers: version: 0.1.0-alpha.6(@azure-tools/typespec-azure-core@0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))))(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/versioning@0.65.0(@typespec/compiler@0.65.0))(@typespec/xml@0.59.0(@typespec/compiler@0.65.0)) '@azure-tools/typespec-autorest': specifier: ~0.51.0 - version: 0.51.0(46ydeuneniox7cgf5iph2c2gou) + version: 0.51.0(jam7mnjbyunevglidmcn4r37mu) '@azure-tools/typespec-azure-core': specifier: ~0.51.0 version: 0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))) @@ -108,10 +108,10 @@ importers: version: 0.51.0(@azure-tools/typespec-azure-core@0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))))(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/openapi@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/versioning@0.65.0(@typespec/compiler@0.65.0)) '@azure-tools/typespec-azure-rulesets': specifier: ~0.51.0 - version: 0.51.0(jfzpdywzlhylutuaycp4bg7qk4) + version: 0.51.0(6ivl7wlwgurmoe44tk3z43uzly) '@azure-tools/typespec-client-generator-core': - specifier: ~0.51.0 - version: 0.51.0(@azure-tools/typespec-azure-core@0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))))(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/openapi@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/versioning@0.65.0(@typespec/compiler@0.65.0))(@typespec/xml@0.59.0(@typespec/compiler@0.65.0)) + specifier: ~0.51.1 + version: 0.51.1(@azure-tools/typespec-azure-core@0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))))(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/openapi@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/versioning@0.65.0(@typespec/compiler@0.65.0))(@typespec/xml@0.59.0(@typespec/compiler@0.65.0)) '@types/fs-extra': specifier: 11.0.4 version: 11.0.4 @@ -231,8 +231,8 @@ packages: '@azure-tools/typespec-client-generator-core': ~0.51.0 '@typespec/compiler': ~0.65.0 - '@azure-tools/typespec-client-generator-core@0.51.0': - resolution: {integrity: sha512-nhnG5EmZmWlvofKipVz4PJEhq95MlO8SqYINvU33SQOI+/8QBp3Y0JV7NJPxKObWdOPZli98VZ/glLEV8YX8YQ==} + '@azure-tools/typespec-client-generator-core@0.51.1': + resolution: {integrity: sha512-FkkH6RWQpIXsug1egIcjZP4/9slGyFxJsKzVqpgvMoZDYfl+6dYfQkesmpTJx1SB96VHyI1SPz2Wk6MLoeuTXQ==} engines: {node: '>=18.0.0'} peerDependencies: '@azure-tools/typespec-azure-core': ~0.51.0 @@ -1500,8 +1500,8 @@ packages: engines: {node: '>=18.0.0'} hasBin: true - '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1NTg1Ny9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz': - resolution: {tarball: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1NTg1Ny9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz} + '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1OTgyNS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz': + resolution: {tarball: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1OTgyNS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz} version: 0.6.11 engines: {node: '>=18.0.0'} peerDependencies: @@ -1509,7 +1509,7 @@ packages: '@azure-tools/typespec-azure-core': '>=0.51.0 <1.0.0' '@azure-tools/typespec-azure-resource-manager': '>=0.51.0 <1.0.0' '@azure-tools/typespec-azure-rulesets': '>=0.51.0 <3.0.0' - '@azure-tools/typespec-client-generator-core': '>=0.51.0 <1.0.0' + '@azure-tools/typespec-client-generator-core': '>=0.51.1 <1.0.0' '@typespec/compiler': '>=0.65.0 <1.0.0' '@typespec/http': '>=0.65.0 <1.0.0' '@typespec/openapi': '>=0.65.0 <1.0.0' @@ -4527,11 +4527,11 @@ snapshots: - debug - supports-color - '@azure-tools/typespec-autorest@0.51.0(46ydeuneniox7cgf5iph2c2gou)': + '@azure-tools/typespec-autorest@0.51.0(jam7mnjbyunevglidmcn4r37mu)': dependencies: '@azure-tools/typespec-azure-core': 0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))) '@azure-tools/typespec-azure-resource-manager': 0.51.0(@azure-tools/typespec-azure-core@0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))))(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/openapi@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/versioning@0.65.0(@typespec/compiler@0.65.0)) - '@azure-tools/typespec-client-generator-core': 0.51.0(@azure-tools/typespec-azure-core@0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))))(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/openapi@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/versioning@0.65.0(@typespec/compiler@0.65.0))(@typespec/xml@0.59.0(@typespec/compiler@0.65.0)) + '@azure-tools/typespec-client-generator-core': 0.51.1(@azure-tools/typespec-azure-core@0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))))(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/openapi@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/versioning@0.65.0(@typespec/compiler@0.65.0))(@typespec/xml@0.59.0(@typespec/compiler@0.65.0)) '@typespec/compiler': 0.65.0 '@typespec/http': 0.65.0(@typespec/compiler@0.65.0) '@typespec/openapi': 0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)) @@ -4555,14 +4555,14 @@ snapshots: change-case: 5.4.4 pluralize: 8.0.0 - '@azure-tools/typespec-azure-rulesets@0.51.0(jfzpdywzlhylutuaycp4bg7qk4)': + '@azure-tools/typespec-azure-rulesets@0.51.0(6ivl7wlwgurmoe44tk3z43uzly)': dependencies: '@azure-tools/typespec-azure-core': 0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))) '@azure-tools/typespec-azure-resource-manager': 0.51.0(@azure-tools/typespec-azure-core@0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))))(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/openapi@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/versioning@0.65.0(@typespec/compiler@0.65.0)) - '@azure-tools/typespec-client-generator-core': 0.51.0(@azure-tools/typespec-azure-core@0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))))(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/openapi@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/versioning@0.65.0(@typespec/compiler@0.65.0))(@typespec/xml@0.59.0(@typespec/compiler@0.65.0)) + '@azure-tools/typespec-client-generator-core': 0.51.1(@azure-tools/typespec-azure-core@0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))))(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/openapi@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/versioning@0.65.0(@typespec/compiler@0.65.0))(@typespec/xml@0.59.0(@typespec/compiler@0.65.0)) '@typespec/compiler': 0.65.0 - '@azure-tools/typespec-client-generator-core@0.51.0(@azure-tools/typespec-azure-core@0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))))(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/openapi@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/versioning@0.65.0(@typespec/compiler@0.65.0))(@typespec/xml@0.59.0(@typespec/compiler@0.65.0))': + '@azure-tools/typespec-client-generator-core@0.51.1(@azure-tools/typespec-azure-core@0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))))(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/openapi@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/versioning@0.65.0(@typespec/compiler@0.65.0))(@typespec/xml@0.59.0(@typespec/compiler@0.65.0))': dependencies: '@azure-tools/typespec-azure-core': 0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))) '@typespec/compiler': 0.65.0 @@ -4784,7 +4784,7 @@ snapshots: semver: 7.6.3 source-map-support: 0.5.21 std-env: 3.8.0 - yaml: 2.5.1 + yaml: 2.7.0 yargs: 17.7.2 zod: 3.23.8 transitivePeerDependencies: @@ -6003,13 +6003,13 @@ snapshots: - bluebird - supports-color - '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1NTg1Ny9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz(pj75u6zo6obzdihzpwvg36i7j4)': + '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1OTgyNS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz(5dspuyrtxidbihsk6ixub7kbfm)': dependencies: - '@azure-tools/typespec-autorest': 0.51.0(46ydeuneniox7cgf5iph2c2gou) + '@azure-tools/typespec-autorest': 0.51.0(jam7mnjbyunevglidmcn4r37mu) '@azure-tools/typespec-azure-core': 0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))) '@azure-tools/typespec-azure-resource-manager': 0.51.0(@azure-tools/typespec-azure-core@0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))))(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/openapi@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/versioning@0.65.0(@typespec/compiler@0.65.0)) - '@azure-tools/typespec-azure-rulesets': 0.51.0(jfzpdywzlhylutuaycp4bg7qk4) - '@azure-tools/typespec-client-generator-core': 0.51.0(@azure-tools/typespec-azure-core@0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))))(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/openapi@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/versioning@0.65.0(@typespec/compiler@0.65.0))(@typespec/xml@0.59.0(@typespec/compiler@0.65.0)) + '@azure-tools/typespec-azure-rulesets': 0.51.0(6ivl7wlwgurmoe44tk3z43uzly) + '@azure-tools/typespec-client-generator-core': 0.51.1(@azure-tools/typespec-azure-core@0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))))(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/openapi@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))(@typespec/versioning@0.65.0(@typespec/compiler@0.65.0))(@typespec/xml@0.59.0(@typespec/compiler@0.65.0)) '@typespec/compiler': 0.65.0 '@typespec/http': 0.65.0(@typespec/compiler@0.65.0) '@typespec/openapi': 0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)) From 9b9f75c42f853586b86a576048c1669d3119ce70 Mon Sep 17 00:00:00 2001 From: AutoPrFromHttpClientPython Date: Thu, 13 Feb 2025 02:17:58 +0000 Subject: [PATCH 04/14] Regenerate for typespec-python (2025-02-13 02:17:58) --- .../core/access/models/_models.py | 2 +- .../specs/azure/core/traits/models/_models.py | 4 +- .../azure/example/basic/models/_models.py | 18 ++++---- .../commonproperties/models/_models.py | 20 ++++----- .../operationtemplates/models/_models.py | 20 ++++----- .../resources/models/_models.py | 32 +++++++------- .../clientnamespace/second/models/_models.py | 2 +- .../encode/datetime/models/_models.py | 4 +- .../payload/jsonmergepatch/models/_models.py | 16 +++---- .../payload/multipart/models/_models.py | 26 +++++------ .../payload-xml/payload/xml/models/_models.py | 44 +++++++++---------- .../typetest/array/models/_models.py | 2 +- .../typetest/dictionary/models/_models.py | 2 +- .../model/enumdiscriminator/models/_models.py | 4 +- .../nesteddiscriminator/models/_models.py | 8 ++-- .../model/recursive/models/_models.py | 2 +- .../singlediscriminator/models/_models.py | 10 ++--- .../additionalproperties/models/_models.py | 22 +++++----- .../property/nullable/models/_models.py | 28 ++++++------ .../property/optional/models/_models.py | 12 ++--- .../property/valuetypes/models/_models.py | 4 +- .../typetest/union/models/_models.py | 22 +++++----- .../versioning/added/models/_models.py | 8 ++-- .../versioning/madeoptional/models/_models.py | 2 +- .../versioning/removed/models/_models.py | 6 +-- .../versioning/renamedfrom/models/_models.py | 4 +- .../encode/datetime/models/_models.py | 4 +- .../payload/jsonmergepatch/models/_models.py | 16 +++---- .../payload/multipart/models/_models.py | 26 +++++------ .../payload-xml/payload/xml/models/_models.py | 44 +++++++++---------- .../typetest/array/models/_models.py | 2 +- .../typetest/dictionary/models/_models.py | 2 +- .../model/enumdiscriminator/models/_models.py | 4 +- .../nesteddiscriminator/models/_models.py | 8 ++-- .../model/recursive/models/_models.py | 2 +- .../singlediscriminator/models/_models.py | 10 ++--- .../additionalproperties/models/_models.py | 22 +++++----- .../property/nullable/models/_models.py | 28 ++++++------ .../property/optional/models/_models.py | 12 ++--- .../property/valuetypes/models/_models.py | 4 +- .../typetest/union/models/_models.py | 22 +++++----- .../versioning/added/models/_models.py | 8 ++-- .../versioning/madeoptional/models/_models.py | 2 +- .../versioning/removed/models/_models.py | 6 +-- .../versioning/renamedfrom/models/_models.py | 4 +- 45 files changed, 275 insertions(+), 275 deletions(-) diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-access/specs/azure/clientgenerator/core/access/models/_models.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-access/specs/azure/clientgenerator/core/access/models/_models.py index dd0e14c5e78..1c7b4a5b4d4 100644 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-access/specs/azure/clientgenerator/core/access/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-access/specs/azure/clientgenerator/core/access/models/_models.py @@ -299,7 +299,7 @@ class RealModel(AbstractModel, discriminator="real"): :vartype kind: str """ - kind: Literal["real"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long + kind: Literal["real"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long,useless-suppression """Required. Default value is \"real\".""" @overload diff --git a/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/models/_models.py b/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/models/_models.py index da83da066df..ee68031219b 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/models/_models.py @@ -59,7 +59,7 @@ class UserActionParam(_model_base.Model): user_action_value: str = rest_field( name="userActionValue", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """User action value. Required.""" @overload @@ -90,7 +90,7 @@ class UserActionResponse(_model_base.Model): user_action_result: str = rest_field( name="userActionResult", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """User action result. Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/models/_models.py b/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/models/_models.py index 75081a63549..befa15f0ba2 100644 --- a/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/models/_models.py @@ -35,13 +35,13 @@ class ActionRequest(_model_base.Model): """Required.""" model_property: Optional["_models.Model"] = rest_field( name="modelProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long array_property: Optional[List[str]] = rest_field( name="arrayProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long record_property: Optional[Dict[str, str]] = rest_field( name="recordProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long @overload def __init__( @@ -82,13 +82,13 @@ class ActionResponse(_model_base.Model): """Required.""" model_property: Optional["_models.Model"] = rest_field( name="modelProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long array_property: Optional[List[str]] = rest_field( name="arrayProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long record_property: Optional[Dict[str, str]] = rest_field( name="recordProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long @overload def __init__( @@ -124,13 +124,13 @@ class Model(_model_base.Model): int32_property: Optional[int] = rest_field( name="int32Property", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long float32_property: Optional[float] = rest_field( name="float32Property", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long enum_property: Optional[Union[str, "_models.EnumEnum"]] = rest_field( name="enumProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """\"EnumValue1\"""" @overload diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/models/_models.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/models/_models.py index e7bf4351785..e07badc4ef5 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/models/_models.py @@ -62,7 +62,7 @@ class ErrorDetail(_model_base.Model): """The error details.""" additional_info: Optional[List["_models.ErrorAdditionalInfo"]] = rest_field( name="additionalInfo", visibility=["read"] - ) + ) # pylint: disable=line-too-long """The error additional info.""" @@ -204,11 +204,11 @@ class ManagedIdentityTrackedResource(TrackedResource): properties: Optional["_models.ManagedIdentityTrackedResourceProperties"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """The resource-specific properties for this resource.""" identity: Optional["_models.ManagedServiceIdentity"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """The managed service identities assigned to this resource.""" @overload @@ -274,12 +274,12 @@ class ManagedServiceIdentity(_model_base.Model): assigned identity.""" type: Union[str, "_models.ManagedServiceIdentityType"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """The type of managed identity assigned to this resource. Required. Known values are: \"None\", \"SystemAssigned\", \"UserAssigned\", and \"SystemAssigned,UserAssigned\".""" user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = rest_field( name="userAssignedIdentities", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """The identities assigned to this resource by the user.""" @overload @@ -325,25 +325,25 @@ class SystemData(_model_base.Model): """The identity that created the resource.""" created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( name="createdByType", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """The type of identity that created the resource. Known values are: \"User\", \"Application\", \"ManagedIdentity\", and \"Key\".""" created_at: Optional[datetime.datetime] = rest_field( name="createdAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) + ) # pylint: disable=line-too-long """The timestamp of resource creation (UTC).""" last_modified_by: Optional[str] = rest_field( name="lastModifiedBy", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """The identity that last modified the resource.""" last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( name="lastModifiedByType", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """The type of identity that last modified the resource. Known values are: \"User\", \"Application\", \"ManagedIdentity\", and \"Key\".""" last_modified_at: Optional[datetime.datetime] = rest_field( name="lastModifiedAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) + ) # pylint: disable=line-too-long """The timestamp of resource last modification (UTC).""" @overload diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/models/_models.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/models/_models.py index c39cf961f66..a6e1a5350b9 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/models/_models.py @@ -65,11 +65,11 @@ class CheckNameAvailabilityResponse(_model_base.Model): name_available: Optional[bool] = rest_field( name="nameAvailable", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Indicates if the resource name is available.""" reason: Optional[Union[str, "_models.CheckNameAvailabilityReason"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """The reason why the given name is not available. Known values are: \"Invalid\" and \"AlreadyExists\".""" message: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -140,7 +140,7 @@ class ErrorDetail(_model_base.Model): """The error details.""" additional_info: Optional[List["_models.ErrorAdditionalInfo"]] = rest_field( name="additionalInfo", visibility=["read"] - ) + ) # pylint: disable=line-too-long """The error additional info.""" @@ -234,7 +234,7 @@ class Operation(_model_base.Model): \"false\" for Azure Resource Manager/control-plane operations.""" display: Optional["_models.OperationDisplay"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Localized display information for this particular operation.""" origin: Optional[Union[str, "_models.Origin"]] = rest_field(visibility=["read"]) """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit @@ -401,7 +401,7 @@ class Order(TrackedResource): properties: Optional["_models.OrderProperties"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """The resource-specific properties for this resource.""" @overload @@ -488,25 +488,25 @@ class SystemData(_model_base.Model): """The identity that created the resource.""" created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( name="createdByType", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """The type of identity that created the resource. Known values are: \"User\", \"Application\", \"ManagedIdentity\", and \"Key\".""" created_at: Optional[datetime.datetime] = rest_field( name="createdAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) + ) # pylint: disable=line-too-long """The timestamp of resource creation (UTC).""" last_modified_by: Optional[str] = rest_field( name="lastModifiedBy", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """The identity that last modified the resource.""" last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( name="lastModifiedByType", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """The type of identity that last modified the resource. Known values are: \"User\", \"Application\", \"ManagedIdentity\", and \"Key\".""" last_modified_at: Optional[datetime.datetime] = rest_field( name="lastModifiedAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) + ) # pylint: disable=line-too-long """The timestamp of resource last modification (UTC).""" @overload diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/models/_models.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/models/_models.py index d57ad92bfc8..4f171f53ff2 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/models/_models.py @@ -61,7 +61,7 @@ class ErrorDetail(_model_base.Model): """The error details.""" additional_info: Optional[List["_models.ErrorAdditionalInfo"]] = rest_field( name="additionalInfo", visibility=["read"] - ) + ) # pylint: disable=line-too-long """The error additional info.""" @@ -166,7 +166,7 @@ class ExtensionsResource(ExtensionResource): properties: Optional["_models.ExtensionsResourceProperties"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """The resource-specific properties for this resource.""" @overload @@ -203,7 +203,7 @@ class ExtensionsResourceProperties(_model_base.Model): """The description of the resource.""" provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( name="provisioningState", visibility=["read"] - ) + ) # pylint: disable=line-too-long """The status of the last operation. Known values are: \"Succeeded\", \"Failed\", \"Canceled\", \"Provisioning\", \"Updating\", \"Deleting\", and \"Accepted\".""" @@ -268,7 +268,7 @@ class LocationResource(ProxyResource): properties: Optional["_models.LocationResourceProperties"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """The resource-specific properties for this resource.""" @overload @@ -305,7 +305,7 @@ class LocationResourceProperties(_model_base.Model): """The description of the resource.""" provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( name="provisioningState", visibility=["read"] - ) + ) # pylint: disable=line-too-long """The status of the last operation. Known values are: \"Succeeded\", \"Failed\", \"Canceled\", \"Provisioning\", \"Updating\", \"Deleting\", and \"Accepted\".""" @@ -349,7 +349,7 @@ class NestedProxyResource(ProxyResource): properties: Optional["_models.NestedProxyResourceProperties"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """The resource-specific properties for this resource.""" @overload @@ -384,7 +384,7 @@ class NestedProxyResourceProperties(_model_base.Model): provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( name="provisioningState", visibility=["read"] - ) + ) # pylint: disable=line-too-long """Provisioning State of the nested child Resource. Known values are: \"Succeeded\", \"Failed\", \"Canceled\", \"Provisioning\", \"Updating\", \"Deleting\", and \"Accepted\".""" description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -519,7 +519,7 @@ class SingletonTrackedResource(TrackedResource): properties: Optional["_models.SingletonTrackedResourceProperties"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """The resource-specific properties for this resource.""" @overload @@ -556,7 +556,7 @@ class SingletonTrackedResourceProperties(_model_base.Model): provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( name="provisioningState", visibility=["read"] - ) + ) # pylint: disable=line-too-long """The status of the last operation. Known values are: \"Succeeded\", \"Failed\", \"Canceled\", \"Provisioning\", \"Updating\", \"Deleting\", and \"Accepted\".""" description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -603,25 +603,25 @@ class SystemData(_model_base.Model): """The identity that created the resource.""" created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( name="createdByType", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """The type of identity that created the resource. Known values are: \"User\", \"Application\", \"ManagedIdentity\", and \"Key\".""" created_at: Optional[datetime.datetime] = rest_field( name="createdAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) + ) # pylint: disable=line-too-long """The timestamp of resource creation (UTC).""" last_modified_by: Optional[str] = rest_field( name="lastModifiedBy", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """The identity that last modified the resource.""" last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( name="lastModifiedByType", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """The type of identity that last modified the resource. Known values are: \"User\", \"Application\", \"ManagedIdentity\", and \"Key\".""" last_modified_at: Optional[datetime.datetime] = rest_field( name="lastModifiedAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) + ) # pylint: disable=line-too-long """The timestamp of resource last modification (UTC).""" @overload @@ -675,7 +675,7 @@ class TopLevelTrackedResource(TrackedResource): properties: Optional["_models.TopLevelTrackedResourceProperties"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """The resource-specific properties for this resource.""" @overload @@ -712,7 +712,7 @@ class TopLevelTrackedResourceProperties(_model_base.Model): provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( name="provisioningState", visibility=["read"] - ) + ) # pylint: disable=line-too-long """The status of the last operation. Known values are: \"Succeeded\", \"Failed\", \"Canceled\", \"Provisioning\", \"Updating\", \"Deleting\", and \"Accepted\".""" description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) diff --git a/packages/typespec-python/test/azure/generated/client-namespace/client/clientnamespace/second/models/_models.py b/packages/typespec-python/test/azure/generated/client-namespace/client/clientnamespace/second/models/_models.py index e30b5d44c70..4208fe05aa8 100644 --- a/packages/typespec-python/test/azure/generated/client-namespace/client/clientnamespace/second/models/_models.py +++ b/packages/typespec-python/test/azure/generated/client-namespace/client/clientnamespace/second/models/_models.py @@ -26,7 +26,7 @@ class SecondClientResult(_model_base.Model): type: Union[str, "_sub_models2.SecondClientEnumType"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required. \"second\"""" @overload diff --git a/packages/typespec-python/test/azure/generated/encode-datetime/encode/datetime/models/_models.py b/packages/typespec-python/test/azure/generated/encode-datetime/encode/datetime/models/_models.py index da2a9d47fff..7c31d2633b9 100644 --- a/packages/typespec-python/test/azure/generated/encode-datetime/encode/datetime/models/_models.py +++ b/packages/typespec-python/test/azure/generated/encode-datetime/encode/datetime/models/_models.py @@ -111,7 +111,7 @@ class UnixTimestampArrayDatetimeProperty(_model_base.Model): value: List[datetime.datetime] = rest_field( visibility=["read", "create", "update", "delete", "query"], format="unix-timestamp" - ) + ) # pylint: disable=line-too-long """Required.""" @overload @@ -142,7 +142,7 @@ class UnixTimestampDatetimeProperty(_model_base.Model): value: datetime.datetime = rest_field( visibility=["read", "create", "update", "delete", "query"], format="unix-timestamp" - ) + ) # pylint: disable=line-too-long """Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/payload-json-merge-patch/payload/jsonmergepatch/models/_models.py b/packages/typespec-python/test/azure/generated/payload-json-merge-patch/payload/jsonmergepatch/models/_models.py index 5a695012117..874a43c2668 100644 --- a/packages/typespec-python/test/azure/generated/payload-json-merge-patch/payload/jsonmergepatch/models/_models.py +++ b/packages/typespec-python/test/azure/generated/payload-json-merge-patch/payload/jsonmergepatch/models/_models.py @@ -74,18 +74,18 @@ class Resource(_model_base.Model): description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) map: Optional[Dict[str, "_models.InnerModel"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long array: Optional[List["_models.InnerModel"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) int_value: Optional[int] = rest_field(name="intValue", visibility=["read", "create", "update", "delete", "query"]) float_value: Optional[float] = rest_field( name="floatValue", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long inner_model: Optional["_models.InnerModel"] = rest_field( name="innerModel", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long int_array: Optional[List[int]] = rest_field( name="intArray", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long @overload def __init__( @@ -134,18 +134,18 @@ class ResourcePatch(_model_base.Model): description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) map: Optional[Dict[str, "_models.InnerModel"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long array: Optional[List["_models.InnerModel"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) int_value: Optional[int] = rest_field(name="intValue", visibility=["read", "create", "update", "delete", "query"]) float_value: Optional[float] = rest_field( name="floatValue", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long inner_model: Optional["_models.InnerModel"] = rest_field( name="innerModel", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long int_array: Optional[List[int]] = rest_field( name="intArray", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long @overload def __init__( diff --git a/packages/typespec-python/test/azure/generated/payload-multipart/payload/multipart/models/_models.py b/packages/typespec-python/test/azure/generated/payload-multipart/payload/multipart/models/_models.py index 83fb5e120d4..0dc6117747a 100644 --- a/packages/typespec-python/test/azure/generated/payload-multipart/payload/multipart/models/_models.py +++ b/packages/typespec-python/test/azure/generated/payload-multipart/payload/multipart/models/_models.py @@ -62,7 +62,7 @@ class BinaryArrayPartsRequest(_model_base.Model): """Required.""" pictures: List[FileType] = rest_field( visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) + ) # pylint: disable=line-too-long """Required.""" @overload @@ -107,15 +107,15 @@ class ComplexHttpPartsModelRequest(_model_base.Model): """Required.""" profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) + ) # pylint: disable=line-too-long """Required.""" previous_addresses: List["_models.Address"] = rest_field( name="previousAddresses", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required.""" pictures: List[FileType] = rest_field( visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) + ) # pylint: disable=line-too-long """Required.""" @overload @@ -161,11 +161,11 @@ class ComplexPartsRequest(_model_base.Model): """Required.""" profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) + ) # pylint: disable=line-too-long """Required.""" pictures: List[FileType] = rest_field( visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) + ) # pylint: disable=line-too-long """Required.""" @overload @@ -200,7 +200,7 @@ class FileWithHttpPartOptionalContentTypeRequest(_model_base.Model): # pylint: profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) + ) # pylint: disable=line-too-long """Required.""" @overload @@ -232,7 +232,7 @@ class FileWithHttpPartRequiredContentTypeRequest(_model_base.Model): # pylint: profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) + ) # pylint: disable=line-too-long """Required.""" @overload @@ -264,7 +264,7 @@ class FileWithHttpPartSpecificContentTypeRequest(_model_base.Model): # pylint: profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) + ) # pylint: disable=line-too-long """Required.""" @overload @@ -330,7 +330,7 @@ class JsonPartRequest(_model_base.Model): """Required.""" profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) + ) # pylint: disable=line-too-long """Required.""" @overload @@ -365,11 +365,11 @@ class MultiBinaryPartsRequest(_model_base.Model): profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) + ) # pylint: disable=line-too-long """Required.""" picture: Optional[FileType] = rest_field( visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) + ) # pylint: disable=line-too-long @overload def __init__( @@ -405,7 +405,7 @@ class MultiPartRequest(_model_base.Model): """Required.""" profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) + ) # pylint: disable=line-too-long """Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/models/_models.py b/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/models/_models.py index bd4c3b2aa6a..16088313c11 100644 --- a/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/models/_models.py +++ b/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/models/_models.py @@ -28,7 +28,7 @@ class ModelWithArrayOfModel(_model_base.Model): name="items", visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "SimpleModel", "name": "items", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" _xml = {"attribute": False, "name": "ModelWithArrayOfModel", "text": False, "unwrapped": False} @@ -66,17 +66,17 @@ class ModelWithAttributes(_model_base.Model): id1: int = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": True, "name": "id1", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" id2: str = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": True, "name": "id2", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" enabled: bool = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "enabled", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" _xml = {"attribute": False, "name": "ModelWithAttributes", "text": False, "unwrapped": False} @@ -112,7 +112,7 @@ class ModelWithDictionary(_model_base.Model): metadata: Dict[str, str] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "metadata", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" _xml = {"attribute": False, "name": "ModelWithDictionary", "text": False, "unwrapped": False} @@ -147,7 +147,7 @@ class ModelWithEmptyArray(_model_base.Model): name="items", visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "SimpleModel", "name": "items", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" _xml = {"attribute": False, "name": "ModelWithEmptyArray", "text": False, "unwrapped": False} @@ -184,12 +184,12 @@ class ModelWithEncodedNames(_model_base.Model): name="modelData", visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "SimpleModelData", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" colors: List[str] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "string", "name": "PossibleColors", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" _xml = {"attribute": False, "name": "ModelWithEncodedNamesSrc", "text": False, "unwrapped": False} @@ -226,12 +226,12 @@ class ModelWithOptionalField(_model_base.Model): item: str = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "item", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" value: Optional[int] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "value", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long _xml = {"attribute": False, "name": "ModelWithOptionalField", "text": False, "unwrapped": False} @@ -268,12 +268,12 @@ class ModelWithRenamedArrays(_model_base.Model): colors: List[str] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "Colors", "name": "Colors", "text": False, "unwrapped": True}, - ) + ) # pylint: disable=line-too-long """Required.""" counts: List[int] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "int32", "name": "Counts", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" _xml = {"attribute": False, "name": "ModelWithRenamedArrays", "text": False, "unwrapped": False} @@ -311,13 +311,13 @@ class ModelWithRenamedFields(_model_base.Model): name="inputData", visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "InputData", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" output_data: "_models.SimpleModel" = rest_field( name="outputData", visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "OutputData", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" _xml = {"attribute": False, "name": "ModelWithRenamedFieldsSrc", "text": False, "unwrapped": False} @@ -354,12 +354,12 @@ class ModelWithSimpleArrays(_model_base.Model): colors: List[str] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "string", "name": "colors", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" counts: List[int] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "int32", "name": "counts", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" _xml = {"attribute": False, "name": "ModelWithSimpleArrays", "text": False, "unwrapped": False} @@ -396,12 +396,12 @@ class ModelWithText(_model_base.Model): language: str = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": True, "name": "language", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" content: str = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "content", "text": True, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" _xml = {"attribute": False, "name": "ModelWithText", "text": False, "unwrapped": False} @@ -438,12 +438,12 @@ class ModelWithUnwrappedArray(_model_base.Model): colors: List[str] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "colors", "name": "colors", "text": False, "unwrapped": True}, - ) + ) # pylint: disable=line-too-long """Required.""" counts: List[int] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "int32", "name": "counts", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" _xml = {"attribute": False, "name": "ModelWithUnwrappedArray", "text": False, "unwrapped": False} @@ -480,12 +480,12 @@ class SimpleModel(_model_base.Model): name: str = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "name", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" age: int = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "age", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" _xml = {"attribute": False, "name": "SimpleModel", "text": False, "unwrapped": False} diff --git a/packages/typespec-python/test/azure/generated/typetest-array/typetest/array/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-array/typetest/array/models/_models.py index 3102e45483a..676c9bdc271 100644 --- a/packages/typespec-python/test/azure/generated/typetest-array/typetest/array/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-array/typetest/array/models/_models.py @@ -30,7 +30,7 @@ class InnerModel(_model_base.Model): """Required string property. Required.""" children: Optional[List["_models.InnerModel"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long @overload def __init__( diff --git a/packages/typespec-python/test/azure/generated/typetest-dictionary/typetest/dictionary/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-dictionary/typetest/dictionary/models/_models.py index 92decb06661..a942f96aa46 100644 --- a/packages/typespec-python/test/azure/generated/typetest-dictionary/typetest/dictionary/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-dictionary/typetest/dictionary/models/_models.py @@ -30,7 +30,7 @@ class InnerModel(_model_base.Model): """Required string property. Required.""" children: Optional[Dict[str, "_models.InnerModel"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long @overload def __init__( diff --git a/packages/typespec-python/test/azure/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/models/_models.py index c37e84c979c..272b1fbfc5f 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/models/_models.py @@ -62,7 +62,7 @@ class Cobra(Snake, discriminator="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 + kind: Literal[SnakeKind.COBRA] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long """discriminator property. Required. Species cobra""" @overload @@ -131,7 +131,7 @@ class Golden(Dog, discriminator="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 + kind: Literal[DogKind.GOLDEN] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long """discriminator property. Required. Species golden""" @overload diff --git a/packages/typespec-python/test/azure/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/models/_models.py index 2dbdcf1abfb..4098685a2ef 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/models/_models.py @@ -71,7 +71,7 @@ class Shark(Fish, discriminator="shark"): """ __mapping__: Dict[str, _model_base.Model] = {} - kind: Literal["shark"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long + kind: Literal["shark"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long,useless-suppression """Required. Default value is \"shark\".""" sharktype: str = rest_discriminator(name="sharktype", visibility=["read", "create", "update", "delete", "query"]) """Required. Default value is None.""" @@ -108,7 +108,7 @@ class GoblinShark(Shark, discriminator="goblin"): """ __mapping__: Dict[str, _model_base.Model] = {} - sharktype: Literal["goblin"] = rest_discriminator(name="sharktype", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + sharktype: Literal["goblin"] = rest_discriminator(name="sharktype", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long """Required. Default value is \"goblin\".""" @overload @@ -146,7 +146,7 @@ class Salmon(Fish, discriminator="salmon"): :vartype partner: ~typetest.model.nesteddiscriminator.models.Fish """ - kind: Literal["salmon"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + kind: Literal["salmon"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long """Required. Default value is \"salmon\".""" friends: Optional[List["_models.Fish"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) hate: Optional[Dict[str, "_models.Fish"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -186,7 +186,7 @@ class SawShark(Shark, discriminator="saw"): """ __mapping__: Dict[str, _model_base.Model] = {} - sharktype: Literal["saw"] = rest_discriminator(name="sharktype", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + sharktype: Literal["saw"] = rest_discriminator(name="sharktype", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long """Required. Default value is \"saw\".""" @overload diff --git a/packages/typespec-python/test/azure/generated/typetest-model-recursive/typetest/model/recursive/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-model-recursive/typetest/model/recursive/models/_models.py index 0910dc67bd5..8d63010ca6c 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-recursive/typetest/model/recursive/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-recursive/typetest/model/recursive/models/_models.py @@ -25,7 +25,7 @@ class Element(_model_base.Model): extension: Optional[List["_models.Extension"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long @overload def __init__( diff --git a/packages/typespec-python/test/azure/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/models/_models.py index 9f9e9a9a572..0e94792827d 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/models/_models.py @@ -110,7 +110,7 @@ class Eagle(Bird, discriminator="eagle"): :vartype partner: ~typetest.model.singlediscriminator.models.Bird """ - kind: Literal["eagle"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long + kind: Literal["eagle"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long,useless-suppression """Required. Default value is \"eagle\".""" friends: Optional[List["_models.Bird"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) hate: Optional[Dict[str, "_models.Bird"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -147,7 +147,7 @@ class Goose(Bird, discriminator="goose"): :vartype kind: str """ - kind: Literal["goose"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long + kind: Literal["goose"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long,useless-suppression """Required. Default value is \"goose\".""" @overload @@ -178,7 +178,7 @@ class SeaGull(Bird, discriminator="seagull"): :vartype kind: str """ - kind: Literal["seagull"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + kind: Literal["seagull"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long """Required. Default value is \"seagull\".""" @overload @@ -209,7 +209,7 @@ class Sparrow(Bird, discriminator="sparrow"): :vartype kind: str """ - kind: Literal["sparrow"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + kind: Literal["sparrow"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long """Required. Default value is \"sparrow\".""" @overload @@ -240,7 +240,7 @@ class TRex(Dinosaur, discriminator="t-rex"): :vartype kind: str """ - kind: Literal["t-rex"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long + kind: Literal["t-rex"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long,useless-suppression """Required. Default value is \"t-rex\".""" @overload diff --git a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py index 68682ec7936..3e81c75dc3f 100644 --- a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py @@ -122,7 +122,7 @@ class DifferentSpreadModelArrayDerived(DifferentSpreadModelArrayRecord): derived_prop: List["_models.ModelForRecord"] = rest_field( name="derivedProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """The index property. Required.""" @overload @@ -186,7 +186,7 @@ class DifferentSpreadModelDerived(DifferentSpreadModelRecord): derived_prop: "_models.ModelForRecord" = rest_field( name="derivedProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """The index property. Required.""" @overload @@ -309,7 +309,7 @@ class ExtendsModelAdditionalProperties(_model_base.Model): known_prop: "_models.ModelForRecord" = rest_field( name="knownProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required.""" @overload @@ -340,7 +340,7 @@ class ExtendsModelArrayAdditionalProperties(_model_base.Model): known_prop: List["_models.ModelForRecord"] = rest_field( name="knownProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required.""" @overload @@ -510,7 +510,7 @@ class ExtendsUnknownAdditionalPropertiesDiscriminatedDerived( :vartype age: float """ - kind: Literal["derived"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + kind: Literal["derived"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long """Required. Default value is \"derived\".""" index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The index property. Required.""" @@ -576,7 +576,7 @@ class IsModelAdditionalProperties(_model_base.Model): known_prop: "_models.ModelForRecord" = rest_field( name="knownProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required.""" @overload @@ -607,7 +607,7 @@ class IsModelArrayAdditionalProperties(_model_base.Model): known_prop: List["_models.ModelForRecord"] = rest_field( name="knownProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required.""" @overload @@ -777,7 +777,7 @@ class IsUnknownAdditionalPropertiesDiscriminatedDerived( :vartype age: float """ - kind: Literal["derived"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + kind: Literal["derived"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long """Required. Default value is \"derived\".""" index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The index property. Required.""" @@ -901,7 +901,7 @@ class SpreadModelArrayRecord(_model_base.Model): known_prop: List["_models.ModelForRecord"] = rest_field( name="knownProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required.""" @overload @@ -932,7 +932,7 @@ class SpreadModelRecord(_model_base.Model): known_prop: "_models.ModelForRecord" = rest_field( name="knownProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required.""" @overload @@ -1183,7 +1183,7 @@ class WidgetData1(_model_base.Model): """Required.""" end: Optional[datetime.datetime] = rest_field( visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) + ) # pylint: disable=line-too-long @overload def __init__( diff --git a/packages/typespec-python/test/azure/generated/typetest-property-nullable/typetest/property/nullable/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-property-nullable/typetest/property/nullable/models/_models.py index 75617a41bac..d3d0de7d18f 100644 --- a/packages/typespec-python/test/azure/generated/typetest-property-nullable/typetest/property/nullable/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-property-nullable/typetest/property/nullable/models/_models.py @@ -30,11 +30,11 @@ class BytesProperty(_model_base.Model): required_property: str = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required property. Required.""" nullable_property: bytes = rest_field( name="nullableProperty", visibility=["read", "create", "update", "delete", "query"], format="base64" - ) + ) # pylint: disable=line-too-long """Property. Required.""" @overload @@ -68,11 +68,11 @@ class CollectionsByteProperty(_model_base.Model): required_property: str = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required property. Required.""" nullable_property: List[bytes] = rest_field( name="nullableProperty", visibility=["read", "create", "update", "delete", "query"], format="base64" - ) + ) # pylint: disable=line-too-long """Property. Required.""" @overload @@ -106,11 +106,11 @@ class CollectionsModelProperty(_model_base.Model): required_property: str = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required property. Required.""" nullable_property: List["_models.InnerModel"] = rest_field( name="nullableProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Property. Required.""" @overload @@ -144,11 +144,11 @@ class CollectionsStringProperty(_model_base.Model): required_property: str = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required property. Required.""" nullable_property: List[str] = rest_field( name="nullableProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Property. Required.""" @overload @@ -182,11 +182,11 @@ class DatetimeProperty(_model_base.Model): required_property: str = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required property. Required.""" nullable_property: datetime.datetime = rest_field( name="nullableProperty", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) + ) # pylint: disable=line-too-long """Property. Required.""" @overload @@ -220,11 +220,11 @@ class DurationProperty(_model_base.Model): required_property: str = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required property. Required.""" nullable_property: datetime.timedelta = rest_field( name="nullableProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Property. Required.""" @overload @@ -288,11 +288,11 @@ class StringProperty(_model_base.Model): required_property: str = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required property. Required.""" nullable_property: str = rest_field( name="nullableProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Property. Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/typetest-property-optional/typetest/property/optional/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-property-optional/typetest/property/optional/models/_models.py index 5e8dbdad678..bb9b7ad9cc2 100644 --- a/packages/typespec-python/test/azure/generated/typetest-property-optional/typetest/property/optional/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-property-optional/typetest/property/optional/models/_models.py @@ -83,7 +83,7 @@ class CollectionsByteProperty(_model_base.Model): property: Optional[List[bytes]] = rest_field( visibility=["read", "create", "update", "delete", "query"], format="base64" - ) + ) # pylint: disable=line-too-long """Property.""" @overload @@ -113,7 +113,7 @@ class CollectionsModelProperty(_model_base.Model): property: Optional[List["_models.StringProperty"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Property.""" @overload @@ -143,7 +143,7 @@ class DatetimeProperty(_model_base.Model): property: Optional[datetime.datetime] = rest_field( visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) + ) # pylint: disable=line-too-long """Property.""" @overload @@ -316,11 +316,11 @@ class RequiredAndOptionalProperty(_model_base.Model): optional_property: Optional[str] = rest_field( name="optionalProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """optional string property.""" required_property: int = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """required int property. Required.""" @overload @@ -464,7 +464,7 @@ class UnionStringLiteralProperty(_model_base.Model): property: Optional[Literal["hello", "world"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Property. Is either a Literal[\"hello\"] type or a Literal[\"world\"] type.""" @overload diff --git a/packages/typespec-python/test/azure/generated/typetest-property-valuetypes/typetest/property/valuetypes/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-property-valuetypes/typetest/property/valuetypes/models/_models.py index e436012c81d..e15fd7c4b65 100644 --- a/packages/typespec-python/test/azure/generated/typetest-property-valuetypes/typetest/property/valuetypes/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-property-valuetypes/typetest/property/valuetypes/models/_models.py @@ -192,7 +192,7 @@ class DatetimeProperty(_model_base.Model): property: datetime.datetime = rest_field( visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) + ) # pylint: disable=line-too-long """Property. Required.""" @overload @@ -339,7 +339,7 @@ class EnumProperty(_model_base.Model): property: Union[str, "_models.FixedInnerEnum"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Property. Required. Known values are: \"ValueOne\" and \"ValueTwo\".""" @overload diff --git a/packages/typespec-python/test/azure/generated/typetest-union/typetest/union/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-union/typetest/union/models/_models.py index 82507a82c34..73443d92627 100644 --- a/packages/typespec-python/test/azure/generated/typetest-union/typetest/union/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-union/typetest/union/models/_models.py @@ -325,7 +325,7 @@ class GetResponse7(_model_base.Model): prop: Union[str, "_models.StringExtensibleNamedUnion"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required. Known values are: \"b\" and \"c\".""" @overload @@ -356,7 +356,7 @@ class GetResponse8(_model_base.Model): prop: Union[Literal["b"], Literal["c"], str] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required. Is one of the following types: Literal[\"b\"], Literal[\"c\"], str""" @overload @@ -426,22 +426,22 @@ class MixedLiteralsCases(_model_base.Model): string_literal: Literal["a", 2, True] = rest_field( name="stringLiteral", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """This should be receive/send the \"a\" variant. Required. Is one of the following types: Literal[\"a\"], Literal[2], float, Literal[True]""" int_literal: Literal["a", 2, True] = rest_field( name="intLiteral", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """This should be receive/send the 2 variant. Required. Is one of the following types: Literal[\"a\"], Literal[2], float, Literal[True]""" float_literal: Literal["a", 2, True] = rest_field( name="floatLiteral", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """This should be receive/send the 3.3 variant. Required. Is one of the following types: Literal[\"a\"], Literal[2], float, Literal[True]""" boolean_literal: Literal["a", 2, True] = rest_field( name="booleanLiteral", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """This should be receive/send the true variant. Required. Is one of the following types: Literal[\"a\"], Literal[2], float, Literal[True]""" @@ -488,27 +488,27 @@ class MixedTypesCases(_model_base.Model): model: Union["_models.Cat", Literal["a"], int, bool] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """This should be receive/send the Cat variant. Required. Is one of the following types: Cat, Literal[\"a\"], int, bool""" literal: Union["_models.Cat", Literal["a"], int, bool] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """This should be receive/send the \"a\" variant. Required. Is one of the following types: Cat, Literal[\"a\"], int, bool""" int_property: Union["_models.Cat", Literal["a"], int, bool] = rest_field( name="int", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """This should be receive/send the int variant. Required. Is one of the following types: Cat, Literal[\"a\"], int, bool""" boolean: Union["_models.Cat", Literal["a"], int, bool] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """This should be receive/send the boolean variant. Required. Is one of the following types: Cat, Literal[\"a\"], int, bool""" array: List[Union["_models.Cat", Literal["a"], int, bool]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """This should be receive/send 4 element with Cat, \"a\", int, and boolean. Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/models/_models.py b/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/models/_models.py index 4723f9db5b8..c3707e33f15 100644 --- a/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/models/_models.py +++ b/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/models/_models.py @@ -32,11 +32,11 @@ class ModelV1(_model_base.Model): """Required.""" enum_prop: Union[str, "_models.EnumV1"] = rest_field( name="enumProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required. Known values are: \"enumMemberV1\" and \"enumMemberV2\".""" union_prop: "_types.UnionV1" = rest_field( name="unionProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required. Is either a str type or a int type.""" @overload @@ -75,11 +75,11 @@ class ModelV2(_model_base.Model): """Required.""" enum_prop: Union[str, "_models.EnumV2"] = rest_field( name="enumProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required. \"enumMember\"""" union_prop: "_types.UnionV2" = rest_field( name="unionProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required. Is either a str type or a int type.""" @overload diff --git a/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/models/_models.py b/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/models/_models.py index 4f831a94814..69ae88f4617 100644 --- a/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/models/_models.py +++ b/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/models/_models.py @@ -27,7 +27,7 @@ class TestModel(_model_base.Model): """Required.""" changed_prop: Optional[str] = rest_field( name="changedProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long @overload def __init__( diff --git a/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/models/_models.py b/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/models/_models.py index ac6c82b5f41..90930bbbdcb 100644 --- a/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/models/_models.py +++ b/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/models/_models.py @@ -32,11 +32,11 @@ class ModelV2(_model_base.Model): """Required.""" enum_prop: Union[str, "_models.EnumV2"] = rest_field( name="enumProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required. \"enumMemberV2\"""" union_prop: "_types.UnionV2" = rest_field( name="unionProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required. Is either a str type or a float type.""" @overload @@ -73,7 +73,7 @@ class ModelV3(_model_base.Model): """Required.""" enum_prop: Union[str, "_models.EnumV3"] = rest_field( name="enumProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required. Known values are: \"enumMemberV1\" and \"enumMemberV2Preview\".""" @overload diff --git a/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/models/_models.py b/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/models/_models.py index 4e8e36ed08b..34c97aa18c4 100644 --- a/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/models/_models.py +++ b/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/models/_models.py @@ -32,11 +32,11 @@ class NewModel(_model_base.Model): """Required.""" enum_prop: Union[str, "_models.NewEnum"] = rest_field( name="enumProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required. \"newEnumMember\"""" union_prop: "_types.NewUnion" = rest_field( name="unionProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required. Is either a str type or a int type.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/encode-datetime/encode/datetime/models/_models.py b/packages/typespec-python/test/unbranded/generated/encode-datetime/encode/datetime/models/_models.py index f68996e2385..7d5c4b481fa 100644 --- a/packages/typespec-python/test/unbranded/generated/encode-datetime/encode/datetime/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/encode-datetime/encode/datetime/models/_models.py @@ -111,7 +111,7 @@ class UnixTimestampArrayDatetimeProperty(_model_base.Model): value: List[datetime.datetime] = rest_field( visibility=["read", "create", "update", "delete", "query"], format="unix-timestamp" - ) + ) # pylint: disable=line-too-long """Required.""" @overload @@ -142,7 +142,7 @@ class UnixTimestampDatetimeProperty(_model_base.Model): value: datetime.datetime = rest_field( visibility=["read", "create", "update", "delete", "query"], format="unix-timestamp" - ) + ) # pylint: disable=line-too-long """Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/payload-json-merge-patch/payload/jsonmergepatch/models/_models.py b/packages/typespec-python/test/unbranded/generated/payload-json-merge-patch/payload/jsonmergepatch/models/_models.py index 8d8ec836387..4f79e4b2361 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-json-merge-patch/payload/jsonmergepatch/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/payload-json-merge-patch/payload/jsonmergepatch/models/_models.py @@ -74,18 +74,18 @@ class Resource(_model_base.Model): description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) map: Optional[Dict[str, "_models.InnerModel"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long array: Optional[List["_models.InnerModel"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) int_value: Optional[int] = rest_field(name="intValue", visibility=["read", "create", "update", "delete", "query"]) float_value: Optional[float] = rest_field( name="floatValue", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long inner_model: Optional["_models.InnerModel"] = rest_field( name="innerModel", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long int_array: Optional[List[int]] = rest_field( name="intArray", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long @overload def __init__( @@ -134,18 +134,18 @@ class ResourcePatch(_model_base.Model): description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) map: Optional[Dict[str, "_models.InnerModel"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long array: Optional[List["_models.InnerModel"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) int_value: Optional[int] = rest_field(name="intValue", visibility=["read", "create", "update", "delete", "query"]) float_value: Optional[float] = rest_field( name="floatValue", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long inner_model: Optional["_models.InnerModel"] = rest_field( name="innerModel", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long int_array: Optional[List[int]] = rest_field( name="intArray", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long @overload def __init__( diff --git a/packages/typespec-python/test/unbranded/generated/payload-multipart/payload/multipart/models/_models.py b/packages/typespec-python/test/unbranded/generated/payload-multipart/payload/multipart/models/_models.py index dd9bdb318c7..e00570b783f 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-multipart/payload/multipart/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/payload-multipart/payload/multipart/models/_models.py @@ -62,7 +62,7 @@ class BinaryArrayPartsRequest(_model_base.Model): """Required.""" pictures: List[FileType] = rest_field( visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) + ) # pylint: disable=line-too-long """Required.""" @overload @@ -107,15 +107,15 @@ class ComplexHttpPartsModelRequest(_model_base.Model): """Required.""" profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) + ) # pylint: disable=line-too-long """Required.""" previous_addresses: List["_models.Address"] = rest_field( name="previousAddresses", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required.""" pictures: List[FileType] = rest_field( visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) + ) # pylint: disable=line-too-long """Required.""" @overload @@ -161,11 +161,11 @@ class ComplexPartsRequest(_model_base.Model): """Required.""" profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) + ) # pylint: disable=line-too-long """Required.""" pictures: List[FileType] = rest_field( visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) + ) # pylint: disable=line-too-long """Required.""" @overload @@ -200,7 +200,7 @@ class FileWithHttpPartOptionalContentTypeRequest(_model_base.Model): # pylint: profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) + ) # pylint: disable=line-too-long """Required.""" @overload @@ -232,7 +232,7 @@ class FileWithHttpPartRequiredContentTypeRequest(_model_base.Model): # pylint: profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) + ) # pylint: disable=line-too-long """Required.""" @overload @@ -264,7 +264,7 @@ class FileWithHttpPartSpecificContentTypeRequest(_model_base.Model): # pylint: profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) + ) # pylint: disable=line-too-long """Required.""" @overload @@ -300,7 +300,7 @@ class JsonPartRequest(_model_base.Model): """Required.""" profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) + ) # pylint: disable=line-too-long """Required.""" @overload @@ -335,11 +335,11 @@ class MultiBinaryPartsRequest(_model_base.Model): profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) + ) # pylint: disable=line-too-long """Required.""" picture: Optional[FileType] = rest_field( visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) + ) # pylint: disable=line-too-long @overload def __init__( @@ -375,7 +375,7 @@ class MultiPartRequest(_model_base.Model): """Required.""" profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) + ) # pylint: disable=line-too-long """Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/models/_models.py b/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/models/_models.py index 3a624109b00..277d0d3a1a3 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/models/_models.py @@ -28,7 +28,7 @@ class ModelWithArrayOfModel(_model_base.Model): name="items", visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "SimpleModel", "name": "items", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" _xml = {"attribute": False, "name": "ModelWithArrayOfModel", "text": False, "unwrapped": False} @@ -66,17 +66,17 @@ class ModelWithAttributes(_model_base.Model): id1: int = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": True, "name": "id1", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" id2: str = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": True, "name": "id2", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" enabled: bool = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "enabled", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" _xml = {"attribute": False, "name": "ModelWithAttributes", "text": False, "unwrapped": False} @@ -112,7 +112,7 @@ class ModelWithDictionary(_model_base.Model): metadata: Dict[str, str] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "metadata", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" _xml = {"attribute": False, "name": "ModelWithDictionary", "text": False, "unwrapped": False} @@ -147,7 +147,7 @@ class ModelWithEmptyArray(_model_base.Model): name="items", visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "SimpleModel", "name": "items", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" _xml = {"attribute": False, "name": "ModelWithEmptyArray", "text": False, "unwrapped": False} @@ -184,12 +184,12 @@ class ModelWithEncodedNames(_model_base.Model): name="modelData", visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "SimpleModelData", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" colors: List[str] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "string", "name": "PossibleColors", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" _xml = {"attribute": False, "name": "ModelWithEncodedNamesSrc", "text": False, "unwrapped": False} @@ -226,12 +226,12 @@ class ModelWithOptionalField(_model_base.Model): item: str = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "item", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" value: Optional[int] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "value", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long _xml = {"attribute": False, "name": "ModelWithOptionalField", "text": False, "unwrapped": False} @@ -268,12 +268,12 @@ class ModelWithRenamedArrays(_model_base.Model): colors: List[str] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "Colors", "name": "Colors", "text": False, "unwrapped": True}, - ) + ) # pylint: disable=line-too-long """Required.""" counts: List[int] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "int32", "name": "Counts", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" _xml = {"attribute": False, "name": "ModelWithRenamedArrays", "text": False, "unwrapped": False} @@ -311,13 +311,13 @@ class ModelWithRenamedFields(_model_base.Model): name="inputData", visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "InputData", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" output_data: "_models.SimpleModel" = rest_field( name="outputData", visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "OutputData", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" _xml = {"attribute": False, "name": "ModelWithRenamedFieldsSrc", "text": False, "unwrapped": False} @@ -354,12 +354,12 @@ class ModelWithSimpleArrays(_model_base.Model): colors: List[str] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "string", "name": "colors", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" counts: List[int] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "int32", "name": "counts", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" _xml = {"attribute": False, "name": "ModelWithSimpleArrays", "text": False, "unwrapped": False} @@ -396,12 +396,12 @@ class ModelWithText(_model_base.Model): language: str = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": True, "name": "language", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" content: str = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "content", "text": True, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" _xml = {"attribute": False, "name": "ModelWithText", "text": False, "unwrapped": False} @@ -438,12 +438,12 @@ class ModelWithUnwrappedArray(_model_base.Model): colors: List[str] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "colors", "name": "colors", "text": False, "unwrapped": True}, - ) + ) # pylint: disable=line-too-long """Required.""" counts: List[int] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "int32", "name": "counts", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" _xml = {"attribute": False, "name": "ModelWithUnwrappedArray", "text": False, "unwrapped": False} @@ -480,12 +480,12 @@ class SimpleModel(_model_base.Model): name: str = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "name", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" age: int = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "age", "text": False, "unwrapped": False}, - ) + ) # pylint: disable=line-too-long """Required.""" _xml = {"attribute": False, "name": "SimpleModel", "text": False, "unwrapped": False} diff --git a/packages/typespec-python/test/unbranded/generated/typetest-array/typetest/array/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-array/typetest/array/models/_models.py index 958abea9cf1..d2c277d8fe9 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-array/typetest/array/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-array/typetest/array/models/_models.py @@ -30,7 +30,7 @@ class InnerModel(_model_base.Model): """Required string property. Required.""" children: Optional[List["_models.InnerModel"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long @overload def __init__( diff --git a/packages/typespec-python/test/unbranded/generated/typetest-dictionary/typetest/dictionary/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-dictionary/typetest/dictionary/models/_models.py index 82822cb115c..bd77f13d178 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-dictionary/typetest/dictionary/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-dictionary/typetest/dictionary/models/_models.py @@ -30,7 +30,7 @@ class InnerModel(_model_base.Model): """Required string property. Required.""" children: Optional[Dict[str, "_models.InnerModel"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long @overload def __init__( diff --git a/packages/typespec-python/test/unbranded/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/models/_models.py index 2af220ea8fa..98f5743572a 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/models/_models.py @@ -62,7 +62,7 @@ class Cobra(Snake, discriminator="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 + kind: Literal[SnakeKind.COBRA] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long """discriminator property. Required. Species cobra""" @overload @@ -131,7 +131,7 @@ class Golden(Dog, discriminator="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 + kind: Literal[DogKind.GOLDEN] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long """discriminator property. Required. Species golden""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/models/_models.py index 0edcd59542b..2bfe181d466 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/models/_models.py @@ -71,7 +71,7 @@ class Shark(Fish, discriminator="shark"): """ __mapping__: Dict[str, _model_base.Model] = {} - kind: Literal["shark"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long + kind: Literal["shark"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long,useless-suppression """Required. Default value is \"shark\".""" sharktype: str = rest_discriminator(name="sharktype", visibility=["read", "create", "update", "delete", "query"]) """Required. Default value is None.""" @@ -108,7 +108,7 @@ class GoblinShark(Shark, discriminator="goblin"): """ __mapping__: Dict[str, _model_base.Model] = {} - sharktype: Literal["goblin"] = rest_discriminator(name="sharktype", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + sharktype: Literal["goblin"] = rest_discriminator(name="sharktype", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long """Required. Default value is \"goblin\".""" @overload @@ -146,7 +146,7 @@ class Salmon(Fish, discriminator="salmon"): :vartype partner: ~typetest.model.nesteddiscriminator.models.Fish """ - kind: Literal["salmon"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + kind: Literal["salmon"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long """Required. Default value is \"salmon\".""" friends: Optional[List["_models.Fish"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) hate: Optional[Dict[str, "_models.Fish"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -186,7 +186,7 @@ class SawShark(Shark, discriminator="saw"): """ __mapping__: Dict[str, _model_base.Model] = {} - sharktype: Literal["saw"] = rest_discriminator(name="sharktype", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + sharktype: Literal["saw"] = rest_discriminator(name="sharktype", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long """Required. Default value is \"saw\".""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/typetest-model-recursive/typetest/model/recursive/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-model-recursive/typetest/model/recursive/models/_models.py index 3df5e36bff5..f28e134c741 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-model-recursive/typetest/model/recursive/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-model-recursive/typetest/model/recursive/models/_models.py @@ -25,7 +25,7 @@ class Element(_model_base.Model): extension: Optional[List["_models.Extension"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long @overload def __init__( diff --git a/packages/typespec-python/test/unbranded/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/models/_models.py index a83c1d64cf1..57ce23909eb 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/models/_models.py @@ -110,7 +110,7 @@ class Eagle(Bird, discriminator="eagle"): :vartype partner: ~typetest.model.singlediscriminator.models.Bird """ - kind: Literal["eagle"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long + kind: Literal["eagle"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long,useless-suppression """Required. Default value is \"eagle\".""" friends: Optional[List["_models.Bird"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) hate: Optional[Dict[str, "_models.Bird"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -147,7 +147,7 @@ class Goose(Bird, discriminator="goose"): :vartype kind: str """ - kind: Literal["goose"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long + kind: Literal["goose"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long,useless-suppression """Required. Default value is \"goose\".""" @overload @@ -178,7 +178,7 @@ class SeaGull(Bird, discriminator="seagull"): :vartype kind: str """ - kind: Literal["seagull"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + kind: Literal["seagull"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long """Required. Default value is \"seagull\".""" @overload @@ -209,7 +209,7 @@ class Sparrow(Bird, discriminator="sparrow"): :vartype kind: str """ - kind: Literal["sparrow"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + kind: Literal["sparrow"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long """Required. Default value is \"sparrow\".""" @overload @@ -240,7 +240,7 @@ class TRex(Dinosaur, discriminator="t-rex"): :vartype kind: str """ - kind: Literal["t-rex"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long + kind: Literal["t-rex"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long,useless-suppression """Required. Default value is \"t-rex\".""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py index 89fb6b1e101..427acbf3142 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py @@ -122,7 +122,7 @@ class DifferentSpreadModelArrayDerived(DifferentSpreadModelArrayRecord): derived_prop: List["_models.ModelForRecord"] = rest_field( name="derivedProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """The index property. Required.""" @overload @@ -186,7 +186,7 @@ class DifferentSpreadModelDerived(DifferentSpreadModelRecord): derived_prop: "_models.ModelForRecord" = rest_field( name="derivedProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """The index property. Required.""" @overload @@ -309,7 +309,7 @@ class ExtendsModelAdditionalProperties(_model_base.Model): known_prop: "_models.ModelForRecord" = rest_field( name="knownProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required.""" @overload @@ -340,7 +340,7 @@ class ExtendsModelArrayAdditionalProperties(_model_base.Model): known_prop: List["_models.ModelForRecord"] = rest_field( name="knownProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required.""" @overload @@ -510,7 +510,7 @@ class ExtendsUnknownAdditionalPropertiesDiscriminatedDerived( :vartype age: float """ - kind: Literal["derived"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + kind: Literal["derived"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long """Required. Default value is \"derived\".""" index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The index property. Required.""" @@ -576,7 +576,7 @@ class IsModelAdditionalProperties(_model_base.Model): known_prop: "_models.ModelForRecord" = rest_field( name="knownProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required.""" @overload @@ -607,7 +607,7 @@ class IsModelArrayAdditionalProperties(_model_base.Model): known_prop: List["_models.ModelForRecord"] = rest_field( name="knownProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required.""" @overload @@ -777,7 +777,7 @@ class IsUnknownAdditionalPropertiesDiscriminatedDerived( :vartype age: float """ - kind: Literal["derived"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + kind: Literal["derived"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long """Required. Default value is \"derived\".""" index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The index property. Required.""" @@ -901,7 +901,7 @@ class SpreadModelArrayRecord(_model_base.Model): known_prop: List["_models.ModelForRecord"] = rest_field( name="knownProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required.""" @overload @@ -932,7 +932,7 @@ class SpreadModelRecord(_model_base.Model): known_prop: "_models.ModelForRecord" = rest_field( name="knownProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required.""" @overload @@ -1183,7 +1183,7 @@ class WidgetData1(_model_base.Model): """Required.""" end: Optional[datetime.datetime] = rest_field( visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) + ) # pylint: disable=line-too-long @overload def __init__( diff --git a/packages/typespec-python/test/unbranded/generated/typetest-property-nullable/typetest/property/nullable/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-property-nullable/typetest/property/nullable/models/_models.py index d0209bb7063..fe2d4c6aa2c 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-property-nullable/typetest/property/nullable/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-property-nullable/typetest/property/nullable/models/_models.py @@ -30,11 +30,11 @@ class BytesProperty(_model_base.Model): required_property: str = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required property. Required.""" nullable_property: bytes = rest_field( name="nullableProperty", visibility=["read", "create", "update", "delete", "query"], format="base64" - ) + ) # pylint: disable=line-too-long """Property. Required.""" @overload @@ -68,11 +68,11 @@ class CollectionsByteProperty(_model_base.Model): required_property: str = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required property. Required.""" nullable_property: List[bytes] = rest_field( name="nullableProperty", visibility=["read", "create", "update", "delete", "query"], format="base64" - ) + ) # pylint: disable=line-too-long """Property. Required.""" @overload @@ -106,11 +106,11 @@ class CollectionsModelProperty(_model_base.Model): required_property: str = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required property. Required.""" nullable_property: List["_models.InnerModel"] = rest_field( name="nullableProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Property. Required.""" @overload @@ -144,11 +144,11 @@ class CollectionsStringProperty(_model_base.Model): required_property: str = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required property. Required.""" nullable_property: List[str] = rest_field( name="nullableProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Property. Required.""" @overload @@ -182,11 +182,11 @@ class DatetimeProperty(_model_base.Model): required_property: str = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required property. Required.""" nullable_property: datetime.datetime = rest_field( name="nullableProperty", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) + ) # pylint: disable=line-too-long """Property. Required.""" @overload @@ -220,11 +220,11 @@ class DurationProperty(_model_base.Model): required_property: str = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required property. Required.""" nullable_property: datetime.timedelta = rest_field( name="nullableProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Property. Required.""" @overload @@ -288,11 +288,11 @@ class StringProperty(_model_base.Model): required_property: str = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required property. Required.""" nullable_property: str = rest_field( name="nullableProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Property. Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/typetest-property-optional/typetest/property/optional/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-property-optional/typetest/property/optional/models/_models.py index 7d20f98e842..c99f12e1142 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-property-optional/typetest/property/optional/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-property-optional/typetest/property/optional/models/_models.py @@ -83,7 +83,7 @@ class CollectionsByteProperty(_model_base.Model): property: Optional[List[bytes]] = rest_field( visibility=["read", "create", "update", "delete", "query"], format="base64" - ) + ) # pylint: disable=line-too-long """Property.""" @overload @@ -113,7 +113,7 @@ class CollectionsModelProperty(_model_base.Model): property: Optional[List["_models.StringProperty"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Property.""" @overload @@ -143,7 +143,7 @@ class DatetimeProperty(_model_base.Model): property: Optional[datetime.datetime] = rest_field( visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) + ) # pylint: disable=line-too-long """Property.""" @overload @@ -316,11 +316,11 @@ class RequiredAndOptionalProperty(_model_base.Model): optional_property: Optional[str] = rest_field( name="optionalProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """optional string property.""" required_property: int = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """required int property. Required.""" @overload @@ -464,7 +464,7 @@ class UnionStringLiteralProperty(_model_base.Model): property: Optional[Literal["hello", "world"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Property. Is either a Literal[\"hello\"] type or a Literal[\"world\"] type.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/typetest-property-valuetypes/typetest/property/valuetypes/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-property-valuetypes/typetest/property/valuetypes/models/_models.py index 1834b01cf16..da78594f897 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-property-valuetypes/typetest/property/valuetypes/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-property-valuetypes/typetest/property/valuetypes/models/_models.py @@ -192,7 +192,7 @@ class DatetimeProperty(_model_base.Model): property: datetime.datetime = rest_field( visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) + ) # pylint: disable=line-too-long """Property. Required.""" @overload @@ -339,7 +339,7 @@ class EnumProperty(_model_base.Model): property: Union[str, "_models.FixedInnerEnum"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Property. Required. Known values are: \"ValueOne\" and \"ValueTwo\".""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/typetest-union/typetest/union/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-union/typetest/union/models/_models.py index 3f1b2f6f514..5dc9d94cddd 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-union/typetest/union/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-union/typetest/union/models/_models.py @@ -325,7 +325,7 @@ class GetResponse7(_model_base.Model): prop: Union[str, "_models.StringExtensibleNamedUnion"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required. Known values are: \"b\" and \"c\".""" @overload @@ -356,7 +356,7 @@ class GetResponse8(_model_base.Model): prop: Union[Literal["b"], Literal["c"], str] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required. Is one of the following types: Literal[\"b\"], Literal[\"c\"], str""" @overload @@ -426,22 +426,22 @@ class MixedLiteralsCases(_model_base.Model): string_literal: Literal["a", 2, True] = rest_field( name="stringLiteral", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """This should be receive/send the \"a\" variant. Required. Is one of the following types: Literal[\"a\"], Literal[2], float, Literal[True]""" int_literal: Literal["a", 2, True] = rest_field( name="intLiteral", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """This should be receive/send the 2 variant. Required. Is one of the following types: Literal[\"a\"], Literal[2], float, Literal[True]""" float_literal: Literal["a", 2, True] = rest_field( name="floatLiteral", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """This should be receive/send the 3.3 variant. Required. Is one of the following types: Literal[\"a\"], Literal[2], float, Literal[True]""" boolean_literal: Literal["a", 2, True] = rest_field( name="booleanLiteral", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """This should be receive/send the true variant. Required. Is one of the following types: Literal[\"a\"], Literal[2], float, Literal[True]""" @@ -488,27 +488,27 @@ class MixedTypesCases(_model_base.Model): model: Union["_models.Cat", Literal["a"], int, bool] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """This should be receive/send the Cat variant. Required. Is one of the following types: Cat, Literal[\"a\"], int, bool""" literal: Union["_models.Cat", Literal["a"], int, bool] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """This should be receive/send the \"a\" variant. Required. Is one of the following types: Cat, Literal[\"a\"], int, bool""" int_property: Union["_models.Cat", Literal["a"], int, bool] = rest_field( name="int", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """This should be receive/send the int variant. Required. Is one of the following types: Cat, Literal[\"a\"], int, bool""" boolean: Union["_models.Cat", Literal["a"], int, bool] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """This should be receive/send the boolean variant. Required. Is one of the following types: Cat, Literal[\"a\"], int, bool""" array: List[Union["_models.Cat", Literal["a"], int, bool]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """This should be receive/send 4 element with Cat, \"a\", int, and boolean. Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/models/_models.py b/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/models/_models.py index a538788bef8..d048e37f098 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/models/_models.py @@ -32,11 +32,11 @@ class ModelV1(_model_base.Model): """Required.""" enum_prop: Union[str, "_models.EnumV1"] = rest_field( name="enumProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required. Known values are: \"enumMemberV1\" and \"enumMemberV2\".""" union_prop: "_types.UnionV1" = rest_field( name="unionProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required. Is either a str type or a int type.""" @overload @@ -75,11 +75,11 @@ class ModelV2(_model_base.Model): """Required.""" enum_prop: Union[str, "_models.EnumV2"] = rest_field( name="enumProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required. \"enumMember\"""" union_prop: "_types.UnionV2" = rest_field( name="unionProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required. Is either a str type or a int type.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/models/_models.py b/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/models/_models.py index 188fde629f2..75b87021b44 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/models/_models.py @@ -27,7 +27,7 @@ class TestModel(_model_base.Model): """Required.""" changed_prop: Optional[str] = rest_field( name="changedProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long @overload def __init__( diff --git a/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/models/_models.py b/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/models/_models.py index 635034a6ba4..668f15c51f6 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/models/_models.py @@ -32,11 +32,11 @@ class ModelV2(_model_base.Model): """Required.""" enum_prop: Union[str, "_models.EnumV2"] = rest_field( name="enumProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required. \"enumMemberV2\"""" union_prop: "_types.UnionV2" = rest_field( name="unionProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required. Is either a str type or a float type.""" @overload @@ -73,7 +73,7 @@ class ModelV3(_model_base.Model): """Required.""" enum_prop: Union[str, "_models.EnumV3"] = rest_field( name="enumProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required. Known values are: \"enumMemberV1\" and \"enumMemberV2Preview\".""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/models/_models.py b/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/models/_models.py index e423bc9b009..9ba820b22f8 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/models/_models.py @@ -32,11 +32,11 @@ class NewModel(_model_base.Model): """Required.""" enum_prop: Union[str, "_models.NewEnum"] = rest_field( name="enumProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required. \"newEnumMember\"""" union_prop: "_types.NewUnion" = rest_field( name="unionProp", visibility=["read", "create", "update", "delete", "query"] - ) + ) # pylint: disable=line-too-long """Required. Is either a str type or a int type.""" @overload From 7e4e81f264ac2d34023ada3f4ef88fb630097fac Mon Sep 17 00:00:00 2001 From: AutoPrFromHttpClientPython Date: Thu, 13 Feb 2025 07:49:46 +0000 Subject: [PATCH 05/14] Update dependencies (2025-02-13 07:49:45) --- packages/autorest.python/package.json | 2 +- packages/typespec-python/package.json | 2 +- pnpm-lock.yaml | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/autorest.python/package.json b/packages/autorest.python/package.json index 280ace6d922..d44206c12b8 100644 --- a/packages/autorest.python/package.json +++ b/packages/autorest.python/package.json @@ -29,7 +29,7 @@ }, "homepage": "https://github.com/Azure/autorest.python/blob/main/README.md", "dependencies": { - "@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1OTgyNS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz", + "@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU2MDY0NC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz", "@autorest/system-requirements": "~1.0.2", "fs-extra": "~11.2.0", "tsx": "~4.19.1" diff --git a/packages/typespec-python/package.json b/packages/typespec-python/package.json index 962f07cce80..6cd69383a72 100644 --- a/packages/typespec-python/package.json +++ b/packages/typespec-python/package.json @@ -60,7 +60,7 @@ "js-yaml": "~4.1.0", "semver": "~7.6.2", "tsx": "~4.19.1", - "@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1OTgyNS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz", + "@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU2MDY0NC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz", "fs-extra": "~11.2.0" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 13fe991d2c4..faf15c567a6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -57,8 +57,8 @@ importers: specifier: ~1.0.2 version: 1.0.2 '@typespec/http-client-python': - specifier: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1OTgyNS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz - version: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1OTgyNS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz(5dspuyrtxidbihsk6ixub7kbfm) + specifier: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU2MDY0NC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz + version: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU2MDY0NC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz(5dspuyrtxidbihsk6ixub7kbfm) fs-extra: specifier: ~11.2.0 version: 11.2.0 @@ -79,8 +79,8 @@ importers: packages/typespec-python: dependencies: '@typespec/http-client-python': - specifier: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1OTgyNS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz - version: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1OTgyNS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz(5dspuyrtxidbihsk6ixub7kbfm) + specifier: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU2MDY0NC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz + version: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU2MDY0NC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz(5dspuyrtxidbihsk6ixub7kbfm) fs-extra: specifier: ~11.2.0 version: 11.2.0 @@ -1500,8 +1500,8 @@ packages: engines: {node: '>=18.0.0'} hasBin: true - '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1OTgyNS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz': - resolution: {tarball: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1OTgyNS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz} + '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU2MDY0NC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz': + resolution: {tarball: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU2MDY0NC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz} version: 0.6.11 engines: {node: '>=18.0.0'} peerDependencies: @@ -6003,7 +6003,7 @@ snapshots: - bluebird - supports-color - '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU1OTgyNS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz(5dspuyrtxidbihsk6ixub7kbfm)': + '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU2MDY0NC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz(5dspuyrtxidbihsk6ixub7kbfm)': dependencies: '@azure-tools/typespec-autorest': 0.51.0(jam7mnjbyunevglidmcn4r37mu) '@azure-tools/typespec-azure-core': 0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))) From cfda56084144dded2c932ab46ffb7401cd9541b4 Mon Sep 17 00:00:00 2001 From: AutoPrFromHttpClientPython Date: Thu, 13 Feb 2025 07:54:18 +0000 Subject: [PATCH 06/14] Regenerate for typespec-python (2025-02-13 07:54:17) --- .../authentication/apikey/_serialization.py | 4 +- .../apikey/aio/_operations/_operations.py | 1 + .../http/custom/_serialization.py | 4 +- .../custom/aio/_operations/_operations.py | 1 + .../authentication/oauth2/_serialization.py | 4 +- .../oauth2/aio/_operations/_operations.py | 1 + .../authentication/union/_serialization.py | 4 +- .../union/aio/_operations/_operations.py | 1 + .../core/access/_serialization.py | 4 +- .../core/access/models/_models.py | 3 +- .../service/header/_serialization.py | 4 +- .../header/aio/_operations/_operations.py | 1 + .../service/path/_serialization.py | 4 +- .../path/aio/_operations/_operations.py | 1 + .../service/query/_serialization.py | 4 +- .../query/aio/_operations/_operations.py | 1 + .../core/flattenproperty/_serialization.py | 4 +- .../aio/_operations/_operations.py | 1 + .../core/usage/_serialization.py | 4 +- .../specs/azure/core/basic/_serialization.py | 4 +- .../core/basic/aio/_operations/_operations.py | 1 + .../azure/core/lro/standard/_serialization.py | 4 +- .../standard/aio/_operations/_operations.py | 1 + .../specs/azure/core/model/_serialization.py | 4 +- .../specs/azure/core/page/_serialization.py | 4 +- .../core/page/aio/operations/_operations.py | 1 + .../specs/azure/core/scalar/_serialization.py | 4 +- .../specs/azure/core/traits/_serialization.py | 4 +- .../traits/aio/_operations/_operations.py | 1 + .../specs/azure/core/traits/models/_models.py | 4 +- .../azure/example/basic/_serialization.py | 4 +- .../basic/aio/_operations/_operations.py | 1 + .../azure/example/basic/models/_models.py | 18 +++---- .../azure/payload/pageable/_serialization.py | 4 +- .../pageable/aio/_operations/_operations.py | 1 + .../commonproperties/_serialization.py | 4 +- .../commonproperties/models/_models.py | 29 +++++----- .../operations/_operations.py | 7 +-- .../operationtemplates/_serialization.py | 4 +- .../operationtemplates/models/_models.py | 29 +++++----- .../operations/_operations.py | 10 ++-- .../resources/_serialization.py | 4 +- .../resources/models/_models.py | 53 ++++++++++--------- .../resources/operations/_operations.py | 42 +++++++-------- .../xmsclientrequestid/_serialization.py | 4 +- .../aio/_operations/_operations.py | 1 + .../azurecore/lro/rpc/_serialization.py | 4 +- .../lro/rpc/aio/_operations/_operations.py | 1 + .../client/clientnamespace/_serialization.py | 4 +- .../aio/_operations/_operations.py | 1 + .../second/aio/_operations/_operations.py | 1 + .../clientnamespace/second/models/_models.py | 2 +- .../client/naming/_serialization.py | 4 +- .../naming/aio/operations/_operations.py | 1 + .../structure/service/_serialization.py | 4 +- .../service/aio/operations/_operations.py | 1 + .../structure/multiclient/_serialization.py | 4 +- .../aio/_operations/_operations.py | 1 + .../renamedoperation/_serialization.py | 4 +- .../aio/operations/_operations.py | 1 + .../twooperationgroup/_serialization.py | 4 +- .../encode/bytes/_serialization.py | 4 +- .../encode/datetime/_serialization.py | 4 +- .../encode/datetime/models/_models.py | 4 +- .../encode/duration/_serialization.py | 4 +- .../encode/numeric/_serialization.py | 4 +- .../headasbooleanfalse/_serialization.py | 4 +- .../aio/_operations/_operations.py | 1 + .../headasbooleantrue/_serialization.py | 4 +- .../aio/_operations/_operations.py | 1 + .../parameters/basic/_serialization.py | 4 +- .../bodyoptionality/_serialization.py | 4 +- .../aio/operations/_operations.py | 1 + .../collectionformat/_serialization.py | 4 +- .../parameters/spread/_serialization.py | 4 +- .../contentnegotiation/_serialization.py | 4 +- .../payload/jsonmergepatch/_serialization.py | 4 +- .../aio/_operations/_operations.py | 1 + .../payload/jsonmergepatch/models/_models.py | 16 +++--- .../payload/mediatype/_serialization.py | 4 +- .../payload/multipart/_serialization.py | 4 +- .../payload/multipart/models/_models.py | 26 ++++----- .../payload/pageable/_serialization.py | 4 +- .../payload-xml/payload/xml/_serialization.py | 4 +- .../payload-xml/payload/xml/models/_models.py | 44 +++++++-------- .../resiliency/srv/driven1/_client.py | 4 +- .../resiliency/srv/driven1/_serialization.py | 4 +- .../resiliency/srv/driven1/aio/_client.py | 4 +- .../driven1/aio/_operations/_operations.py | 1 + .../resiliency/srv/driven2/_client.py | 4 +- .../resiliency/srv/driven2/_serialization.py | 4 +- .../resiliency/srv/driven2/aio/_client.py | 4 +- .../driven2/aio/_operations/_operations.py | 1 + .../_operations/_operations.py | 2 +- .../statuscoderange/_serialization.py | 4 +- .../aio/_operations/_operations.py | 3 +- .../generated/routes/routes/_serialization.py | 4 +- .../routes/aio/operations/_operations.py | 2 +- .../encodedname/json/_serialization.py | 4 +- .../endpoint/notdefined/_serialization.py | 4 +- .../notdefined/aio/_operations/_operations.py | 1 + .../server/path/multiple/_serialization.py | 4 +- .../multiple/aio/_operations/_operations.py | 1 + .../server/path/single/_serialization.py | 4 +- .../single/aio/_operations/_operations.py | 1 + .../versions/notversioned/_serialization.py | 4 +- .../aio/_operations/_operations.py | 1 + .../versions/versioned/_serialization.py | 4 +- .../versioned/aio/_operations/_operations.py | 1 + .../conditionalrequest/_serialization.py | 4 +- .../aio/_operations/_operations.py | 1 + .../repeatability/_serialization.py | 4 +- .../aio/_operations/_operations.py | 1 + .../specialwords/_serialization.py | 4 +- .../typetest/array/_serialization.py | 4 +- .../typetest/array/models/_models.py | 2 +- .../typetest/dictionary/_serialization.py | 4 +- .../typetest/dictionary/models/_models.py | 2 +- .../enum/extensible/_serialization.py | 4 +- .../typetest/enum/fixed/_serialization.py | 4 +- .../typetest/model/empty/_serialization.py | 4 +- .../empty/aio/_operations/_operations.py | 1 + .../model/enumdiscriminator/_serialization.py | 4 +- .../aio/_operations/_operations.py | 1 + .../model/enumdiscriminator/models/_models.py | 5 +- .../nesteddiscriminator/_serialization.py | 4 +- .../aio/_operations/_operations.py | 1 + .../nesteddiscriminator/models/_models.py | 9 ++-- .../model/notdiscriminated/_serialization.py | 4 +- .../aio/_operations/_operations.py | 1 + .../model/recursive/_serialization.py | 4 +- .../recursive/aio/_operations/_operations.py | 1 + .../model/recursive/models/_models.py | 2 +- .../singlediscriminator/_serialization.py | 4 +- .../aio/_operations/_operations.py | 1 + .../singlediscriminator/models/_models.py | 11 ++-- .../typetest/model/usage/_serialization.py | 4 +- .../usage/aio/_operations/_operations.py | 1 + .../model/visibility/_serialization.py | 4 +- .../visibility/aio/_operations/_operations.py | 1 + .../additionalproperties/_serialization.py | 4 +- .../additionalproperties/models/_models.py | 24 ++++----- .../property/nullable/_serialization.py | 4 +- .../property/nullable/models/_models.py | 28 +++++----- .../property/optional/_serialization.py | 4 +- .../property/optional/models/_models.py | 12 ++--- .../property/valuetypes/_serialization.py | 4 +- .../property/valuetypes/models/_models.py | 4 +- .../typetest/scalar/_serialization.py | 4 +- .../typetest/union/_serialization.py | 4 +- .../typetest/union/models/_models.py | 22 ++++---- .../versioning/added/_serialization.py | 4 +- .../added/aio/operations/_operations.py | 1 + .../versioning/added/models/_models.py | 8 +-- .../versioning/madeoptional/_serialization.py | 4 +- .../aio/_operations/_operations.py | 1 + .../versioning/madeoptional/models/_models.py | 2 +- .../versioning/removed/_serialization.py | 4 +- .../removed/aio/_operations/_operations.py | 1 + .../versioning/removed/models/_models.py | 6 +-- .../versioning/renamedfrom/_serialization.py | 4 +- .../renamedfrom/aio/operations/_operations.py | 1 + .../versioning/renamedfrom/models/_models.py | 4 +- .../returntypechangedfrom/_serialization.py | 4 +- .../aio/_operations/_operations.py | 1 + .../typechangedfrom/_serialization.py | 4 +- .../aio/_operations/_operations.py | 1 + .../authentication/apikey/_serialization.py | 4 +- .../http/custom/_serialization.py | 4 +- .../authentication/oauth2/_serialization.py | 4 +- .../authentication/union/_serialization.py | 4 +- .../encode/bytes/_serialization.py | 4 +- .../encode/datetime/_serialization.py | 4 +- .../encode/datetime/models/_models.py | 4 +- .../encode/duration/_serialization.py | 4 +- .../encode/numeric/_serialization.py | 4 +- .../headasbooleanfalse/_serialization.py | 4 +- .../headasbooleantrue/_serialization.py | 4 +- .../parameters/basic/_serialization.py | 4 +- .../bodyoptionality/_serialization.py | 4 +- .../collectionformat/_serialization.py | 4 +- .../parameters/spread/_serialization.py | 4 +- .../contentnegotiation/_serialization.py | 4 +- .../payload/jsonmergepatch/_serialization.py | 4 +- .../payload/jsonmergepatch/models/_models.py | 16 +++--- .../payload/mediatype/_serialization.py | 4 +- .../payload/multipart/_serialization.py | 4 +- .../payload/multipart/models/_models.py | 26 ++++----- .../payload/pageable/_serialization.py | 4 +- .../payload-xml/payload/xml/_serialization.py | 4 +- .../payload-xml/payload/xml/models/_models.py | 44 +++++++-------- .../_operations/_operations.py | 2 +- .../statuscoderange/_serialization.py | 4 +- .../aio/_operations/_operations.py | 2 +- .../generated/routes/routes/_serialization.py | 4 +- .../encodedname/json/_serialization.py | 4 +- .../endpoint/notdefined/_serialization.py | 4 +- .../server/path/multiple/_serialization.py | 4 +- .../server/path/single/_serialization.py | 4 +- .../versions/notversioned/_serialization.py | 4 +- .../versions/versioned/_serialization.py | 4 +- .../conditionalrequest/_serialization.py | 4 +- .../repeatability/_serialization.py | 4 +- .../specialwords/_serialization.py | 4 +- .../typetest/array/_serialization.py | 4 +- .../typetest/array/models/_models.py | 2 +- .../typetest/dictionary/_serialization.py | 4 +- .../typetest/dictionary/models/_models.py | 2 +- .../enum/extensible/_serialization.py | 4 +- .../typetest/enum/fixed/_serialization.py | 4 +- .../typetest/model/empty/_serialization.py | 4 +- .../model/enumdiscriminator/_serialization.py | 4 +- .../model/enumdiscriminator/models/_models.py | 5 +- .../nesteddiscriminator/_serialization.py | 4 +- .../nesteddiscriminator/models/_models.py | 9 ++-- .../model/notdiscriminated/_serialization.py | 4 +- .../model/recursive/_serialization.py | 4 +- .../model/recursive/models/_models.py | 2 +- .../singlediscriminator/_serialization.py | 4 +- .../singlediscriminator/models/_models.py | 11 ++-- .../typetest/model/usage/_serialization.py | 4 +- .../model/visibility/_serialization.py | 4 +- .../additionalproperties/_serialization.py | 4 +- .../additionalproperties/models/_models.py | 24 ++++----- .../property/nullable/_serialization.py | 4 +- .../property/nullable/models/_models.py | 28 +++++----- .../property/optional/_serialization.py | 4 +- .../property/optional/models/_models.py | 12 ++--- .../property/valuetypes/_serialization.py | 4 +- .../property/valuetypes/models/_models.py | 4 +- .../typetest/scalar/_serialization.py | 4 +- .../typetest/union/_serialization.py | 4 +- .../typetest/union/models/_models.py | 22 ++++---- .../versioning/added/_serialization.py | 4 +- .../versioning/added/models/_models.py | 8 +-- .../versioning/madeoptional/_serialization.py | 4 +- .../versioning/madeoptional/models/_models.py | 2 +- .../versioning/removed/_serialization.py | 4 +- .../versioning/removed/models/_models.py | 6 +-- .../versioning/renamedfrom/_serialization.py | 4 +- .../versioning/renamedfrom/models/_models.py | 4 +- .../returntypechangedfrom/_serialization.py | 4 +- .../typechangedfrom/_serialization.py | 4 +- 243 files changed, 676 insertions(+), 607 deletions(-) diff --git a/packages/typespec-python/test/azure/generated/authentication-api-key/authentication/apikey/_serialization.py b/packages/typespec-python/test/azure/generated/authentication-api-key/authentication/apikey/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/authentication-api-key/authentication/apikey/_serialization.py +++ b/packages/typespec-python/test/azure/generated/authentication-api-key/authentication/apikey/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/authentication-api-key/authentication/apikey/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/authentication-api-key/authentication/apikey/aio/_operations/_operations.py index f9520a8eb3a..cb41522dd04 100644 --- a/packages/typespec-python/test/azure/generated/authentication-api-key/authentication/apikey/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/authentication-api-key/authentication/apikey/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/authentication-http-custom/authentication/http/custom/_serialization.py b/packages/typespec-python/test/azure/generated/authentication-http-custom/authentication/http/custom/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/authentication-http-custom/authentication/http/custom/_serialization.py +++ b/packages/typespec-python/test/azure/generated/authentication-http-custom/authentication/http/custom/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/authentication-http-custom/authentication/http/custom/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/authentication-http-custom/authentication/http/custom/aio/_operations/_operations.py index 7aa51e5da9e..05d8705705c 100644 --- a/packages/typespec-python/test/azure/generated/authentication-http-custom/authentication/http/custom/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/authentication-http-custom/authentication/http/custom/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/authentication-oauth2/authentication/oauth2/_serialization.py b/packages/typespec-python/test/azure/generated/authentication-oauth2/authentication/oauth2/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/authentication-oauth2/authentication/oauth2/_serialization.py +++ b/packages/typespec-python/test/azure/generated/authentication-oauth2/authentication/oauth2/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/authentication-oauth2/authentication/oauth2/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/authentication-oauth2/authentication/oauth2/aio/_operations/_operations.py index 4bbc165cab4..605a9ef8500 100644 --- a/packages/typespec-python/test/azure/generated/authentication-oauth2/authentication/oauth2/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/authentication-oauth2/authentication/oauth2/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/authentication-union/authentication/union/_serialization.py b/packages/typespec-python/test/azure/generated/authentication-union/authentication/union/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/authentication-union/authentication/union/_serialization.py +++ b/packages/typespec-python/test/azure/generated/authentication-union/authentication/union/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/authentication-union/authentication/union/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/authentication-union/authentication/union/aio/_operations/_operations.py index 6ccd3b393bb..f849d78b2ee 100644 --- a/packages/typespec-python/test/azure/generated/authentication-union/authentication/union/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/authentication-union/authentication/union/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-access/specs/azure/clientgenerator/core/access/_serialization.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-access/specs/azure/clientgenerator/core/access/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-access/specs/azure/clientgenerator/core/access/_serialization.py +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-access/specs/azure/clientgenerator/core/access/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-access/specs/azure/clientgenerator/core/access/models/_models.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-access/specs/azure/clientgenerator/core/access/models/_models.py index 1c7b4a5b4d4..97448f831e2 100644 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-access/specs/azure/clientgenerator/core/access/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-access/specs/azure/clientgenerator/core/access/models/_models.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -299,7 +300,7 @@ class RealModel(AbstractModel, discriminator="real"): :vartype kind: str """ - kind: Literal["real"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long,useless-suppression + kind: Literal["real"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"real\".""" @overload diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_serialization.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_serialization.py +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_operations/_operations.py index cb976363d03..9971a650bb0 100644 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_serialization.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_serialization.py +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_operations/_operations.py index 8cddfb0bb90..b726db4b001 100644 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_serialization.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_serialization.py +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_operations/_operations.py index 6aa20c409f8..9f61b264ba0 100644 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-flatten-property/specs/azure/clientgenerator/core/flattenproperty/_serialization.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-flatten-property/specs/azure/clientgenerator/core/flattenproperty/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-flatten-property/specs/azure/clientgenerator/core/flattenproperty/_serialization.py +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-flatten-property/specs/azure/clientgenerator/core/flattenproperty/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-flatten-property/specs/azure/clientgenerator/core/flattenproperty/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-flatten-property/specs/azure/clientgenerator/core/flattenproperty/aio/_operations/_operations.py index 6cac4b9822f..19ad559a0bc 100644 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-flatten-property/specs/azure/clientgenerator/core/flattenproperty/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-flatten-property/specs/azure/clientgenerator/core/flattenproperty/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/specs/azure/clientgenerator/core/usage/_serialization.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/specs/azure/clientgenerator/core/usage/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/specs/azure/clientgenerator/core/usage/_serialization.py +++ b/packages/typespec-python/test/azure/generated/azure-client-generator-core-usage/specs/azure/clientgenerator/core/usage/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/azure-core-basic/specs/azure/core/basic/_serialization.py b/packages/typespec-python/test/azure/generated/azure-core-basic/specs/azure/core/basic/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-basic/specs/azure/core/basic/_serialization.py +++ b/packages/typespec-python/test/azure/generated/azure-core-basic/specs/azure/core/basic/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/azure-core-basic/specs/azure/core/basic/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-core-basic/specs/azure/core/basic/aio/_operations/_operations.py index 377b1e07882..58509381250 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-basic/specs/azure/core/basic/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-core-basic/specs/azure/core/basic/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/azure-core-lro-standard/specs/azure/core/lro/standard/_serialization.py b/packages/typespec-python/test/azure/generated/azure-core-lro-standard/specs/azure/core/lro/standard/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-lro-standard/specs/azure/core/lro/standard/_serialization.py +++ b/packages/typespec-python/test/azure/generated/azure-core-lro-standard/specs/azure/core/lro/standard/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/azure-core-lro-standard/specs/azure/core/lro/standard/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-core-lro-standard/specs/azure/core/lro/standard/aio/_operations/_operations.py index 513d9917ab6..c8aa743ff4a 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-lro-standard/specs/azure/core/lro/standard/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-core-lro-standard/specs/azure/core/lro/standard/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/azure-core-model/specs/azure/core/model/_serialization.py b/packages/typespec-python/test/azure/generated/azure-core-model/specs/azure/core/model/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-model/specs/azure/core/model/_serialization.py +++ b/packages/typespec-python/test/azure/generated/azure-core-model/specs/azure/core/model/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/azure-core-page/specs/azure/core/page/_serialization.py b/packages/typespec-python/test/azure/generated/azure-core-page/specs/azure/core/page/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-page/specs/azure/core/page/_serialization.py +++ b/packages/typespec-python/test/azure/generated/azure-core-page/specs/azure/core/page/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/azure-core-page/specs/azure/core/page/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-core-page/specs/azure/core/page/aio/operations/_operations.py index 854b42a9a4d..1cf11641ddd 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-page/specs/azure/core/page/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-core-page/specs/azure/core/page/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/azure-core-scalar/specs/azure/core/scalar/_serialization.py b/packages/typespec-python/test/azure/generated/azure-core-scalar/specs/azure/core/scalar/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-scalar/specs/azure/core/scalar/_serialization.py +++ b/packages/typespec-python/test/azure/generated/azure-core-scalar/specs/azure/core/scalar/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/_serialization.py b/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/_serialization.py +++ b/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/aio/_operations/_operations.py index be4c7979a3c..0cdec372bb8 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/models/_models.py b/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/models/_models.py index ee68031219b..da83da066df 100644 --- a/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azure-core-traits/specs/azure/core/traits/models/_models.py @@ -59,7 +59,7 @@ class UserActionParam(_model_base.Model): user_action_value: str = rest_field( name="userActionValue", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """User action value. Required.""" @overload @@ -90,7 +90,7 @@ class UserActionResponse(_model_base.Model): user_action_result: str = rest_field( name="userActionResult", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """User action result. Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/_serialization.py b/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/_serialization.py +++ b/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/aio/_operations/_operations.py index b37bdc713a9..475464cd1bb 100644 --- a/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/models/_models.py b/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/models/_models.py index befa15f0ba2..75081a63549 100644 --- a/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azure-example-basic/specs/azure/example/basic/models/_models.py @@ -35,13 +35,13 @@ class ActionRequest(_model_base.Model): """Required.""" model_property: Optional["_models.Model"] = rest_field( name="modelProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) array_property: Optional[List[str]] = rest_field( name="arrayProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) record_property: Optional[Dict[str, str]] = rest_field( name="recordProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) @overload def __init__( @@ -82,13 +82,13 @@ class ActionResponse(_model_base.Model): """Required.""" model_property: Optional["_models.Model"] = rest_field( name="modelProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) array_property: Optional[List[str]] = rest_field( name="arrayProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) record_property: Optional[Dict[str, str]] = rest_field( name="recordProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) @overload def __init__( @@ -124,13 +124,13 @@ class Model(_model_base.Model): int32_property: Optional[int] = rest_field( name="int32Property", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) float32_property: Optional[float] = rest_field( name="float32Property", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) enum_property: Optional[Union[str, "_models.EnumEnum"]] = rest_field( name="enumProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """\"EnumValue1\"""" @overload diff --git a/packages/typespec-python/test/azure/generated/azure-payload-pageable/specs/azure/payload/pageable/_serialization.py b/packages/typespec-python/test/azure/generated/azure-payload-pageable/specs/azure/payload/pageable/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/azure-payload-pageable/specs/azure/payload/pageable/_serialization.py +++ b/packages/typespec-python/test/azure/generated/azure-payload-pageable/specs/azure/payload/pageable/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/azure-payload-pageable/specs/azure/payload/pageable/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-payload-pageable/specs/azure/payload/pageable/aio/_operations/_operations.py index 5e2a2b984ee..d179d6d1030 100644 --- a/packages/typespec-python/test/azure/generated/azure-payload-pageable/specs/azure/payload/pageable/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-payload-pageable/specs/azure/payload/pageable/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/_serialization.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/_serialization.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/models/_models.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/models/_models.py index e07badc4ef5..25b335a7f16 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/models/_models.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -62,7 +63,7 @@ class ErrorDetail(_model_base.Model): """The error details.""" additional_info: Optional[List["_models.ErrorAdditionalInfo"]] = rest_field( name="additionalInfo", visibility=["read"] - ) # pylint: disable=line-too-long + ) """The error additional info.""" @@ -101,7 +102,7 @@ class Resource(_model_base.Model): Readonly variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -115,7 +116,7 @@ class Resource(_model_base.Model): id: Optional[str] = rest_field(visibility=["read"]) """Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long""" + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.""" name: Optional[str] = rest_field(visibility=["read"]) """The name of the resource.""" type: Optional[str] = rest_field(visibility=["read"]) @@ -133,7 +134,7 @@ class TrackedResource(Resource): :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -181,7 +182,7 @@ class ManagedIdentityTrackedResource(TrackedResource): :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -204,11 +205,11 @@ class ManagedIdentityTrackedResource(TrackedResource): properties: Optional["_models.ManagedIdentityTrackedResourceProperties"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """The resource-specific properties for this resource.""" identity: Optional["_models.ManagedServiceIdentity"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """The managed service identities assigned to this resource.""" @overload @@ -274,12 +275,12 @@ class ManagedServiceIdentity(_model_base.Model): assigned identity.""" type: Union[str, "_models.ManagedServiceIdentityType"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """The type of managed identity assigned to this resource. Required. Known values are: \"None\", \"SystemAssigned\", \"UserAssigned\", and \"SystemAssigned,UserAssigned\".""" user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = rest_field( name="userAssignedIdentities", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """The identities assigned to this resource by the user.""" @overload @@ -325,25 +326,25 @@ class SystemData(_model_base.Model): """The identity that created the resource.""" created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( name="createdByType", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """The type of identity that created the resource. Known values are: \"User\", \"Application\", \"ManagedIdentity\", and \"Key\".""" created_at: Optional[datetime.datetime] = rest_field( name="createdAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) # pylint: disable=line-too-long + ) """The timestamp of resource creation (UTC).""" last_modified_by: Optional[str] = rest_field( name="lastModifiedBy", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """The identity that last modified the resource.""" last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( name="lastModifiedByType", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """The type of identity that last modified the resource. Known values are: \"User\", \"Application\", \"ManagedIdentity\", and \"Key\".""" last_modified_at: Optional[datetime.datetime] = rest_field( name="lastModifiedAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) # pylint: disable=line-too-long + ) """The timestamp of resource last modification (UTC).""" @overload diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/operations/_operations.py index 36016dde687..000fd3beafc 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-common-properties/azure/resourcemanager/commonproperties/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -54,7 +55,7 @@ def build_managed_identity_get_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -85,7 +86,7 @@ def build_managed_identity_create_with_system_assigned_request( # pylint: disab accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -118,7 +119,7 @@ def build_managed_identity_update_with_user_assigned_and_system_assigned_request accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.CommonProperties/managedIdentityTrackedResources/{managedIdentityTrackedResourceName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/_serialization.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/_serialization.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/models/_models.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/models/_models.py index a6e1a5350b9..f17f322e42e 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/models/_models.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -65,11 +66,11 @@ class CheckNameAvailabilityResponse(_model_base.Model): name_available: Optional[bool] = rest_field( name="nameAvailable", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Indicates if the resource name is available.""" reason: Optional[Union[str, "_models.CheckNameAvailabilityReason"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """The reason why the given name is not available. Known values are: \"Invalid\" and \"AlreadyExists\".""" message: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -140,7 +141,7 @@ class ErrorDetail(_model_base.Model): """The error details.""" additional_info: Optional[List["_models.ErrorAdditionalInfo"]] = rest_field( name="additionalInfo", visibility=["read"] - ) # pylint: disable=line-too-long + ) """The error additional info.""" @@ -234,7 +235,7 @@ class Operation(_model_base.Model): \"false\" for Azure Resource Manager/control-plane operations.""" display: Optional["_models.OperationDisplay"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Localized display information for this particular operation.""" origin: Optional[Union[str, "_models.Origin"]] = rest_field(visibility=["read"]) """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit @@ -301,7 +302,7 @@ class Resource(_model_base.Model): Readonly variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -315,7 +316,7 @@ class Resource(_model_base.Model): id: Optional[str] = rest_field(visibility=["read"]) """Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long""" + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.""" name: Optional[str] = rest_field(visibility=["read"]) """The name of the resource.""" type: Optional[str] = rest_field(visibility=["read"]) @@ -333,7 +334,7 @@ class TrackedResource(Resource): :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -381,7 +382,7 @@ class Order(TrackedResource): :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -401,7 +402,7 @@ class Order(TrackedResource): properties: Optional["_models.OrderProperties"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """The resource-specific properties for this resource.""" @overload @@ -488,25 +489,25 @@ class SystemData(_model_base.Model): """The identity that created the resource.""" created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( name="createdByType", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """The type of identity that created the resource. Known values are: \"User\", \"Application\", \"ManagedIdentity\", and \"Key\".""" created_at: Optional[datetime.datetime] = rest_field( name="createdAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) # pylint: disable=line-too-long + ) """The timestamp of resource creation (UTC).""" last_modified_by: Optional[str] = rest_field( name="lastModifiedBy", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """The identity that last modified the resource.""" last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( name="lastModifiedByType", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """The type of identity that last modified the resource. Known values are: \"User\", \"Application\", \"ManagedIdentity\", and \"Key\".""" last_modified_at: Optional[datetime.datetime] = rest_field( name="lastModifiedAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) # pylint: disable=line-too-long + ) """The timestamp of resource last modification (UTC).""" @overload diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/operations/_operations.py index d5ec4b23443..9099f98d04e 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -108,7 +108,7 @@ def build_check_name_availability_check_local_request( # pylint: disable=name-t accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.OperationTemplates/locations/{location}/checkNameAvailability" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.OperationTemplates/locations/{location}/checkNameAvailability" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "location": _SERIALIZER.url("location", location, "str"), @@ -138,7 +138,7 @@ def build_lro_create_or_replace_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/orders/{orderName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/orders/{orderName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -169,7 +169,7 @@ def build_lro_export_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/orders/{orderName}/export" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/orders/{orderName}/export" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -199,7 +199,7 @@ def build_lro_delete_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/orders/{orderName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.OperationTemplates/orders/{orderName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/_serialization.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/_serialization.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/models/_models.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/models/_models.py index 4f171f53ff2..1e6a9f671ea 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/models/_models.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/models/_models.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -61,7 +62,7 @@ class ErrorDetail(_model_base.Model): """The error details.""" additional_info: Optional[List["_models.ErrorAdditionalInfo"]] = rest_field( name="additionalInfo", visibility=["read"] - ) # pylint: disable=line-too-long + ) """The error additional info.""" @@ -100,7 +101,7 @@ class Resource(_model_base.Model): Readonly variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -114,7 +115,7 @@ class Resource(_model_base.Model): id: Optional[str] = rest_field(visibility=["read"]) """Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long""" + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.""" name: Optional[str] = rest_field(visibility=["read"]) """The name of the resource.""" type: Optional[str] = rest_field(visibility=["read"]) @@ -130,7 +131,7 @@ class ExtensionResource(Resource): Readonly variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -150,7 +151,7 @@ class ExtensionsResource(ExtensionResource): Readonly variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -166,7 +167,7 @@ class ExtensionsResource(ExtensionResource): properties: Optional["_models.ExtensionsResourceProperties"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """The resource-specific properties for this resource.""" @overload @@ -203,7 +204,7 @@ class ExtensionsResourceProperties(_model_base.Model): """The description of the resource.""" provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( name="provisioningState", visibility=["read"] - ) # pylint: disable=line-too-long + ) """The status of the last operation. Known values are: \"Succeeded\", \"Failed\", \"Canceled\", \"Provisioning\", \"Updating\", \"Deleting\", and \"Accepted\".""" @@ -232,7 +233,7 @@ class ProxyResource(Resource): Readonly variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -252,7 +253,7 @@ class LocationResource(ProxyResource): Readonly variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -268,7 +269,7 @@ class LocationResource(ProxyResource): properties: Optional["_models.LocationResourceProperties"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """The resource-specific properties for this resource.""" @overload @@ -305,7 +306,7 @@ class LocationResourceProperties(_model_base.Model): """The description of the resource.""" provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( name="provisioningState", visibility=["read"] - ) # pylint: disable=line-too-long + ) """The status of the last operation. Known values are: \"Succeeded\", \"Failed\", \"Canceled\", \"Provisioning\", \"Updating\", \"Deleting\", and \"Accepted\".""" @@ -333,7 +334,7 @@ class NestedProxyResource(ProxyResource): Readonly variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -349,7 +350,7 @@ class NestedProxyResource(ProxyResource): properties: Optional["_models.NestedProxyResourceProperties"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """The resource-specific properties for this resource.""" @overload @@ -384,7 +385,7 @@ class NestedProxyResourceProperties(_model_base.Model): provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( name="provisioningState", visibility=["read"] - ) # pylint: disable=line-too-long + ) """Provisioning State of the nested child Resource. Known values are: \"Succeeded\", \"Failed\", \"Canceled\", \"Provisioning\", \"Updating\", \"Deleting\", and \"Accepted\".""" description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -451,7 +452,7 @@ class TrackedResource(Resource): :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -499,7 +500,7 @@ class SingletonTrackedResource(TrackedResource): :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -519,7 +520,7 @@ class SingletonTrackedResource(TrackedResource): properties: Optional["_models.SingletonTrackedResourceProperties"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """The resource-specific properties for this resource.""" @overload @@ -556,7 +557,7 @@ class SingletonTrackedResourceProperties(_model_base.Model): provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( name="provisioningState", visibility=["read"] - ) # pylint: disable=line-too-long + ) """The status of the last operation. Known values are: \"Succeeded\", \"Failed\", \"Canceled\", \"Provisioning\", \"Updating\", \"Deleting\", and \"Accepted\".""" description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -603,25 +604,25 @@ class SystemData(_model_base.Model): """The identity that created the resource.""" created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( name="createdByType", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """The type of identity that created the resource. Known values are: \"User\", \"Application\", \"ManagedIdentity\", and \"Key\".""" created_at: Optional[datetime.datetime] = rest_field( name="createdAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) # pylint: disable=line-too-long + ) """The timestamp of resource creation (UTC).""" last_modified_by: Optional[str] = rest_field( name="lastModifiedBy", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """The identity that last modified the resource.""" last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( name="lastModifiedByType", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """The type of identity that last modified the resource. Known values are: \"User\", \"Application\", \"ManagedIdentity\", and \"Key\".""" last_modified_at: Optional[datetime.datetime] = rest_field( name="lastModifiedAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) # pylint: disable=line-too-long + ) """The timestamp of resource last modification (UTC).""" @overload @@ -655,7 +656,7 @@ class TopLevelTrackedResource(TrackedResource): :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -675,7 +676,7 @@ class TopLevelTrackedResource(TrackedResource): properties: Optional["_models.TopLevelTrackedResourceProperties"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """The resource-specific properties for this resource.""" @overload @@ -712,7 +713,7 @@ class TopLevelTrackedResourceProperties(_model_base.Model): provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = rest_field( name="provisioningState", visibility=["read"] - ) # pylint: disable=line-too-long + ) """The status of the last operation. Known values are: \"Succeeded\", \"Failed\", \"Canceled\", \"Provisioning\", \"Updating\", \"Deleting\", and \"Accepted\".""" description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/operations/_operations.py index 09ab59c4777..8db5995f08a 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-resources/azure/resourcemanager/resources/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -59,7 +59,7 @@ def build_top_level_get_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -90,7 +90,7 @@ def build_top_level_create_or_replace_request( # pylint: disable=name-too-long accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -123,7 +123,7 @@ def build_top_level_update_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -155,7 +155,7 @@ def build_top_level_delete_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -185,7 +185,7 @@ def build_top_level_list_by_resource_group_request( # pylint: disable=name-too- accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -239,7 +239,7 @@ def build_top_level_action_sync_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/actionSync" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/actionSync" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -275,7 +275,7 @@ def build_nested_get_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -311,7 +311,7 @@ def build_nested_create_or_replace_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -349,7 +349,7 @@ def build_nested_update_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -386,7 +386,7 @@ def build_nested_delete_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources/{nextedProxyResourceName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -417,7 +417,7 @@ def build_nested_list_by_top_level_tracked_resource_request( # pylint: disable= accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/topLevelTrackedResources/{topLevelTrackedResourceName}/nestedProxyResources" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -447,7 +447,7 @@ def build_singleton_get_by_resource_group_request( # pylint: disable=name-too-l accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/singletonTrackedResources/default" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/singletonTrackedResources/default" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -475,7 +475,7 @@ def build_singleton_create_or_update_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/singletonTrackedResources/default" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/singletonTrackedResources/default" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -503,7 +503,7 @@ def build_singleton_update_request(resource_group_name: str, subscription_id: st accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/singletonTrackedResources/default" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/singletonTrackedResources/default" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -532,7 +532,7 @@ def build_singleton_list_by_resource_group_request( # pylint: disable=name-too- accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/singletonTrackedResources" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.Resources/singletonTrackedResources" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -699,7 +699,7 @@ def build_location_resources_get_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "location": _SERIALIZER.url("location", location, "str"), @@ -728,7 +728,7 @@ def build_location_resources_create_or_update_request( # pylint: disable=name-t accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "location": _SERIALIZER.url("location", location, "str"), @@ -759,7 +759,7 @@ def build_location_resources_update_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "location": _SERIALIZER.url("location", location, "str"), @@ -789,7 +789,7 @@ def build_location_resources_delete_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources/{locationResourceName}" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "location": _SERIALIZER.url("location", location, "str"), @@ -817,7 +817,7 @@ def build_location_resources_list_by_location_request( # pylint: disable=name-t accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.Resources/locations/{location}/locationResources" path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "location": _SERIALIZER.url("location", location, "str"), diff --git a/packages/typespec-python/test/azure/generated/azure-special-headers-client-request-id/azure/specialheaders/xmsclientrequestid/_serialization.py b/packages/typespec-python/test/azure/generated/azure-special-headers-client-request-id/azure/specialheaders/xmsclientrequestid/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/azure-special-headers-client-request-id/azure/specialheaders/xmsclientrequestid/_serialization.py +++ b/packages/typespec-python/test/azure/generated/azure-special-headers-client-request-id/azure/specialheaders/xmsclientrequestid/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/azure-special-headers-client-request-id/azure/specialheaders/xmsclientrequestid/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-special-headers-client-request-id/azure/specialheaders/xmsclientrequestid/aio/_operations/_operations.py index fbf0eedef40..68ff1c791c0 100644 --- a/packages/typespec-python/test/azure/generated/azure-special-headers-client-request-id/azure/specialheaders/xmsclientrequestid/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-special-headers-client-request-id/azure/specialheaders/xmsclientrequestid/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/azurecore-lro-rpc/azurecore/lro/rpc/_serialization.py b/packages/typespec-python/test/azure/generated/azurecore-lro-rpc/azurecore/lro/rpc/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/azurecore-lro-rpc/azurecore/lro/rpc/_serialization.py +++ b/packages/typespec-python/test/azure/generated/azurecore-lro-rpc/azurecore/lro/rpc/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/azurecore-lro-rpc/azurecore/lro/rpc/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azurecore-lro-rpc/azurecore/lro/rpc/aio/_operations/_operations.py index 740388993b7..09ef88fc3ad 100644 --- a/packages/typespec-python/test/azure/generated/azurecore-lro-rpc/azurecore/lro/rpc/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azurecore-lro-rpc/azurecore/lro/rpc/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/client-namespace/client/clientnamespace/_serialization.py b/packages/typespec-python/test/azure/generated/client-namespace/client/clientnamespace/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/client-namespace/client/clientnamespace/_serialization.py +++ b/packages/typespec-python/test/azure/generated/client-namespace/client/clientnamespace/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/client-namespace/client/clientnamespace/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/client-namespace/client/clientnamespace/aio/_operations/_operations.py index 936670cb4f2..daeb3184681 100644 --- a/packages/typespec-python/test/azure/generated/client-namespace/client/clientnamespace/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/client-namespace/client/clientnamespace/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/client-namespace/client/clientnamespace/second/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/client-namespace/client/clientnamespace/second/aio/_operations/_operations.py index ca67117a9e1..ae9b491e736 100644 --- a/packages/typespec-python/test/azure/generated/client-namespace/client/clientnamespace/second/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/client-namespace/client/clientnamespace/second/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/client-namespace/client/clientnamespace/second/models/_models.py b/packages/typespec-python/test/azure/generated/client-namespace/client/clientnamespace/second/models/_models.py index 4208fe05aa8..e30b5d44c70 100644 --- a/packages/typespec-python/test/azure/generated/client-namespace/client/clientnamespace/second/models/_models.py +++ b/packages/typespec-python/test/azure/generated/client-namespace/client/clientnamespace/second/models/_models.py @@ -26,7 +26,7 @@ class SecondClientResult(_model_base.Model): type: Union[str, "_sub_models2.SecondClientEnumType"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required. \"second\"""" @overload diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/_serialization.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/client-naming/client/naming/_serialization.py +++ b/packages/typespec-python/test/azure/generated/client-naming/client/naming/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/operations/_operations.py index 925165588c9..feb60837ffe 100644 --- a/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/client-structure-default/client/structure/service/_serialization.py b/packages/typespec-python/test/azure/generated/client-structure-default/client/structure/service/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/client-structure-default/client/structure/service/_serialization.py +++ b/packages/typespec-python/test/azure/generated/client-structure-default/client/structure/service/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/client-structure-default/client/structure/service/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/client-structure-default/client/structure/service/aio/operations/_operations.py index a0acfb60fa0..88bf08cc6a1 100644 --- a/packages/typespec-python/test/azure/generated/client-structure-default/client/structure/service/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/client-structure-default/client/structure/service/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/client-structure-multiclient/client/structure/multiclient/_serialization.py b/packages/typespec-python/test/azure/generated/client-structure-multiclient/client/structure/multiclient/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/client-structure-multiclient/client/structure/multiclient/_serialization.py +++ b/packages/typespec-python/test/azure/generated/client-structure-multiclient/client/structure/multiclient/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/client-structure-multiclient/client/structure/multiclient/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/client-structure-multiclient/client/structure/multiclient/aio/_operations/_operations.py index 51a94c456ac..e0023216b21 100644 --- a/packages/typespec-python/test/azure/generated/client-structure-multiclient/client/structure/multiclient/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/client-structure-multiclient/client/structure/multiclient/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/client-structure-renamedoperation/client/structure/renamedoperation/_serialization.py b/packages/typespec-python/test/azure/generated/client-structure-renamedoperation/client/structure/renamedoperation/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/client-structure-renamedoperation/client/structure/renamedoperation/_serialization.py +++ b/packages/typespec-python/test/azure/generated/client-structure-renamedoperation/client/structure/renamedoperation/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/client-structure-renamedoperation/client/structure/renamedoperation/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/client-structure-renamedoperation/client/structure/renamedoperation/aio/operations/_operations.py index e3a948be461..febc5847535 100644 --- a/packages/typespec-python/test/azure/generated/client-structure-renamedoperation/client/structure/renamedoperation/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/client-structure-renamedoperation/client/structure/renamedoperation/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/client-structure-twooperationgroup/client/structure/twooperationgroup/_serialization.py b/packages/typespec-python/test/azure/generated/client-structure-twooperationgroup/client/structure/twooperationgroup/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/client-structure-twooperationgroup/client/structure/twooperationgroup/_serialization.py +++ b/packages/typespec-python/test/azure/generated/client-structure-twooperationgroup/client/structure/twooperationgroup/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/encode-bytes/encode/bytes/_serialization.py b/packages/typespec-python/test/azure/generated/encode-bytes/encode/bytes/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/encode-bytes/encode/bytes/_serialization.py +++ b/packages/typespec-python/test/azure/generated/encode-bytes/encode/bytes/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/encode-datetime/encode/datetime/_serialization.py b/packages/typespec-python/test/azure/generated/encode-datetime/encode/datetime/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/encode-datetime/encode/datetime/_serialization.py +++ b/packages/typespec-python/test/azure/generated/encode-datetime/encode/datetime/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/encode-datetime/encode/datetime/models/_models.py b/packages/typespec-python/test/azure/generated/encode-datetime/encode/datetime/models/_models.py index 7c31d2633b9..da2a9d47fff 100644 --- a/packages/typespec-python/test/azure/generated/encode-datetime/encode/datetime/models/_models.py +++ b/packages/typespec-python/test/azure/generated/encode-datetime/encode/datetime/models/_models.py @@ -111,7 +111,7 @@ class UnixTimestampArrayDatetimeProperty(_model_base.Model): value: List[datetime.datetime] = rest_field( visibility=["read", "create", "update", "delete", "query"], format="unix-timestamp" - ) # pylint: disable=line-too-long + ) """Required.""" @overload @@ -142,7 +142,7 @@ class UnixTimestampDatetimeProperty(_model_base.Model): value: datetime.datetime = rest_field( visibility=["read", "create", "update", "delete", "query"], format="unix-timestamp" - ) # pylint: disable=line-too-long + ) """Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/encode-duration/encode/duration/_serialization.py b/packages/typespec-python/test/azure/generated/encode-duration/encode/duration/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/encode-duration/encode/duration/_serialization.py +++ b/packages/typespec-python/test/azure/generated/encode-duration/encode/duration/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/encode-numeric/encode/numeric/_serialization.py b/packages/typespec-python/test/azure/generated/encode-numeric/encode/numeric/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/encode-numeric/encode/numeric/_serialization.py +++ b/packages/typespec-python/test/azure/generated/encode-numeric/encode/numeric/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/headasbooleanfalse/headasbooleanfalse/_serialization.py b/packages/typespec-python/test/azure/generated/headasbooleanfalse/headasbooleanfalse/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/headasbooleanfalse/headasbooleanfalse/_serialization.py +++ b/packages/typespec-python/test/azure/generated/headasbooleanfalse/headasbooleanfalse/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/headasbooleanfalse/headasbooleanfalse/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/headasbooleanfalse/headasbooleanfalse/aio/_operations/_operations.py index 5d4a59c4be5..874cacc5761 100644 --- a/packages/typespec-python/test/azure/generated/headasbooleanfalse/headasbooleanfalse/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/headasbooleanfalse/headasbooleanfalse/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/headasbooleantrue/headasbooleantrue/_serialization.py b/packages/typespec-python/test/azure/generated/headasbooleantrue/headasbooleantrue/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/headasbooleantrue/headasbooleantrue/_serialization.py +++ b/packages/typespec-python/test/azure/generated/headasbooleantrue/headasbooleantrue/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/headasbooleantrue/headasbooleantrue/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/headasbooleantrue/headasbooleantrue/aio/_operations/_operations.py index 396846323f5..00791cf66f3 100644 --- a/packages/typespec-python/test/azure/generated/headasbooleantrue/headasbooleantrue/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/headasbooleantrue/headasbooleantrue/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/parameters-basic/parameters/basic/_serialization.py b/packages/typespec-python/test/azure/generated/parameters-basic/parameters/basic/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/parameters-basic/parameters/basic/_serialization.py +++ b/packages/typespec-python/test/azure/generated/parameters-basic/parameters/basic/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/parameters-body-optionality/parameters/bodyoptionality/_serialization.py b/packages/typespec-python/test/azure/generated/parameters-body-optionality/parameters/bodyoptionality/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/parameters-body-optionality/parameters/bodyoptionality/_serialization.py +++ b/packages/typespec-python/test/azure/generated/parameters-body-optionality/parameters/bodyoptionality/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/parameters-body-optionality/parameters/bodyoptionality/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/parameters-body-optionality/parameters/bodyoptionality/aio/operations/_operations.py index b366e0316d2..0f233986f81 100644 --- a/packages/typespec-python/test/azure/generated/parameters-body-optionality/parameters/bodyoptionality/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/parameters-body-optionality/parameters/bodyoptionality/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/parameters-collection-format/parameters/collectionformat/_serialization.py b/packages/typespec-python/test/azure/generated/parameters-collection-format/parameters/collectionformat/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/parameters-collection-format/parameters/collectionformat/_serialization.py +++ b/packages/typespec-python/test/azure/generated/parameters-collection-format/parameters/collectionformat/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/parameters-spread/parameters/spread/_serialization.py b/packages/typespec-python/test/azure/generated/parameters-spread/parameters/spread/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/parameters-spread/parameters/spread/_serialization.py +++ b/packages/typespec-python/test/azure/generated/parameters-spread/parameters/spread/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/payload-content-negotiation/payload/contentnegotiation/_serialization.py b/packages/typespec-python/test/azure/generated/payload-content-negotiation/payload/contentnegotiation/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/payload-content-negotiation/payload/contentnegotiation/_serialization.py +++ b/packages/typespec-python/test/azure/generated/payload-content-negotiation/payload/contentnegotiation/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/payload-json-merge-patch/payload/jsonmergepatch/_serialization.py b/packages/typespec-python/test/azure/generated/payload-json-merge-patch/payload/jsonmergepatch/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/payload-json-merge-patch/payload/jsonmergepatch/_serialization.py +++ b/packages/typespec-python/test/azure/generated/payload-json-merge-patch/payload/jsonmergepatch/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/payload-json-merge-patch/payload/jsonmergepatch/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/payload-json-merge-patch/payload/jsonmergepatch/aio/_operations/_operations.py index 76849082264..3024573af4d 100644 --- a/packages/typespec-python/test/azure/generated/payload-json-merge-patch/payload/jsonmergepatch/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/payload-json-merge-patch/payload/jsonmergepatch/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/payload-json-merge-patch/payload/jsonmergepatch/models/_models.py b/packages/typespec-python/test/azure/generated/payload-json-merge-patch/payload/jsonmergepatch/models/_models.py index 874a43c2668..5a695012117 100644 --- a/packages/typespec-python/test/azure/generated/payload-json-merge-patch/payload/jsonmergepatch/models/_models.py +++ b/packages/typespec-python/test/azure/generated/payload-json-merge-patch/payload/jsonmergepatch/models/_models.py @@ -74,18 +74,18 @@ class Resource(_model_base.Model): description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) map: Optional[Dict[str, "_models.InnerModel"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) array: Optional[List["_models.InnerModel"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) int_value: Optional[int] = rest_field(name="intValue", visibility=["read", "create", "update", "delete", "query"]) float_value: Optional[float] = rest_field( name="floatValue", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) inner_model: Optional["_models.InnerModel"] = rest_field( name="innerModel", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) int_array: Optional[List[int]] = rest_field( name="intArray", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) @overload def __init__( @@ -134,18 +134,18 @@ class ResourcePatch(_model_base.Model): description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) map: Optional[Dict[str, "_models.InnerModel"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) array: Optional[List["_models.InnerModel"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) int_value: Optional[int] = rest_field(name="intValue", visibility=["read", "create", "update", "delete", "query"]) float_value: Optional[float] = rest_field( name="floatValue", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) inner_model: Optional["_models.InnerModel"] = rest_field( name="innerModel", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) int_array: Optional[List[int]] = rest_field( name="intArray", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) @overload def __init__( diff --git a/packages/typespec-python/test/azure/generated/payload-media-type/payload/mediatype/_serialization.py b/packages/typespec-python/test/azure/generated/payload-media-type/payload/mediatype/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/payload-media-type/payload/mediatype/_serialization.py +++ b/packages/typespec-python/test/azure/generated/payload-media-type/payload/mediatype/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/payload-multipart/payload/multipart/_serialization.py b/packages/typespec-python/test/azure/generated/payload-multipart/payload/multipart/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/payload-multipart/payload/multipart/_serialization.py +++ b/packages/typespec-python/test/azure/generated/payload-multipart/payload/multipart/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/payload-multipart/payload/multipart/models/_models.py b/packages/typespec-python/test/azure/generated/payload-multipart/payload/multipart/models/_models.py index 0dc6117747a..83fb5e120d4 100644 --- a/packages/typespec-python/test/azure/generated/payload-multipart/payload/multipart/models/_models.py +++ b/packages/typespec-python/test/azure/generated/payload-multipart/payload/multipart/models/_models.py @@ -62,7 +62,7 @@ class BinaryArrayPartsRequest(_model_base.Model): """Required.""" pictures: List[FileType] = rest_field( visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) # pylint: disable=line-too-long + ) """Required.""" @overload @@ -107,15 +107,15 @@ class ComplexHttpPartsModelRequest(_model_base.Model): """Required.""" profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) # pylint: disable=line-too-long + ) """Required.""" previous_addresses: List["_models.Address"] = rest_field( name="previousAddresses", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required.""" pictures: List[FileType] = rest_field( visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) # pylint: disable=line-too-long + ) """Required.""" @overload @@ -161,11 +161,11 @@ class ComplexPartsRequest(_model_base.Model): """Required.""" profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) # pylint: disable=line-too-long + ) """Required.""" pictures: List[FileType] = rest_field( visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) # pylint: disable=line-too-long + ) """Required.""" @overload @@ -200,7 +200,7 @@ class FileWithHttpPartOptionalContentTypeRequest(_model_base.Model): # pylint: profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) # pylint: disable=line-too-long + ) """Required.""" @overload @@ -232,7 +232,7 @@ class FileWithHttpPartRequiredContentTypeRequest(_model_base.Model): # pylint: profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) # pylint: disable=line-too-long + ) """Required.""" @overload @@ -264,7 +264,7 @@ class FileWithHttpPartSpecificContentTypeRequest(_model_base.Model): # pylint: profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) # pylint: disable=line-too-long + ) """Required.""" @overload @@ -330,7 +330,7 @@ class JsonPartRequest(_model_base.Model): """Required.""" profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) # pylint: disable=line-too-long + ) """Required.""" @overload @@ -365,11 +365,11 @@ class MultiBinaryPartsRequest(_model_base.Model): profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) # pylint: disable=line-too-long + ) """Required.""" picture: Optional[FileType] = rest_field( visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) # pylint: disable=line-too-long + ) @overload def __init__( @@ -405,7 +405,7 @@ class MultiPartRequest(_model_base.Model): """Required.""" profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) # pylint: disable=line-too-long + ) """Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/_serialization.py b/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/_serialization.py +++ b/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/_serialization.py b/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/_serialization.py +++ b/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/models/_models.py b/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/models/_models.py index 16088313c11..bd4c3b2aa6a 100644 --- a/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/models/_models.py +++ b/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/models/_models.py @@ -28,7 +28,7 @@ class ModelWithArrayOfModel(_model_base.Model): name="items", visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "SimpleModel", "name": "items", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" _xml = {"attribute": False, "name": "ModelWithArrayOfModel", "text": False, "unwrapped": False} @@ -66,17 +66,17 @@ class ModelWithAttributes(_model_base.Model): id1: int = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": True, "name": "id1", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" id2: str = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": True, "name": "id2", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" enabled: bool = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "enabled", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" _xml = {"attribute": False, "name": "ModelWithAttributes", "text": False, "unwrapped": False} @@ -112,7 +112,7 @@ class ModelWithDictionary(_model_base.Model): metadata: Dict[str, str] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "metadata", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" _xml = {"attribute": False, "name": "ModelWithDictionary", "text": False, "unwrapped": False} @@ -147,7 +147,7 @@ class ModelWithEmptyArray(_model_base.Model): name="items", visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "SimpleModel", "name": "items", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" _xml = {"attribute": False, "name": "ModelWithEmptyArray", "text": False, "unwrapped": False} @@ -184,12 +184,12 @@ class ModelWithEncodedNames(_model_base.Model): name="modelData", visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "SimpleModelData", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" colors: List[str] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "string", "name": "PossibleColors", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" _xml = {"attribute": False, "name": "ModelWithEncodedNamesSrc", "text": False, "unwrapped": False} @@ -226,12 +226,12 @@ class ModelWithOptionalField(_model_base.Model): item: str = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "item", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" value: Optional[int] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "value", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) _xml = {"attribute": False, "name": "ModelWithOptionalField", "text": False, "unwrapped": False} @@ -268,12 +268,12 @@ class ModelWithRenamedArrays(_model_base.Model): colors: List[str] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "Colors", "name": "Colors", "text": False, "unwrapped": True}, - ) # pylint: disable=line-too-long + ) """Required.""" counts: List[int] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "int32", "name": "Counts", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" _xml = {"attribute": False, "name": "ModelWithRenamedArrays", "text": False, "unwrapped": False} @@ -311,13 +311,13 @@ class ModelWithRenamedFields(_model_base.Model): name="inputData", visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "InputData", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" output_data: "_models.SimpleModel" = rest_field( name="outputData", visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "OutputData", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" _xml = {"attribute": False, "name": "ModelWithRenamedFieldsSrc", "text": False, "unwrapped": False} @@ -354,12 +354,12 @@ class ModelWithSimpleArrays(_model_base.Model): colors: List[str] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "string", "name": "colors", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" counts: List[int] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "int32", "name": "counts", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" _xml = {"attribute": False, "name": "ModelWithSimpleArrays", "text": False, "unwrapped": False} @@ -396,12 +396,12 @@ class ModelWithText(_model_base.Model): language: str = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": True, "name": "language", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" content: str = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "content", "text": True, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" _xml = {"attribute": False, "name": "ModelWithText", "text": False, "unwrapped": False} @@ -438,12 +438,12 @@ class ModelWithUnwrappedArray(_model_base.Model): colors: List[str] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "colors", "name": "colors", "text": False, "unwrapped": True}, - ) # pylint: disable=line-too-long + ) """Required.""" counts: List[int] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "int32", "name": "counts", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" _xml = {"attribute": False, "name": "ModelWithUnwrappedArray", "text": False, "unwrapped": False} @@ -480,12 +480,12 @@ class SimpleModel(_model_base.Model): name: str = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "name", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" age: int = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "age", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" _xml = {"attribute": False, "name": "SimpleModel", "text": False, "unwrapped": False} diff --git a/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/_client.py b/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/_client.py index 947e75fe47c..796b6f97ea1 100644 --- a/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/_client.py +++ b/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/_client.py @@ -38,7 +38,9 @@ class ResiliencyServiceDrivenClient(ResiliencyServiceDrivenClientOperationsMixin def __init__( # pylint: disable=missing-client-constructor-parameter-credential self, endpoint: str, service_deployment_version: str, **kwargs: Any ) -> None: - _endpoint = "{endpoint}/resiliency/service-driven/client:v1/service:{serviceDeploymentVersion}/api-version:{apiVersion}" # pylint: disable=line-too-long + _endpoint = ( + "{endpoint}/resiliency/service-driven/client:v1/service:{serviceDeploymentVersion}/api-version:{apiVersion}" + ) self._config = ResiliencyServiceDrivenClientConfiguration( endpoint=endpoint, service_deployment_version=service_deployment_version, **kwargs ) diff --git a/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/_serialization.py b/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/_serialization.py +++ b/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/aio/_client.py b/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/aio/_client.py index 7805ec20cd5..3764d17388c 100644 --- a/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/aio/_client.py +++ b/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/aio/_client.py @@ -38,7 +38,9 @@ class ResiliencyServiceDrivenClient(ResiliencyServiceDrivenClientOperationsMixin def __init__( # pylint: disable=missing-client-constructor-parameter-credential self, endpoint: str, service_deployment_version: str, **kwargs: Any ) -> None: - _endpoint = "{endpoint}/resiliency/service-driven/client:v1/service:{serviceDeploymentVersion}/api-version:{apiVersion}" # pylint: disable=line-too-long + _endpoint = ( + "{endpoint}/resiliency/service-driven/client:v1/service:{serviceDeploymentVersion}/api-version:{apiVersion}" + ) self._config = ResiliencyServiceDrivenClientConfiguration( endpoint=endpoint, service_deployment_version=service_deployment_version, **kwargs ) diff --git a/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/aio/_operations/_operations.py index aa57ffd7d3c..c87f95293c7 100644 --- a/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/resiliency-srv-driven1/resiliency/srv/driven1/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/_client.py b/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/_client.py index cb38121494d..cd9821f505f 100644 --- a/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/_client.py +++ b/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/_client.py @@ -57,7 +57,9 @@ class ResiliencyServiceDrivenClient(ResiliencyServiceDrivenClientOperationsMixin def __init__( # pylint: disable=missing-client-constructor-parameter-credential self, endpoint: str, service_deployment_version: str, **kwargs: Any ) -> None: - _endpoint = "{endpoint}/resiliency/service-driven/client:v2/service:{serviceDeploymentVersion}/api-version:{apiVersion}" # pylint: disable=line-too-long + _endpoint = ( + "{endpoint}/resiliency/service-driven/client:v2/service:{serviceDeploymentVersion}/api-version:{apiVersion}" + ) self._config = ResiliencyServiceDrivenClientConfiguration( endpoint=endpoint, service_deployment_version=service_deployment_version, **kwargs ) diff --git a/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/_serialization.py b/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/_serialization.py +++ b/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/aio/_client.py b/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/aio/_client.py index 07b0dea4b1a..31e5741ed20 100644 --- a/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/aio/_client.py +++ b/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/aio/_client.py @@ -57,7 +57,9 @@ class ResiliencyServiceDrivenClient(ResiliencyServiceDrivenClientOperationsMixin def __init__( # pylint: disable=missing-client-constructor-parameter-credential self, endpoint: str, service_deployment_version: str, **kwargs: Any ) -> None: - _endpoint = "{endpoint}/resiliency/service-driven/client:v2/service:{serviceDeploymentVersion}/api-version:{apiVersion}" # pylint: disable=line-too-long + _endpoint = ( + "{endpoint}/resiliency/service-driven/client:v2/service:{serviceDeploymentVersion}/api-version:{apiVersion}" + ) self._config = ResiliencyServiceDrivenClientConfiguration( endpoint=endpoint, service_deployment_version=service_deployment_version, **kwargs ) diff --git a/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/aio/_operations/_operations.py index 279cac29521..e36e4fa5fb9 100644 --- a/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/resiliency-srv-driven2/resiliency/srv/driven2/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py index 517abd62f19..e7130642107 100644 --- a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py @@ -179,7 +179,7 @@ def error_response_status_code404(self, **kwargs: Any) -> Literal[204]: if response.status_code == 404: error = _failsafe_deserialize(_models.NotFoundError, response.json()) raise ResourceNotFoundError(response=response, model=error) - elif 400 <= response.status_code <= 499: + if 400 <= response.status_code <= 499: error = _failsafe_deserialize(_models.Standard4XXError, response.json()) raise HttpResponseError(response=response, model=error) diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_serialization.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_serialization.py +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py index 025309501bb..277e08f3644 100644 --- a/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -146,7 +147,7 @@ async def error_response_status_code404(self, **kwargs: Any) -> Literal[204]: if response.status_code == 404: error = _failsafe_deserialize(_models.NotFoundError, response.json()) raise ResourceNotFoundError(response=response, model=error) - elif 400 <= response.status_code <= 499: + if 400 <= response.status_code <= 499: error = _failsafe_deserialize(_models.Standard4XXError, response.json()) raise HttpResponseError(response=response, model=error) diff --git a/packages/typespec-python/test/azure/generated/routes/routes/_serialization.py b/packages/typespec-python/test/azure/generated/routes/routes/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/routes/routes/_serialization.py +++ b/packages/typespec-python/test/azure/generated/routes/routes/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/routes/routes/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/routes/routes/aio/operations/_operations.py index aebecdc4cc4..01a796e09b6 100644 --- a/packages/typespec-python/test/azure/generated/routes/routes/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/routes/routes/aio/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/serialization-encoded-name-json/serialization/encodedname/json/_serialization.py b/packages/typespec-python/test/azure/generated/serialization-encoded-name-json/serialization/encodedname/json/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/serialization-encoded-name-json/serialization/encodedname/json/_serialization.py +++ b/packages/typespec-python/test/azure/generated/serialization-encoded-name-json/serialization/encodedname/json/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/server-endpoint-not-defined/server/endpoint/notdefined/_serialization.py b/packages/typespec-python/test/azure/generated/server-endpoint-not-defined/server/endpoint/notdefined/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/server-endpoint-not-defined/server/endpoint/notdefined/_serialization.py +++ b/packages/typespec-python/test/azure/generated/server-endpoint-not-defined/server/endpoint/notdefined/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/server-endpoint-not-defined/server/endpoint/notdefined/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/server-endpoint-not-defined/server/endpoint/notdefined/aio/_operations/_operations.py index 3a7badb371d..9de330eec80 100644 --- a/packages/typespec-python/test/azure/generated/server-endpoint-not-defined/server/endpoint/notdefined/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/server-endpoint-not-defined/server/endpoint/notdefined/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/_serialization.py b/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/_serialization.py +++ b/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/aio/_operations/_operations.py index a91a93ecf28..9e6a92fdfce 100644 --- a/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/server-path-multiple/server/path/multiple/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/server-path-single/server/path/single/_serialization.py b/packages/typespec-python/test/azure/generated/server-path-single/server/path/single/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/server-path-single/server/path/single/_serialization.py +++ b/packages/typespec-python/test/azure/generated/server-path-single/server/path/single/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/server-path-single/server/path/single/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/server-path-single/server/path/single/aio/_operations/_operations.py index 4f09e3f447e..76981d29a62 100644 --- a/packages/typespec-python/test/azure/generated/server-path-single/server/path/single/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/server-path-single/server/path/single/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/server-versions-not-versioned/server/versions/notversioned/_serialization.py b/packages/typespec-python/test/azure/generated/server-versions-not-versioned/server/versions/notversioned/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/server-versions-not-versioned/server/versions/notversioned/_serialization.py +++ b/packages/typespec-python/test/azure/generated/server-versions-not-versioned/server/versions/notversioned/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/server-versions-not-versioned/server/versions/notversioned/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/server-versions-not-versioned/server/versions/notversioned/aio/_operations/_operations.py index f6f07f26606..7eee6b02193 100644 --- a/packages/typespec-python/test/azure/generated/server-versions-not-versioned/server/versions/notversioned/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/server-versions-not-versioned/server/versions/notversioned/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/server-versions-versioned/server/versions/versioned/_serialization.py b/packages/typespec-python/test/azure/generated/server-versions-versioned/server/versions/versioned/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/server-versions-versioned/server/versions/versioned/_serialization.py +++ b/packages/typespec-python/test/azure/generated/server-versions-versioned/server/versions/versioned/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/server-versions-versioned/server/versions/versioned/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/server-versions-versioned/server/versions/versioned/aio/_operations/_operations.py index 553f14b3cc2..ccc7f534f4a 100644 --- a/packages/typespec-python/test/azure/generated/server-versions-versioned/server/versions/versioned/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/server-versions-versioned/server/versions/versioned/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/special-headers-conditional-request/specialheaders/conditionalrequest/_serialization.py b/packages/typespec-python/test/azure/generated/special-headers-conditional-request/specialheaders/conditionalrequest/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/special-headers-conditional-request/specialheaders/conditionalrequest/_serialization.py +++ b/packages/typespec-python/test/azure/generated/special-headers-conditional-request/specialheaders/conditionalrequest/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/special-headers-conditional-request/specialheaders/conditionalrequest/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/special-headers-conditional-request/specialheaders/conditionalrequest/aio/_operations/_operations.py index 28bc16e49ec..4d816ef0102 100644 --- a/packages/typespec-python/test/azure/generated/special-headers-conditional-request/specialheaders/conditionalrequest/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/special-headers-conditional-request/specialheaders/conditionalrequest/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/special-headers-repeatability/specialheaders/repeatability/_serialization.py b/packages/typespec-python/test/azure/generated/special-headers-repeatability/specialheaders/repeatability/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/special-headers-repeatability/specialheaders/repeatability/_serialization.py +++ b/packages/typespec-python/test/azure/generated/special-headers-repeatability/specialheaders/repeatability/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/special-headers-repeatability/specialheaders/repeatability/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/special-headers-repeatability/specialheaders/repeatability/aio/_operations/_operations.py index 3943a24a90a..d746a2fb938 100644 --- a/packages/typespec-python/test/azure/generated/special-headers-repeatability/specialheaders/repeatability/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/special-headers-repeatability/specialheaders/repeatability/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/special-words/specialwords/_serialization.py b/packages/typespec-python/test/azure/generated/special-words/specialwords/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/special-words/specialwords/_serialization.py +++ b/packages/typespec-python/test/azure/generated/special-words/specialwords/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/typetest-array/typetest/array/_serialization.py b/packages/typespec-python/test/azure/generated/typetest-array/typetest/array/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/typetest-array/typetest/array/_serialization.py +++ b/packages/typespec-python/test/azure/generated/typetest-array/typetest/array/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/typetest-array/typetest/array/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-array/typetest/array/models/_models.py index 676c9bdc271..3102e45483a 100644 --- a/packages/typespec-python/test/azure/generated/typetest-array/typetest/array/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-array/typetest/array/models/_models.py @@ -30,7 +30,7 @@ class InnerModel(_model_base.Model): """Required string property. Required.""" children: Optional[List["_models.InnerModel"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) @overload def __init__( diff --git a/packages/typespec-python/test/azure/generated/typetest-dictionary/typetest/dictionary/_serialization.py b/packages/typespec-python/test/azure/generated/typetest-dictionary/typetest/dictionary/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/typetest-dictionary/typetest/dictionary/_serialization.py +++ b/packages/typespec-python/test/azure/generated/typetest-dictionary/typetest/dictionary/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/typetest-dictionary/typetest/dictionary/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-dictionary/typetest/dictionary/models/_models.py index a942f96aa46..92decb06661 100644 --- a/packages/typespec-python/test/azure/generated/typetest-dictionary/typetest/dictionary/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-dictionary/typetest/dictionary/models/_models.py @@ -30,7 +30,7 @@ class InnerModel(_model_base.Model): """Required string property. Required.""" children: Optional[Dict[str, "_models.InnerModel"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) @overload def __init__( diff --git a/packages/typespec-python/test/azure/generated/typetest-enum-extensible/typetest/enum/extensible/_serialization.py b/packages/typespec-python/test/azure/generated/typetest-enum-extensible/typetest/enum/extensible/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/typetest-enum-extensible/typetest/enum/extensible/_serialization.py +++ b/packages/typespec-python/test/azure/generated/typetest-enum-extensible/typetest/enum/extensible/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/typetest-enum-fixed/typetest/enum/fixed/_serialization.py b/packages/typespec-python/test/azure/generated/typetest-enum-fixed/typetest/enum/fixed/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/typetest-enum-fixed/typetest/enum/fixed/_serialization.py +++ b/packages/typespec-python/test/azure/generated/typetest-enum-fixed/typetest/enum/fixed/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/typetest-model-empty/typetest/model/empty/_serialization.py b/packages/typespec-python/test/azure/generated/typetest-model-empty/typetest/model/empty/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-empty/typetest/model/empty/_serialization.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-empty/typetest/model/empty/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/typetest-model-empty/typetest/model/empty/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/typetest-model-empty/typetest/model/empty/aio/_operations/_operations.py index b9ee0fcf6e9..6952bd33a7b 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-empty/typetest/model/empty/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-empty/typetest/model/empty/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/_serialization.py b/packages/typespec-python/test/azure/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/_serialization.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/aio/_operations/_operations.py index 30a1ad2e4f4..43816a9ec0e 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/models/_models.py index 272b1fbfc5f..5b02cf7d100 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/models/_models.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -62,7 +63,7 @@ class Cobra(Snake, discriminator="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 # pylint: disable=line-too-long + kind: Literal[SnakeKind.COBRA] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """discriminator property. Required. Species cobra""" @overload @@ -131,7 +132,7 @@ class Golden(Dog, discriminator="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 # pylint: disable=line-too-long + kind: Literal[DogKind.GOLDEN] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """discriminator property. Required. Species golden""" @overload diff --git a/packages/typespec-python/test/azure/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/_serialization.py b/packages/typespec-python/test/azure/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/_serialization.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/aio/_operations/_operations.py index 076a8c13a61..1f39743cc44 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/models/_models.py index 4098685a2ef..ea670066171 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/models/_models.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -71,7 +72,7 @@ class Shark(Fish, discriminator="shark"): """ __mapping__: Dict[str, _model_base.Model] = {} - kind: Literal["shark"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long,useless-suppression + kind: Literal["shark"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"shark\".""" sharktype: str = rest_discriminator(name="sharktype", visibility=["read", "create", "update", "delete", "query"]) """Required. Default value is None.""" @@ -108,7 +109,7 @@ class GoblinShark(Shark, discriminator="goblin"): """ __mapping__: Dict[str, _model_base.Model] = {} - sharktype: Literal["goblin"] = rest_discriminator(name="sharktype", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long + sharktype: Literal["goblin"] = rest_discriminator(name="sharktype", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"goblin\".""" @overload @@ -146,7 +147,7 @@ class Salmon(Fish, discriminator="salmon"): :vartype partner: ~typetest.model.nesteddiscriminator.models.Fish """ - kind: Literal["salmon"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long + kind: Literal["salmon"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"salmon\".""" friends: Optional[List["_models.Fish"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) hate: Optional[Dict[str, "_models.Fish"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -186,7 +187,7 @@ class SawShark(Shark, discriminator="saw"): """ __mapping__: Dict[str, _model_base.Model] = {} - sharktype: Literal["saw"] = rest_discriminator(name="sharktype", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long + sharktype: Literal["saw"] = rest_discriminator(name="sharktype", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"saw\".""" @overload diff --git a/packages/typespec-python/test/azure/generated/typetest-model-notdiscriminated/typetest/model/notdiscriminated/_serialization.py b/packages/typespec-python/test/azure/generated/typetest-model-notdiscriminated/typetest/model/notdiscriminated/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-notdiscriminated/typetest/model/notdiscriminated/_serialization.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-notdiscriminated/typetest/model/notdiscriminated/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/typetest-model-notdiscriminated/typetest/model/notdiscriminated/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/typetest-model-notdiscriminated/typetest/model/notdiscriminated/aio/_operations/_operations.py index dd8c9dcf22c..cb79be55bad 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-notdiscriminated/typetest/model/notdiscriminated/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-notdiscriminated/typetest/model/notdiscriminated/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/typetest-model-recursive/typetest/model/recursive/_serialization.py b/packages/typespec-python/test/azure/generated/typetest-model-recursive/typetest/model/recursive/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-recursive/typetest/model/recursive/_serialization.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-recursive/typetest/model/recursive/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/typetest-model-recursive/typetest/model/recursive/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/typetest-model-recursive/typetest/model/recursive/aio/_operations/_operations.py index 95f55138db5..39648938d1e 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-recursive/typetest/model/recursive/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-recursive/typetest/model/recursive/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/typetest-model-recursive/typetest/model/recursive/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-model-recursive/typetest/model/recursive/models/_models.py index 8d63010ca6c..0910dc67bd5 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-recursive/typetest/model/recursive/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-recursive/typetest/model/recursive/models/_models.py @@ -25,7 +25,7 @@ class Element(_model_base.Model): extension: Optional[List["_models.Extension"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) @overload def __init__( diff --git a/packages/typespec-python/test/azure/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/_serialization.py b/packages/typespec-python/test/azure/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/_serialization.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/aio/_operations/_operations.py index fb594edfb39..0db6370d6c8 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/models/_models.py index 0e94792827d..395bd8fb438 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/models/_models.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -110,7 +111,7 @@ class Eagle(Bird, discriminator="eagle"): :vartype partner: ~typetest.model.singlediscriminator.models.Bird """ - kind: Literal["eagle"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long,useless-suppression + kind: Literal["eagle"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"eagle\".""" friends: Optional[List["_models.Bird"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) hate: Optional[Dict[str, "_models.Bird"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -147,7 +148,7 @@ class Goose(Bird, discriminator="goose"): :vartype kind: str """ - kind: Literal["goose"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long,useless-suppression + kind: Literal["goose"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"goose\".""" @overload @@ -178,7 +179,7 @@ class SeaGull(Bird, discriminator="seagull"): :vartype kind: str """ - kind: Literal["seagull"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long + kind: Literal["seagull"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"seagull\".""" @overload @@ -209,7 +210,7 @@ class Sparrow(Bird, discriminator="sparrow"): :vartype kind: str """ - kind: Literal["sparrow"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long + kind: Literal["sparrow"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"sparrow\".""" @overload @@ -240,7 +241,7 @@ class TRex(Dinosaur, discriminator="t-rex"): :vartype kind: str """ - kind: Literal["t-rex"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long,useless-suppression + kind: Literal["t-rex"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"t-rex\".""" @overload diff --git a/packages/typespec-python/test/azure/generated/typetest-model-usage/typetest/model/usage/_serialization.py b/packages/typespec-python/test/azure/generated/typetest-model-usage/typetest/model/usage/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-usage/typetest/model/usage/_serialization.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-usage/typetest/model/usage/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/typetest-model-usage/typetest/model/usage/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/typetest-model-usage/typetest/model/usage/aio/_operations/_operations.py index 45384bb3700..78fe9a40a7e 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-usage/typetest/model/usage/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-usage/typetest/model/usage/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/typetest-model-visibility/typetest/model/visibility/_serialization.py b/packages/typespec-python/test/azure/generated/typetest-model-visibility/typetest/model/visibility/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-visibility/typetest/model/visibility/_serialization.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-visibility/typetest/model/visibility/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/typetest-model-visibility/typetest/model/visibility/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/typetest-model-visibility/typetest/model/visibility/aio/_operations/_operations.py index 3b54c6e024d..cef65e1ce9d 100644 --- a/packages/typespec-python/test/azure/generated/typetest-model-visibility/typetest/model/visibility/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/typetest-model-visibility/typetest/model/visibility/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/_serialization.py b/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/_serialization.py +++ b/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py index 3e81c75dc3f..bc15a165479 100644 --- a/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -122,7 +122,7 @@ class DifferentSpreadModelArrayDerived(DifferentSpreadModelArrayRecord): derived_prop: List["_models.ModelForRecord"] = rest_field( name="derivedProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """The index property. Required.""" @overload @@ -186,7 +186,7 @@ class DifferentSpreadModelDerived(DifferentSpreadModelRecord): derived_prop: "_models.ModelForRecord" = rest_field( name="derivedProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """The index property. Required.""" @overload @@ -309,7 +309,7 @@ class ExtendsModelAdditionalProperties(_model_base.Model): known_prop: "_models.ModelForRecord" = rest_field( name="knownProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required.""" @overload @@ -340,7 +340,7 @@ class ExtendsModelArrayAdditionalProperties(_model_base.Model): known_prop: List["_models.ModelForRecord"] = rest_field( name="knownProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required.""" @overload @@ -510,7 +510,7 @@ class ExtendsUnknownAdditionalPropertiesDiscriminatedDerived( :vartype age: float """ - kind: Literal["derived"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long + kind: Literal["derived"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"derived\".""" index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The index property. Required.""" @@ -576,7 +576,7 @@ class IsModelAdditionalProperties(_model_base.Model): known_prop: "_models.ModelForRecord" = rest_field( name="knownProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required.""" @overload @@ -607,7 +607,7 @@ class IsModelArrayAdditionalProperties(_model_base.Model): known_prop: List["_models.ModelForRecord"] = rest_field( name="knownProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required.""" @overload @@ -777,7 +777,7 @@ class IsUnknownAdditionalPropertiesDiscriminatedDerived( :vartype age: float """ - kind: Literal["derived"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long + kind: Literal["derived"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"derived\".""" index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The index property. Required.""" @@ -901,7 +901,7 @@ class SpreadModelArrayRecord(_model_base.Model): known_prop: List["_models.ModelForRecord"] = rest_field( name="knownProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required.""" @overload @@ -932,7 +932,7 @@ class SpreadModelRecord(_model_base.Model): known_prop: "_models.ModelForRecord" = rest_field( name="knownProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required.""" @overload @@ -1183,7 +1183,7 @@ class WidgetData1(_model_base.Model): """Required.""" end: Optional[datetime.datetime] = rest_field( visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) # pylint: disable=line-too-long + ) @overload def __init__( diff --git a/packages/typespec-python/test/azure/generated/typetest-property-nullable/typetest/property/nullable/_serialization.py b/packages/typespec-python/test/azure/generated/typetest-property-nullable/typetest/property/nullable/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/typetest-property-nullable/typetest/property/nullable/_serialization.py +++ b/packages/typespec-python/test/azure/generated/typetest-property-nullable/typetest/property/nullable/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/typetest-property-nullable/typetest/property/nullable/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-property-nullable/typetest/property/nullable/models/_models.py index d3d0de7d18f..75617a41bac 100644 --- a/packages/typespec-python/test/azure/generated/typetest-property-nullable/typetest/property/nullable/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-property-nullable/typetest/property/nullable/models/_models.py @@ -30,11 +30,11 @@ class BytesProperty(_model_base.Model): required_property: str = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required property. Required.""" nullable_property: bytes = rest_field( name="nullableProperty", visibility=["read", "create", "update", "delete", "query"], format="base64" - ) # pylint: disable=line-too-long + ) """Property. Required.""" @overload @@ -68,11 +68,11 @@ class CollectionsByteProperty(_model_base.Model): required_property: str = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required property. Required.""" nullable_property: List[bytes] = rest_field( name="nullableProperty", visibility=["read", "create", "update", "delete", "query"], format="base64" - ) # pylint: disable=line-too-long + ) """Property. Required.""" @overload @@ -106,11 +106,11 @@ class CollectionsModelProperty(_model_base.Model): required_property: str = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required property. Required.""" nullable_property: List["_models.InnerModel"] = rest_field( name="nullableProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Property. Required.""" @overload @@ -144,11 +144,11 @@ class CollectionsStringProperty(_model_base.Model): required_property: str = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required property. Required.""" nullable_property: List[str] = rest_field( name="nullableProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Property. Required.""" @overload @@ -182,11 +182,11 @@ class DatetimeProperty(_model_base.Model): required_property: str = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required property. Required.""" nullable_property: datetime.datetime = rest_field( name="nullableProperty", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) # pylint: disable=line-too-long + ) """Property. Required.""" @overload @@ -220,11 +220,11 @@ class DurationProperty(_model_base.Model): required_property: str = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required property. Required.""" nullable_property: datetime.timedelta = rest_field( name="nullableProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Property. Required.""" @overload @@ -288,11 +288,11 @@ class StringProperty(_model_base.Model): required_property: str = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required property. Required.""" nullable_property: str = rest_field( name="nullableProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Property. Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/typetest-property-optional/typetest/property/optional/_serialization.py b/packages/typespec-python/test/azure/generated/typetest-property-optional/typetest/property/optional/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/typetest-property-optional/typetest/property/optional/_serialization.py +++ b/packages/typespec-python/test/azure/generated/typetest-property-optional/typetest/property/optional/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/typetest-property-optional/typetest/property/optional/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-property-optional/typetest/property/optional/models/_models.py index bb9b7ad9cc2..5e8dbdad678 100644 --- a/packages/typespec-python/test/azure/generated/typetest-property-optional/typetest/property/optional/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-property-optional/typetest/property/optional/models/_models.py @@ -83,7 +83,7 @@ class CollectionsByteProperty(_model_base.Model): property: Optional[List[bytes]] = rest_field( visibility=["read", "create", "update", "delete", "query"], format="base64" - ) # pylint: disable=line-too-long + ) """Property.""" @overload @@ -113,7 +113,7 @@ class CollectionsModelProperty(_model_base.Model): property: Optional[List["_models.StringProperty"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Property.""" @overload @@ -143,7 +143,7 @@ class DatetimeProperty(_model_base.Model): property: Optional[datetime.datetime] = rest_field( visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) # pylint: disable=line-too-long + ) """Property.""" @overload @@ -316,11 +316,11 @@ class RequiredAndOptionalProperty(_model_base.Model): optional_property: Optional[str] = rest_field( name="optionalProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """optional string property.""" required_property: int = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """required int property. Required.""" @overload @@ -464,7 +464,7 @@ class UnionStringLiteralProperty(_model_base.Model): property: Optional[Literal["hello", "world"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Property. Is either a Literal[\"hello\"] type or a Literal[\"world\"] type.""" @overload diff --git a/packages/typespec-python/test/azure/generated/typetest-property-valuetypes/typetest/property/valuetypes/_serialization.py b/packages/typespec-python/test/azure/generated/typetest-property-valuetypes/typetest/property/valuetypes/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/typetest-property-valuetypes/typetest/property/valuetypes/_serialization.py +++ b/packages/typespec-python/test/azure/generated/typetest-property-valuetypes/typetest/property/valuetypes/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/typetest-property-valuetypes/typetest/property/valuetypes/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-property-valuetypes/typetest/property/valuetypes/models/_models.py index e15fd7c4b65..e436012c81d 100644 --- a/packages/typespec-python/test/azure/generated/typetest-property-valuetypes/typetest/property/valuetypes/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-property-valuetypes/typetest/property/valuetypes/models/_models.py @@ -192,7 +192,7 @@ class DatetimeProperty(_model_base.Model): property: datetime.datetime = rest_field( visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) # pylint: disable=line-too-long + ) """Property. Required.""" @overload @@ -339,7 +339,7 @@ class EnumProperty(_model_base.Model): property: Union[str, "_models.FixedInnerEnum"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Property. Required. Known values are: \"ValueOne\" and \"ValueTwo\".""" @overload diff --git a/packages/typespec-python/test/azure/generated/typetest-scalar/typetest/scalar/_serialization.py b/packages/typespec-python/test/azure/generated/typetest-scalar/typetest/scalar/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/typetest-scalar/typetest/scalar/_serialization.py +++ b/packages/typespec-python/test/azure/generated/typetest-scalar/typetest/scalar/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/typetest-union/typetest/union/_serialization.py b/packages/typespec-python/test/azure/generated/typetest-union/typetest/union/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/typetest-union/typetest/union/_serialization.py +++ b/packages/typespec-python/test/azure/generated/typetest-union/typetest/union/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/typetest-union/typetest/union/models/_models.py b/packages/typespec-python/test/azure/generated/typetest-union/typetest/union/models/_models.py index 73443d92627..82507a82c34 100644 --- a/packages/typespec-python/test/azure/generated/typetest-union/typetest/union/models/_models.py +++ b/packages/typespec-python/test/azure/generated/typetest-union/typetest/union/models/_models.py @@ -325,7 +325,7 @@ class GetResponse7(_model_base.Model): prop: Union[str, "_models.StringExtensibleNamedUnion"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required. Known values are: \"b\" and \"c\".""" @overload @@ -356,7 +356,7 @@ class GetResponse8(_model_base.Model): prop: Union[Literal["b"], Literal["c"], str] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required. Is one of the following types: Literal[\"b\"], Literal[\"c\"], str""" @overload @@ -426,22 +426,22 @@ class MixedLiteralsCases(_model_base.Model): string_literal: Literal["a", 2, True] = rest_field( name="stringLiteral", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """This should be receive/send the \"a\" variant. Required. Is one of the following types: Literal[\"a\"], Literal[2], float, Literal[True]""" int_literal: Literal["a", 2, True] = rest_field( name="intLiteral", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """This should be receive/send the 2 variant. Required. Is one of the following types: Literal[\"a\"], Literal[2], float, Literal[True]""" float_literal: Literal["a", 2, True] = rest_field( name="floatLiteral", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """This should be receive/send the 3.3 variant. Required. Is one of the following types: Literal[\"a\"], Literal[2], float, Literal[True]""" boolean_literal: Literal["a", 2, True] = rest_field( name="booleanLiteral", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """This should be receive/send the true variant. Required. Is one of the following types: Literal[\"a\"], Literal[2], float, Literal[True]""" @@ -488,27 +488,27 @@ class MixedTypesCases(_model_base.Model): model: Union["_models.Cat", Literal["a"], int, bool] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """This should be receive/send the Cat variant. Required. Is one of the following types: Cat, Literal[\"a\"], int, bool""" literal: Union["_models.Cat", Literal["a"], int, bool] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """This should be receive/send the \"a\" variant. Required. Is one of the following types: Cat, Literal[\"a\"], int, bool""" int_property: Union["_models.Cat", Literal["a"], int, bool] = rest_field( name="int", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """This should be receive/send the int variant. Required. Is one of the following types: Cat, Literal[\"a\"], int, bool""" boolean: Union["_models.Cat", Literal["a"], int, bool] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """This should be receive/send the boolean variant. Required. Is one of the following types: Cat, Literal[\"a\"], int, bool""" array: List[Union["_models.Cat", Literal["a"], int, bool]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """This should be receive/send 4 element with Cat, \"a\", int, and boolean. Required.""" @overload diff --git a/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/_serialization.py b/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/_serialization.py +++ b/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/aio/operations/_operations.py index b5ec0e234bf..ee609fd604b 100644 --- a/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/models/_models.py b/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/models/_models.py index c3707e33f15..4723f9db5b8 100644 --- a/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/models/_models.py +++ b/packages/typespec-python/test/azure/generated/versioning-added/versioning/added/models/_models.py @@ -32,11 +32,11 @@ class ModelV1(_model_base.Model): """Required.""" enum_prop: Union[str, "_models.EnumV1"] = rest_field( name="enumProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required. Known values are: \"enumMemberV1\" and \"enumMemberV2\".""" union_prop: "_types.UnionV1" = rest_field( name="unionProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required. Is either a str type or a int type.""" @overload @@ -75,11 +75,11 @@ class ModelV2(_model_base.Model): """Required.""" enum_prop: Union[str, "_models.EnumV2"] = rest_field( name="enumProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required. \"enumMember\"""" union_prop: "_types.UnionV2" = rest_field( name="unionProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required. Is either a str type or a int type.""" @overload diff --git a/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/_serialization.py b/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/_serialization.py +++ b/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/aio/_operations/_operations.py index 285f44e4d7f..e59f4897cdf 100644 --- a/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/models/_models.py b/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/models/_models.py index 69ae88f4617..4f831a94814 100644 --- a/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/models/_models.py +++ b/packages/typespec-python/test/azure/generated/versioning-madeoptional/versioning/madeoptional/models/_models.py @@ -27,7 +27,7 @@ class TestModel(_model_base.Model): """Required.""" changed_prop: Optional[str] = rest_field( name="changedProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) @overload def __init__( diff --git a/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/_serialization.py b/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/_serialization.py +++ b/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/aio/_operations/_operations.py index e1137e5df7d..d1fd773d544 100644 --- a/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/models/_models.py b/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/models/_models.py index 90930bbbdcb..ac6c82b5f41 100644 --- a/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/models/_models.py +++ b/packages/typespec-python/test/azure/generated/versioning-removed/versioning/removed/models/_models.py @@ -32,11 +32,11 @@ class ModelV2(_model_base.Model): """Required.""" enum_prop: Union[str, "_models.EnumV2"] = rest_field( name="enumProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required. \"enumMemberV2\"""" union_prop: "_types.UnionV2" = rest_field( name="unionProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required. Is either a str type or a float type.""" @overload @@ -73,7 +73,7 @@ class ModelV3(_model_base.Model): """Required.""" enum_prop: Union[str, "_models.EnumV3"] = rest_field( name="enumProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required. Known values are: \"enumMemberV1\" and \"enumMemberV2Preview\".""" @overload diff --git a/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/_serialization.py b/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/_serialization.py +++ b/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/aio/operations/_operations.py index 4f1663fbce7..3ec4aef9bb3 100644 --- a/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/models/_models.py b/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/models/_models.py index 34c97aa18c4..4e8e36ed08b 100644 --- a/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/models/_models.py +++ b/packages/typespec-python/test/azure/generated/versioning-renamedfrom/versioning/renamedfrom/models/_models.py @@ -32,11 +32,11 @@ class NewModel(_model_base.Model): """Required.""" enum_prop: Union[str, "_models.NewEnum"] = rest_field( name="enumProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required. \"newEnumMember\"""" union_prop: "_types.NewUnion" = rest_field( name="unionProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required. Is either a str type or a int type.""" @overload diff --git a/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_serialization.py b/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_serialization.py +++ b/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_operations/_operations.py index 6cc9bc2bb67..8a6d8510cc6 100644 --- a/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/azure/generated/versioning-typechangedfrom/versioning/typechangedfrom/_serialization.py b/packages/typespec-python/test/azure/generated/versioning-typechangedfrom/versioning/typechangedfrom/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/typespec-python/test/azure/generated/versioning-typechangedfrom/versioning/typechangedfrom/_serialization.py +++ b/packages/typespec-python/test/azure/generated/versioning-typechangedfrom/versioning/typechangedfrom/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/azure/generated/versioning-typechangedfrom/versioning/typechangedfrom/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/versioning-typechangedfrom/versioning/typechangedfrom/aio/_operations/_operations.py index a55e76ab915..facba2f832c 100644 --- a/packages/typespec-python/test/azure/generated/versioning-typechangedfrom/versioning/typechangedfrom/aio/_operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/versioning-typechangedfrom/versioning/typechangedfrom/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/typespec-python/test/unbranded/generated/authentication-api-key/authentication/apikey/_serialization.py b/packages/typespec-python/test/unbranded/generated/authentication-api-key/authentication/apikey/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/authentication-api-key/authentication/apikey/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/authentication-api-key/authentication/apikey/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/authentication-http-custom/authentication/http/custom/_serialization.py b/packages/typespec-python/test/unbranded/generated/authentication-http-custom/authentication/http/custom/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/authentication-http-custom/authentication/http/custom/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/authentication-http-custom/authentication/http/custom/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/authentication-oauth2/authentication/oauth2/_serialization.py b/packages/typespec-python/test/unbranded/generated/authentication-oauth2/authentication/oauth2/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/authentication-oauth2/authentication/oauth2/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/authentication-oauth2/authentication/oauth2/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/authentication-union/authentication/union/_serialization.py b/packages/typespec-python/test/unbranded/generated/authentication-union/authentication/union/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/authentication-union/authentication/union/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/authentication-union/authentication/union/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/_serialization.py b/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/encode-bytes/encode/bytes/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/encode-datetime/encode/datetime/_serialization.py b/packages/typespec-python/test/unbranded/generated/encode-datetime/encode/datetime/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/encode-datetime/encode/datetime/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/encode-datetime/encode/datetime/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/encode-datetime/encode/datetime/models/_models.py b/packages/typespec-python/test/unbranded/generated/encode-datetime/encode/datetime/models/_models.py index 7d5c4b481fa..f68996e2385 100644 --- a/packages/typespec-python/test/unbranded/generated/encode-datetime/encode/datetime/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/encode-datetime/encode/datetime/models/_models.py @@ -111,7 +111,7 @@ class UnixTimestampArrayDatetimeProperty(_model_base.Model): value: List[datetime.datetime] = rest_field( visibility=["read", "create", "update", "delete", "query"], format="unix-timestamp" - ) # pylint: disable=line-too-long + ) """Required.""" @overload @@ -142,7 +142,7 @@ class UnixTimestampDatetimeProperty(_model_base.Model): value: datetime.datetime = rest_field( visibility=["read", "create", "update", "delete", "query"], format="unix-timestamp" - ) # pylint: disable=line-too-long + ) """Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/encode-duration/encode/duration/_serialization.py b/packages/typespec-python/test/unbranded/generated/encode-duration/encode/duration/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/encode-duration/encode/duration/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/encode-duration/encode/duration/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/encode-numeric/encode/numeric/_serialization.py b/packages/typespec-python/test/unbranded/generated/encode-numeric/encode/numeric/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/encode-numeric/encode/numeric/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/encode-numeric/encode/numeric/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/headasbooleanfalse/headasbooleanfalse/_serialization.py b/packages/typespec-python/test/unbranded/generated/headasbooleanfalse/headasbooleanfalse/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/headasbooleanfalse/headasbooleanfalse/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/headasbooleanfalse/headasbooleanfalse/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/headasbooleantrue/headasbooleantrue/_serialization.py b/packages/typespec-python/test/unbranded/generated/headasbooleantrue/headasbooleantrue/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/headasbooleantrue/headasbooleantrue/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/headasbooleantrue/headasbooleantrue/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/parameters-basic/parameters/basic/_serialization.py b/packages/typespec-python/test/unbranded/generated/parameters-basic/parameters/basic/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/parameters-basic/parameters/basic/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/parameters-basic/parameters/basic/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/parameters-body-optionality/parameters/bodyoptionality/_serialization.py b/packages/typespec-python/test/unbranded/generated/parameters-body-optionality/parameters/bodyoptionality/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/parameters-body-optionality/parameters/bodyoptionality/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/parameters-body-optionality/parameters/bodyoptionality/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/parameters-collection-format/parameters/collectionformat/_serialization.py b/packages/typespec-python/test/unbranded/generated/parameters-collection-format/parameters/collectionformat/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/parameters-collection-format/parameters/collectionformat/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/parameters-collection-format/parameters/collectionformat/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/parameters-spread/parameters/spread/_serialization.py b/packages/typespec-python/test/unbranded/generated/parameters-spread/parameters/spread/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/parameters-spread/parameters/spread/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/parameters-spread/parameters/spread/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/payload-content-negotiation/payload/contentnegotiation/_serialization.py b/packages/typespec-python/test/unbranded/generated/payload-content-negotiation/payload/contentnegotiation/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-content-negotiation/payload/contentnegotiation/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/payload-content-negotiation/payload/contentnegotiation/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/payload-json-merge-patch/payload/jsonmergepatch/_serialization.py b/packages/typespec-python/test/unbranded/generated/payload-json-merge-patch/payload/jsonmergepatch/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-json-merge-patch/payload/jsonmergepatch/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/payload-json-merge-patch/payload/jsonmergepatch/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/payload-json-merge-patch/payload/jsonmergepatch/models/_models.py b/packages/typespec-python/test/unbranded/generated/payload-json-merge-patch/payload/jsonmergepatch/models/_models.py index 4f79e4b2361..8d8ec836387 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-json-merge-patch/payload/jsonmergepatch/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/payload-json-merge-patch/payload/jsonmergepatch/models/_models.py @@ -74,18 +74,18 @@ class Resource(_model_base.Model): description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) map: Optional[Dict[str, "_models.InnerModel"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) array: Optional[List["_models.InnerModel"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) int_value: Optional[int] = rest_field(name="intValue", visibility=["read", "create", "update", "delete", "query"]) float_value: Optional[float] = rest_field( name="floatValue", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) inner_model: Optional["_models.InnerModel"] = rest_field( name="innerModel", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) int_array: Optional[List[int]] = rest_field( name="intArray", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) @overload def __init__( @@ -134,18 +134,18 @@ class ResourcePatch(_model_base.Model): description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) map: Optional[Dict[str, "_models.InnerModel"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) array: Optional[List["_models.InnerModel"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) int_value: Optional[int] = rest_field(name="intValue", visibility=["read", "create", "update", "delete", "query"]) float_value: Optional[float] = rest_field( name="floatValue", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) inner_model: Optional["_models.InnerModel"] = rest_field( name="innerModel", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) int_array: Optional[List[int]] = rest_field( name="intArray", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) @overload def __init__( diff --git a/packages/typespec-python/test/unbranded/generated/payload-media-type/payload/mediatype/_serialization.py b/packages/typespec-python/test/unbranded/generated/payload-media-type/payload/mediatype/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-media-type/payload/mediatype/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/payload-media-type/payload/mediatype/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/payload-multipart/payload/multipart/_serialization.py b/packages/typespec-python/test/unbranded/generated/payload-multipart/payload/multipart/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-multipart/payload/multipart/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/payload-multipart/payload/multipart/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/payload-multipart/payload/multipart/models/_models.py b/packages/typespec-python/test/unbranded/generated/payload-multipart/payload/multipart/models/_models.py index e00570b783f..dd9bdb318c7 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-multipart/payload/multipart/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/payload-multipart/payload/multipart/models/_models.py @@ -62,7 +62,7 @@ class BinaryArrayPartsRequest(_model_base.Model): """Required.""" pictures: List[FileType] = rest_field( visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) # pylint: disable=line-too-long + ) """Required.""" @overload @@ -107,15 +107,15 @@ class ComplexHttpPartsModelRequest(_model_base.Model): """Required.""" profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) # pylint: disable=line-too-long + ) """Required.""" previous_addresses: List["_models.Address"] = rest_field( name="previousAddresses", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required.""" pictures: List[FileType] = rest_field( visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) # pylint: disable=line-too-long + ) """Required.""" @overload @@ -161,11 +161,11 @@ class ComplexPartsRequest(_model_base.Model): """Required.""" profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) # pylint: disable=line-too-long + ) """Required.""" pictures: List[FileType] = rest_field( visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) # pylint: disable=line-too-long + ) """Required.""" @overload @@ -200,7 +200,7 @@ class FileWithHttpPartOptionalContentTypeRequest(_model_base.Model): # pylint: profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) # pylint: disable=line-too-long + ) """Required.""" @overload @@ -232,7 +232,7 @@ class FileWithHttpPartRequiredContentTypeRequest(_model_base.Model): # pylint: profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) # pylint: disable=line-too-long + ) """Required.""" @overload @@ -264,7 +264,7 @@ class FileWithHttpPartSpecificContentTypeRequest(_model_base.Model): # pylint: profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) # pylint: disable=line-too-long + ) """Required.""" @overload @@ -300,7 +300,7 @@ class JsonPartRequest(_model_base.Model): """Required.""" profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) # pylint: disable=line-too-long + ) """Required.""" @overload @@ -335,11 +335,11 @@ class MultiBinaryPartsRequest(_model_base.Model): profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) # pylint: disable=line-too-long + ) """Required.""" picture: Optional[FileType] = rest_field( visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) # pylint: disable=line-too-long + ) @overload def __init__( @@ -375,7 +375,7 @@ class MultiPartRequest(_model_base.Model): """Required.""" profile_image: FileType = rest_field( name="profileImage", visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True - ) # pylint: disable=line-too-long + ) """Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/_serialization.py b/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/_serialization.py b/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/models/_models.py b/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/models/_models.py index 277d0d3a1a3..3a624109b00 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/models/_models.py @@ -28,7 +28,7 @@ class ModelWithArrayOfModel(_model_base.Model): name="items", visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "SimpleModel", "name": "items", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" _xml = {"attribute": False, "name": "ModelWithArrayOfModel", "text": False, "unwrapped": False} @@ -66,17 +66,17 @@ class ModelWithAttributes(_model_base.Model): id1: int = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": True, "name": "id1", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" id2: str = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": True, "name": "id2", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" enabled: bool = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "enabled", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" _xml = {"attribute": False, "name": "ModelWithAttributes", "text": False, "unwrapped": False} @@ -112,7 +112,7 @@ class ModelWithDictionary(_model_base.Model): metadata: Dict[str, str] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "metadata", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" _xml = {"attribute": False, "name": "ModelWithDictionary", "text": False, "unwrapped": False} @@ -147,7 +147,7 @@ class ModelWithEmptyArray(_model_base.Model): name="items", visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "SimpleModel", "name": "items", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" _xml = {"attribute": False, "name": "ModelWithEmptyArray", "text": False, "unwrapped": False} @@ -184,12 +184,12 @@ class ModelWithEncodedNames(_model_base.Model): name="modelData", visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "SimpleModelData", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" colors: List[str] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "string", "name": "PossibleColors", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" _xml = {"attribute": False, "name": "ModelWithEncodedNamesSrc", "text": False, "unwrapped": False} @@ -226,12 +226,12 @@ class ModelWithOptionalField(_model_base.Model): item: str = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "item", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" value: Optional[int] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "value", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) _xml = {"attribute": False, "name": "ModelWithOptionalField", "text": False, "unwrapped": False} @@ -268,12 +268,12 @@ class ModelWithRenamedArrays(_model_base.Model): colors: List[str] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "Colors", "name": "Colors", "text": False, "unwrapped": True}, - ) # pylint: disable=line-too-long + ) """Required.""" counts: List[int] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "int32", "name": "Counts", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" _xml = {"attribute": False, "name": "ModelWithRenamedArrays", "text": False, "unwrapped": False} @@ -311,13 +311,13 @@ class ModelWithRenamedFields(_model_base.Model): name="inputData", visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "InputData", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" output_data: "_models.SimpleModel" = rest_field( name="outputData", visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "OutputData", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" _xml = {"attribute": False, "name": "ModelWithRenamedFieldsSrc", "text": False, "unwrapped": False} @@ -354,12 +354,12 @@ class ModelWithSimpleArrays(_model_base.Model): colors: List[str] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "string", "name": "colors", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" counts: List[int] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "int32", "name": "counts", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" _xml = {"attribute": False, "name": "ModelWithSimpleArrays", "text": False, "unwrapped": False} @@ -396,12 +396,12 @@ class ModelWithText(_model_base.Model): language: str = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": True, "name": "language", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" content: str = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "content", "text": True, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" _xml = {"attribute": False, "name": "ModelWithText", "text": False, "unwrapped": False} @@ -438,12 +438,12 @@ class ModelWithUnwrappedArray(_model_base.Model): colors: List[str] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "colors", "name": "colors", "text": False, "unwrapped": True}, - ) # pylint: disable=line-too-long + ) """Required.""" counts: List[int] = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "itemsName": "int32", "name": "counts", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" _xml = {"attribute": False, "name": "ModelWithUnwrappedArray", "text": False, "unwrapped": False} @@ -480,12 +480,12 @@ class SimpleModel(_model_base.Model): name: str = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "name", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" age: int = rest_field( visibility=["read", "create", "update", "delete", "query"], xml={"attribute": False, "name": "age", "text": False, "unwrapped": False}, - ) # pylint: disable=line-too-long + ) """Required.""" _xml = {"attribute": False, "name": "SimpleModel", "text": False, "unwrapped": False} diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py index eab51d7c9d6..3f507c9bcec 100644 --- a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_operations/_operations.py @@ -172,7 +172,7 @@ def error_response_status_code404(self, **kwargs: Any) -> Literal[204]: if response.status_code == 404: error = _failsafe_deserialize(_models.NotFoundError, response.json()) raise ResourceNotFoundError(response=response, model=error) - elif 400 <= response.status_code <= 499: + if 400 <= response.status_code <= 499: error = _failsafe_deserialize(_models.Standard4XXError, response.json()) raise HttpResponseError(response=response, model=error) diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_serialization.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py index 25932c2b754..ddff2b497d7 100644 --- a/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/response-status-code-range/response/statuscoderange/aio/_operations/_operations.py @@ -143,7 +143,7 @@ async def error_response_status_code404(self, **kwargs: Any) -> Literal[204]: if response.status_code == 404: error = _failsafe_deserialize(_models.NotFoundError, response.json()) raise ResourceNotFoundError(response=response, model=error) - elif 400 <= response.status_code <= 499: + if 400 <= response.status_code <= 499: error = _failsafe_deserialize(_models.Standard4XXError, response.json()) raise HttpResponseError(response=response, model=error) diff --git a/packages/typespec-python/test/unbranded/generated/routes/routes/_serialization.py b/packages/typespec-python/test/unbranded/generated/routes/routes/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/routes/routes/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/routes/routes/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/serialization-encoded-name-json/serialization/encodedname/json/_serialization.py b/packages/typespec-python/test/unbranded/generated/serialization-encoded-name-json/serialization/encodedname/json/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/serialization-encoded-name-json/serialization/encodedname/json/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/serialization-encoded-name-json/serialization/encodedname/json/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/server-endpoint-not-defined/server/endpoint/notdefined/_serialization.py b/packages/typespec-python/test/unbranded/generated/server-endpoint-not-defined/server/endpoint/notdefined/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/server-endpoint-not-defined/server/endpoint/notdefined/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/server-endpoint-not-defined/server/endpoint/notdefined/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/_serialization.py b/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/server-path-multiple/server/path/multiple/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/server-path-single/server/path/single/_serialization.py b/packages/typespec-python/test/unbranded/generated/server-path-single/server/path/single/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/server-path-single/server/path/single/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/server-path-single/server/path/single/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/server-versions-not-versioned/server/versions/notversioned/_serialization.py b/packages/typespec-python/test/unbranded/generated/server-versions-not-versioned/server/versions/notversioned/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/server-versions-not-versioned/server/versions/notversioned/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/server-versions-not-versioned/server/versions/notversioned/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/server-versions-versioned/server/versions/versioned/_serialization.py b/packages/typespec-python/test/unbranded/generated/server-versions-versioned/server/versions/versioned/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/server-versions-versioned/server/versions/versioned/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/server-versions-versioned/server/versions/versioned/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/special-headers-conditional-request/specialheaders/conditionalrequest/_serialization.py b/packages/typespec-python/test/unbranded/generated/special-headers-conditional-request/specialheaders/conditionalrequest/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/special-headers-conditional-request/specialheaders/conditionalrequest/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/special-headers-conditional-request/specialheaders/conditionalrequest/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/special-headers-repeatability/specialheaders/repeatability/_serialization.py b/packages/typespec-python/test/unbranded/generated/special-headers-repeatability/specialheaders/repeatability/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/special-headers-repeatability/specialheaders/repeatability/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/special-headers-repeatability/specialheaders/repeatability/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/special-words/specialwords/_serialization.py b/packages/typespec-python/test/unbranded/generated/special-words/specialwords/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/special-words/specialwords/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/special-words/specialwords/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/typetest-array/typetest/array/_serialization.py b/packages/typespec-python/test/unbranded/generated/typetest-array/typetest/array/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-array/typetest/array/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-array/typetest/array/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/typetest-array/typetest/array/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-array/typetest/array/models/_models.py index d2c277d8fe9..958abea9cf1 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-array/typetest/array/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-array/typetest/array/models/_models.py @@ -30,7 +30,7 @@ class InnerModel(_model_base.Model): """Required string property. Required.""" children: Optional[List["_models.InnerModel"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) @overload def __init__( diff --git a/packages/typespec-python/test/unbranded/generated/typetest-dictionary/typetest/dictionary/_serialization.py b/packages/typespec-python/test/unbranded/generated/typetest-dictionary/typetest/dictionary/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-dictionary/typetest/dictionary/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-dictionary/typetest/dictionary/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/typetest-dictionary/typetest/dictionary/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-dictionary/typetest/dictionary/models/_models.py index bd77f13d178..82822cb115c 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-dictionary/typetest/dictionary/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-dictionary/typetest/dictionary/models/_models.py @@ -30,7 +30,7 @@ class InnerModel(_model_base.Model): """Required string property. Required.""" children: Optional[Dict[str, "_models.InnerModel"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) @overload def __init__( diff --git a/packages/typespec-python/test/unbranded/generated/typetest-enum-extensible/typetest/enum/extensible/_serialization.py b/packages/typespec-python/test/unbranded/generated/typetest-enum-extensible/typetest/enum/extensible/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-enum-extensible/typetest/enum/extensible/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-enum-extensible/typetest/enum/extensible/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/typetest-enum-fixed/typetest/enum/fixed/_serialization.py b/packages/typespec-python/test/unbranded/generated/typetest-enum-fixed/typetest/enum/fixed/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-enum-fixed/typetest/enum/fixed/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-enum-fixed/typetest/enum/fixed/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/typetest-model-empty/typetest/model/empty/_serialization.py b/packages/typespec-python/test/unbranded/generated/typetest-model-empty/typetest/model/empty/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-model-empty/typetest/model/empty/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-model-empty/typetest/model/empty/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/_serialization.py b/packages/typespec-python/test/unbranded/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/models/_models.py index 98f5743572a..c7c9c5e87eb 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-model-enumdiscriminator/typetest/model/enumdiscriminator/models/_models.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Unbranded Corporation. All rights reserved. @@ -62,7 +63,7 @@ class Cobra(Snake, discriminator="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 # pylint: disable=line-too-long + kind: Literal[SnakeKind.COBRA] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """discriminator property. Required. Species cobra""" @overload @@ -131,7 +132,7 @@ class Golden(Dog, discriminator="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 # pylint: disable=line-too-long + kind: Literal[DogKind.GOLDEN] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """discriminator property. Required. Species golden""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/_serialization.py b/packages/typespec-python/test/unbranded/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/models/_models.py index 2bfe181d466..ad373f8e4ef 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-model-nesteddiscriminator/typetest/model/nesteddiscriminator/models/_models.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Unbranded Corporation. All rights reserved. @@ -71,7 +72,7 @@ class Shark(Fish, discriminator="shark"): """ __mapping__: Dict[str, _model_base.Model] = {} - kind: Literal["shark"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long,useless-suppression + kind: Literal["shark"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"shark\".""" sharktype: str = rest_discriminator(name="sharktype", visibility=["read", "create", "update", "delete", "query"]) """Required. Default value is None.""" @@ -108,7 +109,7 @@ class GoblinShark(Shark, discriminator="goblin"): """ __mapping__: Dict[str, _model_base.Model] = {} - sharktype: Literal["goblin"] = rest_discriminator(name="sharktype", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long + sharktype: Literal["goblin"] = rest_discriminator(name="sharktype", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"goblin\".""" @overload @@ -146,7 +147,7 @@ class Salmon(Fish, discriminator="salmon"): :vartype partner: ~typetest.model.nesteddiscriminator.models.Fish """ - kind: Literal["salmon"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long + kind: Literal["salmon"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"salmon\".""" friends: Optional[List["_models.Fish"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) hate: Optional[Dict[str, "_models.Fish"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -186,7 +187,7 @@ class SawShark(Shark, discriminator="saw"): """ __mapping__: Dict[str, _model_base.Model] = {} - sharktype: Literal["saw"] = rest_discriminator(name="sharktype", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long + sharktype: Literal["saw"] = rest_discriminator(name="sharktype", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"saw\".""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/typetest-model-notdiscriminated/typetest/model/notdiscriminated/_serialization.py b/packages/typespec-python/test/unbranded/generated/typetest-model-notdiscriminated/typetest/model/notdiscriminated/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-model-notdiscriminated/typetest/model/notdiscriminated/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-model-notdiscriminated/typetest/model/notdiscriminated/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/typetest-model-recursive/typetest/model/recursive/_serialization.py b/packages/typespec-python/test/unbranded/generated/typetest-model-recursive/typetest/model/recursive/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-model-recursive/typetest/model/recursive/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-model-recursive/typetest/model/recursive/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/typetest-model-recursive/typetest/model/recursive/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-model-recursive/typetest/model/recursive/models/_models.py index f28e134c741..3df5e36bff5 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-model-recursive/typetest/model/recursive/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-model-recursive/typetest/model/recursive/models/_models.py @@ -25,7 +25,7 @@ class Element(_model_base.Model): extension: Optional[List["_models.Extension"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) @overload def __init__( diff --git a/packages/typespec-python/test/unbranded/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/_serialization.py b/packages/typespec-python/test/unbranded/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/models/_models.py index 57ce23909eb..cf4ba943085 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-model-singlediscriminator/typetest/model/singlediscriminator/models/_models.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Unbranded Corporation. All rights reserved. @@ -110,7 +111,7 @@ class Eagle(Bird, discriminator="eagle"): :vartype partner: ~typetest.model.singlediscriminator.models.Bird """ - kind: Literal["eagle"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long,useless-suppression + kind: Literal["eagle"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"eagle\".""" friends: Optional[List["_models.Bird"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) hate: Optional[Dict[str, "_models.Bird"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -147,7 +148,7 @@ class Goose(Bird, discriminator="goose"): :vartype kind: str """ - kind: Literal["goose"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long,useless-suppression + kind: Literal["goose"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"goose\".""" @overload @@ -178,7 +179,7 @@ class SeaGull(Bird, discriminator="seagull"): :vartype kind: str """ - kind: Literal["seagull"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long + kind: Literal["seagull"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"seagull\".""" @overload @@ -209,7 +210,7 @@ class Sparrow(Bird, discriminator="sparrow"): :vartype kind: str """ - kind: Literal["sparrow"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long + kind: Literal["sparrow"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"sparrow\".""" @overload @@ -240,7 +241,7 @@ class TRex(Dinosaur, discriminator="t-rex"): :vartype kind: str """ - kind: Literal["t-rex"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long,useless-suppression + kind: Literal["t-rex"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"t-rex\".""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/typetest-model-usage/typetest/model/usage/_serialization.py b/packages/typespec-python/test/unbranded/generated/typetest-model-usage/typetest/model/usage/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-model-usage/typetest/model/usage/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-model-usage/typetest/model/usage/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/typetest-model-visibility/typetest/model/visibility/_serialization.py b/packages/typespec-python/test/unbranded/generated/typetest-model-visibility/typetest/model/visibility/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-model-visibility/typetest/model/visibility/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-model-visibility/typetest/model/visibility/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/_serialization.py b/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py index 427acbf3142..ab3118fff98 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-property-additionalproperties/typetest/property/additionalproperties/models/_models.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Unbranded Corporation. All rights reserved. @@ -122,7 +122,7 @@ class DifferentSpreadModelArrayDerived(DifferentSpreadModelArrayRecord): derived_prop: List["_models.ModelForRecord"] = rest_field( name="derivedProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """The index property. Required.""" @overload @@ -186,7 +186,7 @@ class DifferentSpreadModelDerived(DifferentSpreadModelRecord): derived_prop: "_models.ModelForRecord" = rest_field( name="derivedProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """The index property. Required.""" @overload @@ -309,7 +309,7 @@ class ExtendsModelAdditionalProperties(_model_base.Model): known_prop: "_models.ModelForRecord" = rest_field( name="knownProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required.""" @overload @@ -340,7 +340,7 @@ class ExtendsModelArrayAdditionalProperties(_model_base.Model): known_prop: List["_models.ModelForRecord"] = rest_field( name="knownProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required.""" @overload @@ -510,7 +510,7 @@ class ExtendsUnknownAdditionalPropertiesDiscriminatedDerived( :vartype age: float """ - kind: Literal["derived"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long + kind: Literal["derived"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"derived\".""" index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The index property. Required.""" @@ -576,7 +576,7 @@ class IsModelAdditionalProperties(_model_base.Model): known_prop: "_models.ModelForRecord" = rest_field( name="knownProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required.""" @overload @@ -607,7 +607,7 @@ class IsModelArrayAdditionalProperties(_model_base.Model): known_prop: List["_models.ModelForRecord"] = rest_field( name="knownProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required.""" @overload @@ -777,7 +777,7 @@ class IsUnknownAdditionalPropertiesDiscriminatedDerived( :vartype age: float """ - kind: Literal["derived"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore # pylint: disable=line-too-long + kind: Literal["derived"] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Required. Default value is \"derived\".""" index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The index property. Required.""" @@ -901,7 +901,7 @@ class SpreadModelArrayRecord(_model_base.Model): known_prop: List["_models.ModelForRecord"] = rest_field( name="knownProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required.""" @overload @@ -932,7 +932,7 @@ class SpreadModelRecord(_model_base.Model): known_prop: "_models.ModelForRecord" = rest_field( name="knownProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required.""" @overload @@ -1183,7 +1183,7 @@ class WidgetData1(_model_base.Model): """Required.""" end: Optional[datetime.datetime] = rest_field( visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) # pylint: disable=line-too-long + ) @overload def __init__( diff --git a/packages/typespec-python/test/unbranded/generated/typetest-property-nullable/typetest/property/nullable/_serialization.py b/packages/typespec-python/test/unbranded/generated/typetest-property-nullable/typetest/property/nullable/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-property-nullable/typetest/property/nullable/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-property-nullable/typetest/property/nullable/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/typetest-property-nullable/typetest/property/nullable/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-property-nullable/typetest/property/nullable/models/_models.py index fe2d4c6aa2c..d0209bb7063 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-property-nullable/typetest/property/nullable/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-property-nullable/typetest/property/nullable/models/_models.py @@ -30,11 +30,11 @@ class BytesProperty(_model_base.Model): required_property: str = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required property. Required.""" nullable_property: bytes = rest_field( name="nullableProperty", visibility=["read", "create", "update", "delete", "query"], format="base64" - ) # pylint: disable=line-too-long + ) """Property. Required.""" @overload @@ -68,11 +68,11 @@ class CollectionsByteProperty(_model_base.Model): required_property: str = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required property. Required.""" nullable_property: List[bytes] = rest_field( name="nullableProperty", visibility=["read", "create", "update", "delete", "query"], format="base64" - ) # pylint: disable=line-too-long + ) """Property. Required.""" @overload @@ -106,11 +106,11 @@ class CollectionsModelProperty(_model_base.Model): required_property: str = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required property. Required.""" nullable_property: List["_models.InnerModel"] = rest_field( name="nullableProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Property. Required.""" @overload @@ -144,11 +144,11 @@ class CollectionsStringProperty(_model_base.Model): required_property: str = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required property. Required.""" nullable_property: List[str] = rest_field( name="nullableProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Property. Required.""" @overload @@ -182,11 +182,11 @@ class DatetimeProperty(_model_base.Model): required_property: str = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required property. Required.""" nullable_property: datetime.datetime = rest_field( name="nullableProperty", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) # pylint: disable=line-too-long + ) """Property. Required.""" @overload @@ -220,11 +220,11 @@ class DurationProperty(_model_base.Model): required_property: str = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required property. Required.""" nullable_property: datetime.timedelta = rest_field( name="nullableProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Property. Required.""" @overload @@ -288,11 +288,11 @@ class StringProperty(_model_base.Model): required_property: str = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required property. Required.""" nullable_property: str = rest_field( name="nullableProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Property. Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/typetest-property-optional/typetest/property/optional/_serialization.py b/packages/typespec-python/test/unbranded/generated/typetest-property-optional/typetest/property/optional/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-property-optional/typetest/property/optional/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-property-optional/typetest/property/optional/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/typetest-property-optional/typetest/property/optional/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-property-optional/typetest/property/optional/models/_models.py index c99f12e1142..7d20f98e842 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-property-optional/typetest/property/optional/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-property-optional/typetest/property/optional/models/_models.py @@ -83,7 +83,7 @@ class CollectionsByteProperty(_model_base.Model): property: Optional[List[bytes]] = rest_field( visibility=["read", "create", "update", "delete", "query"], format="base64" - ) # pylint: disable=line-too-long + ) """Property.""" @overload @@ -113,7 +113,7 @@ class CollectionsModelProperty(_model_base.Model): property: Optional[List["_models.StringProperty"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Property.""" @overload @@ -143,7 +143,7 @@ class DatetimeProperty(_model_base.Model): property: Optional[datetime.datetime] = rest_field( visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) # pylint: disable=line-too-long + ) """Property.""" @overload @@ -316,11 +316,11 @@ class RequiredAndOptionalProperty(_model_base.Model): optional_property: Optional[str] = rest_field( name="optionalProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """optional string property.""" required_property: int = rest_field( name="requiredProperty", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """required int property. Required.""" @overload @@ -464,7 +464,7 @@ class UnionStringLiteralProperty(_model_base.Model): property: Optional[Literal["hello", "world"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Property. Is either a Literal[\"hello\"] type or a Literal[\"world\"] type.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/typetest-property-valuetypes/typetest/property/valuetypes/_serialization.py b/packages/typespec-python/test/unbranded/generated/typetest-property-valuetypes/typetest/property/valuetypes/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-property-valuetypes/typetest/property/valuetypes/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-property-valuetypes/typetest/property/valuetypes/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/typetest-property-valuetypes/typetest/property/valuetypes/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-property-valuetypes/typetest/property/valuetypes/models/_models.py index da78594f897..1834b01cf16 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-property-valuetypes/typetest/property/valuetypes/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-property-valuetypes/typetest/property/valuetypes/models/_models.py @@ -192,7 +192,7 @@ class DatetimeProperty(_model_base.Model): property: datetime.datetime = rest_field( visibility=["read", "create", "update", "delete", "query"], format="rfc3339" - ) # pylint: disable=line-too-long + ) """Property. Required.""" @overload @@ -339,7 +339,7 @@ class EnumProperty(_model_base.Model): property: Union[str, "_models.FixedInnerEnum"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Property. Required. Known values are: \"ValueOne\" and \"ValueTwo\".""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/typetest-scalar/typetest/scalar/_serialization.py b/packages/typespec-python/test/unbranded/generated/typetest-scalar/typetest/scalar/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-scalar/typetest/scalar/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-scalar/typetest/scalar/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/typetest-union/typetest/union/_serialization.py b/packages/typespec-python/test/unbranded/generated/typetest-union/typetest/union/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-union/typetest/union/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-union/typetest/union/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/typetest-union/typetest/union/models/_models.py b/packages/typespec-python/test/unbranded/generated/typetest-union/typetest/union/models/_models.py index 5dc9d94cddd..3f1b2f6f514 100644 --- a/packages/typespec-python/test/unbranded/generated/typetest-union/typetest/union/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/typetest-union/typetest/union/models/_models.py @@ -325,7 +325,7 @@ class GetResponse7(_model_base.Model): prop: Union[str, "_models.StringExtensibleNamedUnion"] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required. Known values are: \"b\" and \"c\".""" @overload @@ -356,7 +356,7 @@ class GetResponse8(_model_base.Model): prop: Union[Literal["b"], Literal["c"], str] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required. Is one of the following types: Literal[\"b\"], Literal[\"c\"], str""" @overload @@ -426,22 +426,22 @@ class MixedLiteralsCases(_model_base.Model): string_literal: Literal["a", 2, True] = rest_field( name="stringLiteral", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """This should be receive/send the \"a\" variant. Required. Is one of the following types: Literal[\"a\"], Literal[2], float, Literal[True]""" int_literal: Literal["a", 2, True] = rest_field( name="intLiteral", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """This should be receive/send the 2 variant. Required. Is one of the following types: Literal[\"a\"], Literal[2], float, Literal[True]""" float_literal: Literal["a", 2, True] = rest_field( name="floatLiteral", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """This should be receive/send the 3.3 variant. Required. Is one of the following types: Literal[\"a\"], Literal[2], float, Literal[True]""" boolean_literal: Literal["a", 2, True] = rest_field( name="booleanLiteral", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """This should be receive/send the true variant. Required. Is one of the following types: Literal[\"a\"], Literal[2], float, Literal[True]""" @@ -488,27 +488,27 @@ class MixedTypesCases(_model_base.Model): model: Union["_models.Cat", Literal["a"], int, bool] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """This should be receive/send the Cat variant. Required. Is one of the following types: Cat, Literal[\"a\"], int, bool""" literal: Union["_models.Cat", Literal["a"], int, bool] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """This should be receive/send the \"a\" variant. Required. Is one of the following types: Cat, Literal[\"a\"], int, bool""" int_property: Union["_models.Cat", Literal["a"], int, bool] = rest_field( name="int", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """This should be receive/send the int variant. Required. Is one of the following types: Cat, Literal[\"a\"], int, bool""" boolean: Union["_models.Cat", Literal["a"], int, bool] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """This should be receive/send the boolean variant. Required. Is one of the following types: Cat, Literal[\"a\"], int, bool""" array: List[Union["_models.Cat", Literal["a"], int, bool]] = rest_field( visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """This should be receive/send 4 element with Cat, \"a\", int, and boolean. Required.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/_serialization.py b/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/models/_models.py b/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/models/_models.py index d048e37f098..a538788bef8 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-added/versioning/added/models/_models.py @@ -32,11 +32,11 @@ class ModelV1(_model_base.Model): """Required.""" enum_prop: Union[str, "_models.EnumV1"] = rest_field( name="enumProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required. Known values are: \"enumMemberV1\" and \"enumMemberV2\".""" union_prop: "_types.UnionV1" = rest_field( name="unionProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required. Is either a str type or a int type.""" @overload @@ -75,11 +75,11 @@ class ModelV2(_model_base.Model): """Required.""" enum_prop: Union[str, "_models.EnumV2"] = rest_field( name="enumProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required. \"enumMember\"""" union_prop: "_types.UnionV2" = rest_field( name="unionProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required. Is either a str type or a int type.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/_serialization.py b/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/models/_models.py b/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/models/_models.py index 75b87021b44..188fde629f2 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-madeoptional/versioning/madeoptional/models/_models.py @@ -27,7 +27,7 @@ class TestModel(_model_base.Model): """Required.""" changed_prop: Optional[str] = rest_field( name="changedProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) @overload def __init__( diff --git a/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/_serialization.py b/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/models/_models.py b/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/models/_models.py index 668f15c51f6..635034a6ba4 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-removed/versioning/removed/models/_models.py @@ -32,11 +32,11 @@ class ModelV2(_model_base.Model): """Required.""" enum_prop: Union[str, "_models.EnumV2"] = rest_field( name="enumProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required. \"enumMemberV2\"""" union_prop: "_types.UnionV2" = rest_field( name="unionProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required. Is either a str type or a float type.""" @overload @@ -73,7 +73,7 @@ class ModelV3(_model_base.Model): """Required.""" enum_prop: Union[str, "_models.EnumV3"] = rest_field( name="enumProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required. Known values are: \"enumMemberV1\" and \"enumMemberV2Preview\".""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/_serialization.py b/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/models/_models.py b/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/models/_models.py index 9ba820b22f8..e423bc9b009 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-renamedfrom/versioning/renamedfrom/models/_models.py @@ -32,11 +32,11 @@ class NewModel(_model_base.Model): """Required.""" enum_prop: Union[str, "_models.NewEnum"] = rest_field( name="enumProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required. \"newEnumMember\"""" union_prop: "_types.NewUnion" = rest_field( name="unionProp", visibility=["read", "create", "update", "delete", "query"] - ) # pylint: disable=line-too-long + ) """Required. Is either a str type or a int type.""" @overload diff --git a/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_serialization.py b/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-returntypechangedfrom/versioning/returntypechangedfrom/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/typespec-python/test/unbranded/generated/versioning-typechangedfrom/versioning/typechangedfrom/_serialization.py b/packages/typespec-python/test/unbranded/generated/versioning-typechangedfrom/versioning/typechangedfrom/_serialization.py index 00075c6255e..764b2cf027b 100644 --- a/packages/typespec-python/test/unbranded/generated/versioning-typechangedfrom/versioning/typechangedfrom/_serialization.py +++ b/packages/typespec-python/test/unbranded/generated/versioning-typechangedfrom/versioning/typechangedfrom/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Unbranded Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) From a41a34cbe341ddacf8ffa90fc0dc8ac7dea66df3 Mon Sep 17 00:00:00 2001 From: AutoPrFromHttpClientPython Date: Thu, 13 Feb 2025 08:08:20 +0000 Subject: [PATCH 07/14] Regenerate for autorest.python (2025-02-13 08:08:20) --- .../azure/mgmt/test/_serialization.py | 4 ++-- .../azure/test/_generated/_serialization.py | 4 ++-- .../key/credential/sample/_serialization.py | 4 ++-- .../azure/basic/sample/_serialization.py | 4 ++-- .../azure/directives/sample/_serialization.py | 4 ++-- .../sample/aio/_operations/_operations.py | 1 + .../azure/mgmt/sample/_serialization.py | 4 ++-- .../azure/multiapi/sample/_serialization.py | 2 +- .../multiapi/sample/aio/_operations_mixin.py | 1 - .../azure/multiapi/sample/v1/_metadata.json | 2 +- .../_multiapi_service_client_operations.py | 2 +- .../_multiapi_service_client_operations.py | 1 + .../_multiapi_service_client_operations.py | 1 + .../bodyduration/_serialization.py | 4 ++-- .../AzureReport/azurereport/_serialization.py | 4 ++-- ...rest_report_service_for_azure_operations.py | 1 + .../azurespecialproperties/_configuration.py | 1 + .../aio/_configuration.py | 1 + .../aio/operations/_header_operations.py | 1 + .../_api_version_default_operations.py | 2 +- .../operations/_header_operations.py | 1 + .../_subscription_in_credentials_operations.py | 10 +++++----- .../_subscription_in_method_operations.py | 8 ++++---- .../custompollerpager/_serialization.py | 4 ++-- .../aio/operations/_paging_operations.py | 3 +-- .../custombaseurlpaging/_configuration.py | 1 + .../custombaseurlpaging/_serialization.py | 4 ++-- .../custombaseurlpaging/aio/_configuration.py | 1 + .../Head/head/_serialization.py | 4 ++-- .../headexceptions/_serialization.py | 4 ++-- .../_serialization.py | 4 ++-- .../AcceptanceTests/Lro/lro/_configuration.py | 1 + .../AcceptanceTests/Lro/lro/_serialization.py | 4 ++-- .../Lro/lro/aio/_configuration.py | 1 + .../_serialization.py | 4 ++-- ..._with_paramaterized_endpoints_operations.py | 1 + .../mixedapiversion/_serialization.py | 4 ++-- .../aio/operations/_header_operations.py | 1 + .../_api_version_default_operations.py | 2 +- .../operations/_header_operations.py | 1 + .../_subscription_in_credentials_operations.py | 10 +++++----- .../_subscription_in_method_operations.py | 8 ++++---- .../packagemode/batch/head/_serialization.py | 4 ++-- .../packagemode/batch/paging/_serialization.py | 4 ++-- .../aio/operations/_paging_operations.py | 3 +-- .../packagemode/customize/_serialization.py | 4 ++-- .../packagemode/dataplane/_serialization.py | 4 ++-- .../azure/package/mode/_serialization.py | 4 ++-- .../Paging/paging/_serialization.py | 4 ++-- .../securityaadswagger/_serialization.py | 4 ++-- .../_autorest_security_aad_operations.py | 1 + .../securitykeyswagger/_serialization.py | 4 ++-- .../_autorest_security_key_operations.py | 1 + .../storage/_serialization.py | 4 ++-- .../operations/_storage_accounts_operations.py | 18 +++++++++--------- .../subscriptionidapiversion/_serialization.py | 4 ++-- .../_serialization.py | 4 ++-- .../_serialization.py | 4 ++-- .../_serialization.py | 4 ++-- .../aio/_operations/_operations.py | 1 + .../_configuration.py | 1 + .../_serialization.py | 4 ++-- .../aio/_configuration.py | 1 + .../operations/_operations.py | 4 +++- .../_serialization.py | 4 ++-- .../_serialization.py | 4 ++-- .../_configuration.py | 1 + .../_serialization.py | 4 ++-- .../aio/_configuration.py | 1 + .../_serialization.py | 4 ++-- .../headversiontolerant/_serialization.py | 4 ++-- .../lropagingversiontolerant/_serialization.py | 4 ++-- .../LroPagingVersionTolerant/setup.py | 1 + .../lroversiontolerant/_configuration.py | 1 + .../lroversiontolerant/_serialization.py | 4 ++-- .../lroversiontolerant/aio/_configuration.py | 1 + .../_operations/_operations.py | 1 + .../_serialization.py | 4 ++-- .../aio/_operations/_operations.py | 1 + .../pagingversiontolerant/_serialization.py | 4 ++-- .../storageversiontolerant/_serialization.py | 4 ++-- .../operations/_operations.py | 18 ++++++++++-------- .../_serialization.py | 4 ++-- .../_operations/_patch.py | 1 + .../_serialization.py | 4 ++-- .../aio/_operations/_operations.py | 1 + .../aio/_operations/_patch.py | 1 + .../_serialization.py | 4 ++-- .../aio/_operations/_operations.py | 1 + .../_serialization.py | 4 ++-- .../_serialization.py | 4 ++-- .../_serialization.py | 4 ++-- .../aio/_operations/_operations.py | 1 + .../Multiapi/multiapi/_serialization.py | 2 +- .../_multiapi_service_client_operations.py | 1 + .../_multiapi_service_client_operations.py | 1 + .../_multiapi_service_client_operations.py | 1 + .../_serialization.py | 2 +- .../aio/_operations_mixin.py | 1 - .../v1/_metadata.json | 2 +- .../_multiapi_service_client_operations.py | 2 +- .../_multiapi_service_client_operations.py | 1 + .../_multiapi_service_client_operations.py | 1 + .../multiapicustombaseurl/_serialization.py | 2 +- .../v1/aio/operations/__init__.py | 1 + ...ustom_base_url_service_client_operations.py | 1 + .../v1/operations/__init__.py | 1 + .../v2/aio/operations/__init__.py | 1 + ...ustom_base_url_service_client_operations.py | 1 + .../v2/operations/__init__.py | 1 + .../multiapidataplane/_serialization.py | 2 +- .../multiapidataplane/aio/_operations_mixin.py | 1 - .../multiapidataplane/v1/_metadata.json | 2 +- .../_multiapi_service_client_operations.py | 2 +- .../_multiapi_service_client_operations.py | 1 + .../_multiapi_service_client_operations.py | 1 + .../multiapikeywordonly/_serialization.py | 2 +- .../aio/_operations_mixin.py | 1 - .../multiapikeywordonly/v1/_metadata.json | 2 +- .../_multiapi_service_client_operations.py | 2 +- .../_multiapi_service_client_operations.py | 1 + .../_multiapi_service_client_operations.py | 1 + .../multiapinoasync/_serialization.py | 2 +- .../multiapisecurity/_serialization.py | 2 +- .../multiapisecurity/aio/_operations_mixin.py | 1 - .../multiapisecurity/v1/_metadata.json | 2 +- .../_multiapi_service_client_operations.py | 2 +- .../submodule/_serialization.py | 2 +- .../submodule/aio/_operations_mixin.py | 1 - .../submodule/v1/_metadata.json | 2 +- .../_multiapi_service_client_operations.py | 2 +- .../_multiapi_service_client_operations.py | 1 + .../_multiapi_service_client_operations.py | 1 + .../unittests/storage_models/serialization.py | 4 ++-- .../additionalproperties/_serialization.py | 4 ++-- .../Anything/anything/_serialization.py | 4 ++-- .../operations/_anything_client_operations.py | 1 + .../Expected/AcceptanceTests/Anything/setup.py | 1 + .../BodyArray/bodyarray/_serialization.py | 4 ++-- .../vanilla/body/array/_serialization.py | 4 ++-- .../BodyBinary/bodybinary/_serialization.py | 4 ++-- .../BodyBoolean/bodyboolean/_serialization.py | 4 ++-- .../BodyByte/bodybyte/_serialization.py | 4 ++-- .../bodybytewithpackagename/_serialization.py | 4 ++-- .../BodyDate/bodydate/_serialization.py | 4 ++-- .../bodydatetime/_serialization.py | 4 ++-- .../bodydatetimerfc1123/_serialization.py | 4 ++-- .../bodydictionary/_serialization.py | 4 ++-- .../bodyduration/_serialization.py | 4 ++-- .../BodyFile/bodyfile/_serialization.py | 4 ++-- .../bodyformdata/_serialization.py | 4 ++-- .../bodyformurlencodeddata/_serialization.py | 4 ++-- .../BodyInteger/bodyinteger/_serialization.py | 4 ++-- .../BodyNumber/bodynumber/_serialization.py | 4 ++-- .../BodyString/bodystring/_serialization.py | 4 ++-- .../BodyTime/bodytime/_serialization.py | 4 ++-- .../ClientEnum/clientenum/_serialization.py | 4 ++-- .../operations/_client_with_enum_operations.py | 1 + .../Constants/constants/_serialization.py | 4 ++-- .../operations/_contants_operations.py | 2 +- .../custombaseurlmoreoptions/_configuration.py | 1 + .../custombaseurlmoreoptions/_serialization.py | 4 ++-- .../aio/_configuration.py | 1 + .../errorwithsecrets/_serialization.py | 4 ++-- .../_error_with_secrets_operations.py | 1 + .../extensibleenumsswagger/_serialization.py | 4 ++-- .../Header/header/_serialization.py | 4 ++-- ...to_rest_http_infrastructure_test_service.py | 1 + .../Http/httpinfrastructure/_serialization.py | 4 ++-- ...to_rest_http_infrastructure_test_service.py | 1 + .../incorrecterrorresponse/_serialization.py | 4 ++-- ...ncorrect_returned_error_model_operations.py | 1 + .../internaloperation/_serialization.py | 4 ++-- .../_media_types_client_operations.py | 1 + .../MediaTypes/mediatypes/_serialization.py | 4 ++-- .../_media_types_client_operations.py | 1 + .../mergepatchjson/_serialization.py | 4 ++-- .../_merge_patch_json_client_operations.py | 1 + .../modelflattening/_serialization.py | 4 ++-- .../modelflattening/aio/operations/__init__.py | 1 + ...ource_flattening_test_service_operations.py | 1 + .../modelflattening/operations/__init__.py | 1 + .../multipleinheritance/_serialization.py | 4 ++-- .../aio/operations/__init__.py | 1 + ...le_inheritance_service_client_operations.py | 1 + .../multipleinheritance/operations/__init__.py | 1 + .../nooperations/_serialization.py | 4 ++-- .../nonstringenums/_serialization.py | 4 ++-- .../ObjectType/objecttype/_serialization.py | 4 ++-- .../_object_type_client_operations.py | 1 + .../packagemode/_serialization.py | 4 ++-- .../operations/_anything_client_operations.py | 1 + .../parameterflattening/_serialization.py | 4 ++-- .../parameterizedendpoint/_serialization.py | 4 ++-- ..._parmaterized_endpoint_client_operations.py | 1 + .../Report/report/_serialization.py | 4 ++-- .../_auto_rest_report_service_operations.py | 1 + .../reservedwords/_serialization.py | 4 ++-- .../_reserved_words_client_operations.py | 1 + .../securityaadswagger/_serialization.py | 4 ++-- .../_autorest_security_aad_operations.py | 1 + .../_serialization.py | 4 ++-- .../aio/operations/__init__.py | 1 + ...y_aad_swagger_credential_flag_operations.py | 1 + .../operations/__init__.py | 1 + .../securitykeyswagger/_serialization.py | 4 ++-- .../_autorest_security_key_operations.py | 1 + .../_serialization.py | 4 ++-- .../aio/operations/__init__.py | 1 + ...y_key_swagger_credential_flag_operations.py | 1 + .../operations/__init__.py | 1 + .../url/operations/_path_items_operations.py | 9 +++++---- .../Url/url/operations/_paths_operations.py | 4 ++-- .../Url/url/operations/_queries_operations.py | 2 +- .../urlmulticollectionformat/__init__.py | 1 + .../urlmulticollectionformat/_configuration.py | 1 + .../urlmulticollectionformat/_serialization.py | 4 ++-- .../urlmulticollectionformat/aio/__init__.py | 1 + .../aio/_configuration.py | 1 + .../_auto_rest_validation_test_operations.py | 1 + .../Xml/xmlservice/_serialization.py | 4 ++-- .../xmserrorresponse/_serialization.py | 4 ++-- .../_serialization.py | 4 ++-- .../anythingversiontolerant/_serialization.py | 4 ++-- .../aio/_operations/_operations.py | 1 + .../AnythingVersionTolerant/setup.py | 1 + .../bodyarrayversiontolerant/_serialization.py | 4 ++-- .../_serialization.py | 4 ++-- .../_serialization.py | 4 ++-- .../bodybyteversiontolerant/_serialization.py | 4 ++-- .../_serialization.py | 4 ++-- .../_serialization.py | 4 ++-- .../_serialization.py | 4 ++-- .../bodydateversiontolerant/_serialization.py | 4 ++-- .../_serialization.py | 4 ++-- .../_serialization.py | 4 ++-- .../bodyfileversiontolerant/_serialization.py | 4 ++-- .../_serialization.py | 4 ++-- .../_serialization.py | 4 ++-- .../_serialization.py | 4 ++-- .../_serialization.py | 4 ++-- .../_serialization.py | 4 ++-- .../bodytimeversiontolerant/_serialization.py | 4 ++-- .../_serialization.py | 4 ++-- .../aio/_operations/_operations.py | 1 + .../constantsversiontolerant/_serialization.py | 4 ++-- .../operations/_operations.py | 2 +- .../_configuration.py | 1 + .../_serialization.py | 4 ++-- .../aio/_configuration.py | 1 + .../_serialization.py | 4 ++-- .../_serialization.py | 4 ++-- .../aio/_operations/_operations.py | 1 + .../_serialization.py | 4 ++-- .../headerversiontolerant/_serialization.py | 4 ++-- .../_client.py | 1 + .../_serialization.py | 4 ++-- .../aio/_client.py | 1 + .../operations/_operations.py | 2 +- .../_serialization.py | 4 ++-- .../aio/_operations/_operations.py | 1 + .../_serialization.py | 4 ++-- .../aio/_operations/_operations.py | 1 + .../_serialization.py | 4 ++-- .../aio/_operations/_operations.py | 1 + .../_operations/_operations.py | 2 +- .../_serialization.py | 4 ++-- .../aio/_operations/_operations.py | 2 +- .../_serialization.py | 4 ++-- .../aio/_operations/_operations.py | 1 + .../anything_client/_serialization.py | 4 ++-- .../aio/_operations/_operations.py | 1 + .../NoNamespaceFlagVersionTolerant/setup.py | 1 + .../_serialization.py | 4 ++-- .../_serialization.py | 4 ++-- .../_serialization.py | 4 ++-- .../aio/_operations/_operations.py | 1 + .../_serialization.py | 4 ++-- .../_serialization.py | 4 ++-- .../aio/_operations/_operations.py | 1 + .../reportversiontolerant/_serialization.py | 4 ++-- .../aio/_operations/_operations.py | 1 + .../_serialization.py | 4 ++-- .../_serialization.py | 4 ++-- .../aio/operations/_operations.py | 1 + .../_serialization.py | 4 ++-- .../aio/_operations/_operations.py | 1 + .../_serialization.py | 4 ++-- .../aio/_operations/_operations.py | 1 + .../_configuration.py | 1 + .../_serialization.py | 4 ++-- .../aio/_configuration.py | 1 + .../urlversiontolerant/_serialization.py | 4 ++-- .../operations/_operations.py | 14 ++++++++------ .../_serialization.py | 4 ++-- .../aio/_operations/_operations.py | 1 + .../_serialization.py | 4 ++-- .../_serialization.py | 4 ++-- 298 files changed, 480 insertions(+), 373 deletions(-) diff --git a/packages/autorest.python/samples/specification/azure-mgmt-test/test/azure-mgmt-test/azure/mgmt/test/_serialization.py b/packages/autorest.python/samples/specification/azure-mgmt-test/test/azure-mgmt-test/azure/mgmt/test/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/samples/specification/azure-mgmt-test/test/azure-mgmt-test/azure/mgmt/test/_serialization.py +++ b/packages/autorest.python/samples/specification/azure-mgmt-test/test/azure-mgmt-test/azure/mgmt/test/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/samples/specification/azure-test/test/azure-test/azure/test/_generated/_serialization.py b/packages/autorest.python/samples/specification/azure-test/test/azure-test/azure/test/_generated/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/samples/specification/azure-test/test/azure-test/azure/test/_generated/_serialization.py +++ b/packages/autorest.python/samples/specification/azure-test/test/azure-test/azure/test/_generated/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/samples/specification/azure_key_credential/generated/azure/key/credential/sample/_serialization.py b/packages/autorest.python/samples/specification/azure_key_credential/generated/azure/key/credential/sample/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/samples/specification/azure_key_credential/generated/azure/key/credential/sample/_serialization.py +++ b/packages/autorest.python/samples/specification/azure_key_credential/generated/azure/key/credential/sample/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/samples/specification/basic/generated/azure/basic/sample/_serialization.py b/packages/autorest.python/samples/specification/basic/generated/azure/basic/sample/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/samples/specification/basic/generated/azure/basic/sample/_serialization.py +++ b/packages/autorest.python/samples/specification/basic/generated/azure/basic/sample/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/samples/specification/directives/generated/azure/directives/sample/_serialization.py b/packages/autorest.python/samples/specification/directives/generated/azure/directives/sample/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/samples/specification/directives/generated/azure/directives/sample/_serialization.py +++ b/packages/autorest.python/samples/specification/directives/generated/azure/directives/sample/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/samples/specification/directives/generated/azure/directives/sample/aio/_operations/_operations.py b/packages/autorest.python/samples/specification/directives/generated/azure/directives/sample/aio/_operations/_operations.py index 801ef8948ad..bbf66ce7462 100644 --- a/packages/autorest.python/samples/specification/directives/generated/azure/directives/sample/aio/_operations/_operations.py +++ b/packages/autorest.python/samples/specification/directives/generated/azure/directives/sample/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/samples/specification/management/generated/azure/mgmt/sample/_serialization.py b/packages/autorest.python/samples/specification/management/generated/azure/mgmt/sample/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/samples/specification/management/generated/azure/mgmt/sample/_serialization.py +++ b/packages/autorest.python/samples/specification/management/generated/azure/mgmt/sample/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/_serialization.py b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/_serialization.py index 1ad578bf803..84b9785ccf4 100644 --- a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/_serialization.py +++ b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/_serialization.py @@ -1360,7 +1360,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/aio/_operations_mixin.py b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/aio/_operations_mixin.py index 41ce5c16130..1e78a1b03f9 100644 --- a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/aio/_operations_mixin.py +++ b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/aio/_operations_mixin.py @@ -53,7 +53,6 @@ async def begin_test_lro_and_paging( test_lro_and_paging_options: Optional[_models.TestLroAndPagingOptions] = None, **kwargs: Any ) -> AsyncLROPoller[AsyncIterable["_models.Product"]]: - # pylint: disable=line-too-long """A long-running paging operation that includes a nextLink that has 10 pages. :param client_request_id: Default value is None. diff --git a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_metadata.json b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_metadata.json index 95e2f0c1049..79c8a4d9e77 100644 --- a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_metadata.json +++ b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_metadata.json @@ -161,7 +161,7 @@ "async": { "coroutine": true, "signature": "async def begin_test_lro_and_paging(\n self,\n client_request_id: Optional[str] = None,\n test_lro_and_paging_options: Optional[_models.TestLroAndPagingOptions] = None,\n **kwargs: Any\n) -\u003e AsyncLROPoller[AsyncIterable[\"_models.Product\"]]:\n", - "doc": "# pylint: disable=line-too-long\n\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id: Default value is None.\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group. Default value is None.\n:type test_lro_and_paging_options: ~azure.multiapi.sample.v1.models.TestLroAndPagingOptions\n:return: An instance of LROPoller that returns an iterator like instance of either PagingResult\n or the result of cls(response)\n:rtype:\n ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~azure.multiapi.sample.v1.models.Product]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", + "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id: Default value is None.\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group. Default value is None.\n:type test_lro_and_paging_options: ~azure.multiapi.sample.v1.models.TestLroAndPagingOptions\n:return: An instance of LROPoller that returns an iterator like instance of either PagingResult\n or the result of cls(response)\n:rtype:\n ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~azure.multiapi.sample.v1.models.Product]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", "call": "client_request_id, test_lro_and_paging_options, **kwargs" } }, diff --git a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/_multiapi_service_client_operations.py index bf71d0174ea..59945624ff3 100644 --- a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v1/aio/operations/_multiapi_service_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -322,7 +323,6 @@ async def begin_test_lro_and_paging( test_lro_and_paging_options: Optional[_models.TestLroAndPagingOptions] = None, **kwargs: Any ) -> AsyncLROPoller[AsyncIterable["_models.Product"]]: - # pylint: disable=line-too-long """A long-running paging operation that includes a nextLink that has 10 pages. :param client_request_id: Default value is None. diff --git a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_multiapi_service_client_operations.py index 95651ce5c65..7ed8aeb2349 100644 --- a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v2/aio/operations/_multiapi_service_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_multiapi_service_client_operations.py index 6e58afb6428..75a04d4e212 100644 --- a/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/samples/specification/multiapi/generated/azure/multiapi/sample/v3/aio/operations/_multiapi_service_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_serialization.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_serialization.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/_serialization.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/_serialization.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/aio/operations/_auto_rest_report_service_for_azure_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/aio/operations/_auto_rest_report_service_for_azure_operations.py index 2de813f5868..b69dc933662 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/aio/operations/_auto_rest_report_service_for_azure_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureReport/azurereport/aio/operations/_auto_rest_report_service_for_azure_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_configuration.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_configuration.py index 406dedcbca3..34e2482bfea 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_configuration.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/_configuration.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/_configuration.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/_configuration.py index aa478fab72e..8516bdf9e4d 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/_configuration.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/_configuration.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_header_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_header_operations.py index e9e7f0d34a2..5cf15ab3a21 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_header_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/aio/operations/_header_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_api_version_default_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_api_version_default_operations.py index db3befc2914..96aa11dbd20 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_api_version_default_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_api_version_default_operations.py @@ -67,7 +67,7 @@ def build_get_method_global_not_provided_valid_request(**kwargs: Any) -> HttpReq # Construct URL _url = kwargs.pop( "template_url", "/azurespecials/apiVersion/method/string/none/query/globalNotProvided/2015-07-01-preview" - ) # pylint: disable=line-too-long + ) # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_header_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_header_operations.py index b177396244d..7842317ad2d 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_header_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_header_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_subscription_in_credentials_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_subscription_in_credentials_operations.py index 89a308b5401..d3bc5b3cdc0 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_subscription_in_credentials_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_subscription_in_credentials_operations.py @@ -47,7 +47,7 @@ def build_post_method_global_valid_request(subscription_id: str, **kwargs: Any) _url = kwargs.pop( "template_url", "/azurespecials/subscriptionId/method/string/none/path/global/1234-5678-9012-3456/{subscriptionId}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -68,7 +68,7 @@ def build_post_method_global_null_request(subscription_id: str, **kwargs: Any) - # Construct URL _url = kwargs.pop( "template_url", "/azurespecials/subscriptionId/method/string/none/path/global/null/{subscriptionId}" - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -94,7 +94,7 @@ def build_post_method_global_not_provided_valid_request( # pylint: disable=name _url = kwargs.pop( "template_url", "/azurespecials/subscriptionId/method/string/none/path/globalNotProvided/1234-5678-9012-3456/{subscriptionId}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -119,7 +119,7 @@ def build_post_path_global_valid_request(subscription_id: str, **kwargs: Any) -> _url = kwargs.pop( "template_url", "/azurespecials/subscriptionId/path/string/none/path/global/1234-5678-9012-3456/{subscriptionId}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -141,7 +141,7 @@ def build_post_swagger_global_valid_request(subscription_id: str, **kwargs: Any) _url = kwargs.pop( "template_url", "/azurespecials/subscriptionId/swagger/string/none/path/global/1234-5678-9012-3456/{subscriptionId}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_subscription_in_method_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_subscription_in_method_operations.py index 053edfb4852..fe897c52150 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_subscription_in_method_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/AzureSpecials/azurespecialproperties/operations/_subscription_in_method_operations.py @@ -47,7 +47,7 @@ def build_post_method_local_valid_request(subscription_id: str, **kwargs: Any) - _url = kwargs.pop( "template_url", "/azurespecials/subscriptionId/method/string/none/path/local/1234-5678-9012-3456/{subscriptionId}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -68,7 +68,7 @@ def build_post_method_local_null_request(subscription_id: str, **kwargs: Any) -> # Construct URL _url = kwargs.pop( "template_url", "/azurespecials/subscriptionId/method/string/none/path/local/null/{subscriptionId}" - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -89,7 +89,7 @@ def build_post_path_local_valid_request(subscription_id: str, **kwargs: Any) -> # Construct URL _url = kwargs.pop( "template_url", "/azurespecials/subscriptionId/path/string/none/path/local/1234-5678-9012-3456/{subscriptionId}" - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -111,7 +111,7 @@ def build_post_swagger_local_valid_request(subscription_id: str, **kwargs: Any) _url = kwargs.pop( "template_url", "/azurespecials/subscriptionId/swagger/string/none/path/local/1234-5678-9012-3456/{subscriptionId}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_serialization.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_serialization.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/operations/_paging_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/operations/_paging_operations.py index dcb5b79c204..ebf7086fe22 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/operations/_paging_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomPollerPager/custompollerpager/aio/operations/_paging_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1602,7 +1602,6 @@ async def begin_get_multiple_pages_lro( paging_get_multiple_pages_lro_options: Optional[_models.PagingGetMultiplePagesLroOptions] = None, **kwargs: Any ) -> AsyncCustomPoller[AsyncIterable["_models.Product"]]: - # pylint: disable=line-too-long """A long-running paging operation that includes a nextLink that has 10 pages. :param client_request_id: Default value is None. diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_configuration.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_configuration.py index 88028fb9be1..6350252f834 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_configuration.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_configuration.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_serialization.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_serialization.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/_configuration.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/_configuration.py index bc400395fa9..c372d0e339f 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/_configuration.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/_configuration.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Head/head/_serialization.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Head/head/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Head/head/_serialization.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Head/head/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/_serialization.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/_serialization.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadExceptions/headexceptions/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_serialization.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_serialization.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/HeadWithAzureKeyCredentialPolicy/headwithazurekeycredentialpolicy/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_configuration.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_configuration.py index 489d6ad4ba6..206362a524e 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_configuration.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_configuration.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_serialization.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_serialization.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/_configuration.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/_configuration.py index 98a959a9762..8ce9ddd5bd8 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/_configuration.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Lro/lro/aio/_configuration.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_serialization.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_serialization.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/operations/_lro_with_paramaterized_endpoints_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/operations/_lro_with_paramaterized_endpoints_operations.py index 20dc6647198..b758545cba0 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/operations/_lro_with_paramaterized_endpoints_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/LroWithParameterizedEndpoints/lrowithparameterizedendpoints/aio/operations/_lro_with_paramaterized_endpoints_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/_serialization.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/_serialization.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_header_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_header_operations.py index fa6a3ded1cc..7a1e66e79ac 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_header_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/aio/operations/_header_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_api_version_default_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_api_version_default_operations.py index fc74bafd0ed..f561ecbf538 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_api_version_default_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_api_version_default_operations.py @@ -66,7 +66,7 @@ def build_get_method_global_not_provided_valid_request(**kwargs: Any) -> HttpReq # Construct URL _url = kwargs.pop( "template_url", "/azurespecials/apiVersion/method/string/none/query/globalNotProvided/2015-07-01-preview" - ) # pylint: disable=line-too-long + ) # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_header_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_header_operations.py index 85f57ecf5ce..114a7c23b42 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_header_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_header_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_subscription_in_credentials_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_subscription_in_credentials_operations.py index d71df57910a..c01bf61432f 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_subscription_in_credentials_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_subscription_in_credentials_operations.py @@ -46,7 +46,7 @@ def build_post_method_global_valid_request(subscription_id: str, **kwargs: Any) _url = kwargs.pop( "template_url", "/azurespecials/subscriptionId/method/string/none/path/global/1234-5678-9012-3456/{subscriptionId}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -67,7 +67,7 @@ def build_post_method_global_null_request(subscription_id: str, **kwargs: Any) - # Construct URL _url = kwargs.pop( "template_url", "/azurespecials/subscriptionId/method/string/none/path/global/null/{subscriptionId}" - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -93,7 +93,7 @@ def build_post_method_global_not_provided_valid_request( # pylint: disable=name _url = kwargs.pop( "template_url", "/azurespecials/subscriptionId/method/string/none/path/globalNotProvided/1234-5678-9012-3456/{subscriptionId}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -118,7 +118,7 @@ def build_post_path_global_valid_request(subscription_id: str, **kwargs: Any) -> _url = kwargs.pop( "template_url", "/azurespecials/subscriptionId/path/string/none/path/global/1234-5678-9012-3456/{subscriptionId}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -140,7 +140,7 @@ def build_post_swagger_global_valid_request(subscription_id: str, **kwargs: Any) _url = kwargs.pop( "template_url", "/azurespecials/subscriptionId/swagger/string/none/path/global/1234-5678-9012-3456/{subscriptionId}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_subscription_in_method_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_subscription_in_method_operations.py index fc4b5464caf..2f8a858fb7d 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_subscription_in_method_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/MixedApiVersion/mixedapiversion/operations/_subscription_in_method_operations.py @@ -46,7 +46,7 @@ def build_post_method_local_valid_request(subscription_id: str, **kwargs: Any) - _url = kwargs.pop( "template_url", "/azurespecials/subscriptionId/method/string/none/path/local/1234-5678-9012-3456/{subscriptionId}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -67,7 +67,7 @@ def build_post_method_local_null_request(subscription_id: str, **kwargs: Any) -> # Construct URL _url = kwargs.pop( "template_url", "/azurespecials/subscriptionId/method/string/none/path/local/null/{subscriptionId}" - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -88,7 +88,7 @@ def build_post_path_local_valid_request(subscription_id: str, **kwargs: Any) -> # Construct URL _url = kwargs.pop( "template_url", "/azurespecials/subscriptionId/path/string/none/path/local/1234-5678-9012-3456/{subscriptionId}" - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -110,7 +110,7 @@ def build_post_swagger_local_valid_request(subscription_id: str, **kwargs: Any) _url = kwargs.pop( "template_url", "/azurespecials/subscriptionId/swagger/string/none/path/local/1234-5678-9012-3456/{subscriptionId}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/head/_serialization.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/head/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/head/_serialization.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/head/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/paging/_serialization.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/paging/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/paging/_serialization.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/paging/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/paging/aio/operations/_paging_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/paging/aio/operations/_paging_operations.py index d94be854992..1e054677e9e 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/paging/aio/operations/_paging_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeBatch/azure/packagemode/batch/paging/aio/operations/_paging_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1600,7 +1600,6 @@ async def begin_get_multiple_pages_lro( paging_get_multiple_pages_lro_options: Optional[_models.PagingGetMultiplePagesLroOptions] = None, **kwargs: Any ) -> AsyncLROPoller[AsyncIterable["_models.Product"]]: - # pylint: disable=line-too-long """A long-running paging operation that includes a nextLink that has 10 pages. :param client_request_id: Default value is None. diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeCustomize/azure/packagemode/customize/_serialization.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeCustomize/azure/packagemode/customize/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeCustomize/azure/packagemode/customize/_serialization.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeCustomize/azure/packagemode/customize/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeDataPlane/azure/packagemode/dataplane/_serialization.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeDataPlane/azure/packagemode/dataplane/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeDataPlane/azure/packagemode/dataplane/_serialization.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeDataPlane/azure/packagemode/dataplane/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeMgmtPlane/azure/package/mode/_serialization.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeMgmtPlane/azure/package/mode/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeMgmtPlane/azure/package/mode/_serialization.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/PackageModeMgmtPlane/azure/package/mode/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/_serialization.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/_serialization.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/Paging/paging/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/_serialization.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/_serialization.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/aio/operations/_autorest_security_aad_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/aio/operations/_autorest_security_aad_operations.py index 755225894c0..f64d0fddd96 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/aio/operations/_autorest_security_aad_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/aio/operations/_autorest_security_aad_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/_serialization.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/_serialization.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/aio/operations/_autorest_security_key_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/aio/operations/_autorest_security_key_operations.py index c86f2e170ba..f20f5090e14 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/aio/operations/_autorest_security_key_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/aio/operations/_autorest_security_key_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_serialization.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_serialization.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/operations/_storage_accounts_operations.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/operations/_storage_accounts_operations.py index af62bc7a0e4..be3b3bc7b6c 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/operations/_storage_accounts_operations.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/StorageManagementClient/storage/operations/_storage_accounts_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -57,7 +57,7 @@ def build_check_name_availability_request(subscription_id: str, **kwargs: Any) - # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } @@ -89,7 +89,7 @@ def build_create_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "accountName": _SERIALIZER.url("account_name", account_name, "str"), @@ -119,7 +119,7 @@ def build_delete_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "accountName": _SERIALIZER.url("account_name", account_name, "str"), @@ -147,7 +147,7 @@ def build_get_properties_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "accountName": _SERIALIZER.url("account_name", account_name, "str"), @@ -179,7 +179,7 @@ def build_update_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "accountName": _SERIALIZER.url("account_name", account_name, "str"), @@ -212,7 +212,7 @@ def build_list_keys_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "accountName": _SERIALIZER.url("account_name", account_name, "str"), @@ -265,7 +265,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -296,7 +296,7 @@ def build_regenerate_key_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "accountName": _SERIALIZER.url("account_name", account_name, "str"), diff --git a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_serialization.py b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_serialization.py +++ b/packages/autorest.python/test/azure/legacy/Expected/AcceptanceTests/SubscriptionIdApiVersion/subscriptionidapiversion/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureBodyDurationVersionTolerant/bodydurationversiontolerant/_serialization.py b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureBodyDurationVersionTolerant/bodydurationversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureBodyDurationVersionTolerant/bodydurationversiontolerant/_serialization.py +++ b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureBodyDurationVersionTolerant/bodydurationversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureParameterGroupingVersionTolerant/azureparametergroupingversiontolerant/_serialization.py b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureParameterGroupingVersionTolerant/azureparametergroupingversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureParameterGroupingVersionTolerant/azureparametergroupingversiontolerant/_serialization.py +++ b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureParameterGroupingVersionTolerant/azureparametergroupingversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureReportVersionTolerant/azurereportversiontolerant/_serialization.py b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureReportVersionTolerant/azurereportversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureReportVersionTolerant/azurereportversiontolerant/_serialization.py +++ b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureReportVersionTolerant/azurereportversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureReportVersionTolerant/azurereportversiontolerant/aio/_operations/_operations.py b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureReportVersionTolerant/azurereportversiontolerant/aio/_operations/_operations.py index 3fe23841171..28a5dc3bcad 100644 --- a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureReportVersionTolerant/azurereportversiontolerant/aio/_operations/_operations.py +++ b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureReportVersionTolerant/azurereportversiontolerant/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureSpecialsVersionTolerant/azurespecialpropertiesversiontolerant/_configuration.py b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureSpecialsVersionTolerant/azurespecialpropertiesversiontolerant/_configuration.py index 406dedcbca3..34e2482bfea 100644 --- a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureSpecialsVersionTolerant/azurespecialpropertiesversiontolerant/_configuration.py +++ b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureSpecialsVersionTolerant/azurespecialpropertiesversiontolerant/_configuration.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureSpecialsVersionTolerant/azurespecialpropertiesversiontolerant/_serialization.py b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureSpecialsVersionTolerant/azurespecialpropertiesversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureSpecialsVersionTolerant/azurespecialpropertiesversiontolerant/_serialization.py +++ b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureSpecialsVersionTolerant/azurespecialpropertiesversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureSpecialsVersionTolerant/azurespecialpropertiesversiontolerant/aio/_configuration.py b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureSpecialsVersionTolerant/azurespecialpropertiesversiontolerant/aio/_configuration.py index aa478fab72e..8516bdf9e4d 100644 --- a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureSpecialsVersionTolerant/azurespecialpropertiesversiontolerant/aio/_configuration.py +++ b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureSpecialsVersionTolerant/azurespecialpropertiesversiontolerant/aio/_configuration.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureSpecialsVersionTolerant/azurespecialpropertiesversiontolerant/operations/_operations.py b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureSpecialsVersionTolerant/azurespecialpropertiesversiontolerant/operations/_operations.py index 3cdd3f4b3a8..73546d2abae 100644 --- a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureSpecialsVersionTolerant/azurespecialpropertiesversiontolerant/operations/_operations.py +++ b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/AzureSpecialsVersionTolerant/azurespecialpropertiesversiontolerant/operations/_operations.py @@ -111,7 +111,9 @@ def build_subscription_in_credentials_post_method_global_not_provided_valid_requ accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/azurespecials/subscriptionId/method/string/none/path/globalNotProvided/1234-5678-9012-3456/{subscriptionId}" # pylint: disable=line-too-long + _url = ( + "/azurespecials/subscriptionId/method/string/none/path/globalNotProvided/1234-5678-9012-3456/{subscriptionId}" + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } diff --git a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/CustomBaseUriVersionTolerant/custombaseurlversiontolerant/_serialization.py b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/CustomBaseUriVersionTolerant/custombaseurlversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/CustomBaseUriVersionTolerant/custombaseurlversiontolerant/_serialization.py +++ b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/CustomBaseUriVersionTolerant/custombaseurlversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/CustomPollerPagerVersionTolerant/custompollerpagerversiontolerant/_serialization.py b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/CustomPollerPagerVersionTolerant/custompollerpagerversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/CustomPollerPagerVersionTolerant/custompollerpagerversiontolerant/_serialization.py +++ b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/CustomPollerPagerVersionTolerant/custompollerpagerversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/CustomUrlPagingVersionTolerant/custombaseurlpagingversiontolerant/_configuration.py b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/CustomUrlPagingVersionTolerant/custombaseurlpagingversiontolerant/_configuration.py index 88028fb9be1..6350252f834 100644 --- a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/CustomUrlPagingVersionTolerant/custombaseurlpagingversiontolerant/_configuration.py +++ b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/CustomUrlPagingVersionTolerant/custombaseurlpagingversiontolerant/_configuration.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/CustomUrlPagingVersionTolerant/custombaseurlpagingversiontolerant/_serialization.py b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/CustomUrlPagingVersionTolerant/custombaseurlpagingversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/CustomUrlPagingVersionTolerant/custombaseurlpagingversiontolerant/_serialization.py +++ b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/CustomUrlPagingVersionTolerant/custombaseurlpagingversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/CustomUrlPagingVersionTolerant/custombaseurlpagingversiontolerant/aio/_configuration.py b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/CustomUrlPagingVersionTolerant/custombaseurlpagingversiontolerant/aio/_configuration.py index bc400395fa9..c372d0e339f 100644 --- a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/CustomUrlPagingVersionTolerant/custombaseurlpagingversiontolerant/aio/_configuration.py +++ b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/CustomUrlPagingVersionTolerant/custombaseurlpagingversiontolerant/aio/_configuration.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/HeadExceptionsVersionTolerant/headexceptionsversiontolerant/_serialization.py b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/HeadExceptionsVersionTolerant/headexceptionsversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/HeadExceptionsVersionTolerant/headexceptionsversiontolerant/_serialization.py +++ b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/HeadExceptionsVersionTolerant/headexceptionsversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/HeadVersionTolerant/headversiontolerant/_serialization.py b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/HeadVersionTolerant/headversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/HeadVersionTolerant/headversiontolerant/_serialization.py +++ b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/HeadVersionTolerant/headversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroPagingVersionTolerant/lropagingversiontolerant/_serialization.py b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroPagingVersionTolerant/lropagingversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroPagingVersionTolerant/lropagingversiontolerant/_serialization.py +++ b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroPagingVersionTolerant/lropagingversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroPagingVersionTolerant/setup.py b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroPagingVersionTolerant/setup.py index 0fc6c766620..86e99d8ba4e 100644 --- a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroPagingVersionTolerant/setup.py +++ b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroPagingVersionTolerant/setup.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroVersionTolerant/lroversiontolerant/_configuration.py b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroVersionTolerant/lroversiontolerant/_configuration.py index 489d6ad4ba6..206362a524e 100644 --- a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroVersionTolerant/lroversiontolerant/_configuration.py +++ b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroVersionTolerant/lroversiontolerant/_configuration.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroVersionTolerant/lroversiontolerant/_serialization.py b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroVersionTolerant/lroversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroVersionTolerant/lroversiontolerant/_serialization.py +++ b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroVersionTolerant/lroversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroVersionTolerant/lroversiontolerant/aio/_configuration.py b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroVersionTolerant/lroversiontolerant/aio/_configuration.py index 98a959a9762..8ce9ddd5bd8 100644 --- a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroVersionTolerant/lroversiontolerant/aio/_configuration.py +++ b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroVersionTolerant/lroversiontolerant/aio/_configuration.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroWithParameterizedEndpointsVersionTolerant/lrowithparameterizedendpointsversiontolerant/_operations/_operations.py b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroWithParameterizedEndpointsVersionTolerant/lrowithparameterizedendpointsversiontolerant/_operations/_operations.py index 069eaf5d706..7d51f988446 100644 --- a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroWithParameterizedEndpointsVersionTolerant/lrowithparameterizedendpointsversiontolerant/_operations/_operations.py +++ b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroWithParameterizedEndpointsVersionTolerant/lrowithparameterizedendpointsversiontolerant/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroWithParameterizedEndpointsVersionTolerant/lrowithparameterizedendpointsversiontolerant/_serialization.py b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroWithParameterizedEndpointsVersionTolerant/lrowithparameterizedendpointsversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroWithParameterizedEndpointsVersionTolerant/lrowithparameterizedendpointsversiontolerant/_serialization.py +++ b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroWithParameterizedEndpointsVersionTolerant/lrowithparameterizedendpointsversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroWithParameterizedEndpointsVersionTolerant/lrowithparameterizedendpointsversiontolerant/aio/_operations/_operations.py b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroWithParameterizedEndpointsVersionTolerant/lrowithparameterizedendpointsversiontolerant/aio/_operations/_operations.py index 6d5d6f5d909..e0c1aa94319 100644 --- a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroWithParameterizedEndpointsVersionTolerant/lrowithparameterizedendpointsversiontolerant/aio/_operations/_operations.py +++ b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/LroWithParameterizedEndpointsVersionTolerant/lrowithparameterizedendpointsversiontolerant/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/PagingVersionTolerant/pagingversiontolerant/_serialization.py b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/PagingVersionTolerant/pagingversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/PagingVersionTolerant/pagingversiontolerant/_serialization.py +++ b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/PagingVersionTolerant/pagingversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/StorageManagementClientVersionTolerant/storageversiontolerant/_serialization.py b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/StorageManagementClientVersionTolerant/storageversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/StorageManagementClientVersionTolerant/storageversiontolerant/_serialization.py +++ b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/StorageManagementClientVersionTolerant/storageversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/StorageManagementClientVersionTolerant/storageversiontolerant/operations/_operations.py b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/StorageManagementClientVersionTolerant/storageversiontolerant/operations/_operations.py index 249dcc24beb..560e9f024a1 100644 --- a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/StorageManagementClientVersionTolerant/storageversiontolerant/operations/_operations.py +++ b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/StorageManagementClientVersionTolerant/storageversiontolerant/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -86,7 +86,7 @@ def build_storage_accounts_create_request( accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "accountName": _SERIALIZER.url("account_name", account_name, "str"), @@ -113,7 +113,7 @@ def build_storage_accounts_delete_request( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2015-05-01-preview")) # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "accountName": _SERIALIZER.url("account_name", account_name, "str"), @@ -138,7 +138,7 @@ def build_storage_accounts_get_properties_request( # pylint: disable=name-too-l accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "accountName": _SERIALIZER.url("account_name", account_name, "str"), @@ -167,7 +167,7 @@ def build_storage_accounts_update_request( accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "accountName": _SERIALIZER.url("account_name", account_name, "str"), @@ -197,7 +197,7 @@ def build_storage_accounts_list_keys_request( accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "accountName": _SERIALIZER.url("account_name", account_name, "str"), @@ -249,7 +249,9 @@ def build_storage_accounts_list_by_resource_group_request( # pylint: disable=na accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts" # pylint: disable=line-too-long + _url = ( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts" + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -277,7 +279,7 @@ def build_storage_accounts_regenerate_key_request( # pylint: disable=name-too-l accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" # pylint: disable=line-too-long + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "accountName": _SERIALIZER.url("account_name", account_name, "str"), diff --git a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/SubscriptionIdApiVersionVersionTolerant/subscriptionidapiversionversiontolerant/_serialization.py b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/SubscriptionIdApiVersionVersionTolerant/subscriptionidapiversionversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/SubscriptionIdApiVersionVersionTolerant/subscriptionidapiversionversiontolerant/_serialization.py +++ b/packages/autorest.python/test/azure/version-tolerant/Expected/AcceptanceTests/SubscriptionIdApiVersionVersionTolerant/subscriptionidapiversionversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGCustomizationCustomizedVersionTolerant/dpgcustomizationcustomizedversiontolerant/_operations/_patch.py b/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGCustomizationCustomizedVersionTolerant/dpgcustomizationcustomizedversiontolerant/_operations/_patch.py index 10168cbbd04..6391d4a44ec 100644 --- a/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGCustomizationCustomizedVersionTolerant/dpgcustomizationcustomizedversiontolerant/_operations/_patch.py +++ b/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGCustomizationCustomizedVersionTolerant/dpgcustomizationcustomizedversiontolerant/_operations/_patch.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # pyright: reportUnnecessaryTypeIgnoreComment=false # ------------------------------------ # Copyright (c) Microsoft Corporation. diff --git a/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGCustomizationCustomizedVersionTolerant/dpgcustomizationcustomizedversiontolerant/_serialization.py b/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGCustomizationCustomizedVersionTolerant/dpgcustomizationcustomizedversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGCustomizationCustomizedVersionTolerant/dpgcustomizationcustomizedversiontolerant/_serialization.py +++ b/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGCustomizationCustomizedVersionTolerant/dpgcustomizationcustomizedversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGCustomizationCustomizedVersionTolerant/dpgcustomizationcustomizedversiontolerant/aio/_operations/_operations.py b/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGCustomizationCustomizedVersionTolerant/dpgcustomizationcustomizedversiontolerant/aio/_operations/_operations.py index d88c959bff6..1bd1b4813a4 100644 --- a/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGCustomizationCustomizedVersionTolerant/dpgcustomizationcustomizedversiontolerant/aio/_operations/_operations.py +++ b/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGCustomizationCustomizedVersionTolerant/dpgcustomizationcustomizedversiontolerant/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGCustomizationCustomizedVersionTolerant/dpgcustomizationcustomizedversiontolerant/aio/_operations/_patch.py b/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGCustomizationCustomizedVersionTolerant/dpgcustomizationcustomizedversiontolerant/aio/_operations/_patch.py index 434f6fa94a3..cc1c517e417 100644 --- a/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGCustomizationCustomizedVersionTolerant/dpgcustomizationcustomizedversiontolerant/aio/_operations/_patch.py +++ b/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGCustomizationCustomizedVersionTolerant/dpgcustomizationcustomizedversiontolerant/aio/_operations/_patch.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # pyright: reportUnnecessaryTypeIgnoreComment=false # ------------------------------------ # Copyright (c) Microsoft Corporation. diff --git a/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGCustomizationInitialVersionTolerant/dpgcustomizationinitialversiontolerant/_serialization.py b/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGCustomizationInitialVersionTolerant/dpgcustomizationinitialversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGCustomizationInitialVersionTolerant/dpgcustomizationinitialversiontolerant/_serialization.py +++ b/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGCustomizationInitialVersionTolerant/dpgcustomizationinitialversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGCustomizationInitialVersionTolerant/dpgcustomizationinitialversiontolerant/aio/_operations/_operations.py b/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGCustomizationInitialVersionTolerant/dpgcustomizationinitialversiontolerant/aio/_operations/_operations.py index d88c959bff6..1bd1b4813a4 100644 --- a/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGCustomizationInitialVersionTolerant/dpgcustomizationinitialversiontolerant/aio/_operations/_operations.py +++ b/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGCustomizationInitialVersionTolerant/dpgcustomizationinitialversiontolerant/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGServiceDrivenInitialVersionTolerant/dpgservicedriveninitialversiontolerant/_serialization.py b/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGServiceDrivenInitialVersionTolerant/dpgservicedriveninitialversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGServiceDrivenInitialVersionTolerant/dpgservicedriveninitialversiontolerant/_serialization.py +++ b/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGServiceDrivenInitialVersionTolerant/dpgservicedriveninitialversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGServiceDrivenUpdateOneVersionTolerant/dpgservicedrivenupdateoneversiontolerant/_serialization.py b/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGServiceDrivenUpdateOneVersionTolerant/dpgservicedrivenupdateoneversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGServiceDrivenUpdateOneVersionTolerant/dpgservicedrivenupdateoneversiontolerant/_serialization.py +++ b/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGServiceDrivenUpdateOneVersionTolerant/dpgservicedrivenupdateoneversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGTestModelsVersionTolerant/dpgtestmodelsversiontolerant/_serialization.py b/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGTestModelsVersionTolerant/dpgtestmodelsversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGTestModelsVersionTolerant/dpgtestmodelsversiontolerant/_serialization.py +++ b/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGTestModelsVersionTolerant/dpgtestmodelsversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGTestModelsVersionTolerant/dpgtestmodelsversiontolerant/aio/_operations/_operations.py b/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGTestModelsVersionTolerant/dpgtestmodelsversiontolerant/aio/_operations/_operations.py index 62df33c3066..6f1af99006f 100644 --- a/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGTestModelsVersionTolerant/dpgtestmodelsversiontolerant/aio/_operations/_operations.py +++ b/packages/autorest.python/test/dpg/version-tolerant/Expected/AcceptanceTests/DPGTestModelsVersionTolerant/dpgtestmodelsversiontolerant/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/_serialization.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/_serialization.py index 1ad578bf803..84b9785ccf4 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/_serialization.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/_serialization.py @@ -1360,7 +1360,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/operations/_multiapi_service_client_operations.py index ade2701e6d6..da34fa3ab72 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/operations/_multiapi_service_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_multiapi_service_client_operations.py index fb9447b4402..ef02e70fd33 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_multiapi_service_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_multiapi_service_client_operations.py index 97c4d332d0c..617f59a807d 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_multiapi_service_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/_serialization.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/_serialization.py index 1ad578bf803..84b9785ccf4 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/_serialization.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/_serialization.py @@ -1360,7 +1360,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/aio/_operations_mixin.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/aio/_operations_mixin.py index 383f7fd05d0..07be08cf8ae 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/aio/_operations_mixin.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/aio/_operations_mixin.py @@ -55,7 +55,6 @@ async def begin_test_lro_and_paging( test_lro_and_paging_options: Optional[_models.TestLroAndPagingOptions] = None, **kwargs: Any ) -> AsyncLROPoller[AsyncIterable["_models.Product"]]: - # pylint: disable=line-too-long """A long-running paging operation that includes a nextLink that has 10 pages. :param client_request_id: Default value is None. diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_metadata.json b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_metadata.json index e0f1d908799..d8820f5f99e 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_metadata.json +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_metadata.json @@ -161,7 +161,7 @@ "async": { "coroutine": true, "signature": "async def begin_test_lro_and_paging(\n self,\n client_request_id: Optional[str] = None,\n test_lro_and_paging_options: Optional[_models.TestLroAndPagingOptions] = None,\n **kwargs: Any\n) -\u003e AsyncLROPoller[AsyncIterable[\"_models.Product\"]]:\n", - "doc": "# pylint: disable=line-too-long\n\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id: Default value is None.\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group. Default value is None.\n:type test_lro_and_paging_options:\n ~multiapicredentialdefaultpolicy.v1.models.TestLroAndPagingOptions\n:return: An instance of LROPoller that returns an iterator like instance of either PagingResult\n or the result of cls(response)\n:rtype:\n ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapicredentialdefaultpolicy.v1.models.Product]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", + "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id: Default value is None.\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group. Default value is None.\n:type test_lro_and_paging_options:\n ~multiapicredentialdefaultpolicy.v1.models.TestLroAndPagingOptions\n:return: An instance of LROPoller that returns an iterator like instance of either PagingResult\n or the result of cls(response)\n:rtype:\n ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapicredentialdefaultpolicy.v1.models.Product]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", "call": "client_request_id, test_lro_and_paging_options, **kwargs" } }, diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/operations/_multiapi_service_client_operations.py index 97a2ca1cb9f..3fd4d1d6faa 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/operations/_multiapi_service_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -322,7 +323,6 @@ async def begin_test_lro_and_paging( test_lro_and_paging_options: Optional[_models.TestLroAndPagingOptions] = None, **kwargs: Any ) -> AsyncLROPoller[AsyncIterable["_models.Product"]]: - # pylint: disable=line-too-long """A long-running paging operation that includes a nextLink that has 10 pages. :param client_request_id: Default value is None. diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_multiapi_service_client_operations.py index 3bb6b8555bc..987991bf77e 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_multiapi_service_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_multiapi_service_client_operations.py index c1765973ab2..37b6f7c0444 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_multiapi_service_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/_serialization.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/_serialization.py index 1ad578bf803..84b9785ccf4 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/_serialization.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/_serialization.py @@ -1360,7 +1360,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/aio/operations/__init__.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/aio/operations/__init__.py index 40541c05116..fcfeaddc7e6 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/aio/operations/__init__.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/aio/operations/__init__.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/aio/operations/_multiapi_custom_base_url_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/aio/operations/_multiapi_custom_base_url_service_client_operations.py index dc3cc527caa..e1b7e5b8284 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/aio/operations/_multiapi_custom_base_url_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/aio/operations/_multiapi_custom_base_url_service_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/operations/__init__.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/operations/__init__.py index 40541c05116..fcfeaddc7e6 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/operations/__init__.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/operations/__init__.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/aio/operations/__init__.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/aio/operations/__init__.py index 40541c05116..fcfeaddc7e6 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/aio/operations/__init__.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/aio/operations/__init__.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/aio/operations/_multiapi_custom_base_url_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/aio/operations/_multiapi_custom_base_url_service_client_operations.py index 6bbcee4be50..e67f64f309a 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/aio/operations/_multiapi_custom_base_url_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/aio/operations/_multiapi_custom_base_url_service_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/operations/__init__.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/operations/__init__.py index 40541c05116..fcfeaddc7e6 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/operations/__init__.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/operations/__init__.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/_serialization.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/_serialization.py index 1ad578bf803..84b9785ccf4 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/_serialization.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/_serialization.py @@ -1360,7 +1360,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/aio/_operations_mixin.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/aio/_operations_mixin.py index 0d8e7162766..e8b708ca879 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/aio/_operations_mixin.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/aio/_operations_mixin.py @@ -55,7 +55,6 @@ async def begin_test_lro_and_paging( test_lro_and_paging_options: Optional[_models.TestLroAndPagingOptions] = None, **kwargs: Any ) -> AsyncLROPoller[AsyncIterable["_models.Product"]]: - # pylint: disable=line-too-long """A long-running paging operation that includes a nextLink that has 10 pages. :param client_request_id: Default value is None. diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_metadata.json b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_metadata.json index 3c61b609e87..dc85166c75a 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_metadata.json +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_metadata.json @@ -161,7 +161,7 @@ "async": { "coroutine": true, "signature": "async def begin_test_lro_and_paging(\n self,\n client_request_id: Optional[str] = None,\n test_lro_and_paging_options: Optional[_models.TestLroAndPagingOptions] = None,\n **kwargs: Any\n) -\u003e AsyncLROPoller[AsyncIterable[\"_models.Product\"]]:\n", - "doc": "# pylint: disable=line-too-long\n\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id: Default value is None.\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group. Default value is None.\n:type test_lro_and_paging_options: ~multiapidataplane.v1.models.TestLroAndPagingOptions\n:return: An instance of LROPoller that returns an iterator like instance of either PagingResult\n or the result of cls(response)\n:rtype:\n ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapidataplane.v1.models.Product]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", + "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id: Default value is None.\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group. Default value is None.\n:type test_lro_and_paging_options: ~multiapidataplane.v1.models.TestLroAndPagingOptions\n:return: An instance of LROPoller that returns an iterator like instance of either PagingResult\n or the result of cls(response)\n:rtype:\n ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapidataplane.v1.models.Product]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", "call": "client_request_id, test_lro_and_paging_options, **kwargs" } }, diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/operations/_multiapi_service_client_operations.py index 1592e7e3079..757deed5c66 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/operations/_multiapi_service_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -321,7 +322,6 @@ async def begin_test_lro_and_paging( test_lro_and_paging_options: Optional[_models.TestLroAndPagingOptions] = None, **kwargs: Any ) -> AsyncLROPoller[AsyncIterable["_models.Product"]]: - # pylint: disable=line-too-long """A long-running paging operation that includes a nextLink that has 10 pages. :param client_request_id: Default value is None. diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_multiapi_service_client_operations.py index 4b446c5f02c..3b94b31754e 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_multiapi_service_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_multiapi_service_client_operations.py index 9e5c6f71af5..9b257384760 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_multiapi_service_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/_serialization.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/_serialization.py index 1ad578bf803..84b9785ccf4 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/_serialization.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/_serialization.py @@ -1360,7 +1360,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/aio/_operations_mixin.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/aio/_operations_mixin.py index 4fe052cfe62..5d76a53b11c 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/aio/_operations_mixin.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/aio/_operations_mixin.py @@ -56,7 +56,6 @@ async def begin_test_lro_and_paging( client_request_id: Optional[str] = None, **kwargs: Any ) -> AsyncLROPoller[AsyncIterable["_models.Product"]]: - # pylint: disable=line-too-long """A long-running paging operation that includes a nextLink that has 10 pages. :param test_lro_and_paging_options: Parameter group. Default value is None. diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/_metadata.json b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/_metadata.json index 3edaf131320..bb512943425 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/_metadata.json +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/_metadata.json @@ -161,7 +161,7 @@ "async": { "coroutine": true, "signature": "async def begin_test_lro_and_paging(\n self,\n test_lro_and_paging_options: Optional[_models.TestLroAndPagingOptions] = None,\n *,\n client_request_id: Optional[str] = None,\n **kwargs: Any\n) -\u003e AsyncLROPoller[AsyncIterable[\"_models.Product\"]]:\n", - "doc": "# pylint: disable=line-too-long\n\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param test_lro_and_paging_options: Parameter group. Default value is None.\n:type test_lro_and_paging_options: ~multiapikeywordonly.v1.models.TestLroAndPagingOptions\n:keyword client_request_id: Default value is None.\n:paramtype client_request_id: str\n:return: An instance of LROPoller that returns an iterator like instance of either PagingResult\n or the result of cls(response)\n:rtype:\n ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapikeywordonly.v1.models.Product]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", + "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param test_lro_and_paging_options: Parameter group. Default value is None.\n:type test_lro_and_paging_options: ~multiapikeywordonly.v1.models.TestLroAndPagingOptions\n:keyword client_request_id: Default value is None.\n:paramtype client_request_id: str\n:return: An instance of LROPoller that returns an iterator like instance of either PagingResult\n or the result of cls(response)\n:rtype:\n ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapikeywordonly.v1.models.Product]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", "call": "test_lro_and_paging_options, client_request_id=client_request_id, **kwargs" } }, diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/aio/operations/_multiapi_service_client_operations.py index 1a4887a3ccf..5e580b5c92c 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v1/aio/operations/_multiapi_service_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -323,7 +324,6 @@ async def begin_test_lro_and_paging( client_request_id: Optional[str] = None, **kwargs: Any ) -> AsyncLROPoller[AsyncIterable["_models.Product"]]: - # pylint: disable=line-too-long """A long-running paging operation that includes a nextLink that has 10 pages. :param test_lro_and_paging_options: Parameter group. Default value is None. diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/aio/operations/_multiapi_service_client_operations.py index b6feefbb231..f58b8eb6caf 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v2/aio/operations/_multiapi_service_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/aio/operations/_multiapi_service_client_operations.py index e75413f0e1e..056d9c2cbcb 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiKeywordOnly/multiapikeywordonly/v3/aio/operations/_multiapi_service_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/_serialization.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/_serialization.py index 1ad578bf803..84b9785ccf4 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/_serialization.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/_serialization.py @@ -1360,7 +1360,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/_serialization.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/_serialization.py index 1ad578bf803..84b9785ccf4 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/_serialization.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/_serialization.py @@ -1360,7 +1360,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/aio/_operations_mixin.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/aio/_operations_mixin.py index 28acde6ef7c..f33111ee65c 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/aio/_operations_mixin.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/aio/_operations_mixin.py @@ -55,7 +55,6 @@ async def begin_test_lro_and_paging( test_lro_and_paging_options: Optional[_models.TestLroAndPagingOptions] = None, **kwargs: Any ) -> AsyncLROPoller[AsyncIterable["_models.Product"]]: - # pylint: disable=line-too-long """A long-running paging operation that includes a nextLink that has 10 pages. :param client_request_id: Default value is None. diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/_metadata.json b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/_metadata.json index 0e6aee39314..8298a83ebdc 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/_metadata.json +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/_metadata.json @@ -161,7 +161,7 @@ "async": { "coroutine": true, "signature": "async def begin_test_lro_and_paging(\n self,\n client_request_id: Optional[str] = None,\n test_lro_and_paging_options: Optional[_models.TestLroAndPagingOptions] = None,\n **kwargs: Any\n) -\u003e AsyncLROPoller[AsyncIterable[\"_models.Product\"]]:\n", - "doc": "# pylint: disable=line-too-long\n\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id: Default value is None.\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group. Default value is None.\n:type test_lro_and_paging_options: ~multiapisecurity.v1.models.TestLroAndPagingOptions\n:return: An instance of LROPoller that returns an iterator like instance of either PagingResult\n or the result of cls(response)\n:rtype:\n ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapisecurity.v1.models.Product]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", + "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id: Default value is None.\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group. Default value is None.\n:type test_lro_and_paging_options: ~multiapisecurity.v1.models.TestLroAndPagingOptions\n:return: An instance of LROPoller that returns an iterator like instance of either PagingResult\n or the result of cls(response)\n:rtype:\n ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapisecurity.v1.models.Product]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", "call": "client_request_id, test_lro_and_paging_options, **kwargs" } }, diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/aio/operations/_multiapi_service_client_operations.py index 3dc7f3d0999..d132baa2094 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiSecurity/multiapisecurity/v1/aio/operations/_multiapi_service_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -321,7 +322,6 @@ async def begin_test_lro_and_paging( test_lro_and_paging_options: Optional[_models.TestLroAndPagingOptions] = None, **kwargs: Any ) -> AsyncLROPoller[AsyncIterable["_models.Product"]]: - # pylint: disable=line-too-long """A long-running paging operation that includes a nextLink that has 10 pages. :param client_request_id: Default value is None. diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/_serialization.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/_serialization.py index 1ad578bf803..84b9785ccf4 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/_serialization.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/_serialization.py @@ -1360,7 +1360,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/aio/_operations_mixin.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/aio/_operations_mixin.py index 7f09d080a5e..4cd54f84d22 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/aio/_operations_mixin.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/aio/_operations_mixin.py @@ -55,7 +55,6 @@ async def begin_test_lro_and_paging( test_lro_and_paging_options: Optional[_models.TestLroAndPagingOptions] = None, **kwargs: Any ) -> AsyncLROPoller[AsyncIterable["_models.Product"]]: - # pylint: disable=line-too-long """A long-running paging operation that includes a nextLink that has 10 pages. :param client_request_id: Default value is None. diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_metadata.json b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_metadata.json index 9c6ece66781..c75db23fff8 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_metadata.json +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_metadata.json @@ -161,7 +161,7 @@ "async": { "coroutine": true, "signature": "async def begin_test_lro_and_paging(\n self,\n client_request_id: Optional[str] = None,\n test_lro_and_paging_options: Optional[_models.TestLroAndPagingOptions] = None,\n **kwargs: Any\n) -\u003e AsyncLROPoller[AsyncIterable[\"_models.Product\"]]:\n", - "doc": "# pylint: disable=line-too-long\n\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id: Default value is None.\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group. Default value is None.\n:type test_lro_and_paging_options:\n ~multiapiwithsubmodule.submodule.v1.models.TestLroAndPagingOptions\n:return: An instance of LROPoller that returns an iterator like instance of either PagingResult\n or the result of cls(response)\n:rtype:\n ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapiwithsubmodule.submodule.v1.models.Product]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", + "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id: Default value is None.\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group. Default value is None.\n:type test_lro_and_paging_options:\n ~multiapiwithsubmodule.submodule.v1.models.TestLroAndPagingOptions\n:return: An instance of LROPoller that returns an iterator like instance of either PagingResult\n or the result of cls(response)\n:rtype:\n ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapiwithsubmodule.submodule.v1.models.Product]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"", "call": "client_request_id, test_lro_and_paging_options, **kwargs" } }, diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/operations/_multiapi_service_client_operations.py index 7f47fddb36c..54b93917ade 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/operations/_multiapi_service_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -322,7 +323,6 @@ async def begin_test_lro_and_paging( test_lro_and_paging_options: Optional[_models.TestLroAndPagingOptions] = None, **kwargs: Any ) -> AsyncLROPoller[AsyncIterable["_models.Product"]]: - # pylint: disable=line-too-long """A long-running paging operation that includes a nextLink that has 10 pages. :param client_request_id: Default value is None. diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_multiapi_service_client_operations.py index 3dcd40687ba..2d97548f614 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_multiapi_service_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_multiapi_service_client_operations.py b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_multiapi_service_client_operations.py index b1d0c672ba7..14a227374fd 100644 --- a/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_multiapi_service_client_operations.py +++ b/packages/autorest.python/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_multiapi_service_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/unittests/storage_models/serialization.py b/packages/autorest.python/test/unittests/storage_models/serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/unittests/storage_models/serialization.py +++ b/packages/autorest.python/test/unittests/storage_models/serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/AdditionalProperties/additionalproperties/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/aio/operations/_anything_client_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/aio/operations/_anything_client_operations.py index e89cf0692d4..3fe0929065a 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/aio/operations/_anything_client_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Anything/anything/aio/operations/_anything_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Anything/setup.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Anything/setup.py index 9d4a80b9064..e41f7d898bb 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Anything/setup.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Anything/setup.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArray/bodyarray/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyArrayWithNamespaceFolders/vanilla/body/array/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBinary/bodybinary/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBinary/bodybinary/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBinary/bodybinary/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBinary/bodybinary/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyBoolean/bodyboolean/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByte/bodybyte/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyByteWithPackageName/bodybytewithpackagename/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDate/bodydate/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTime/bodydatetime/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDictionary/bodydictionary/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyDuration/bodyduration/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFile/bodyfile/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormData/bodyformdata/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyFormUrlEncodedData/bodyformurlencodeddata/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyInteger/bodyinteger/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyNumber/bodynumber/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyString/bodystring/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/BodyTime/bodytime/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ClientEnum/clientenum/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ClientEnum/clientenum/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ClientEnum/clientenum/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ClientEnum/clientenum/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ClientEnum/clientenum/aio/operations/_client_with_enum_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ClientEnum/clientenum/aio/operations/_client_with_enum_operations.py index f25d2ab3cee..f7422945602 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ClientEnum/clientenum/aio/operations/_client_with_enum_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ClientEnum/clientenum/aio/operations/_client_with_enum_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/operations/_contants_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/operations/_contants_operations.py index 6c56ede9935..ca106752fca 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/operations/_contants_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Constants/constants/operations/_contants_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_configuration.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_configuration.py index 56dc8d8dc66..eaeaac27bf0 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_configuration.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_configuration.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/_configuration.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/_configuration.py index 89d8bd8835f..a9ff1973031 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/_configuration.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/CustomBaseUriMoreOptions/custombaseurlmoreoptions/aio/_configuration.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ErrorWithSecrets/errorwithsecrets/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ErrorWithSecrets/errorwithsecrets/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ErrorWithSecrets/errorwithsecrets/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ErrorWithSecrets/errorwithsecrets/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ErrorWithSecrets/errorwithsecrets/aio/operations/_error_with_secrets_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ErrorWithSecrets/errorwithsecrets/aio/operations/_error_with_secrets_operations.py index 08246458074..14acaa7dc63 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ErrorWithSecrets/errorwithsecrets/aio/operations/_error_with_secrets_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ErrorWithSecrets/errorwithsecrets/aio/operations/_error_with_secrets_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ExtensibleEnums/extensibleenumsswagger/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Header/header/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_auto_rest_http_infrastructure_test_service.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_auto_rest_http_infrastructure_test_service.py index b338e6147eb..7bf797ad3b8 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_auto_rest_http_infrastructure_test_service.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_auto_rest_http_infrastructure_test_service.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/_auto_rest_http_infrastructure_test_service.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/_auto_rest_http_infrastructure_test_service.py index 961442f7d76..c3a4693a795 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/_auto_rest_http_infrastructure_test_service.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Http/httpinfrastructure/aio/_auto_rest_http_infrastructure_test_service.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/operations/_incorrect_returned_error_model_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/operations/_incorrect_returned_error_model_operations.py index 9943c672fdc..9b55ecf31ba 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/operations/_incorrect_returned_error_model_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/IncorrectErrorResponse/incorrecterrorresponse/aio/operations/_incorrect_returned_error_model_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/InternalOperation/internaloperation/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/InternalOperation/internaloperation/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/InternalOperation/internaloperation/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/InternalOperation/internaloperation/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/InternalOperation/internaloperation/aio/operations/_media_types_client_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/InternalOperation/internaloperation/aio/operations/_media_types_client_operations.py index 1d6dc01d57e..bea95dd9c00 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/InternalOperation/internaloperation/aio/operations/_media_types_client_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/InternalOperation/internaloperation/aio/operations/_media_types_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/operations/_media_types_client_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/operations/_media_types_client_operations.py index aefef5e8ed6..89f50647ed8 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/operations/_media_types_client_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MediaTypes/mediatypes/aio/operations/_media_types_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MergePatchJson/mergepatchjson/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MergePatchJson/mergepatchjson/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MergePatchJson/mergepatchjson/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MergePatchJson/mergepatchjson/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MergePatchJson/mergepatchjson/aio/operations/_merge_patch_json_client_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MergePatchJson/mergepatchjson/aio/operations/_merge_patch_json_client_operations.py index ab7b8ac82d9..6b1896ffde8 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MergePatchJson/mergepatchjson/aio/operations/_merge_patch_json_client_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MergePatchJson/mergepatchjson/aio/operations/_merge_patch_json_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/operations/__init__.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/operations/__init__.py index 3e16d8447cf..39cc78befb5 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/operations/__init__.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/operations/__init__.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/operations/_auto_rest_resource_flattening_test_service_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/operations/_auto_rest_resource_flattening_test_service_operations.py index abba75f91df..f4d69dc6e6b 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/operations/_auto_rest_resource_flattening_test_service_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/aio/operations/_auto_rest_resource_flattening_test_service_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/operations/__init__.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/operations/__init__.py index 3e16d8447cf..39cc78befb5 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/operations/__init__.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ModelFlattening/modelflattening/operations/__init__.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/operations/__init__.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/operations/__init__.py index ede5f9b3691..8c33c179879 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/operations/__init__.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/operations/__init__.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/operations/_multiple_inheritance_service_client_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/operations/_multiple_inheritance_service_client_operations.py index 572022a0f9d..5b39b65dcf9 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/operations/_multiple_inheritance_service_client_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/aio/operations/_multiple_inheritance_service_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/operations/__init__.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/operations/__init__.py index ede5f9b3691..8c33c179879 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/operations/__init__.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/MultipleInheritance/multipleinheritance/operations/__init__.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/NoOperations/nooperations/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/NoOperations/nooperations/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/NoOperations/nooperations/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/NoOperations/nooperations/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/NonStringEnums/nonstringenums/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/aio/operations/_object_type_client_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/aio/operations/_object_type_client_operations.py index 3a0674713a1..ea8933f64bc 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/aio/operations/_object_type_client_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ObjectType/objecttype/aio/operations/_object_type_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/PackageModeDataPlane/packagemode/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/PackageModeDataPlane/packagemode/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/PackageModeDataPlane/packagemode/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/PackageModeDataPlane/packagemode/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/PackageModeDataPlane/packagemode/aio/operations/_anything_client_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/PackageModeDataPlane/packagemode/aio/operations/_anything_client_operations.py index e89cf0692d4..3fe0929065a 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/PackageModeDataPlane/packagemode/aio/operations/_anything_client_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/PackageModeDataPlane/packagemode/aio/operations/_anything_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterFlattening/parameterflattening/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterizedEndpoint/parameterizedendpoint/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterizedEndpoint/parameterizedendpoint/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterizedEndpoint/parameterizedendpoint/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterizedEndpoint/parameterizedendpoint/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterizedEndpoint/parameterizedendpoint/aio/operations/_parmaterized_endpoint_client_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterizedEndpoint/parameterizedendpoint/aio/operations/_parmaterized_endpoint_client_operations.py index ca24058c44c..f103e196b0b 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterizedEndpoint/parameterizedendpoint/aio/operations/_parmaterized_endpoint_client_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ParameterizedEndpoint/parameterizedendpoint/aio/operations/_parmaterized_endpoint_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/aio/operations/_auto_rest_report_service_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/aio/operations/_auto_rest_report_service_operations.py index fff2cc1b39c..7077bc3dbe8 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/aio/operations/_auto_rest_report_service_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Report/report/aio/operations/_auto_rest_report_service_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/aio/operations/_reserved_words_client_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/aio/operations/_reserved_words_client_operations.py index 0f6b3a96582..b395dc12eb4 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/aio/operations/_reserved_words_client_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/ReservedWords/reservedwords/aio/operations/_reserved_words_client_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/aio/operations/_autorest_security_aad_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/aio/operations/_autorest_security_aad_operations.py index bdfc0f31055..07e79742b43 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/aio/operations/_autorest_security_aad_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwagger/securityaadswagger/aio/operations/_autorest_security_aad_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/aio/operations/__init__.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/aio/operations/__init__.py index e636d96676e..c64fbebaf18 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/aio/operations/__init__.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/aio/operations/__init__.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/aio/operations/_security_aad_swagger_credential_flag_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/aio/operations/_security_aad_swagger_credential_flag_operations.py index c4377a7254b..aa7715371af 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/aio/operations/_security_aad_swagger_credential_flag_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/aio/operations/_security_aad_swagger_credential_flag_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/operations/__init__.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/operations/__init__.py index e636d96676e..c64fbebaf18 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/operations/__init__.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityAadSwaggerCredentialFlag/securityaadswaggercredentialflag/operations/__init__.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/aio/operations/_autorest_security_key_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/aio/operations/_autorest_security_key_operations.py index ea5e8f4efb9..b08db4ee2c7 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/aio/operations/_autorest_security_key_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwagger/securitykeyswagger/aio/operations/_autorest_security_key_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/aio/operations/__init__.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/aio/operations/__init__.py index 2f05089946e..c39916b7199 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/aio/operations/__init__.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/aio/operations/__init__.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/aio/operations/_security_key_swagger_credential_flag_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/aio/operations/_security_key_swagger_credential_flag_operations.py index 1509d33c767..2f70a450e6e 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/aio/operations/_security_key_swagger_credential_flag_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/aio/operations/_security_key_swagger_credential_flag_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/operations/__init__.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/operations/__init__.py index 2f05089946e..c39916b7199 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/operations/__init__.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/SecurityKeySwaggerCredentialFlag/securitykeyswaggercredentialflag/operations/__init__.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_path_items_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_path_items_operations.py index deb985a6e05..9bb6aab0a94 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_path_items_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_path_items_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -56,7 +57,7 @@ def build_get_all_with_values_request( _url = kwargs.pop( "template_url", "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/globalStringQuery/pathItemStringQuery/localStringQuery", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "pathItemStringPath": _SERIALIZER.url("path_item_string_path", path_item_string_path, "str"), "globalStringPath": _SERIALIZER.url("global_string_path", global_string_path, "str"), @@ -98,7 +99,7 @@ def build_get_global_query_null_request( _url = kwargs.pop( "template_url", "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/null/pathItemStringQuery/localStringQuery", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "pathItemStringPath": _SERIALIZER.url("path_item_string_path", path_item_string_path, "str"), "globalStringPath": _SERIALIZER.url("global_string_path", global_string_path, "str"), @@ -140,7 +141,7 @@ def build_get_global_and_local_query_null_request( # pylint: disable=name-too-l _url = kwargs.pop( "template_url", "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/null/pathItemStringQuery/null", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "pathItemStringPath": _SERIALIZER.url("path_item_string_path", path_item_string_path, "str"), "globalStringPath": _SERIALIZER.url("global_string_path", global_string_path, "str"), @@ -182,7 +183,7 @@ def build_get_local_path_item_query_null_request( # pylint: disable=name-too-lo _url = kwargs.pop( "template_url", "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/globalStringQuery/null/null", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "pathItemStringPath": _SERIALIZER.url("path_item_string_path", path_item_string_path, "str"), "globalStringPath": _SERIALIZER.url("global_string_path", global_string_path, "str"), diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_paths_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_paths_operations.py index 19104240809..8692a91fb20 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_paths_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_paths_operations.py @@ -268,7 +268,7 @@ def build_string_url_encoded_request(**kwargs: Any) -> HttpRequest: # Construct URL _url = kwargs.pop( "template_url", "/paths/string/begin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend/{stringPath}" - ) # pylint: disable=line-too-long + ) path_format_arguments = { "stringPath": _SERIALIZER.url("string_path", string_path, "str"), } @@ -542,7 +542,7 @@ def build_array_csv_in_path_request(array_path: List[str], **kwargs: Any) -> Htt _url = kwargs.pop( "template_url", "/paths/array/ArrayPath1%2cbegin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend%2c%2c/{arrayPath}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "arrayPath": _SERIALIZER.url("array_path", array_path, "[str]", div=","), } diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_queries_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_queries_operations.py index 0dbbaace82c..4de0e541a75 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_queries_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Url/url/operations/_queries_operations.py @@ -357,7 +357,7 @@ def build_string_url_encoded_request(**kwargs: Any) -> HttpRequest: # Construct URL _url = kwargs.pop( "template_url", "/queries/string/begin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend" - ) # pylint: disable=line-too-long + ) # Construct parameters _params["stringQuery"] = _SERIALIZER.query("string_query", string_query, "str") diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/__init__.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/__init__.py index f3812c02e7f..67f2c7faace 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/__init__.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/__init__.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_configuration.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_configuration.py index cad9091ba86..79335b14905 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_configuration.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_configuration.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/__init__.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/__init__.py index 3f41a334a21..2077bbccc7b 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/__init__.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/__init__.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/_configuration.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/_configuration.py index 6a6b7955010..65af94ceff3 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/_configuration.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/UrlMultiCollectionFormat/urlmulticollectionformat/aio/_configuration.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/aio/operations/_auto_rest_validation_test_operations.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/aio/operations/_auto_rest_validation_test_operations.py index 6f2d968a256..e37ac252122 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/aio/operations/_auto_rest_validation_test_operations.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Validation/validation/aio/operations/_auto_rest_validation_test_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/Xml/xmlservice/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_serialization.py b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_serialization.py +++ b/packages/autorest.python/test/vanilla/legacy/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/AdditionalPropertiesVersionTolerant/additionalpropertiesversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/AdditionalPropertiesVersionTolerant/additionalpropertiesversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/AdditionalPropertiesVersionTolerant/additionalpropertiesversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/AdditionalPropertiesVersionTolerant/additionalpropertiesversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/AnythingVersionTolerant/anythingversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/AnythingVersionTolerant/anythingversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/AnythingVersionTolerant/anythingversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/AnythingVersionTolerant/anythingversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/AnythingVersionTolerant/anythingversiontolerant/aio/_operations/_operations.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/AnythingVersionTolerant/anythingversiontolerant/aio/_operations/_operations.py index fcb94ed360f..0ea7e14d276 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/AnythingVersionTolerant/anythingversiontolerant/aio/_operations/_operations.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/AnythingVersionTolerant/anythingversiontolerant/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/AnythingVersionTolerant/setup.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/AnythingVersionTolerant/setup.py index abcf4fc0505..f06a9d2ede9 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/AnythingVersionTolerant/setup.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/AnythingVersionTolerant/setup.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyArrayVersionTolerant/bodyarrayversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyArrayVersionTolerant/bodyarrayversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyArrayVersionTolerant/bodyarrayversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyArrayVersionTolerant/bodyarrayversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyBinaryVersionTolerant/bodybinaryversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyBinaryVersionTolerant/bodybinaryversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyBinaryVersionTolerant/bodybinaryversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyBinaryVersionTolerant/bodybinaryversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyBooleanVersionTolerant/bodybooleanversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyBooleanVersionTolerant/bodybooleanversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyBooleanVersionTolerant/bodybooleanversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyBooleanVersionTolerant/bodybooleanversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyByteVersionTolerant/bodybyteversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyByteVersionTolerant/bodybyteversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyByteVersionTolerant/bodybyteversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyByteVersionTolerant/bodybyteversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyComplexVersionTolerant/bodycomplexversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyComplexVersionTolerant/bodycomplexversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyComplexVersionTolerant/bodycomplexversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyComplexVersionTolerant/bodycomplexversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyDateTimeRfc1123VersionTolerant/bodydatetimerfc1123versiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyDateTimeRfc1123VersionTolerant/bodydatetimerfc1123versiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyDateTimeRfc1123VersionTolerant/bodydatetimerfc1123versiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyDateTimeRfc1123VersionTolerant/bodydatetimerfc1123versiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyDateTimeVersionTolerant/bodydatetimeversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyDateTimeVersionTolerant/bodydatetimeversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyDateTimeVersionTolerant/bodydatetimeversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyDateTimeVersionTolerant/bodydatetimeversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyDateVersionTolerant/bodydateversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyDateVersionTolerant/bodydateversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyDateVersionTolerant/bodydateversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyDateVersionTolerant/bodydateversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyDictionaryVersionTolerant/bodydictionaryversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyDictionaryVersionTolerant/bodydictionaryversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyDictionaryVersionTolerant/bodydictionaryversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyDictionaryVersionTolerant/bodydictionaryversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyDurationVersionTolerant/bodydurationversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyDurationVersionTolerant/bodydurationversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyDurationVersionTolerant/bodydurationversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyDurationVersionTolerant/bodydurationversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFileVersionTolerant/bodyfileversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFileVersionTolerant/bodyfileversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFileVersionTolerant/bodyfileversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFileVersionTolerant/bodyfileversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormDataVersionTolerant/bodyformdataversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormDataVersionTolerant/bodyformdataversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormDataVersionTolerant/bodyformdataversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormDataVersionTolerant/bodyformdataversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyFormUrlEncodedDataVersionTolerant/bodyformurlencodeddataversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyIntegerVersionTolerant/bodyintegerversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyIntegerVersionTolerant/bodyintegerversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyIntegerVersionTolerant/bodyintegerversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyIntegerVersionTolerant/bodyintegerversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyNumberVersionTolerant/bodynumberversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyNumberVersionTolerant/bodynumberversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyNumberVersionTolerant/bodynumberversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyNumberVersionTolerant/bodynumberversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyStringVersionTolerant/bodystringversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyStringVersionTolerant/bodystringversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyStringVersionTolerant/bodystringversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyStringVersionTolerant/bodystringversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyTimeVersionTolerant/bodytimeversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyTimeVersionTolerant/bodytimeversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyTimeVersionTolerant/bodytimeversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/BodyTimeVersionTolerant/bodytimeversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ClientEnumVersionTolerant/clientenumversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ClientEnumVersionTolerant/clientenumversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ClientEnumVersionTolerant/clientenumversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ClientEnumVersionTolerant/clientenumversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ClientEnumVersionTolerant/clientenumversiontolerant/aio/_operations/_operations.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ClientEnumVersionTolerant/clientenumversiontolerant/aio/_operations/_operations.py index 6f0db41f68d..cbd7fedc8b5 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ClientEnumVersionTolerant/clientenumversiontolerant/aio/_operations/_operations.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ClientEnumVersionTolerant/clientenumversiontolerant/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ConstantsVersionTolerant/constantsversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ConstantsVersionTolerant/constantsversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ConstantsVersionTolerant/constantsversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ConstantsVersionTolerant/constantsversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ConstantsVersionTolerant/constantsversiontolerant/operations/_operations.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ConstantsVersionTolerant/constantsversiontolerant/operations/_operations.py index c142cf774e6..8d68c54f46d 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ConstantsVersionTolerant/constantsversiontolerant/operations/_operations.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ConstantsVersionTolerant/constantsversiontolerant/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/CustomBaseUriMoreOptionsVersionTolerant/custombaseurlmoreoptionsversiontolerant/_configuration.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/CustomBaseUriMoreOptionsVersionTolerant/custombaseurlmoreoptionsversiontolerant/_configuration.py index 56dc8d8dc66..eaeaac27bf0 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/CustomBaseUriMoreOptionsVersionTolerant/custombaseurlmoreoptionsversiontolerant/_configuration.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/CustomBaseUriMoreOptionsVersionTolerant/custombaseurlmoreoptionsversiontolerant/_configuration.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/CustomBaseUriMoreOptionsVersionTolerant/custombaseurlmoreoptionsversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/CustomBaseUriMoreOptionsVersionTolerant/custombaseurlmoreoptionsversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/CustomBaseUriMoreOptionsVersionTolerant/custombaseurlmoreoptionsversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/CustomBaseUriMoreOptionsVersionTolerant/custombaseurlmoreoptionsversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/CustomBaseUriMoreOptionsVersionTolerant/custombaseurlmoreoptionsversiontolerant/aio/_configuration.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/CustomBaseUriMoreOptionsVersionTolerant/custombaseurlmoreoptionsversiontolerant/aio/_configuration.py index 89d8bd8835f..a9ff1973031 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/CustomBaseUriMoreOptionsVersionTolerant/custombaseurlmoreoptionsversiontolerant/aio/_configuration.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/CustomBaseUriMoreOptionsVersionTolerant/custombaseurlmoreoptionsversiontolerant/aio/_configuration.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/CustomBaseUriVersionTolerant/custombaseurlversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/CustomBaseUriVersionTolerant/custombaseurlversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/CustomBaseUriVersionTolerant/custombaseurlversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/CustomBaseUriVersionTolerant/custombaseurlversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ErrorWithSecretsVersionTolerant/errorwithsecretsversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ErrorWithSecretsVersionTolerant/errorwithsecretsversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ErrorWithSecretsVersionTolerant/errorwithsecretsversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ErrorWithSecretsVersionTolerant/errorwithsecretsversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ErrorWithSecretsVersionTolerant/errorwithsecretsversiontolerant/aio/_operations/_operations.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ErrorWithSecretsVersionTolerant/errorwithsecretsversiontolerant/aio/_operations/_operations.py index 490ef54600a..686cbc198e5 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ErrorWithSecretsVersionTolerant/errorwithsecretsversiontolerant/aio/_operations/_operations.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ErrorWithSecretsVersionTolerant/errorwithsecretsversiontolerant/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ExtensibleEnumsVersionTolerant/extensibleenumsswaggerversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ExtensibleEnumsVersionTolerant/extensibleenumsswaggerversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ExtensibleEnumsVersionTolerant/extensibleenumsswaggerversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ExtensibleEnumsVersionTolerant/extensibleenumsswaggerversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/HeaderVersionTolerant/headerversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/HeaderVersionTolerant/headerversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/HeaderVersionTolerant/headerversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/HeaderVersionTolerant/headerversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/HttpVersionTolerant/httpinfrastructureversiontolerant/_client.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/HttpVersionTolerant/httpinfrastructureversiontolerant/_client.py index ac627d8e7ba..a08769b1233 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/HttpVersionTolerant/httpinfrastructureversiontolerant/_client.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/HttpVersionTolerant/httpinfrastructureversiontolerant/_client.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/HttpVersionTolerant/httpinfrastructureversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/HttpVersionTolerant/httpinfrastructureversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/HttpVersionTolerant/httpinfrastructureversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/HttpVersionTolerant/httpinfrastructureversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/HttpVersionTolerant/httpinfrastructureversiontolerant/aio/_client.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/HttpVersionTolerant/httpinfrastructureversiontolerant/aio/_client.py index b1d3d17af2a..945cf652136 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/HttpVersionTolerant/httpinfrastructureversiontolerant/aio/_client.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/HttpVersionTolerant/httpinfrastructureversiontolerant/aio/_client.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/HttpVersionTolerant/httpinfrastructureversiontolerant/operations/_operations.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/HttpVersionTolerant/httpinfrastructureversiontolerant/operations/_operations.py index 2523aa50271..70efb5dd6c5 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/HttpVersionTolerant/httpinfrastructureversiontolerant/operations/_operations.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/HttpVersionTolerant/httpinfrastructureversiontolerant/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/IncorrectErrorResponseVersionTolerant/incorrecterrorresponseversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/IncorrectErrorResponseVersionTolerant/incorrecterrorresponseversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/IncorrectErrorResponseVersionTolerant/incorrecterrorresponseversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/IncorrectErrorResponseVersionTolerant/incorrecterrorresponseversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/IncorrectErrorResponseVersionTolerant/incorrecterrorresponseversiontolerant/aio/_operations/_operations.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/IncorrectErrorResponseVersionTolerant/incorrecterrorresponseversiontolerant/aio/_operations/_operations.py index b290de3ffd9..b0beebdd56b 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/IncorrectErrorResponseVersionTolerant/incorrecterrorresponseversiontolerant/aio/_operations/_operations.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/IncorrectErrorResponseVersionTolerant/incorrecterrorresponseversiontolerant/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/MediaTypesVersionTolerant/mediatypesversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/MediaTypesVersionTolerant/mediatypesversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/MediaTypesVersionTolerant/mediatypesversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/MediaTypesVersionTolerant/mediatypesversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/MediaTypesVersionTolerant/mediatypesversiontolerant/aio/_operations/_operations.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/MediaTypesVersionTolerant/mediatypesversiontolerant/aio/_operations/_operations.py index 899603572b2..2ca56457b68 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/MediaTypesVersionTolerant/mediatypesversiontolerant/aio/_operations/_operations.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/MediaTypesVersionTolerant/mediatypesversiontolerant/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/MergePatchJsonVersionTolerant/mergepatchjsonversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/MergePatchJsonVersionTolerant/mergepatchjsonversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/MergePatchJsonVersionTolerant/mergepatchjsonversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/MergePatchJsonVersionTolerant/mergepatchjsonversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/MergePatchJsonVersionTolerant/mergepatchjsonversiontolerant/aio/_operations/_operations.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/MergePatchJsonVersionTolerant/mergepatchjsonversiontolerant/aio/_operations/_operations.py index 48250d032eb..11db875dd89 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/MergePatchJsonVersionTolerant/mergepatchjsonversiontolerant/aio/_operations/_operations.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/MergePatchJsonVersionTolerant/mergepatchjsonversiontolerant/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ModelFlatteningVersionTolerant/modelflatteningversiontolerant/_operations/_operations.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ModelFlatteningVersionTolerant/modelflatteningversiontolerant/_operations/_operations.py index ca5207965a6..f3c70920e9a 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ModelFlatteningVersionTolerant/modelflatteningversiontolerant/_operations/_operations.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ModelFlatteningVersionTolerant/modelflatteningversiontolerant/_operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ModelFlatteningVersionTolerant/modelflatteningversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ModelFlatteningVersionTolerant/modelflatteningversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ModelFlatteningVersionTolerant/modelflatteningversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ModelFlatteningVersionTolerant/modelflatteningversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ModelFlatteningVersionTolerant/modelflatteningversiontolerant/aio/_operations/_operations.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ModelFlatteningVersionTolerant/modelflatteningversiontolerant/aio/_operations/_operations.py index c95106e31e5..2b9735c5b27 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ModelFlatteningVersionTolerant/modelflatteningversiontolerant/aio/_operations/_operations.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ModelFlatteningVersionTolerant/modelflatteningversiontolerant/aio/_operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/MultipleInheritanceVersionTolerant/multipleinheritanceversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/MultipleInheritanceVersionTolerant/multipleinheritanceversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/MultipleInheritanceVersionTolerant/multipleinheritanceversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/MultipleInheritanceVersionTolerant/multipleinheritanceversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/MultipleInheritanceVersionTolerant/multipleinheritanceversiontolerant/aio/_operations/_operations.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/MultipleInheritanceVersionTolerant/multipleinheritanceversiontolerant/aio/_operations/_operations.py index 0dc9a38a2d9..4df48dfd90a 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/MultipleInheritanceVersionTolerant/multipleinheritanceversiontolerant/aio/_operations/_operations.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/MultipleInheritanceVersionTolerant/multipleinheritanceversiontolerant/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/NoNamespaceFlagVersionTolerant/anything_client/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/NoNamespaceFlagVersionTolerant/anything_client/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/NoNamespaceFlagVersionTolerant/anything_client/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/NoNamespaceFlagVersionTolerant/anything_client/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/NoNamespaceFlagVersionTolerant/anything_client/aio/_operations/_operations.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/NoNamespaceFlagVersionTolerant/anything_client/aio/_operations/_operations.py index fcb94ed360f..0ea7e14d276 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/NoNamespaceFlagVersionTolerant/anything_client/aio/_operations/_operations.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/NoNamespaceFlagVersionTolerant/anything_client/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/NoNamespaceFlagVersionTolerant/setup.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/NoNamespaceFlagVersionTolerant/setup.py index 557c11e8742..ae60df4bd12 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/NoNamespaceFlagVersionTolerant/setup.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/NoNamespaceFlagVersionTolerant/setup.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/NoOperationsVersionTolerant/nooperationsversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/NoOperationsVersionTolerant/nooperationsversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/NoOperationsVersionTolerant/nooperationsversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/NoOperationsVersionTolerant/nooperationsversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/NonStringEnumsVersionTolerant/nonstringenumsversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/NonStringEnumsVersionTolerant/nonstringenumsversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/NonStringEnumsVersionTolerant/nonstringenumsversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/NonStringEnumsVersionTolerant/nonstringenumsversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ObjectTypeVersionTolerant/objecttypeversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ObjectTypeVersionTolerant/objecttypeversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ObjectTypeVersionTolerant/objecttypeversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ObjectTypeVersionTolerant/objecttypeversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ObjectTypeVersionTolerant/objecttypeversiontolerant/aio/_operations/_operations.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ObjectTypeVersionTolerant/objecttypeversiontolerant/aio/_operations/_operations.py index 7f2df404f75..6f2ac1bc158 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ObjectTypeVersionTolerant/objecttypeversiontolerant/aio/_operations/_operations.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ObjectTypeVersionTolerant/objecttypeversiontolerant/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ParameterFlatteningVersionTolerant/parameterflatteningversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ParameterFlatteningVersionTolerant/parameterflatteningversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ParameterFlatteningVersionTolerant/parameterflatteningversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ParameterFlatteningVersionTolerant/parameterflatteningversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ParameterizedEndpointVersionTolerant/parameterizedendpointversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ParameterizedEndpointVersionTolerant/parameterizedendpointversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ParameterizedEndpointVersionTolerant/parameterizedendpointversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ParameterizedEndpointVersionTolerant/parameterizedendpointversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ParameterizedEndpointVersionTolerant/parameterizedendpointversiontolerant/aio/_operations/_operations.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ParameterizedEndpointVersionTolerant/parameterizedendpointversiontolerant/aio/_operations/_operations.py index e4f60416616..6d10d70b36c 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ParameterizedEndpointVersionTolerant/parameterizedendpointversiontolerant/aio/_operations/_operations.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ParameterizedEndpointVersionTolerant/parameterizedendpointversiontolerant/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ReportVersionTolerant/reportversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ReportVersionTolerant/reportversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ReportVersionTolerant/reportversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ReportVersionTolerant/reportversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ReportVersionTolerant/reportversiontolerant/aio/_operations/_operations.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ReportVersionTolerant/reportversiontolerant/aio/_operations/_operations.py index 8585a5f8fc5..176d3577b19 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ReportVersionTolerant/reportversiontolerant/aio/_operations/_operations.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ReportVersionTolerant/reportversiontolerant/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/RequiredOptionalVersionTolerant/requiredoptionalversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/RequiredOptionalVersionTolerant/requiredoptionalversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/RequiredOptionalVersionTolerant/requiredoptionalversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/RequiredOptionalVersionTolerant/requiredoptionalversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ReservedWordsVersionTolerant/reservedwordsversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ReservedWordsVersionTolerant/reservedwordsversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ReservedWordsVersionTolerant/reservedwordsversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ReservedWordsVersionTolerant/reservedwordsversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ReservedWordsVersionTolerant/reservedwordsversiontolerant/aio/operations/_operations.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ReservedWordsVersionTolerant/reservedwordsversiontolerant/aio/operations/_operations.py index 4d8a8e8169c..665cf4375f1 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ReservedWordsVersionTolerant/reservedwordsversiontolerant/aio/operations/_operations.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ReservedWordsVersionTolerant/reservedwordsversiontolerant/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/SecurityAadSwaggerVersionTolerant/securityaadswaggerversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/SecurityAadSwaggerVersionTolerant/securityaadswaggerversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/SecurityAadSwaggerVersionTolerant/securityaadswaggerversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/SecurityAadSwaggerVersionTolerant/securityaadswaggerversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/SecurityAadSwaggerVersionTolerant/securityaadswaggerversiontolerant/aio/_operations/_operations.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/SecurityAadSwaggerVersionTolerant/securityaadswaggerversiontolerant/aio/_operations/_operations.py index c1ad1bc2455..0485b794abd 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/SecurityAadSwaggerVersionTolerant/securityaadswaggerversiontolerant/aio/_operations/_operations.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/SecurityAadSwaggerVersionTolerant/securityaadswaggerversiontolerant/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/SecurityKeySwaggerVersionTolerant/securitykeyswaggerversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/SecurityKeySwaggerVersionTolerant/securitykeyswaggerversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/SecurityKeySwaggerVersionTolerant/securitykeyswaggerversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/SecurityKeySwaggerVersionTolerant/securitykeyswaggerversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/SecurityKeySwaggerVersionTolerant/securitykeyswaggerversiontolerant/aio/_operations/_operations.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/SecurityKeySwaggerVersionTolerant/securitykeyswaggerversiontolerant/aio/_operations/_operations.py index 0db98da5583..66c4f430737 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/SecurityKeySwaggerVersionTolerant/securitykeyswaggerversiontolerant/aio/_operations/_operations.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/SecurityKeySwaggerVersionTolerant/securitykeyswaggerversiontolerant/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/UrlMultiCollectionFormatVersionTolerant/urlmulticollectionformatversiontolerant/_configuration.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/UrlMultiCollectionFormatVersionTolerant/urlmulticollectionformatversiontolerant/_configuration.py index cad9091ba86..79335b14905 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/UrlMultiCollectionFormatVersionTolerant/urlmulticollectionformatversiontolerant/_configuration.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/UrlMultiCollectionFormatVersionTolerant/urlmulticollectionformatversiontolerant/_configuration.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/UrlMultiCollectionFormatVersionTolerant/urlmulticollectionformatversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/UrlMultiCollectionFormatVersionTolerant/urlmulticollectionformatversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/UrlMultiCollectionFormatVersionTolerant/urlmulticollectionformatversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/UrlMultiCollectionFormatVersionTolerant/urlmulticollectionformatversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/UrlMultiCollectionFormatVersionTolerant/urlmulticollectionformatversiontolerant/aio/_configuration.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/UrlMultiCollectionFormatVersionTolerant/urlmulticollectionformatversiontolerant/aio/_configuration.py index 6a6b7955010..65af94ceff3 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/UrlMultiCollectionFormatVersionTolerant/urlmulticollectionformatversiontolerant/aio/_configuration.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/UrlMultiCollectionFormatVersionTolerant/urlmulticollectionformatversiontolerant/aio/_configuration.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/UrlVersionTolerant/urlversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/UrlVersionTolerant/urlversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/UrlVersionTolerant/urlversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/UrlVersionTolerant/urlversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/UrlVersionTolerant/urlversiontolerant/operations/_operations.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/UrlVersionTolerant/urlversiontolerant/operations/_operations.py index 1250b003d41..bfef552bb81 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/UrlVersionTolerant/urlversiontolerant/operations/_operations.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/UrlVersionTolerant/urlversiontolerant/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -536,7 +536,9 @@ def build_paths_array_csv_in_path_request(array_path: List[str], **kwargs: Any) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/paths/array/ArrayPath1%2cbegin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend%2c%2c/{arrayPath}" # pylint: disable=line-too-long + _url = ( + "/paths/array/ArrayPath1%2cbegin%21%2A%27%28%29%3B%3A%40%20%26%3D%2B%24%2C%2F%3F%23%5B%5Dend%2c%2c/{arrayPath}" + ) path_format_arguments = { "arrayPath": _SERIALIZER.url("array_path", array_path, "[str]", div=","), } @@ -1271,7 +1273,7 @@ def build_path_items_get_all_with_values_request( # pylint: disable=name-too-lo accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/globalStringQuery/pathItemStringQuery/localStringQuery" # pylint: disable=line-too-long + _url = "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/globalStringQuery/pathItemStringQuery/localStringQuery" path_format_arguments = { "pathItemStringPath": _SERIALIZER.url("path_item_string_path", path_item_string_path, "str"), "globalStringPath": _SERIALIZER.url("global_string_path", global_string_path, "str"), @@ -1310,7 +1312,7 @@ def build_path_items_get_global_query_null_request( # pylint: disable=name-too- accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/null/pathItemStringQuery/localStringQuery" # pylint: disable=line-too-long + _url = "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/null/pathItemStringQuery/localStringQuery" path_format_arguments = { "pathItemStringPath": _SERIALIZER.url("path_item_string_path", path_item_string_path, "str"), "globalStringPath": _SERIALIZER.url("global_string_path", global_string_path, "str"), @@ -1349,7 +1351,7 @@ def build_path_items_get_global_and_local_query_null_request( # pylint: disable accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/null/pathItemStringQuery/null" # pylint: disable=line-too-long + _url = "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/null/pathItemStringQuery/null" path_format_arguments = { "pathItemStringPath": _SERIALIZER.url("path_item_string_path", path_item_string_path, "str"), "globalStringPath": _SERIALIZER.url("global_string_path", global_string_path, "str"), @@ -1388,7 +1390,7 @@ def build_path_items_get_local_path_item_query_null_request( # pylint: disable= accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/globalStringQuery/null/null" # pylint: disable=line-too-long + _url = "/pathitem/nullable/globalStringPath/{globalStringPath}/pathItemStringPath/{pathItemStringPath}/localStringPath/{localStringPath}/globalStringQuery/null/null" path_format_arguments = { "pathItemStringPath": _SERIALIZER.url("path_item_string_path", path_item_string_path, "str"), "globalStringPath": _SERIALIZER.url("global_string_path", global_string_path, "str"), diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ValidationVersionTolerant/validationversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ValidationVersionTolerant/validationversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ValidationVersionTolerant/validationversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ValidationVersionTolerant/validationversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ValidationVersionTolerant/validationversiontolerant/aio/_operations/_operations.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ValidationVersionTolerant/validationversiontolerant/aio/_operations/_operations.py index f4a6c20637e..470f3e26d1e 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ValidationVersionTolerant/validationversiontolerant/aio/_operations/_operations.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/ValidationVersionTolerant/validationversiontolerant/aio/_operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/XmlVersionTolerant/xmlserviceversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/XmlVersionTolerant/xmlserviceversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/XmlVersionTolerant/xmlserviceversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/XmlVersionTolerant/xmlserviceversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) diff --git a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/XmsErrorResponseVersionTolerant/xmserrorresponseversiontolerant/_serialization.py b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/XmsErrorResponseVersionTolerant/xmserrorresponseversiontolerant/_serialization.py index a066e16a64d..e2a20b1d534 100644 --- a/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/XmsErrorResponseVersionTolerant/xmserrorresponseversiontolerant/_serialization.py +++ b/packages/autorest.python/test/vanilla/version-tolerant/Expected/AcceptanceTests/XmsErrorResponseVersionTolerant/xmserrorresponseversiontolerant/_serialization.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # -------------------------------------------------------------------------- # # Copyright (c) Microsoft Corporation. All rights reserved. @@ -1361,7 +1361,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( # pylint: disable=line-too-long + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name ) ) From 72b26c43cd67cb1c3129b07452fc1ce36c1e25a5 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Thu, 13 Feb 2025 16:41:55 +0800 Subject: [PATCH 08/14] fix ci --- packages/typespec-python/scripts/eng/pylintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/typespec-python/scripts/eng/pylintrc b/packages/typespec-python/scripts/eng/pylintrc index 802317e3fb9..4b6d4c1749c 100644 --- a/packages/typespec-python/scripts/eng/pylintrc +++ b/packages/typespec-python/scripts/eng/pylintrc @@ -17,7 +17,7 @@ enable=useless-suppression # too-many-arguments: Due to the nature of the CLI many commands have large arguments set which reflect in large arguments set in corresponding methods. # too-many-lines: Due to code generation many files end up with too many lines. # Let's black deal with bad-continuation -disable=missing-docstring,locally-disabled,fixme,cyclic-import,too-many-arguments,invalid-name,duplicate-code,too-few-public-methods,consider-using-f-string,super-with-arguments,redefined-builtin,import-outside-toplevel,client-suffix-needed,unnecessary-dunder-call,unnecessary-ellipsis,disallowed-name,consider-using-max-builtin,unknown-option-value +disable=missing-docstring,locally-disabled,fixme,cyclic-import,too-many-arguments,invalid-name,duplicate-code,too-few-public-methods,consider-using-f-string,super-with-arguments,redefined-builtin,import-outside-toplevel,client-suffix-needed,unnecessary-dunder-call,unnecessary-ellipsis,disallowed-name,consider-using-max-builtin,unknown-option-value,client-accepts-api-version-keyword [FORMAT] max-line-length=120 From f9432748a6ab5db3829ab6056a35b00f0147bb5a Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Thu, 13 Feb 2025 16:43:02 +0800 Subject: [PATCH 09/14] add changelog --- .../auto-microsoft-bum-tsp-0.65.0-2025-1-13-16-42-46.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .chronus/changes/auto-microsoft-bum-tsp-0.65.0-2025-1-13-16-42-46.md diff --git a/.chronus/changes/auto-microsoft-bum-tsp-0.65.0-2025-1-13-16-42-46.md b/.chronus/changes/auto-microsoft-bum-tsp-0.65.0-2025-1-13-16-42-46.md new file mode 100644 index 00000000000..4345372073d --- /dev/null +++ b/.chronus/changes/auto-microsoft-bum-tsp-0.65.0-2025-1-13-16-42-46.md @@ -0,0 +1,8 @@ +--- +changeKind: internal +packages: + - "@autorest/python" + - "@azure-tools/typespec-python" +--- + +Bump @typespec/*@0.65.0 and @azure-tools/*@0.51.0 \ No newline at end of file From d346059d8b861f85023225db8e0ef2c066ab6ad3 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Thu, 13 Feb 2025 16:46:26 +0800 Subject: [PATCH 10/14] bump version --- .chronus/changes/add-testcases-2025-1-11-11-37-49.md | 7 ------- .../auto-microsoft-bum-tsp-0.65.0-2025-1-13-16-42-46.md | 8 -------- packages/autorest.python/CHANGELOG.md | 4 ++++ packages/autorest.python/package.json | 4 ++-- packages/typespec-python/CHANGELOG.md | 4 ++++ packages/typespec-python/package.json | 4 ++-- 6 files changed, 12 insertions(+), 19 deletions(-) delete mode 100644 .chronus/changes/add-testcases-2025-1-11-11-37-49.md delete mode 100644 .chronus/changes/auto-microsoft-bum-tsp-0.65.0-2025-1-13-16-42-46.md diff --git a/.chronus/changes/add-testcases-2025-1-11-11-37-49.md b/.chronus/changes/add-testcases-2025-1-11-11-37-49.md deleted file mode 100644 index a1d4de7ddb2..00000000000 --- a/.chronus/changes/add-testcases-2025-1-11-11-37-49.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: internal -packages: - - "@azure-tools/typespec-python" ---- - -add testcases for latest spector scenarios \ No newline at end of file diff --git a/.chronus/changes/auto-microsoft-bum-tsp-0.65.0-2025-1-13-16-42-46.md b/.chronus/changes/auto-microsoft-bum-tsp-0.65.0-2025-1-13-16-42-46.md deleted file mode 100644 index 4345372073d..00000000000 --- a/.chronus/changes/auto-microsoft-bum-tsp-0.65.0-2025-1-13-16-42-46.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -changeKind: internal -packages: - - "@autorest/python" - - "@azure-tools/typespec-python" ---- - -Bump @typespec/*@0.65.0 and @azure-tools/*@0.51.0 \ No newline at end of file diff --git a/packages/autorest.python/CHANGELOG.md b/packages/autorest.python/CHANGELOG.md index dd300337ac3..b765ea6f371 100644 --- a/packages/autorest.python/CHANGELOG.md +++ b/packages/autorest.python/CHANGELOG.md @@ -1,5 +1,9 @@ # Release +## 6.28.4 + +No changes, version bump only. + ## 6.28.3 No changes, version bump only. diff --git a/packages/autorest.python/package.json b/packages/autorest.python/package.json index d44206c12b8..10dd7998004 100644 --- a/packages/autorest.python/package.json +++ b/packages/autorest.python/package.json @@ -1,6 +1,6 @@ { "name": "@autorest/python", - "version": "6.28.3", + "version": "6.28.4", "description": "The Python extension for generators in AutoRest.", "scripts": { "start": "node ./scripts/run-python3.js ./scripts/start.py", @@ -47,4 +47,4 @@ "requirements.txt", "generator/" ] -} \ No newline at end of file +} diff --git a/packages/typespec-python/CHANGELOG.md b/packages/typespec-python/CHANGELOG.md index b0718dd9bd2..2488a498ebf 100644 --- a/packages/typespec-python/CHANGELOG.md +++ b/packages/typespec-python/CHANGELOG.md @@ -1,5 +1,9 @@ # Release +## 0.38.4 + +No changes, version bump only. + ## 0.38.3 - [#3038](https://github.com/Azure/autorest.python/pull/3038) Fix crash when value of `--package-pprint-name` contains space diff --git a/packages/typespec-python/package.json b/packages/typespec-python/package.json index 6cd69383a72..984ac23651f 100644 --- a/packages/typespec-python/package.json +++ b/packages/typespec-python/package.json @@ -1,6 +1,6 @@ { "name": "@azure-tools/typespec-python", - "version": "0.38.3", + "version": "0.38.4", "author": "Microsoft Corporation", "description": "TypeSpec emitter for Python SDKs", "homepage": "https://github.com/Azure/autorest.python", @@ -89,4 +89,4 @@ "chalk": "5.3.0", "@types/fs-extra": "11.0.4" } -} \ No newline at end of file +} From 60bee32aebd1a49a0baf55c372347153e002fcd1 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Thu, 13 Feb 2025 17:32:47 +0800 Subject: [PATCH 11/14] fix test --- packages/typespec-python/scripts/eng/pylintrc | 2 +- packages/typespec-python/scripts/eng/regenerate.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/typespec-python/scripts/eng/pylintrc b/packages/typespec-python/scripts/eng/pylintrc index 4b6d4c1749c..802317e3fb9 100644 --- a/packages/typespec-python/scripts/eng/pylintrc +++ b/packages/typespec-python/scripts/eng/pylintrc @@ -17,7 +17,7 @@ enable=useless-suppression # too-many-arguments: Due to the nature of the CLI many commands have large arguments set which reflect in large arguments set in corresponding methods. # too-many-lines: Due to code generation many files end up with too many lines. # Let's black deal with bad-continuation -disable=missing-docstring,locally-disabled,fixme,cyclic-import,too-many-arguments,invalid-name,duplicate-code,too-few-public-methods,consider-using-f-string,super-with-arguments,redefined-builtin,import-outside-toplevel,client-suffix-needed,unnecessary-dunder-call,unnecessary-ellipsis,disallowed-name,consider-using-max-builtin,unknown-option-value,client-accepts-api-version-keyword +disable=missing-docstring,locally-disabled,fixme,cyclic-import,too-many-arguments,invalid-name,duplicate-code,too-few-public-methods,consider-using-f-string,super-with-arguments,redefined-builtin,import-outside-toplevel,client-suffix-needed,unnecessary-dunder-call,unnecessary-ellipsis,disallowed-name,consider-using-max-builtin,unknown-option-value [FORMAT] max-line-length=120 diff --git a/packages/typespec-python/scripts/eng/regenerate.ts b/packages/typespec-python/scripts/eng/regenerate.ts index e43dedf3b37..6c872705fd2 100644 --- a/packages/typespec-python/scripts/eng/regenerate.ts +++ b/packages/typespec-python/scripts/eng/regenerate.ts @@ -196,6 +196,9 @@ async function getSubdirectories(baseDir: string, flags: RegenerateFlags): Promi // after fix test generation for nested operation group, remove this check if (mainTspRelativePath.includes("client-operation-group")) return; + // after https://github.com/Azure/autorest.python/issues/3043 fixed, remove this check + if (mainTspRelativePath.includes("azure/client-generator-core/api-version")) return; + const hasMainTsp = await promises .access(mainTspPath) .then(() => true) From 6956f4678f1b88b34ce3a16914fa91c9707232dd Mon Sep 17 00:00:00 2001 From: AutoPrFromHttpClientPython Date: Thu, 13 Feb 2025 09:37:27 +0000 Subject: [PATCH 12/14] Update dependencies (2025-02-13 09:37:26) --- packages/autorest.python/package.json | 2 +- packages/typespec-python/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/autorest.python/package.json b/packages/autorest.python/package.json index 10dd7998004..7c1afb60bd9 100644 --- a/packages/autorest.python/package.json +++ b/packages/autorest.python/package.json @@ -47,4 +47,4 @@ "requirements.txt", "generator/" ] -} +} \ No newline at end of file diff --git a/packages/typespec-python/package.json b/packages/typespec-python/package.json index 984ac23651f..14e9262c2a2 100644 --- a/packages/typespec-python/package.json +++ b/packages/typespec-python/package.json @@ -89,4 +89,4 @@ "chalk": "5.3.0", "@types/fs-extra": "11.0.4" } -} +} \ No newline at end of file From 44575a53b398c0a7a0fbf1df497036fc3c489750 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Thu, 13 Feb 2025 11:02:32 +0000 Subject: [PATCH 13/14] update --- .../CHANGELOG.md | 5 - .../LICENSE | 21 - .../MANIFEST.in | 8 - .../README.md | 45 - .../apiview-properties.json | 6 - .../client/__init__.py | 1 - .../client/alternateapiversion/__init__.py | 1 - .../alternateapiversion/service/__init__.py | 1 - .../service/header/__init__.py | 32 - .../service/header/_client.py | 94 - .../service/header/_configuration.py | 47 - .../service/header/_model_base.py | 1235 ---------- .../service/header/_operations/__init__.py | 25 - .../service/header/_operations/_operations.py | 96 - .../service/header/_operations/_patch.py | 20 - .../service/header/_patch.py | 20 - .../service/header/_serialization.py | 2050 ----------------- .../service/header/_vendor.py | 25 - .../service/header/_version.py | 9 - .../service/header/aio/__init__.py | 29 - .../service/header/aio/_client.py | 96 - .../service/header/aio/_configuration.py | 47 - .../header/aio/_operations/__init__.py | 25 - .../header/aio/_operations/_operations.py | 80 - .../service/header/aio/_operations/_patch.py | 20 - .../service/header/aio/_patch.py | 20 - .../service/header/aio/_vendor.py | 25 - .../service/header/py.typed | 1 - .../dev_requirements.txt | 3 - .../generated_tests/conftest.py | 35 - .../generated_tests/test_header.py | 22 - .../generated_tests/test_header_async.py | 23 - .../generated_tests/testpreparer.py | 24 - .../generated_tests/testpreparer_async.py | 20 - .../setup.py | 72 - .../CHANGELOG.md | 5 - .../LICENSE | 21 - .../MANIFEST.in | 8 - .../README.md | 45 - .../apiview-properties.json | 6 - .../client/__init__.py | 1 - .../client/alternateapiversion/__init__.py | 1 - .../alternateapiversion/service/__init__.py | 1 - .../service/path/__init__.py | 32 - .../service/path/_client.py | 94 - .../service/path/_configuration.py | 47 - .../service/path/_model_base.py | 1235 ---------- .../service/path/_operations/__init__.py | 25 - .../service/path/_operations/_operations.py | 95 - .../service/path/_operations/_patch.py | 20 - .../service/path/_patch.py | 20 - .../service/path/_serialization.py | 2050 ----------------- .../service/path/_vendor.py | 25 - .../service/path/_version.py | 9 - .../service/path/aio/__init__.py | 29 - .../service/path/aio/_client.py | 96 - .../service/path/aio/_configuration.py | 47 - .../service/path/aio/_operations/__init__.py | 25 - .../path/aio/_operations/_operations.py | 80 - .../service/path/aio/_operations/_patch.py | 20 - .../service/path/aio/_patch.py | 20 - .../service/path/aio/_vendor.py | 25 - .../alternateapiversion/service/path/py.typed | 1 - .../dev_requirements.txt | 3 - .../generated_tests/conftest.py | 35 - .../generated_tests/test_path.py | 22 - .../generated_tests/test_path_async.py | 23 - .../generated_tests/testpreparer.py | 24 - .../generated_tests/testpreparer_async.py | 20 - .../setup.py | 72 - .../CHANGELOG.md | 5 - .../LICENSE | 21 - .../MANIFEST.in | 8 - .../README.md | 45 - .../apiview-properties.json | 6 - .../client/__init__.py | 1 - .../client/alternateapiversion/__init__.py | 1 - .../alternateapiversion/service/__init__.py | 1 - .../service/query/__init__.py | 32 - .../service/query/_client.py | 94 - .../service/query/_configuration.py | 47 - .../service/query/_model_base.py | 1235 ---------- .../service/query/_operations/__init__.py | 25 - .../service/query/_operations/_operations.py | 96 - .../service/query/_operations/_patch.py | 20 - .../service/query/_patch.py | 20 - .../service/query/_serialization.py | 2050 ----------------- .../service/query/_vendor.py | 25 - .../service/query/_version.py | 9 - .../service/query/aio/__init__.py | 29 - .../service/query/aio/_client.py | 96 - .../service/query/aio/_configuration.py | 47 - .../service/query/aio/_operations/__init__.py | 25 - .../query/aio/_operations/_operations.py | 80 - .../service/query/aio/_operations/_patch.py | 20 - .../service/query/aio/_patch.py | 20 - .../service/query/aio/_vendor.py | 25 - .../service/query/py.typed | 1 - .../dev_requirements.txt | 3 - .../generated_tests/conftest.py | 35 - .../generated_tests/test_query.py | 22 - .../generated_tests/test_query_async.py | 23 - .../generated_tests/testpreparer.py | 24 - .../generated_tests/testpreparer_async.py | 20 - .../setup.py | 72 - 105 files changed, 12848 deletions(-) delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/CHANGELOG.md delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/LICENSE delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/MANIFEST.in delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/README.md delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/apiview-properties.json delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/__init__.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/__init__.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/__init__.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/__init__.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_client.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_configuration.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_model_base.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_operations/__init__.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_operations/_operations.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_operations/_patch.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_patch.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_serialization.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_vendor.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_version.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/__init__.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_client.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_configuration.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_operations/__init__.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_operations/_operations.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_operations/_patch.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_patch.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_vendor.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/py.typed delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/dev_requirements.txt delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/conftest.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/test_header.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/test_header_async.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/testpreparer.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/testpreparer_async.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/setup.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/CHANGELOG.md delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/LICENSE delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/MANIFEST.in delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/README.md delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/apiview-properties.json delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/__init__.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/__init__.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/__init__.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/__init__.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_client.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_configuration.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_model_base.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_operations/__init__.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_operations/_operations.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_operations/_patch.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_patch.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_serialization.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_vendor.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_version.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/__init__.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_client.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_configuration.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_operations/__init__.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_operations/_operations.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_operations/_patch.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_patch.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_vendor.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/py.typed delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/dev_requirements.txt delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/conftest.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/test_path.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/test_path_async.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/testpreparer.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/testpreparer_async.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/setup.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/CHANGELOG.md delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/LICENSE delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/MANIFEST.in delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/README.md delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/apiview-properties.json delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/__init__.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/__init__.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/__init__.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/__init__.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_client.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_configuration.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_model_base.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_operations/__init__.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_operations/_operations.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_operations/_patch.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_patch.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_serialization.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_vendor.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_version.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/__init__.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_client.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_configuration.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_operations/__init__.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_operations/_operations.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_operations/_patch.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_patch.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_vendor.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/py.typed delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/dev_requirements.txt delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/conftest.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/test_query.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/test_query_async.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/testpreparer.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/testpreparer_async.py delete mode 100644 packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/setup.py diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/CHANGELOG.md b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/CHANGELOG.md deleted file mode 100644 index 628743d283a..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/CHANGELOG.md +++ /dev/null @@ -1,5 +0,0 @@ -# Release History - -## 1.0.0b1 (1970-01-01) - -- Initial version diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/LICENSE b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/LICENSE deleted file mode 100644 index 63447fd8bbb..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -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. \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/MANIFEST.in b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/MANIFEST.in deleted file mode 100644 index 0c8c941a444..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/MANIFEST.in +++ /dev/null @@ -1,8 +0,0 @@ -include *.md -include LICENSE -include client/alternateapiversion/service/header/py.typed -recursive-include tests *.py -recursive-include samples *.py *.md -include client/__init__.py -include client/alternateapiversion/__init__.py -include client/alternateapiversion/service/__init__.py \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/README.md b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/README.md deleted file mode 100644 index 9cb0388f158..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/README.md +++ /dev/null @@ -1,45 +0,0 @@ - - -# Client Alternateapiversion Service Header client library for Python - - -## Getting started - -### Install the package - -```bash -python -m pip install client-alternateapiversion-service-header -``` - -#### 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 Client Alternateapiversion Service Header 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 opencode@microsoft.com with any -additional questions or comments. - - -[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/ - diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/apiview-properties.json b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/apiview-properties.json deleted file mode 100644 index 59f18237883..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/apiview-properties.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "CrossLanguagePackageId": "Client.AlternateApiVersion.Service.Header", - "CrossLanguageDefinitionId": { - "client.alternateapiversion.service.header.HeaderClient.header_api_version": "Client.AlternateApiVersion.Service.Header.headerApiVersion" - } -} \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/__init__.py deleted file mode 100644 index d55ccad1f57..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/__init__.py deleted file mode 100644 index d55ccad1f57..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/__init__.py deleted file mode 100644 index d55ccad1f57..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/__init__.py deleted file mode 100644 index b4f101648cc..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._client import HeaderClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "HeaderClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore - -_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_client.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_client.py deleted file mode 100644 index c836af11b71..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_client.py +++ /dev/null @@ -1,94 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any -from typing_extensions import Self - -from azure.core import PipelineClient -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse - -from ._configuration import HeaderClientConfiguration -from ._operations import HeaderClientOperationsMixin -from ._serialization import Deserializer, Serializer - - -class HeaderClient(HeaderClientOperationsMixin): - """HeaderClient. - - :keyword endpoint: Service host. Default value is "http://localhost:3000". - :paramtype endpoint: str - :keyword version: Default value is "2025-01-01". Note that overriding this default value may - result in unsupported behavior. - :paramtype version: str - """ - - def __init__( # pylint: disable=missing-client-constructor-parameter-credential - self, *, endpoint: str = "http://localhost:3000", **kwargs: Any - ) -> None: - _endpoint = "{endpoint}" - self._config = HeaderClientConfiguration(endpoint=endpoint, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs) - - self._serialize = Serializer() - self._deserialize = Deserializer() - self._serialize.client_side_validation = False - - def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client.send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_configuration.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_configuration.py deleted file mode 100644 index e0b34da732f..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_configuration.py +++ /dev/null @@ -1,47 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any - -from azure.core.pipeline import policies - -from ._version import VERSION - - -class HeaderClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for HeaderClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param endpoint: Service host. Default value is "http://localhost:3000". - :type endpoint: str - :keyword version: Default value is "2025-01-01". Note that overriding this default value may - result in unsupported behavior. - :paramtype version: str - """ - - def __init__(self, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None: - version: str = kwargs.pop("version", "2025-01-01") - - self.endpoint = endpoint - self.version = version - kwargs.setdefault("sdk_moniker", "client-alternateapiversion-service-header/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_model_base.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_model_base.py deleted file mode 100644 index 3072ee252ed..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_model_base.py +++ /dev/null @@ -1,1235 +0,0 @@ -# pylint: disable=too-many-lines -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=protected-access, broad-except - -import copy -import calendar -import decimal -import functools -import sys -import logging -import base64 -import re -import typing -import enum -import email.utils -from datetime import datetime, date, time, timedelta, timezone -from json import JSONEncoder -import xml.etree.ElementTree as ET -from typing_extensions import Self -import isodate -from azure.core.exceptions import DeserializationError -from azure.core import CaseInsensitiveEnumMeta -from azure.core.pipeline import PipelineResponse -from azure.core.serialization import _Null - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping - -_LOGGER = logging.getLogger(__name__) - -__all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] - -TZ_UTC = timezone.utc -_T = typing.TypeVar("_T") - - -def _timedelta_as_isostr(td: timedelta) -> str: - """Converts a datetime.timedelta object into an ISO 8601 formatted string, e.g. 'P4DT12H30M05S' - - Function adapted from the Tin Can Python project: https://github.com/RusticiSoftware/TinCanPython - - :param timedelta td: The timedelta to convert - :rtype: str - :return: ISO8601 version of this timedelta - """ - - # Split seconds to larger units - seconds = td.total_seconds() - minutes, seconds = divmod(seconds, 60) - hours, minutes = divmod(minutes, 60) - days, hours = divmod(hours, 24) - - days, hours, minutes = list(map(int, (days, hours, minutes))) - seconds = round(seconds, 6) - - # Build date - date_str = "" - if days: - date_str = "%sD" % days - - if hours or minutes or seconds: - # Build time - time_str = "T" - - # Hours - bigger_exists = date_str or hours - if bigger_exists: - time_str += "{:02}H".format(hours) - - # Minutes - bigger_exists = bigger_exists or minutes - if bigger_exists: - time_str += "{:02}M".format(minutes) - - # Seconds - try: - if seconds.is_integer(): - seconds_string = "{:02}".format(int(seconds)) - else: - # 9 chars long w/ leading 0, 6 digits after decimal - seconds_string = "%09.6f" % seconds - # Remove trailing zeros - seconds_string = seconds_string.rstrip("0") - except AttributeError: # int.is_integer() raises - seconds_string = "{:02}".format(seconds) - - time_str += "{}S".format(seconds_string) - else: - time_str = "" - - return "P" + date_str + time_str - - -def _serialize_bytes(o, format: typing.Optional[str] = None) -> str: - encoded = base64.b64encode(o).decode() - if format == "base64url": - return encoded.strip("=").replace("+", "-").replace("/", "_") - return encoded - - -def _serialize_datetime(o, format: typing.Optional[str] = None): - if hasattr(o, "year") and hasattr(o, "hour"): - if format == "rfc7231": - return email.utils.format_datetime(o, usegmt=True) - if format == "unix-timestamp": - return int(calendar.timegm(o.utctimetuple())) - - # astimezone() fails for naive times in Python 2.7, so make make sure o is aware (tzinfo is set) - if not o.tzinfo: - iso_formatted = o.replace(tzinfo=TZ_UTC).isoformat() - else: - iso_formatted = o.astimezone(TZ_UTC).isoformat() - # Replace the trailing "+00:00" UTC offset with "Z" (RFC 3339: https://www.ietf.org/rfc/rfc3339.txt) - return iso_formatted.replace("+00:00", "Z") - # Next try datetime.date or datetime.time - return o.isoformat() - - -def _is_readonly(p): - try: - return p._visibility == ["read"] - except AttributeError: - return False - - -class SdkJSONEncoder(JSONEncoder): - """A JSON encoder that's capable of serializing datetime objects and bytes.""" - - def __init__(self, *args, exclude_readonly: bool = False, format: typing.Optional[str] = None, **kwargs): - super().__init__(*args, **kwargs) - self.exclude_readonly = exclude_readonly - self.format = format - - def default(self, o): # pylint: disable=too-many-return-statements - if _is_model(o): - if self.exclude_readonly: - readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] - return {k: v for k, v in o.items() if k not in readonly_props} - return dict(o.items()) - try: - return super(SdkJSONEncoder, self).default(o) - except TypeError: - if isinstance(o, _Null): - return None - if isinstance(o, decimal.Decimal): - return float(o) - if isinstance(o, (bytes, bytearray)): - return _serialize_bytes(o, self.format) - try: - # First try datetime.datetime - return _serialize_datetime(o, self.format) - except AttributeError: - pass - # Last, try datetime.timedelta - try: - return _timedelta_as_isostr(o) - except AttributeError: - # This will be raised when it hits value.total_seconds in the method above - pass - return super(SdkJSONEncoder, self).default(o) - - -_VALID_DATE = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" + r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") -_VALID_RFC7231 = re.compile( - r"(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s\d{2}\s" - r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT" -) - - -def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: - """Deserialize ISO-8601 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :rtype: ~datetime.datetime - :returns: The datetime object from that input - """ - if isinstance(attr, datetime): - # i'm already deserialized - return attr - attr = attr.upper() - match = _VALID_DATE.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - check_decimal = attr.split(".") - if len(check_decimal) > 1: - decimal_str = "" - for digit in check_decimal[1]: - if digit.isdigit(): - decimal_str += digit - else: - break - if len(decimal_str) > 6: - attr = attr.replace(decimal_str, decimal_str[0:6]) - - date_obj = isodate.parse_datetime(attr) - test_utc = date_obj.utctimetuple() - if test_utc.tm_year > 9999 or test_utc.tm_year < 1: - raise OverflowError("Hit max or min date") - return date_obj - - -def _deserialize_datetime_rfc7231(attr: typing.Union[str, datetime]) -> datetime: - """Deserialize RFC7231 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :rtype: ~datetime.datetime - :returns: The datetime object from that input - """ - if isinstance(attr, datetime): - # i'm already deserialized - return attr - match = _VALID_RFC7231.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - return email.utils.parsedate_to_datetime(attr) - - -def _deserialize_datetime_unix_timestamp(attr: typing.Union[float, datetime]) -> datetime: - """Deserialize unix timestamp into Datetime object. - - :param str attr: response string to be deserialized. - :rtype: ~datetime.datetime - :returns: The datetime object from that input - """ - if isinstance(attr, datetime): - # i'm already deserialized - return attr - return datetime.fromtimestamp(attr, TZ_UTC) - - -def _deserialize_date(attr: typing.Union[str, date]) -> date: - """Deserialize ISO-8601 formatted string into Date object. - :param str attr: response string to be deserialized. - :rtype: date - :returns: The date object from that input - """ - # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - if isinstance(attr, date): - return attr - return isodate.parse_date(attr, defaultmonth=None, defaultday=None) # type: ignore - - -def _deserialize_time(attr: typing.Union[str, time]) -> time: - """Deserialize ISO-8601 formatted string into time object. - - :param str attr: response string to be deserialized. - :rtype: datetime.time - :returns: The time object from that input - """ - if isinstance(attr, time): - return attr - return isodate.parse_time(attr) - - -def _deserialize_bytes(attr): - if isinstance(attr, (bytes, bytearray)): - return attr - return bytes(base64.b64decode(attr)) - - -def _deserialize_bytes_base64(attr): - if isinstance(attr, (bytes, bytearray)): - return attr - padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore - attr = attr + padding # type: ignore - encoded = attr.replace("-", "+").replace("_", "/") - return bytes(base64.b64decode(encoded)) - - -def _deserialize_duration(attr): - if isinstance(attr, timedelta): - return attr - return isodate.parse_duration(attr) - - -def _deserialize_decimal(attr): - if isinstance(attr, decimal.Decimal): - return attr - return decimal.Decimal(str(attr)) - - -def _deserialize_int_as_str(attr): - if isinstance(attr, int): - return attr - return int(attr) - - -_DESERIALIZE_MAPPING = { - datetime: _deserialize_datetime, - date: _deserialize_date, - time: _deserialize_time, - bytes: _deserialize_bytes, - bytearray: _deserialize_bytes, - timedelta: _deserialize_duration, - typing.Any: lambda x: x, - decimal.Decimal: _deserialize_decimal, -} - -_DESERIALIZE_MAPPING_WITHFORMAT = { - "rfc3339": _deserialize_datetime, - "rfc7231": _deserialize_datetime_rfc7231, - "unix-timestamp": _deserialize_datetime_unix_timestamp, - "base64": _deserialize_bytes, - "base64url": _deserialize_bytes_base64, -} - - -def get_deserializer(annotation: typing.Any, rf: typing.Optional["_RestField"] = None): - if annotation is int and rf and rf._format == "str": - return _deserialize_int_as_str - if rf and rf._format: - return _DESERIALIZE_MAPPING_WITHFORMAT.get(rf._format) - return _DESERIALIZE_MAPPING.get(annotation) # pyright: ignore - - -def _get_type_alias_type(module_name: str, alias_name: str): - types = { - k: v - for k, v in sys.modules[module_name].__dict__.items() - if isinstance(v, typing._GenericAlias) # type: ignore - } - if alias_name not in types: - return alias_name - return types[alias_name] - - -def _get_model(module_name: str, model_name: str): - models = {k: v for k, v in sys.modules[module_name].__dict__.items() if isinstance(v, type)} - module_end = module_name.rsplit(".", 1)[0] - models.update({k: v for k, v in sys.modules[module_end].__dict__.items() if isinstance(v, type)}) - if isinstance(model_name, str): - model_name = model_name.split(".")[-1] - if model_name not in models: - return model_name - return models[model_name] - - -_UNSET = object() - - -class _MyMutableMapping(MutableMapping[str, typing.Any]): # pylint: disable=unsubscriptable-object - def __init__(self, data: typing.Dict[str, typing.Any]) -> None: - self._data = data - - def __contains__(self, key: typing.Any) -> bool: - return key in self._data - - def __getitem__(self, key: str) -> typing.Any: - return self._data.__getitem__(key) - - def __setitem__(self, key: str, value: typing.Any) -> None: - self._data.__setitem__(key, value) - - def __delitem__(self, key: str) -> None: - self._data.__delitem__(key) - - def __iter__(self) -> typing.Iterator[typing.Any]: - return self._data.__iter__() - - def __len__(self) -> int: - return self._data.__len__() - - def __ne__(self, other: typing.Any) -> bool: - return not self.__eq__(other) - - def keys(self) -> typing.KeysView[str]: - """ - :returns: a set-like object providing a view on D's keys - :rtype: ~typing.KeysView - """ - return self._data.keys() - - def values(self) -> typing.ValuesView[typing.Any]: - """ - :returns: an object providing a view on D's values - :rtype: ~typing.ValuesView - """ - return self._data.values() - - def items(self) -> typing.ItemsView[str, typing.Any]: - """ - :returns: set-like object providing a view on D's items - :rtype: ~typing.ItemsView - """ - return self._data.items() - - def get(self, key: str, default: typing.Any = None) -> typing.Any: - """ - Get the value for key if key is in the dictionary, else default. - :param str key: The key to look up. - :param any default: The value to return if key is not in the dictionary. Defaults to None - :returns: D[k] if k in D, else d. - :rtype: any - """ - try: - return self[key] - except KeyError: - return default - - @typing.overload - def pop(self, key: str) -> typing.Any: ... - - @typing.overload - def pop(self, key: str, default: _T) -> _T: ... - - @typing.overload - def pop(self, key: str, default: typing.Any) -> typing.Any: ... - - def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: - """ - Removes specified key and return the corresponding value. - :param str key: The key to pop. - :param any default: The value to return if key is not in the dictionary - :returns: The value corresponding to the key. - :rtype: any - :raises KeyError: If key is not found and default is not given. - """ - if default is _UNSET: - return self._data.pop(key) - return self._data.pop(key, default) - - def popitem(self) -> typing.Tuple[str, typing.Any]: - """ - Removes and returns some (key, value) pair - :returns: The (key, value) pair. - :rtype: tuple - :raises KeyError: if D is empty. - """ - return self._data.popitem() - - def clear(self) -> None: - """ - Remove all items from D. - """ - self._data.clear() - - def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: - """ - Updates D from mapping/iterable E and F. - :param any args: Either a mapping object or an iterable of key-value pairs. - """ - self._data.update(*args, **kwargs) - - @typing.overload - def setdefault(self, key: str, default: None = None) -> None: ... - - @typing.overload - def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... - - def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: - """ - Same as calling D.get(k, d), and setting D[k]=d if k not found - :param str key: The key to look up. - :param any default: The value to set if key is not in the dictionary - :returns: D[k] if k in D, else d. - :rtype: any - """ - if default is _UNSET: - return self._data.setdefault(key) - return self._data.setdefault(key, default) - - def __eq__(self, other: typing.Any) -> bool: - try: - other_model = self.__class__(other) - except Exception: - return False - return self._data == other_model._data - - def __repr__(self) -> str: - return str(self._data) - - -def _is_model(obj: typing.Any) -> bool: - return getattr(obj, "_is_model", False) - - -def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-many-return-statements - if isinstance(o, list): - return [_serialize(x, format) for x in o] - if isinstance(o, dict): - return {k: _serialize(v, format) for k, v in o.items()} - if isinstance(o, set): - return {_serialize(x, format) for x in o} - if isinstance(o, tuple): - return tuple(_serialize(x, format) for x in o) - if isinstance(o, (bytes, bytearray)): - return _serialize_bytes(o, format) - if isinstance(o, decimal.Decimal): - return float(o) - if isinstance(o, enum.Enum): - return o.value - if isinstance(o, int): - if format == "str": - return str(o) - return o - try: - # First try datetime.datetime - return _serialize_datetime(o, format) - except AttributeError: - pass - # Last, try datetime.timedelta - try: - return _timedelta_as_isostr(o) - except AttributeError: - # This will be raised when it hits value.total_seconds in the method above - pass - return o - - -def _get_rest_field( - attr_to_rest_field: typing.Dict[str, "_RestField"], rest_name: str -) -> typing.Optional["_RestField"]: - try: - return next(rf for rf in attr_to_rest_field.values() if rf._rest_name == rest_name) - except StopIteration: - return None - - -def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typing.Any: - if not rf: - return _serialize(value, None) - if rf._is_multipart_file_input: - return value - if rf._is_model: - return _deserialize(rf._type, value) - if isinstance(value, ET.Element): - value = _deserialize(rf._type, value) - return _serialize(value, rf._format) - - -class Model(_MyMutableMapping): - _is_model = True - # label whether current class's _attr_to_rest_field has been calculated - # could not see _attr_to_rest_field directly because subclass inherits it from parent class - _calculated: typing.Set[str] = set() - - def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: - class_name = self.__class__.__name__ - if len(args) > 1: - raise TypeError(f"{class_name}.__init__() takes 2 positional arguments but {len(args) + 1} were given") - dict_to_pass = { - rest_field._rest_name: rest_field._default - for rest_field in self._attr_to_rest_field.values() - if rest_field._default is not _UNSET - } - if args: # pylint: disable=too-many-nested-blocks - if isinstance(args[0], ET.Element): - existed_attr_keys = [] - model_meta = getattr(self, "_xml", {}) - - for rf in self._attr_to_rest_field.values(): - prop_meta = getattr(rf, "_xml", {}) - xml_name = prop_meta.get("name", rf._rest_name) - xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) - if xml_ns: - xml_name = "{" + xml_ns + "}" + xml_name - - # attribute - if prop_meta.get("attribute", False) and args[0].get(xml_name) is not None: - existed_attr_keys.append(xml_name) - dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].get(xml_name)) - continue - - # unwrapped element is array - if prop_meta.get("unwrapped", False): - # unwrapped array could either use prop items meta/prop meta - if prop_meta.get("itemsName"): - xml_name = prop_meta.get("itemsName") - xml_ns = prop_meta.get("itemNs") - if xml_ns: - xml_name = "{" + xml_ns + "}" + xml_name - items = args[0].findall(xml_name) # pyright: ignore - if len(items) > 0: - existed_attr_keys.append(xml_name) - dict_to_pass[rf._rest_name] = _deserialize(rf._type, items) - continue - - # text element is primitive type - if prop_meta.get("text", False): - if args[0].text is not None: - dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].text) - continue - - # wrapped element could be normal property or array, it should only have one element - item = args[0].find(xml_name) - if item is not None: - existed_attr_keys.append(xml_name) - dict_to_pass[rf._rest_name] = _deserialize(rf._type, item) - - # rest thing is additional properties - for e in args[0]: - if e.tag not in existed_attr_keys: - dict_to_pass[e.tag] = _convert_element(e) - else: - dict_to_pass.update( - {k: _create_value(_get_rest_field(self._attr_to_rest_field, k), v) for k, v in args[0].items()} - ) - else: - non_attr_kwargs = [k for k in kwargs if k not in self._attr_to_rest_field] - if non_attr_kwargs: - # actual type errors only throw the first wrong keyword arg they see, so following that. - raise TypeError(f"{class_name}.__init__() got an unexpected keyword argument '{non_attr_kwargs[0]}'") - dict_to_pass.update( - { - self._attr_to_rest_field[k]._rest_name: _create_value(self._attr_to_rest_field[k], v) - for k, v in kwargs.items() - if v is not None - } - ) - super().__init__(dict_to_pass) - - def copy(self) -> "Model": - return Model(self.__dict__) - - def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: - if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated: - # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', - # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' - mros = cls.__mro__[:-9][::-1] # ignore parents, and reverse the mro order - attr_to_rest_field: typing.Dict[str, _RestField] = { # map attribute name to rest_field property - k: v for mro_class in mros for k, v in mro_class.__dict__.items() if k[0] != "_" and hasattr(v, "_type") - } - annotations = { - k: v - for mro_class in mros - if hasattr(mro_class, "__annotations__") - for k, v in mro_class.__annotations__.items() - } - for attr, rf in attr_to_rest_field.items(): - rf._module = cls.__module__ - if not rf._type: - rf._type = rf._get_deserialize_callable_from_annotation(annotations.get(attr, None)) - if not rf._rest_name_input: - rf._rest_name_input = attr - cls._attr_to_rest_field: typing.Dict[str, _RestField] = dict(attr_to_rest_field.items()) - cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") - - return super().__new__(cls) # pylint: disable=no-value-for-parameter - - def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: - for base in cls.__bases__: - if hasattr(base, "__mapping__"): - base.__mapping__[discriminator or cls.__name__] = cls # type: ignore - - @classmethod - def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]: - for v in cls.__dict__.values(): - if isinstance(v, _RestField) and v._is_discriminator and v._rest_name not in exist_discriminators: - return v - return None - - @classmethod - def _deserialize(cls, data, exist_discriminators): - if not hasattr(cls, "__mapping__"): - return cls(data) - discriminator = cls._get_discriminator(exist_discriminators) - if discriminator is None: - return cls(data) - exist_discriminators.append(discriminator._rest_name) - if isinstance(data, ET.Element): - model_meta = getattr(cls, "_xml", {}) - prop_meta = getattr(discriminator, "_xml", {}) - xml_name = prop_meta.get("name", discriminator._rest_name) - xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) - if xml_ns: - xml_name = "{" + xml_ns + "}" + xml_name - - if data.get(xml_name) is not None: - discriminator_value = data.get(xml_name) - else: - discriminator_value = data.find(xml_name).text # pyright: ignore - else: - discriminator_value = data.get(discriminator._rest_name) - mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore - return mapped_cls._deserialize(data, exist_discriminators) - - def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.Any]: - """Return a dict that can be turned into json using json.dump. - - :keyword bool exclude_readonly: Whether to remove the readonly properties. - :returns: A dict JSON compatible object - :rtype: dict - """ - - result = {} - readonly_props = [] - if exclude_readonly: - readonly_props = [p._rest_name for p in self._attr_to_rest_field.values() if _is_readonly(p)] - for k, v in self.items(): - if exclude_readonly and k in readonly_props: # pyright: ignore - continue - is_multipart_file_input = False - try: - is_multipart_file_input = next( - rf for rf in self._attr_to_rest_field.values() if rf._rest_name == k - )._is_multipart_file_input - except StopIteration: - pass - result[k] = v if is_multipart_file_input else Model._as_dict_value(v, exclude_readonly=exclude_readonly) - return result - - @staticmethod - def _as_dict_value(v: typing.Any, exclude_readonly: bool = False) -> typing.Any: - if v is None or isinstance(v, _Null): - return None - if isinstance(v, (list, tuple, set)): - return type(v)(Model._as_dict_value(x, exclude_readonly=exclude_readonly) for x in v) - if isinstance(v, dict): - return {dk: Model._as_dict_value(dv, exclude_readonly=exclude_readonly) for dk, dv in v.items()} - return v.as_dict(exclude_readonly=exclude_readonly) if hasattr(v, "as_dict") else v - - -def _deserialize_model(model_deserializer: typing.Optional[typing.Callable], obj): - if _is_model(obj): - return obj - return _deserialize(model_deserializer, obj) - - -def _deserialize_with_optional(if_obj_deserializer: typing.Optional[typing.Callable], obj): - if obj is None: - return obj - return _deserialize_with_callable(if_obj_deserializer, obj) - - -def _deserialize_with_union(deserializers, obj): - for deserializer in deserializers: - try: - return _deserialize(deserializer, obj) - except DeserializationError: - pass - raise DeserializationError() - - -def _deserialize_dict( - value_deserializer: typing.Optional[typing.Callable], - module: typing.Optional[str], - obj: typing.Dict[typing.Any, typing.Any], -): - if obj is None: - return obj - if isinstance(obj, ET.Element): - obj = {child.tag: child for child in obj} - return {k: _deserialize(value_deserializer, v, module) for k, v in obj.items()} - - -def _deserialize_multiple_sequence( - entry_deserializers: typing.List[typing.Optional[typing.Callable]], - module: typing.Optional[str], - obj, -): - if obj is None: - return obj - return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers)) - - -def _deserialize_sequence( - deserializer: typing.Optional[typing.Callable], - module: typing.Optional[str], - obj, -): - if obj is None: - return obj - if isinstance(obj, ET.Element): - obj = list(obj) - return type(obj)(_deserialize(deserializer, entry, module) for entry in obj) - - -def _sorted_annotations(types: typing.List[typing.Any]) -> typing.List[typing.Any]: - return sorted( - types, - key=lambda x: hasattr(x, "__name__") and x.__name__.lower() in ("str", "float", "int", "bool"), - ) - - -def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-branches - annotation: typing.Any, - module: typing.Optional[str], - rf: typing.Optional["_RestField"] = None, -) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: - if not annotation: - return None - - # is it a type alias? - if isinstance(annotation, str): - if module is not None: - annotation = _get_type_alias_type(module, annotation) - - # is it a forward ref / in quotes? - if isinstance(annotation, (str, typing.ForwardRef)): - try: - model_name = annotation.__forward_arg__ # type: ignore - except AttributeError: - model_name = annotation - if module is not None: - annotation = _get_model(module, model_name) # type: ignore - - try: - if module and _is_model(annotation): - if rf: - rf._is_model = True - - return functools.partial(_deserialize_model, annotation) # pyright: ignore - except Exception: - pass - - # is it a literal? - try: - if annotation.__origin__ is typing.Literal: # pyright: ignore - return None - except AttributeError: - pass - - # is it optional? - try: - if any(a for a in annotation.__args__ if a == type(None)): # pyright: ignore - if len(annotation.__args__) <= 2: # pyright: ignore - if_obj_deserializer = _get_deserialize_callable_from_annotation( - next(a for a in annotation.__args__ if a != type(None)), module, rf # pyright: ignore - ) - - return functools.partial(_deserialize_with_optional, if_obj_deserializer) - # the type is Optional[Union[...]], we need to remove the None type from the Union - annotation_copy = copy.copy(annotation) - annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a != type(None)] # pyright: ignore - return _get_deserialize_callable_from_annotation(annotation_copy, module, rf) - except AttributeError: - pass - - # is it union? - if getattr(annotation, "__origin__", None) is typing.Union: - # initial ordering is we make `string` the last deserialization option, because it is often them most generic - deserializers = [ - _get_deserialize_callable_from_annotation(arg, module, rf) - for arg in _sorted_annotations(annotation.__args__) # pyright: ignore - ] - - return functools.partial(_deserialize_with_union, deserializers) - - try: - if annotation._name == "Dict": # pyright: ignore - value_deserializer = _get_deserialize_callable_from_annotation( - annotation.__args__[1], module, rf # pyright: ignore - ) - - return functools.partial( - _deserialize_dict, - value_deserializer, - module, - ) - except (AttributeError, IndexError): - pass - try: - if annotation._name in ["List", "Set", "Tuple", "Sequence"]: # pyright: ignore - if len(annotation.__args__) > 1: # pyright: ignore - entry_deserializers = [ - _get_deserialize_callable_from_annotation(dt, module, rf) - for dt in annotation.__args__ # pyright: ignore - ] - return functools.partial(_deserialize_multiple_sequence, entry_deserializers, module) - deserializer = _get_deserialize_callable_from_annotation( - annotation.__args__[0], module, rf # pyright: ignore - ) - - return functools.partial(_deserialize_sequence, deserializer, module) - except (TypeError, IndexError, AttributeError, SyntaxError): - pass - - def _deserialize_default( - deserializer, - obj, - ): - if obj is None: - return obj - try: - return _deserialize_with_callable(deserializer, obj) - except Exception: - pass - return obj - - if get_deserializer(annotation, rf): - return functools.partial(_deserialize_default, get_deserializer(annotation, rf)) - - return functools.partial(_deserialize_default, annotation) - - -def _deserialize_with_callable( - deserializer: typing.Optional[typing.Callable[[typing.Any], typing.Any]], - value: typing.Any, -): # pylint: disable=too-many-return-statements - try: - if value is None or isinstance(value, _Null): - return None - if isinstance(value, ET.Element): - if deserializer is str: - return value.text or "" - if deserializer is int: - return int(value.text) if value.text else None - if deserializer is float: - return float(value.text) if value.text else None - if deserializer is bool: - return value.text == "true" if value.text else None - if deserializer is None: - return value - if deserializer in [int, float, bool]: - return deserializer(value) - if isinstance(deserializer, CaseInsensitiveEnumMeta): - try: - return deserializer(value) - except ValueError: - # for unknown value, return raw value - return value - if isinstance(deserializer, type) and issubclass(deserializer, Model): - return deserializer._deserialize(value, []) - return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value) - except Exception as e: - raise DeserializationError() from e - - -def _deserialize( - deserializer: typing.Any, - value: typing.Any, - module: typing.Optional[str] = None, - rf: typing.Optional["_RestField"] = None, - format: typing.Optional[str] = None, -) -> typing.Any: - if isinstance(value, PipelineResponse): - value = value.http_response.json() - if rf is None and format: - rf = _RestField(format=format) - if not isinstance(deserializer, functools.partial): - deserializer = _get_deserialize_callable_from_annotation(deserializer, module, rf) - return _deserialize_with_callable(deserializer, value) - - -def _failsafe_deserialize( - deserializer: typing.Any, - value: typing.Any, - module: typing.Optional[str] = None, - rf: typing.Optional["_RestField"] = None, - format: typing.Optional[str] = None, -) -> typing.Any: - try: - return _deserialize(deserializer, value, module, rf, format) - except DeserializationError: - _LOGGER.warning( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - -def _failsafe_deserialize_xml( - deserializer: typing.Any, - value: typing.Any, -) -> typing.Any: - try: - return _deserialize_xml(deserializer, value) - except DeserializationError: - _LOGGER.warning( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - -class _RestField: - def __init__( - self, - *, - name: typing.Optional[str] = None, - type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin - is_discriminator: bool = False, - visibility: typing.Optional[typing.List[str]] = None, - default: typing.Any = _UNSET, - format: typing.Optional[str] = None, - is_multipart_file_input: bool = False, - xml: typing.Optional[typing.Dict[str, typing.Any]] = None, - ): - self._type = type - self._rest_name_input = name - self._module: typing.Optional[str] = None - self._is_discriminator = is_discriminator - self._visibility = visibility - self._is_model = False - self._default = default - self._format = format - self._is_multipart_file_input = is_multipart_file_input - self._xml = xml if xml is not None else {} - - @property - def _class_type(self) -> typing.Any: - return getattr(self._type, "args", [None])[0] - - @property - def _rest_name(self) -> str: - if self._rest_name_input is None: - raise ValueError("Rest name was never set") - return self._rest_name_input - - def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin - # by this point, type and rest_name will have a value bc we default - # them in __new__ of the Model class - item = obj.get(self._rest_name) - if item is None: - return item - if self._is_model: - return item - return _deserialize(self._type, _serialize(item, self._format), rf=self) - - def __set__(self, obj: Model, value) -> None: - if value is None: - # we want to wipe out entries if users set attr to None - try: - obj.__delitem__(self._rest_name) - except KeyError: - pass - return - if self._is_model: - if not _is_model(value): - value = _deserialize(self._type, value) - obj.__setitem__(self._rest_name, value) - return - obj.__setitem__(self._rest_name, _serialize(value, self._format)) - - def _get_deserialize_callable_from_annotation( - self, annotation: typing.Any - ) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: - return _get_deserialize_callable_from_annotation(annotation, self._module, self) - - -def rest_field( - *, - name: typing.Optional[str] = None, - type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin - visibility: typing.Optional[typing.List[str]] = None, - default: typing.Any = _UNSET, - format: typing.Optional[str] = None, - is_multipart_file_input: bool = False, - xml: typing.Optional[typing.Dict[str, typing.Any]] = None, -) -> typing.Any: - return _RestField( - name=name, - type=type, - visibility=visibility, - default=default, - format=format, - is_multipart_file_input=is_multipart_file_input, - xml=xml, - ) - - -def rest_discriminator( - *, - name: typing.Optional[str] = None, - type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin - visibility: typing.Optional[typing.List[str]] = None, - xml: typing.Optional[typing.Dict[str, typing.Any]] = None, -) -> typing.Any: - return _RestField(name=name, type=type, is_discriminator=True, visibility=visibility, xml=xml) - - -def serialize_xml(model: Model, exclude_readonly: bool = False) -> str: - """Serialize a model to XML. - - :param Model model: The model to serialize. - :param bool exclude_readonly: Whether to exclude readonly properties. - :returns: The XML representation of the model. - :rtype: str - """ - return ET.tostring(_get_element(model, exclude_readonly), encoding="unicode") # type: ignore - - -def _get_element( - o: typing.Any, - exclude_readonly: bool = False, - parent_meta: typing.Optional[typing.Dict[str, typing.Any]] = None, - wrapped_element: typing.Optional[ET.Element] = None, -) -> typing.Union[ET.Element, typing.List[ET.Element]]: - if _is_model(o): - model_meta = getattr(o, "_xml", {}) - - # if prop is a model, then use the prop element directly, else generate a wrapper of model - if wrapped_element is None: - wrapped_element = _create_xml_element( - model_meta.get("name", o.__class__.__name__), - model_meta.get("prefix"), - model_meta.get("ns"), - ) - - readonly_props = [] - if exclude_readonly: - readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] - - for k, v in o.items(): - # do not serialize readonly properties - if exclude_readonly and k in readonly_props: - continue - - prop_rest_field = _get_rest_field(o._attr_to_rest_field, k) - if prop_rest_field: - prop_meta = getattr(prop_rest_field, "_xml").copy() - # use the wire name as xml name if no specific name is set - if prop_meta.get("name") is None: - prop_meta["name"] = k - else: - # additional properties will not have rest field, use the wire name as xml name - prop_meta = {"name": k} - - # if no ns for prop, use model's - if prop_meta.get("ns") is None and model_meta.get("ns"): - prop_meta["ns"] = model_meta.get("ns") - prop_meta["prefix"] = model_meta.get("prefix") - - if prop_meta.get("unwrapped", False): - # unwrapped could only set on array - wrapped_element.extend(_get_element(v, exclude_readonly, prop_meta)) - elif prop_meta.get("text", False): - # text could only set on primitive type - wrapped_element.text = _get_primitive_type_value(v) - elif prop_meta.get("attribute", False): - xml_name = prop_meta.get("name", k) - if prop_meta.get("ns"): - ET.register_namespace(prop_meta.get("prefix"), prop_meta.get("ns")) # pyright: ignore - xml_name = "{" + prop_meta.get("ns") + "}" + xml_name # pyright: ignore - # attribute should be primitive type - wrapped_element.set(xml_name, _get_primitive_type_value(v)) - else: - # other wrapped prop element - wrapped_element.append(_get_wrapped_element(v, exclude_readonly, prop_meta)) - return wrapped_element - if isinstance(o, list): - return [_get_element(x, exclude_readonly, parent_meta) for x in o] # type: ignore - if isinstance(o, dict): - result = [] - for k, v in o.items(): - result.append( - _get_wrapped_element( - v, - exclude_readonly, - { - "name": k, - "ns": parent_meta.get("ns") if parent_meta else None, - "prefix": parent_meta.get("prefix") if parent_meta else None, - }, - ) - ) - return result - - # primitive case need to create element based on parent_meta - if parent_meta: - return _get_wrapped_element( - o, - exclude_readonly, - { - "name": parent_meta.get("itemsName", parent_meta.get("name")), - "prefix": parent_meta.get("itemsPrefix", parent_meta.get("prefix")), - "ns": parent_meta.get("itemsNs", parent_meta.get("ns")), - }, - ) - - raise ValueError("Could not serialize value into xml: " + o) - - -def _get_wrapped_element( - v: typing.Any, - exclude_readonly: bool, - meta: typing.Optional[typing.Dict[str, typing.Any]], -) -> ET.Element: - wrapped_element = _create_xml_element( - meta.get("name") if meta else None, meta.get("prefix") if meta else None, meta.get("ns") if meta else None - ) - if isinstance(v, (dict, list)): - wrapped_element.extend(_get_element(v, exclude_readonly, meta)) - elif _is_model(v): - _get_element(v, exclude_readonly, meta, wrapped_element) - else: - wrapped_element.text = _get_primitive_type_value(v) - return wrapped_element - - -def _get_primitive_type_value(v) -> str: - if v is True: - return "true" - if v is False: - return "false" - if isinstance(v, _Null): - return "" - return str(v) - - -def _create_xml_element(tag, prefix=None, ns=None): - if prefix and ns: - ET.register_namespace(prefix, ns) - if ns: - return ET.Element("{" + ns + "}" + tag) - return ET.Element(tag) - - -def _deserialize_xml( - deserializer: typing.Any, - value: str, -) -> typing.Any: - element = ET.fromstring(value) # nosec - return _deserialize(deserializer, element) - - -def _convert_element(e: ET.Element): - # dict case - if len(e.attrib) > 0 or len({child.tag for child in e}) > 1: - dict_result: typing.Dict[str, typing.Any] = {} - for child in e: - if dict_result.get(child.tag) is not None: - if isinstance(dict_result[child.tag], list): - dict_result[child.tag].append(_convert_element(child)) - else: - dict_result[child.tag] = [dict_result[child.tag], _convert_element(child)] - else: - dict_result[child.tag] = _convert_element(child) - dict_result.update(e.attrib) - return dict_result - # array case - if len(e) > 0: - array_result: typing.List[typing.Any] = [] - for child in e: - array_result.append(_convert_element(child)) - return array_result - # primitive case - return e.text diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_operations/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_operations/__init__.py deleted file mode 100644 index f9c721d92b6..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_operations/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import HeaderClientOperationsMixin # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "HeaderClientOperationsMixin", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_operations/_operations.py deleted file mode 100644 index 75e2cff2876..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_operations/_operations.py +++ /dev/null @@ -1,96 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict - -from .._serialization import Serializer -from .._vendor import HeaderClientMixinABC - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_header_header_api_version_request(**kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - - version: str = kwargs.pop("version", _headers.pop("x-ms-version", "2025-01-01")) - # Construct URL - _url = "/azure/client-generator-core/api-version/header" - - # Construct headers - _headers["x-ms-version"] = _SERIALIZER.header("version", version, "str") - - return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) - - -class HeaderClientOperationsMixin(HeaderClientMixinABC): - - @distributed_trace - def header_api_version(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """Header api version parameter. - - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_header_header_api_version_request( - version=self._config.version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_operations/_patch.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_operations/_patch.py deleted file mode 100644 index f7dd3251033..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__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/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_patch.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_patch.py deleted file mode 100644 index f7dd3251033..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__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/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_serialization.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_serialization.py deleted file mode 100644 index e2a20b1d534..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_serialization.py +++ /dev/null @@ -1,2050 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# -------------------------------------------------------------------------- -# -# Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# 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. -# -# -------------------------------------------------------------------------- - -# pyright: reportUnnecessaryTypeIgnoreComment=false - -from base64 import b64decode, b64encode -import calendar -import datetime -import decimal -import email -from enum import Enum -import json -import logging -import re -import sys -import codecs -from typing import ( - Dict, - Any, - cast, - Optional, - Union, - AnyStr, - IO, - Mapping, - Callable, - MutableMapping, - List, -) - -try: - from urllib import quote # type: ignore -except ImportError: - from urllib.parse import quote -import xml.etree.ElementTree as ET - -import isodate # type: ignore -from typing_extensions import Self - -from azure.core.exceptions import DeserializationError, SerializationError -from azure.core.serialization import NULL as CoreNull - -_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") - -JSON = MutableMapping[str, Any] - - -class RawDeserializer: - - # Accept "text" because we're open minded people... - JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") - - # Name used in context - CONTEXT_NAME = "deserialized_data" - - @classmethod - def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: - """Decode data according to content-type. - - Accept a stream of data as well, but will be load at once in memory for now. - - If no content-type, will return the string version (not bytes, not stream) - - :param data: Input, could be bytes or stream (will be decoded with UTF8) or text - :type data: str or bytes or IO - :param str content_type: The content type. - :return: The deserialized data. - :rtype: object - """ - if hasattr(data, "read"): - # Assume a stream - data = cast(IO, data).read() - - if isinstance(data, bytes): - data_as_str = data.decode(encoding="utf-8-sig") - else: - # Explain to mypy the correct type. - data_as_str = cast(str, data) - - # Remove Byte Order Mark if present in string - data_as_str = data_as_str.lstrip(_BOM) - - if content_type is None: - return data - - if cls.JSON_REGEXP.match(content_type): - try: - return json.loads(data_as_str) - except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) from err - elif "xml" in (content_type or []): - try: - - try: - if isinstance(data, unicode): # type: ignore - # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string - data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore - except NameError: - pass - - return ET.fromstring(data_as_str) # nosec - except ET.ParseError as err: - # It might be because the server has an issue, and returned JSON with - # content-type XML.... - # So let's try a JSON load, and if it's still broken - # let's flow the initial exception - def _json_attemp(data): - try: - return True, json.loads(data) - except ValueError: - return False, None # Don't care about this one - - success, json_result = _json_attemp(data) - if success: - return json_result - # If i'm here, it's not JSON, it's not XML, let's scream - # and raise the last context in this block (the XML exception) - # The function hack is because Py2.7 messes up with exception - # context otherwise. - _LOGGER.critical("Wasn't XML not JSON, failing") - raise DeserializationError("XML is invalid") from err - elif content_type.startswith("text/"): - return data_as_str - raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) - - @classmethod - def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: - """Deserialize from HTTP response. - - Use bytes and headers to NOT use any requests/aiohttp or whatever - specific implementation. - Headers will tested for "content-type" - - :param bytes body_bytes: The body of the response. - :param dict headers: The headers of the response. - :returns: The deserialized data. - :rtype: object - """ - # Try to use content-type from headers if available - content_type = None - if "content-type" in headers: - content_type = headers["content-type"].split(";")[0].strip().lower() - # Ouch, this server did not declare what it sent... - # Let's guess it's JSON... - # Also, since Autorest was considering that an empty body was a valid JSON, - # need that test as well.... - else: - content_type = "application/json" - - if body_bytes: - return cls.deserialize_from_text(body_bytes, content_type) - return None - - -_LOGGER = logging.getLogger(__name__) - -try: - _long_type = long # type: ignore -except NameError: - _long_type = int - -TZ_UTC = datetime.timezone.utc - -_FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: # pylint: disable=consider-using-dict-items - if k not in self._attribute_map: - _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) - elif k in self._validation and self._validation[k].get("readonly", False): - _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) - else: - setattr(self, k, kwargs[k]) - - def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are equal - :rtype: bool - """ - if isinstance(other, self.__class__): - return self.__dict__ == other.__dict__ - return False - - def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are not equal - :rtype: bool - """ - return not self.__eq__(other) - - def __str__(self) -> str: - return str(self.__dict__) - - @classmethod - def enable_additional_properties_sending(cls) -> None: - cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} - - @classmethod - def is_xml_model(cls) -> bool: - try: - cls._xml_map # type: ignore - except AttributeError: - return False - return True - - @classmethod - def _create_xml_node(cls): - """Create XML node. - - :returns: The XML node - :rtype: xml.etree.ElementTree.Element - """ - try: - xml_map = cls._xml_map # type: ignore - except AttributeError: - xml_map = {} - - return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - - def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to server from this model. - - This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, keep_readonly=keep_readonly, **kwargs - ) - - def as_dict( - self, - keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, - **kwargs: Any - ) -> JSON: - """Return a dict that can be serialized using json.dump. - - Advanced usage might optionally use a callback as parameter: - - .. code::python - - def my_key_transformer(key, attr_desc, value): - return key - - Key is the attribute name used in Python. Attr_desc - is a dict of metadata. Currently contains 'type' with the - msrest type and 'key' with the RestAPI encoded key. - Value is the current value in this object. - - The string returned will be used to serialize the key. - If the return type is a list, this is considered hierarchical - result dict. - - See the three examples in this file: - - - attribute_transformer - - full_restapi_key_transformer - - last_restapi_key_transformer - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :param function key_transformer: A key transformer function. - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs - ) - - @classmethod - def _infer_class_models(cls): - try: - str_models = cls.__module__.rsplit(".", 1)[0] - models = sys.modules[str_models] - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - if cls.__name__ not in client_models: - raise ValueError("Not Autorest generated code") - except Exception: # pylint: disable=broad-exception-caught - # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. - client_models = {cls.__name__: cls} - return client_models - - @classmethod - def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: - """Parse a str using the RestAPI syntax and return a model. - - :param str data: A str using RestAPI structure. JSON by default. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def from_dict( - cls, - data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, - content_type: Optional[str] = None, - ) -> Self: - """Parse a dict using given key extractor return a model. - - By default consider key - extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor - and last_rest_key_case_insensitive_extractor) - - :param dict data: A dict using RestAPI structure - :param function key_extractors: A key extractor function. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises: DeserializationError if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( # type: ignore - [ # type: ignore - attribute_key_case_insensitive_extractor, - rest_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - if key_extractors is None - else key_extractors - ) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def _flatten_subtype(cls, key, objects): - if "_subtype_map" not in cls.__dict__: - return {} - result = dict(cls._subtype_map[key]) - for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access - return result - - @classmethod - def _classify(cls, response, objects): - """Check the class _subtype_map for any child classes. - We want to ignore any inherited _subtype_maps. - - :param dict response: The initial data - :param dict objects: The class objects - :returns: The class to be used - :rtype: class - """ - for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): - subtype_value = None - - if not isinstance(response, ET.Element): - rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) - else: - subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) - if subtype_value: - # Try to match base class. Can be class name only - # (bug to fix in Autorest to support x-ms-discriminator-name) - if cls.__name__ == subtype_value: - return cls - flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) - try: - return objects[flatten_mapping_type[subtype_value]] # type: ignore - except KeyError: - _LOGGER.warning( - "Subtype value %s has no mapping, use base class %s.", - subtype_value, - cls.__name__, - ) - break - else: - _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) - break - return cls - - @classmethod - def _get_rest_key_parts(cls, attr_key): - """Get the RestAPI key of this attr, split it and decode part - :param str attr_key: Attribute key must be in attribute_map. - :returns: A list of RestAPI part - :rtype: list - """ - rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) - return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] - - -def _decode_attribute_map_key(key): - """This decode a key in an _attribute_map to the actual key we want to look at - inside the received data. - - :param str key: A key string from the generated code - :returns: The decoded key - :rtype: str - """ - return key.replace("\\.", ".") - - -class Serializer: # pylint: disable=too-many-public-methods - """Request object model serializer.""" - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} - days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} - months = { - 1: "Jan", - 2: "Feb", - 3: "Mar", - 4: "Apr", - 5: "May", - 6: "Jun", - 7: "Jul", - 8: "Aug", - 9: "Sep", - 10: "Oct", - 11: "Nov", - 12: "Dec", - } - validation = { - "min_length": lambda x, y: len(x) < y, - "max_length": lambda x, y: len(x) > y, - "minimum": lambda x, y: x < y, - "maximum": lambda x, y: x > y, - "minimum_ex": lambda x, y: x <= y, - "maximum_ex": lambda x, y: x >= y, - "min_items": lambda x, y: len(x) < y, - "max_items": lambda x, y: len(x) > y, - "pattern": lambda x, y: not re.match(y, x, re.UNICODE), - "unique": lambda x, y: len(x) != len(set(x)), - "multiple": lambda x, y: x % y != 0, - } - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.serialize_type = { - "iso-8601": Serializer.serialize_iso, - "rfc-1123": Serializer.serialize_rfc, - "unix-time": Serializer.serialize_unix, - "duration": Serializer.serialize_duration, - "date": Serializer.serialize_date, - "time": Serializer.serialize_time, - "decimal": Serializer.serialize_decimal, - "long": Serializer.serialize_long, - "bytearray": Serializer.serialize_bytearray, - "base64": Serializer.serialize_base64, - "object": self.serialize_object, - "[]": self.serialize_iter, - "{}": self.serialize_dict, - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_transformer = full_restapi_key_transformer - self.client_side_validation = True - - def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals - self, target_obj, data_type=None, **kwargs - ): - """Serialize data into a string according to type. - - :param object target_obj: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, dict - :raises SerializationError: if serialization fails. - :returns: The serialized data. - """ - key_transformer = kwargs.get("key_transformer", self.key_transformer) - keep_readonly = kwargs.get("keep_readonly", False) - if target_obj is None: - return None - - attr_name = None - class_name = target_obj.__class__.__name__ - - if data_type: - return self.serialize_data(target_obj, data_type, **kwargs) - - if not hasattr(target_obj, "_attribute_map"): - data_type = type(target_obj).__name__ - if data_type in self.basic_types.values(): - return self.serialize_data(target_obj, data_type, **kwargs) - - # Force "is_xml" kwargs if we detect a XML model - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) - - serialized = {} - if is_xml_model_serialization: - serialized = target_obj._create_xml_node() # pylint: disable=protected-access - try: - attributes = target_obj._attribute_map # pylint: disable=protected-access - for attr, attr_desc in attributes.items(): - attr_name = attr - if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access - attr_name, {} - ).get("readonly", False): - continue - - if attr_name == "additional_properties" and attr_desc["key"] == "": - if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) - continue - try: - - orig_attr = getattr(target_obj, attr) - if is_xml_model_serialization: - pass # Don't provide "transformer" for XML for now. Keep "orig_attr" - else: # JSON - keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) - keys = keys if isinstance(keys, list) else [keys] - - kwargs["serialization_ctxt"] = attr_desc - new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) - - if is_xml_model_serialization: - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - xml_prefix = xml_desc.get("prefix", None) - xml_ns = xml_desc.get("ns", None) - if xml_desc.get("attr", False): - if xml_ns: - ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) # type: ignore - continue - if xml_desc.get("text", False): - serialized.text = new_attr # type: ignore - continue - if isinstance(new_attr, list): - serialized.extend(new_attr) # type: ignore - elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, - # we MUST replace the tag with the local tag. But keeping the namespaces. - if "name" not in getattr(orig_attr, "_xml_map", {}): - splitted_tag = new_attr.tag.split("}") - if len(splitted_tag) == 2: # Namespace - new_attr.tag = "}".join([splitted_tag[0], xml_name]) - else: - new_attr.tag = xml_name - serialized.append(new_attr) # type: ignore - else: # That's a basic type - # Integrate namespace if necessary - local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = str(new_attr) - serialized.append(local_node) # type: ignore - else: # JSON - for k in reversed(keys): # type: ignore - new_attr = {k: new_attr} - - _new_attr = new_attr - _serialized = serialized - for k in keys: # type: ignore - if k not in _serialized: - _serialized.update(_new_attr) # type: ignore - _new_attr = _new_attr[k] # type: ignore - _serialized = _serialized[k] - except ValueError as err: - if isinstance(err, SerializationError): - raise - - except (AttributeError, KeyError, TypeError) as err: - msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise SerializationError(msg) from err - return serialized - - def body(self, data, data_type, **kwargs): - """Serialize data intended for a request body. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: dict - :raises SerializationError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized request body - """ - - # Just in case this is a dict - internal_data_type_str = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type_str, None) - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - if internal_data_type and issubclass(internal_data_type, Model): - is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) - else: - is_xml_model_serialization = False - if internal_data_type and not isinstance(internal_data_type, Enum): - try: - deserializer = Deserializer(self.dependencies) - # Since it's on serialization, it's almost sure that format is not JSON REST - # We're not able to deal with additional properties for now. - deserializer.additional_properties_detection = False - if is_xml_model_serialization: - deserializer.key_extractors = [ # type: ignore - attribute_key_case_insensitive_extractor, - ] - else: - deserializer.key_extractors = [ - rest_key_case_insensitive_extractor, - attribute_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access - except DeserializationError as err: - raise SerializationError("Unable to build a model: " + str(err)) from err - - return self._serialize(data, data_type, **kwargs) - - def url(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL path. - - :param str name: The name of the URL path parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :returns: The serialized URL path - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - """ - try: - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - - if kwargs.get("skip_quote") is True: - output = str(output) - output = output.replace("{", quote("{")).replace("}", quote("}")) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return output - - def query(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL query. - - :param str name: The name of the query parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, list - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized query parameter - """ - try: - # Treat the list aside, since we don't want to encode the div separator - if data_type.startswith("["): - internal_data_type = data_type[1:-1] - do_quote = not kwargs.get("skip_quote", False) - return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) - - # Not a list, regular serialization - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - if kwargs.get("skip_quote") is True: - output = str(output) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def header(self, name, data, data_type, **kwargs): - """Serialize data intended for a request header. - - :param str name: The name of the header. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized header - """ - try: - if data_type in ["[str]"]: - data = ["" if d is None else d for d in data] - - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def serialize_data(self, data, data_type, **kwargs): - """Serialize generic data according to supplied data type. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :raises AttributeError: if required data is None. - :raises ValueError: if data is None - :raises SerializationError: if serialization fails. - :returns: The serialized data. - :rtype: str, int, float, bool, dict, list - """ - if data is None: - raise ValueError("No value for given attribute") - - try: - if data is CoreNull: - return None - if data_type in self.basic_types.values(): - return self.serialize_basic(data, data_type, **kwargs) - - if data_type in self.serialize_type: - return self.serialize_type[data_type](data, **kwargs) - - # If dependencies is empty, try with current data class - # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) - if issubclass(enum_type, Enum): - return Serializer.serialize_enum(data, enum_obj=enum_type) - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.serialize_type: - return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) - - except (ValueError, TypeError) as err: - msg = "Unable to serialize value: {!r} as type: {!r}." - raise SerializationError(msg.format(data, data_type)) from err - return self._serialize(data, **kwargs) - - @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements - custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) - if custom_serializer: - return custom_serializer - if kwargs.get("is_xml", False): - return cls._xml_basic_types_serializers.get(data_type) - - @classmethod - def serialize_basic(cls, data, data_type, **kwargs): - """Serialize basic builting data type. - Serializes objects to str, int, float or bool. - - Possible kwargs: - - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - - is_xml bool : If set, use xml_basic_types_serializers - - :param obj data: Object to be serialized. - :param str data_type: Type of object in the iterable. - :rtype: str, int, float, bool - :return: serialized object - """ - custom_serializer = cls._get_custom_serializers(data_type, **kwargs) - if custom_serializer: - return custom_serializer(data) - if data_type == "str": - return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used - - @classmethod - def serialize_unicode(cls, data): - """Special handling for serializing unicode strings in Py2. - Encode to UTF-8 if unicode, otherwise handle as a str. - - :param str data: Object to be serialized. - :rtype: str - :return: serialized object - """ - try: # If I received an enum, return its value - return data.value - except AttributeError: - pass - - try: - if isinstance(data, unicode): # type: ignore - # Don't change it, JSON and XML ElementTree are totally able - # to serialize correctly u'' strings - return data - except NameError: - return str(data) - return str(data) - - def serialize_iter(self, data, iter_type, div=None, **kwargs): - """Serialize iterable. - - Supported kwargs: - - serialization_ctxt dict : The current entry of _attribute_map, or same format. - serialization_ctxt['type'] should be same as data_type. - - is_xml bool : If set, serialize as XML - - :param list data: Object to be serialized. - :param str iter_type: Type of object in the iterable. - :param str div: If set, this str will be used to combine the elements - in the iterable into a combined string. Default is 'None'. - Defaults to False. - :rtype: list, str - :return: serialized iterable - """ - if isinstance(data, str): - raise SerializationError("Refuse str type as a valid iter type.") - - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - is_xml = kwargs.get("is_xml", False) - - serialized = [] - for d in data: - try: - serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized.append(None) - - if kwargs.get("do_quote", False): - serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] - - if div: - serialized = ["" if s is None else str(s) for s in serialized] - serialized = div.join(serialized) - - if "xml" in serialization_ctxt or is_xml: - # XML serialization is more complicated - xml_desc = serialization_ctxt.get("xml", {}) - xml_name = xml_desc.get("name") - if not xml_name: - xml_name = serialization_ctxt["key"] - - # Create a wrap node if necessary (use the fact that Element and list have "append") - is_wrapped = xml_desc.get("wrapped", False) - node_name = xml_desc.get("itemsName", xml_name) - if is_wrapped: - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - else: - final_result = [] - # All list elements to "local_node" - for el in serialized: - if isinstance(el, ET.Element): - el_node = el - else: - el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - if el is not None: # Otherwise it writes "None" :-p - el_node.text = str(el) - final_result.append(el_node) - return final_result - return serialized - - def serialize_dict(self, attr, dict_type, **kwargs): - """Serialize a dictionary of objects. - - :param dict attr: Object to be serialized. - :param str dict_type: Type of object in the dictionary. - :rtype: dict - :return: serialized dictionary - """ - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized[self.serialize_unicode(key)] = None - - if "xml" in serialization_ctxt: - # XML serialization is more complicated - xml_desc = serialization_ctxt["xml"] - xml_name = xml_desc["name"] - - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - for key, value in serialized.items(): - ET.SubElement(final_result, key).text = value - return final_result - - return serialized - - def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Serialize a generic object. - This will be handled as a dictionary. If object passed in is not - a basic type (str, int, float, dict, list) it will simply be - cast to str. - - :param dict attr: Object to be serialized. - :rtype: dict or str - :return: serialized object - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - return attr - obj_type = type(attr) - if obj_type in self.basic_types: - return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) - if obj_type is _long_type: - return self.serialize_long(attr) - if obj_type is str: - return self.serialize_unicode(attr) - if obj_type is datetime.datetime: - return self.serialize_iso(attr) - if obj_type is datetime.date: - return self.serialize_date(attr) - if obj_type is datetime.time: - return self.serialize_time(attr) - if obj_type is datetime.timedelta: - return self.serialize_duration(attr) - if obj_type is decimal.Decimal: - return self.serialize_decimal(attr) - - # If it's a model or I know this dependency, serialize as a Model - if obj_type in self.dependencies.values() or isinstance(attr, Model): - return self._serialize(attr) - - if obj_type == dict: - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) - except ValueError: - serialized[self.serialize_unicode(key)] = None - return serialized - - if obj_type == list: - serialized = [] - for obj in attr: - try: - serialized.append(self.serialize_object(obj, **kwargs)) - except ValueError: - pass - return serialized - return str(attr) - - @staticmethod - def serialize_enum(attr, enum_obj=None): - try: - result = attr.value - except AttributeError: - result = attr - try: - enum_obj(result) # type: ignore - return result - except ValueError as exc: - for enum_value in enum_obj: # type: ignore - if enum_value.value.lower() == str(attr).lower(): - return enum_value.value - error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) from exc - - @staticmethod - def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument - """Serialize bytearray into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - return b64encode(attr).decode() - - @staticmethod - def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument - """Serialize str into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - encoded = b64encode(attr).decode("ascii") - return encoded.strip("=").replace("+", "-").replace("/", "_") - - @staticmethod - def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Decimal object to float. - - :param decimal attr: Object to be serialized. - :rtype: float - :return: serialized decimal - """ - return float(attr) - - @staticmethod - def serialize_long(attr, **kwargs): # pylint: disable=unused-argument - """Serialize long (Py2) or int (Py3). - - :param int attr: Object to be serialized. - :rtype: int/long - :return: serialized long - """ - return _long_type(attr) - - @staticmethod - def serialize_date(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Date object into ISO-8601 formatted string. - - :param Date attr: Object to be serialized. - :rtype: str - :return: serialized date - """ - if isinstance(attr, str): - attr = isodate.parse_date(attr) - t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) - return t - - @staticmethod - def serialize_time(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Time object into ISO-8601 formatted string. - - :param datetime.time attr: Object to be serialized. - :rtype: str - :return: serialized time - """ - if isinstance(attr, str): - attr = isodate.parse_time(attr) - t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) - if attr.microsecond: - t += ".{:02}".format(attr.microsecond) - return t - - @staticmethod - def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument - """Serialize TimeDelta object into ISO-8601 formatted string. - - :param TimeDelta attr: Object to be serialized. - :rtype: str - :return: serialized duration - """ - if isinstance(attr, str): - attr = isodate.parse_duration(attr) - return isodate.duration_isoformat(attr) - - @staticmethod - def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into RFC-1123 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises TypeError: if format invalid. - :return: serialized rfc - """ - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - except AttributeError as exc: - raise TypeError("RFC1123 object must be valid Datetime object.") from exc - - return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( - Serializer.days[utc.tm_wday], - utc.tm_mday, - Serializer.months[utc.tm_mon], - utc.tm_year, - utc.tm_hour, - utc.tm_min, - utc.tm_sec, - ) - - @staticmethod - def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into ISO-8601 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises SerializationError: if format invalid. - :return: serialized iso - """ - if isinstance(attr, str): - attr = isodate.parse_datetime(attr) - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - if utc.tm_year > 9999 or utc.tm_year < 1: - raise OverflowError("Hit max or min date") - - microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") - if microseconds: - microseconds = "." + microseconds - date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( - utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec - ) - return date + microseconds + "Z" - except (ValueError, OverflowError) as err: - msg = "Unable to serialize datetime object." - raise SerializationError(msg) from err - except AttributeError as err: - msg = "ISO-8601 object must be valid Datetime object." - raise TypeError(msg) from err - - @staticmethod - def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param Datetime attr: Object to be serialized. - :rtype: int - :raises SerializationError: if format invalid - :return: serialied unix - """ - if isinstance(attr, int): - return attr - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - return int(calendar.timegm(attr.utctimetuple())) - except AttributeError as exc: - raise TypeError("Unix time object must be valid Datetime object.") from exc - - -def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - key = attr_desc["key"] - working_data = data - - while "." in key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = working_data.get(working_key, data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - return working_data.get(key) - - -def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements - attr, attr_desc, data -): - key = attr_desc["key"] - working_data = data - - while "." in key: - dict_keys = _FLATTEN.split(key) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - if working_data: - return attribute_key_case_insensitive_extractor(key, None, working_data) - - -def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_extractor(dict_keys[-1], None, data) - - -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - This is the case insensitive version of "last_rest_key_extractor" - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) - - -def attribute_key_extractor(attr, _, data): - return data.get(attr) - - -def attribute_key_case_insensitive_extractor(attr, _, data): - found_key = None - lower_attr = attr.lower() - for key in data: - if lower_attr == key.lower(): - found_key = key - break - - return data.get(found_key) - - -def _extract_name_from_internal_type(internal_type): - """Given an internal type XML description, extract correct XML name with namespace. - - :param dict internal_type: An model type - :rtype: tuple - :returns: A tuple XML name + namespace dict - """ - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - xml_name = internal_type_xml_map.get("name", internal_type.__name__) - xml_ns = internal_type_xml_map.get("ns", None) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - return xml_name - - -def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements - if isinstance(data, dict): - return None - - # Test if this model is XML ready first - if not isinstance(data, ET.Element): - return None - - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - - # Look for a children - is_iter_type = attr_desc["type"].startswith("[") - is_wrapped = xml_desc.get("wrapped", False) - internal_type = attr_desc.get("internalType", None) - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - - # Integrate namespace if necessary - xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - - # If it's an attribute, that's simple - if xml_desc.get("attr", False): - return data.get(xml_name) - - # If it's x-ms-text, that's simple too - if xml_desc.get("text", False): - return data.text - - # Scenario where I take the local name: - # - Wrapped node - # - Internal type is an enum (considered basic types) - # - Internal type has no XML/Name node - if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): - children = data.findall(xml_name) - # If internal type has a local name and it's not a list, I use that name - elif not is_iter_type and internal_type and "name" in internal_type_xml_map: - xml_name = _extract_name_from_internal_type(internal_type) - children = data.findall(xml_name) - # That's an array - else: - if internal_type: # Complex type, ignore itemsName and use the complex type name - items_name = _extract_name_from_internal_type(internal_type) - else: - items_name = xml_desc.get("itemsName", xml_name) - children = data.findall(items_name) - - if len(children) == 0: - if is_iter_type: - if is_wrapped: - return None # is_wrapped no node, we want None - return [] # not wrapped, assume empty list - return None # Assume it's not there, maybe an optional node. - - # If is_iter_type and not wrapped, return all found children - if is_iter_type: - if not is_wrapped: - return children - # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) - ) - return list(children[0]) # Might be empty list and that's ok. - - # Here it's not a itertype, we should have found one element only or empty - if len(children) > 1: - raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) - return children[0] - - -class Deserializer: - """Response object model deserializer. - - :param dict classes: Class type dictionary for deserializing complex types. - :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. - """ - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.deserialize_type = { - "iso-8601": Deserializer.deserialize_iso, - "rfc-1123": Deserializer.deserialize_rfc, - "unix-time": Deserializer.deserialize_unix, - "duration": Deserializer.deserialize_duration, - "date": Deserializer.deserialize_date, - "time": Deserializer.deserialize_time, - "decimal": Deserializer.deserialize_decimal, - "long": Deserializer.deserialize_long, - "bytearray": Deserializer.deserialize_bytearray, - "base64": Deserializer.deserialize_base64, - "object": self.deserialize_object, - "[]": self.deserialize_iter, - "{}": self.deserialize_dict, - } - self.deserialize_expected_types = { - "duration": (isodate.Duration, datetime.timedelta), - "iso-8601": (datetime.datetime), - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_extractors = [rest_key_extractor, xml_key_extractor] - # Additional properties only works if the "rest_key_extractor" is used to - # extract the keys. Making it to work whatever the key extractor is too much - # complicated, with no real scenario for now. - # So adding a flag to disable additional properties detection. This flag should be - # used if your expect the deserialization to NOT come from a JSON REST syntax. - # Otherwise, result are unexpected - self.additional_properties_detection = True - - def __call__(self, target_obj, response_data, content_type=None): - """Call the deserializer to process a REST response. - - :param str target_obj: Target data type to deserialize to. - :param requests.Response response_data: REST response object. - :param str content_type: Swagger "produces" if available. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - data = self._unpack_content(response_data, content_type) - return self._deserialize(target_obj, data) - - def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements - """Call the deserializer on a model. - - Data needs to be already deserialized as JSON or XML ElementTree - - :param str target_obj: Target data type to deserialize to. - :param object data: Object to deserialize. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - # This is already a model, go recursive just in case - if hasattr(data, "_attribute_map"): - constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] - try: - for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access - if attr in constants: - continue - value = getattr(data, attr) - if value is None: - continue - local_type = mapconfig["type"] - internal_data_type = local_type.strip("[]{}") - if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): - continue - setattr(data, attr, self._deserialize(local_type, value)) - return data - except AttributeError: - return - - response, class_name = self._classify_target(target_obj, data) - - if isinstance(response, str): - return self.deserialize_data(data, response) - if isinstance(response, type) and issubclass(response, Enum): - return self.deserialize_enum(data, response) - - if data is None or data is CoreNull: - return data - try: - attributes = response._attribute_map # type: ignore # pylint: disable=protected-access - d_attrs = {} - for attr, attr_desc in attributes.items(): - # Check empty string. If it's not empty, someone has a real "additionalProperties"... - if attr == "additional_properties" and attr_desc["key"] == "": - continue - raw_value = None - # Enhance attr_desc with some dynamic data - attr_desc = attr_desc.copy() # Do a copy, do not change the real one - internal_data_type = attr_desc["type"].strip("[]{}") - if internal_data_type in self.dependencies: - attr_desc["internalType"] = self.dependencies[internal_data_type] - - for key_extractor in self.key_extractors: - found_value = key_extractor(attr, attr_desc, data) - if found_value is not None: - if raw_value is not None and raw_value != found_value: - msg = ( - "Ignoring extracted value '%s' from %s for key '%s'" - " (duplicate extraction, follow extractors order)" - ) - _LOGGER.warning(msg, found_value, key_extractor, attr) - continue - raw_value = found_value - - value = self.deserialize_data(raw_value, attr_desc["type"]) - d_attrs[attr] = value - except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name # type: ignore - raise DeserializationError(msg) from err - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) - - def _build_additional_properties(self, attribute_map, data): - if not self.additional_properties_detection: - return None - if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": - # Check empty string. If it's not empty, someone has a real "additionalProperties" - return None - if isinstance(data, ET.Element): - data = {el.tag: el.text for el in data} - - known_keys = { - _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) - for desc in attribute_map.values() - if desc["key"] != "" - } - present_keys = set(data.keys()) - missing_keys = present_keys - known_keys - return {key: data[key] for key in missing_keys} - - def _classify_target(self, target, data): - """Check to see whether the deserialization target object can - be classified into a subclass. - Once classification has been determined, initialize object. - - :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :return: The classified target object and its class name. - :rtype: tuple - """ - if target is None: - return None, None - - if isinstance(target, str): - try: - target = self.dependencies[target] - except KeyError: - return target, target - - try: - target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access - except AttributeError: - pass # Target is not a Model, no classify - return target, target.__class__.__name__ # type: ignore - - def failsafe_deserialize(self, target_obj, data, content_type=None): - """Ignores any errors encountered in deserialization, - and falls back to not deserializing the object. Recommended - for use in error deserialization, as we want to return the - HttpResponseError to users, and not have them deal with - a deserialization error. - - :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :param str content_type: Swagger "produces" if available. - :return: Deserialized object. - :rtype: object - """ - try: - return self(target_obj, data, content_type=content_type) - except: # pylint: disable=bare-except - _LOGGER.debug( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - @staticmethod - def _unpack_content(raw_data, content_type=None): - """Extract the correct structure for deserialization. - - If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. - if we can't, raise. Your Pipeline should have a RawDeserializer. - - If not a pipeline response and raw_data is bytes or string, use content-type - to decode it. If no content-type, try JSON. - - If raw_data is something else, bypass all logic and return it directly. - - :param obj raw_data: Data to be processed. - :param str content_type: How to parse if raw_data is a string/bytes. - :raises JSONDecodeError: If JSON is requested and parsing is impossible. - :raises UnicodeDecodeError: If bytes is not UTF8 - :rtype: object - :return: Unpacked content. - """ - # Assume this is enough to detect a Pipeline Response without importing it - context = getattr(raw_data, "context", {}) - if context: - if RawDeserializer.CONTEXT_NAME in context: - return context[RawDeserializer.CONTEXT_NAME] - raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") - - # Assume this is enough to recognize universal_http.ClientResponse without importing it - if hasattr(raw_data, "body"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) - - # Assume this enough to recognize requests.Response without importing it. - if hasattr(raw_data, "_content_consumed"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - - if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore - return raw_data - - def _instantiate_model(self, response, attrs, additional_properties=None): - """Instantiate a response model passing in deserialized args. - - :param Response response: The response model class. - :param dict attrs: The deserialized response attributes. - :param dict additional_properties: Additional properties to be set. - :rtype: Response - :return: The instantiated response model. - """ - if callable(response): - subtype = getattr(response, "_subtype_map", {}) - try: - readonly = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("readonly") - ] - const = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("constant") - ] - kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} - response_obj = response(**kwargs) - for attr in readonly: - setattr(response_obj, attr, attrs.get(attr)) - if additional_properties: - response_obj.additional_properties = additional_properties # type: ignore - return response_obj - except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) from err - else: - try: - for attr, value in attrs.items(): - setattr(response, attr, value) - return response - except Exception as exp: - msg = "Unable to populate response model. " - msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) from exp - - def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements - """Process data for deserialization according to data type. - - :param str data: The response string to be deserialized. - :param str data_type: The type to deserialize to. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - if data is None: - return data - - try: - if not data_type: - return data - if data_type in self.basic_types.values(): - return self.deserialize_basic(data, data_type) - if data_type in self.deserialize_type: - if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): - return data - - is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment - "object", - "[]", - r"{}", - ] - if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: - return None - data_val = self.deserialize_type[data_type](data) - return data_val - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.deserialize_type: - return self.deserialize_type[iter_type](data, data_type[1:-1]) - - obj_type = self.dependencies[data_type] - if issubclass(obj_type, Enum): - if isinstance(data, ET.Element): - data = data.text - return self.deserialize_enum(data, obj_type) - - except (ValueError, TypeError, AttributeError) as err: - msg = "Unable to deserialize response data." - msg += " Data: {}, {}".format(data, data_type) - raise DeserializationError(msg) from err - return self._deserialize(obj_type, data) - - def deserialize_iter(self, attr, iter_type): - """Deserialize an iterable. - - :param list attr: Iterable to be deserialized. - :param str iter_type: The type of object in the iterable. - :return: Deserialized iterable. - :rtype: list - """ - if attr is None: - return None - if isinstance(attr, ET.Element): # If I receive an element here, get the children - attr = list(attr) - if not isinstance(attr, (list, set)): - raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) - return [self.deserialize_data(a, iter_type) for a in attr] - - def deserialize_dict(self, attr, dict_type): - """Deserialize a dictionary. - - :param dict/list attr: Dictionary to be deserialized. Also accepts - a list of key, value pairs. - :param str dict_type: The object type of the items in the dictionary. - :return: Deserialized dictionary. - :rtype: dict - """ - if isinstance(attr, list): - return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} - - if isinstance(attr, ET.Element): - # Transform value into {"Key": "value"} - attr = {el.tag: el.text for el in attr} - return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - - def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Deserialize a generic object. - This will be handled as a dictionary. - - :param dict attr: Dictionary to be deserialized. - :return: Deserialized object. - :rtype: dict - :raises TypeError: if non-builtin datatype encountered. - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - # Do no recurse on XML, just return the tree as-is - return attr - if isinstance(attr, str): - return self.deserialize_basic(attr, "str") - obj_type = type(attr) - if obj_type in self.basic_types: - return self.deserialize_basic(attr, self.basic_types[obj_type]) - if obj_type is _long_type: - return self.deserialize_long(attr) - - if obj_type == dict: - deserialized = {} - for key, value in attr.items(): - try: - deserialized[key] = self.deserialize_object(value, **kwargs) - except ValueError: - deserialized[key] = None - return deserialized - - if obj_type == list: - deserialized = [] - for obj in attr: - try: - deserialized.append(self.deserialize_object(obj, **kwargs)) - except ValueError: - pass - return deserialized - - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) - - def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements - """Deserialize basic builtin data type from string. - Will attempt to convert to str, int, float and bool. - This function will also accept '1', '0', 'true' and 'false' as - valid bool values. - - :param str attr: response string to be deserialized. - :param str data_type: deserialization data type. - :return: Deserialized basic type. - :rtype: str, int, float or bool - :raises TypeError: if string format is not valid. - """ - # If we're here, data is supposed to be a basic type. - # If it's still an XML node, take the text - if isinstance(attr, ET.Element): - attr = attr.text - if not attr: - if data_type == "str": - # None or '', node is empty string. - return "" - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None - - if data_type == "bool": - if attr in [True, False, 1, 0]: - return bool(attr) - if isinstance(attr, str): - if attr.lower() in ["true", "1"]: - return True - if attr.lower() in ["false", "0"]: - return False - raise TypeError("Invalid boolean value: {}".format(attr)) - - if data_type == "str": - return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used - - @staticmethod - def deserialize_unicode(data): - """Preserve unicode objects in Python 2, otherwise return data - as a string. - - :param str data: response string to be deserialized. - :return: Deserialized string. - :rtype: str or unicode - """ - # We might be here because we have an enum modeled as string, - # and we try to deserialize a partial dict with enum inside - if isinstance(data, Enum): - return data - - # Consider this is real string - try: - if isinstance(data, unicode): # type: ignore - return data - except NameError: - return str(data) - return str(data) - - @staticmethod - def deserialize_enum(data, enum_obj): - """Deserialize string into enum object. - - If the string is not a valid enum value it will be returned as-is - and a warning will be logged. - - :param str data: Response string to be deserialized. If this value is - None or invalid it will be returned as-is. - :param Enum enum_obj: Enum object to deserialize to. - :return: Deserialized enum object. - :rtype: Enum - """ - if isinstance(data, enum_obj) or data is None: - return data - if isinstance(data, Enum): - data = data.value - if isinstance(data, int): - # Workaround. We might consider remove it in the future. - try: - return list(enum_obj.__members__.values())[data] - except IndexError as exc: - error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) from exc - try: - return enum_obj(str(data)) - except ValueError: - for enum_value in enum_obj: - if enum_value.value.lower() == str(data).lower(): - return enum_value - # We don't fail anymore for unknown value, we deserialize as a string - _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) - return Deserializer.deserialize_unicode(data) - - @staticmethod - def deserialize_bytearray(attr): - """Deserialize string into bytearray. - - :param str attr: response string to be deserialized. - :return: Deserialized bytearray - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return bytearray(b64decode(attr)) # type: ignore - - @staticmethod - def deserialize_base64(attr): - """Deserialize base64 encoded string into string. - - :param str attr: response string to be deserialized. - :return: Deserialized base64 string - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore - attr = attr + padding # type: ignore - encoded = attr.replace("-", "+").replace("_", "/") - return b64decode(encoded) - - @staticmethod - def deserialize_decimal(attr): - """Deserialize string into Decimal object. - - :param str attr: response string to be deserialized. - :return: Deserialized decimal - :raises DeserializationError: if string format invalid. - :rtype: decimal - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - return decimal.Decimal(str(attr)) # type: ignore - except decimal.DecimalException as err: - msg = "Invalid decimal {}".format(attr) - raise DeserializationError(msg) from err - - @staticmethod - def deserialize_long(attr): - """Deserialize string into long (Py2) or int (Py3). - - :param str attr: response string to be deserialized. - :return: Deserialized int - :rtype: long or int - :raises ValueError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return _long_type(attr) # type: ignore - - @staticmethod - def deserialize_duration(attr): - """Deserialize ISO-8601 formatted string into TimeDelta object. - - :param str attr: response string to be deserialized. - :return: Deserialized duration - :rtype: TimeDelta - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - duration = isodate.parse_duration(attr) - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize duration object." - raise DeserializationError(msg) from err - return duration - - @staticmethod - def deserialize_date(attr): - """Deserialize ISO-8601 formatted string into Date object. - - :param str attr: response string to be deserialized. - :return: Deserialized date - :rtype: Date - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=0, defaultday=0) - - @staticmethod - def deserialize_time(attr): - """Deserialize ISO-8601 formatted string into time object. - - :param str attr: response string to be deserialized. - :return: Deserialized time - :rtype: datetime.time - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - return isodate.parse_time(attr) - - @staticmethod - def deserialize_rfc(attr): - """Deserialize RFC-1123 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized RFC datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - parsed_date = email.utils.parsedate_tz(attr) # type: ignore - date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) - ) - if not date_obj.tzinfo: - date_obj = date_obj.astimezone(tz=TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to rfc datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_iso(attr): - """Deserialize ISO-8601 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized ISO datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - attr = attr.upper() # type: ignore - match = Deserializer.valid_date.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - check_decimal = attr.split(".") - if len(check_decimal) > 1: - decimal_str = "" - for digit in check_decimal[1]: - if digit.isdigit(): - decimal_str += digit - else: - break - if len(decimal_str) > 6: - attr = attr.replace(decimal_str, decimal_str[0:6]) - - date_obj = isodate.parse_datetime(attr) - test_utc = date_obj.utctimetuple() - if test_utc.tm_year > 9999 or test_utc.tm_year < 1: - raise OverflowError("Hit max or min date") - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_unix(attr): - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param int attr: Object to be serialized. - :return: Deserialized datetime - :rtype: Datetime - :raises DeserializationError: if format invalid - """ - if isinstance(attr, ET.Element): - attr = int(attr.text) # type: ignore - try: - attr = int(attr) - date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to unix datetime object." - raise DeserializationError(msg) from err - return date_obj diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_vendor.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_vendor.py deleted file mode 100644 index ef95074c5c9..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_vendor.py +++ /dev/null @@ -1,25 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from abc import ABC -from typing import TYPE_CHECKING - -from ._configuration import HeaderClientConfiguration - -if TYPE_CHECKING: - from azure.core import PipelineClient - - from ._serialization import Deserializer, Serializer - - -class HeaderClientMixinABC(ABC): - """DO NOT use this class. It is for internal typing use only.""" - - _client: "PipelineClient" - _config: HeaderClientConfiguration - _serialize: "Serializer" - _deserialize: "Deserializer" diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_version.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_version.py deleted file mode 100644 index be71c81bd28..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -VERSION = "1.0.0b1" diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/__init__.py deleted file mode 100644 index 6107d5900e3..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._client import HeaderClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "HeaderClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore - -_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_client.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_client.py deleted file mode 100644 index 1a9b26f9efe..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_client.py +++ /dev/null @@ -1,96 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable -from typing_extensions import Self - -from azure.core import AsyncPipelineClient -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest - -from .._serialization import Deserializer, Serializer -from ._configuration import HeaderClientConfiguration -from ._operations import HeaderClientOperationsMixin - - -class HeaderClient(HeaderClientOperationsMixin): - """HeaderClient. - - :keyword endpoint: Service host. Default value is "http://localhost:3000". - :paramtype endpoint: str - :keyword version: Default value is "2025-01-01". Note that overriding this default value may - result in unsupported behavior. - :paramtype version: str - """ - - def __init__( # pylint: disable=missing-client-constructor-parameter-credential - self, *, endpoint: str = "http://localhost:3000", **kwargs: Any - ) -> None: - _endpoint = "{endpoint}" - self._config = HeaderClientConfiguration(endpoint=endpoint, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncPipelineClient = AsyncPipelineClient(base_url=_endpoint, policies=_policies, **kwargs) - - self._serialize = Serializer() - self._deserialize = Deserializer() - self._serialize.client_side_validation = False - - def send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client.send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_configuration.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_configuration.py deleted file mode 100644 index e6dff658177..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_configuration.py +++ /dev/null @@ -1,47 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any - -from azure.core.pipeline import policies - -from .._version import VERSION - - -class HeaderClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for HeaderClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param endpoint: Service host. Default value is "http://localhost:3000". - :type endpoint: str - :keyword version: Default value is "2025-01-01". Note that overriding this default value may - result in unsupported behavior. - :paramtype version: str - """ - - def __init__(self, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None: - version: str = kwargs.pop("version", "2025-01-01") - - self.endpoint = endpoint - self.version = version - kwargs.setdefault("sdk_moniker", "client-alternateapiversion-service-header/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_operations/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_operations/__init__.py deleted file mode 100644 index f9c721d92b6..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_operations/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import HeaderClientOperationsMixin # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "HeaderClientOperationsMixin", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_operations/_operations.py deleted file mode 100644 index 9971a650bb0..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_operations/_operations.py +++ /dev/null @@ -1,80 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ..._operations._operations import build_header_header_api_version_request -from .._vendor import HeaderClientMixinABC - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class HeaderClientOperationsMixin(HeaderClientMixinABC): - - @distributed_trace_async - async def header_api_version(self, **kwargs: Any) -> None: - """Header api version parameter. - - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_header_header_api_version_request( - version=self._config.version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_operations/_patch.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_operations/_patch.py deleted file mode 100644 index f7dd3251033..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__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/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_patch.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_patch.py deleted file mode 100644 index f7dd3251033..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__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/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_vendor.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_vendor.py deleted file mode 100644 index 5dabe25fe75..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/aio/_vendor.py +++ /dev/null @@ -1,25 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from abc import ABC -from typing import TYPE_CHECKING - -from ._configuration import HeaderClientConfiguration - -if TYPE_CHECKING: - from azure.core import AsyncPipelineClient - - from .._serialization import Deserializer, Serializer - - -class HeaderClientMixinABC(ABC): - """DO NOT use this class. It is for internal typing use only.""" - - _client: "AsyncPipelineClient" - _config: HeaderClientConfiguration - _serialize: "Serializer" - _deserialize: "Deserializer" diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/py.typed b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/py.typed deleted file mode 100644 index e5aff4f83af..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/client/alternateapiversion/service/header/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/dev_requirements.txt b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/dev_requirements.txt deleted file mode 100644 index 10548647144..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/dev_requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ --e ../../../tools/azure-sdk-tools -../../core/azure-core -aiohttp \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/conftest.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/conftest.py deleted file mode 100644 index e23f2f3a90f..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/conftest.py +++ /dev/null @@ -1,35 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import os -import pytest -from dotenv import load_dotenv -from devtools_testutils import ( - test_proxy, - add_general_regex_sanitizer, - add_body_key_sanitizer, - add_header_regex_sanitizer, -) - -load_dotenv() - - -# For security, please avoid record sensitive identity information in recordings -@pytest.fixture(scope="session", autouse=True) -def add_sanitizers(test_proxy): - header_subscription_id = os.environ.get("HEADER_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") - header_tenant_id = os.environ.get("HEADER_TENANT_ID", "00000000-0000-0000-0000-000000000000") - header_client_id = os.environ.get("HEADER_CLIENT_ID", "00000000-0000-0000-0000-000000000000") - header_client_secret = os.environ.get("HEADER_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=header_subscription_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=header_tenant_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=header_client_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=header_client_secret, value="00000000-0000-0000-0000-000000000000") - - add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") - add_header_regex_sanitizer(key="Cookie", value="cookie;") - add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/test_header.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/test_header.py deleted file mode 100644 index 1b1f4435135..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/test_header.py +++ /dev/null @@ -1,22 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import pytest -from devtools_testutils import recorded_by_proxy -from testpreparer import HeaderClientTestBase, HeaderPreparer - - -@pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestHeader(HeaderClientTestBase): - @HeaderPreparer() - @recorded_by_proxy - def test_header_api_version(self, header_endpoint): - client = self.create_client(endpoint=header_endpoint) - response = client.header_api_version() - - # please add some check logic here by yourself - # ... diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/test_header_async.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/test_header_async.py deleted file mode 100644 index 617bceb8515..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/test_header_async.py +++ /dev/null @@ -1,23 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import pytest -from devtools_testutils.aio import recorded_by_proxy_async -from testpreparer import HeaderPreparer -from testpreparer_async import HeaderClientTestBaseAsync - - -@pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestHeaderAsync(HeaderClientTestBaseAsync): - @HeaderPreparer() - @recorded_by_proxy_async - async def test_header_api_version(self, header_endpoint): - client = self.create_async_client(endpoint=header_endpoint) - response = await client.header_api_version() - - # please add some check logic here by yourself - # ... diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/testpreparer.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/testpreparer.py deleted file mode 100644 index 7d5c99b5138..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/testpreparer.py +++ /dev/null @@ -1,24 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from client.alternateapiversion.service.header import HeaderClient -from devtools_testutils import AzureRecordedTestCase, PowerShellPreparer -import functools - - -class HeaderClientTestBase(AzureRecordedTestCase): - - def create_client(self, endpoint): - credential = self.get_credential(HeaderClient) - return self.create_client_from_credential( - HeaderClient, - credential=credential, - endpoint=endpoint, - ) - - -HeaderPreparer = functools.partial(PowerShellPreparer, "header", header_endpoint="https://fake_header_endpoint.com") diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/testpreparer_async.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/testpreparer_async.py deleted file mode 100644 index beb3a02c59a..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/generated_tests/testpreparer_async.py +++ /dev/null @@ -1,20 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from client.alternateapiversion.service.header.aio import HeaderClient -from devtools_testutils import AzureRecordedTestCase - - -class HeaderClientTestBaseAsync(AzureRecordedTestCase): - - def create_async_client(self, endpoint): - credential = self.get_credential(HeaderClient, is_async=True) - return self.create_client_from_credential( - HeaderClient, - credential=credential, - endpoint=endpoint, - ) diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/setup.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/setup.py deleted file mode 100644 index 78f636396b6..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-header/setup.py +++ /dev/null @@ -1,72 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# coding: utf-8 - -import os -import re -from setuptools import setup, find_packages - - -PACKAGE_NAME = "client-alternateapiversion-service-header" -PACKAGE_PPRINT_NAME = "Client Alternateapiversion Service Header" - -# a-b-c => a/b/c -package_folder_path = PACKAGE_NAME.replace("-", "/") - -# Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, "_version.py"), "r") as fd: - version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) - -if not version: - raise RuntimeError("Cannot find version information") - - -setup( - name=PACKAGE_NAME, - version=version, - description="Microsoft {} Client Library for Python".format(PACKAGE_PPRINT_NAME), - long_description=open("README.md", "r").read(), - long_description_content_type="text/markdown", - license="MIT License", - author="Microsoft Corporation", - author_email="azpysdkhelp@microsoft.com", - url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk", - keywords="azure, azure sdk", - classifiers=[ - "Development Status :: 4 - Beta", - "Programming Language :: Python", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "License :: OSI Approved :: MIT License", - ], - zip_safe=False, - packages=find_packages( - exclude=[ - "tests", - # Exclude packages that will be covered by PEP420 or nspkg - "client", - "client.alternateapiversion", - "client.alternateapiversion.service", - ] - ), - include_package_data=True, - package_data={ - "client.alternateapiversion.service.header": ["py.typed"], - }, - install_requires=[ - "isodate>=0.6.1", - "azure-core>=1.30.0", - "typing-extensions>=4.6.0", - ], - python_requires=">=3.8", -) diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/CHANGELOG.md b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/CHANGELOG.md deleted file mode 100644 index 628743d283a..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/CHANGELOG.md +++ /dev/null @@ -1,5 +0,0 @@ -# Release History - -## 1.0.0b1 (1970-01-01) - -- Initial version diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/LICENSE b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/LICENSE deleted file mode 100644 index 63447fd8bbb..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -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. \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/MANIFEST.in b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/MANIFEST.in deleted file mode 100644 index 5c683e9f9a3..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/MANIFEST.in +++ /dev/null @@ -1,8 +0,0 @@ -include *.md -include LICENSE -include client/alternateapiversion/service/path/py.typed -recursive-include tests *.py -recursive-include samples *.py *.md -include client/__init__.py -include client/alternateapiversion/__init__.py -include client/alternateapiversion/service/__init__.py \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/README.md b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/README.md deleted file mode 100644 index b25a7a5c82b..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/README.md +++ /dev/null @@ -1,45 +0,0 @@ - - -# Client Alternateapiversion Service Path client library for Python - - -## Getting started - -### Install the package - -```bash -python -m pip install client-alternateapiversion-service-path -``` - -#### 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 Client Alternateapiversion Service Path 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 opencode@microsoft.com with any -additional questions or comments. - - -[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/ - diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/apiview-properties.json b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/apiview-properties.json deleted file mode 100644 index 342d9f29e28..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/apiview-properties.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "CrossLanguagePackageId": "Client.AlternateApiVersion.Service.Path", - "CrossLanguageDefinitionId": { - "client.alternateapiversion.service.path.PathClient.path_api_version": "Client.AlternateApiVersion.Service.Path.pathApiVersion" - } -} \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/__init__.py deleted file mode 100644 index d55ccad1f57..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/__init__.py deleted file mode 100644 index d55ccad1f57..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/__init__.py deleted file mode 100644 index d55ccad1f57..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/__init__.py deleted file mode 100644 index 2b63a50720f..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._client import PathClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "PathClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore - -_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_client.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_client.py deleted file mode 100644 index cbbd2c51152..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_client.py +++ /dev/null @@ -1,94 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any -from typing_extensions import Self - -from azure.core import PipelineClient -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse - -from ._configuration import PathClientConfiguration -from ._operations import PathClientOperationsMixin -from ._serialization import Deserializer, Serializer - - -class PathClient(PathClientOperationsMixin): - """PathClient. - - :keyword endpoint: Service host. Default value is "http://localhost:3000". - :paramtype endpoint: str - :keyword version: Default value is "2025-01-01". Note that overriding this default value may - result in unsupported behavior. - :paramtype version: str - """ - - def __init__( # pylint: disable=missing-client-constructor-parameter-credential - self, *, endpoint: str = "http://localhost:3000", **kwargs: Any - ) -> None: - _endpoint = "{endpoint}" - self._config = PathClientConfiguration(endpoint=endpoint, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs) - - self._serialize = Serializer() - self._deserialize = Deserializer() - self._serialize.client_side_validation = False - - def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client.send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_configuration.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_configuration.py deleted file mode 100644 index 41b5eaf919b..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_configuration.py +++ /dev/null @@ -1,47 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any - -from azure.core.pipeline import policies - -from ._version import VERSION - - -class PathClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for PathClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param endpoint: Service host. Default value is "http://localhost:3000". - :type endpoint: str - :keyword version: Default value is "2025-01-01". Note that overriding this default value may - result in unsupported behavior. - :paramtype version: str - """ - - def __init__(self, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None: - version: str = kwargs.pop("version", "2025-01-01") - - self.endpoint = endpoint - self.version = version - kwargs.setdefault("sdk_moniker", "client-alternateapiversion-service-path/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_model_base.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_model_base.py deleted file mode 100644 index 3072ee252ed..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_model_base.py +++ /dev/null @@ -1,1235 +0,0 @@ -# pylint: disable=too-many-lines -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=protected-access, broad-except - -import copy -import calendar -import decimal -import functools -import sys -import logging -import base64 -import re -import typing -import enum -import email.utils -from datetime import datetime, date, time, timedelta, timezone -from json import JSONEncoder -import xml.etree.ElementTree as ET -from typing_extensions import Self -import isodate -from azure.core.exceptions import DeserializationError -from azure.core import CaseInsensitiveEnumMeta -from azure.core.pipeline import PipelineResponse -from azure.core.serialization import _Null - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping - -_LOGGER = logging.getLogger(__name__) - -__all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] - -TZ_UTC = timezone.utc -_T = typing.TypeVar("_T") - - -def _timedelta_as_isostr(td: timedelta) -> str: - """Converts a datetime.timedelta object into an ISO 8601 formatted string, e.g. 'P4DT12H30M05S' - - Function adapted from the Tin Can Python project: https://github.com/RusticiSoftware/TinCanPython - - :param timedelta td: The timedelta to convert - :rtype: str - :return: ISO8601 version of this timedelta - """ - - # Split seconds to larger units - seconds = td.total_seconds() - minutes, seconds = divmod(seconds, 60) - hours, minutes = divmod(minutes, 60) - days, hours = divmod(hours, 24) - - days, hours, minutes = list(map(int, (days, hours, minutes))) - seconds = round(seconds, 6) - - # Build date - date_str = "" - if days: - date_str = "%sD" % days - - if hours or minutes or seconds: - # Build time - time_str = "T" - - # Hours - bigger_exists = date_str or hours - if bigger_exists: - time_str += "{:02}H".format(hours) - - # Minutes - bigger_exists = bigger_exists or minutes - if bigger_exists: - time_str += "{:02}M".format(minutes) - - # Seconds - try: - if seconds.is_integer(): - seconds_string = "{:02}".format(int(seconds)) - else: - # 9 chars long w/ leading 0, 6 digits after decimal - seconds_string = "%09.6f" % seconds - # Remove trailing zeros - seconds_string = seconds_string.rstrip("0") - except AttributeError: # int.is_integer() raises - seconds_string = "{:02}".format(seconds) - - time_str += "{}S".format(seconds_string) - else: - time_str = "" - - return "P" + date_str + time_str - - -def _serialize_bytes(o, format: typing.Optional[str] = None) -> str: - encoded = base64.b64encode(o).decode() - if format == "base64url": - return encoded.strip("=").replace("+", "-").replace("/", "_") - return encoded - - -def _serialize_datetime(o, format: typing.Optional[str] = None): - if hasattr(o, "year") and hasattr(o, "hour"): - if format == "rfc7231": - return email.utils.format_datetime(o, usegmt=True) - if format == "unix-timestamp": - return int(calendar.timegm(o.utctimetuple())) - - # astimezone() fails for naive times in Python 2.7, so make make sure o is aware (tzinfo is set) - if not o.tzinfo: - iso_formatted = o.replace(tzinfo=TZ_UTC).isoformat() - else: - iso_formatted = o.astimezone(TZ_UTC).isoformat() - # Replace the trailing "+00:00" UTC offset with "Z" (RFC 3339: https://www.ietf.org/rfc/rfc3339.txt) - return iso_formatted.replace("+00:00", "Z") - # Next try datetime.date or datetime.time - return o.isoformat() - - -def _is_readonly(p): - try: - return p._visibility == ["read"] - except AttributeError: - return False - - -class SdkJSONEncoder(JSONEncoder): - """A JSON encoder that's capable of serializing datetime objects and bytes.""" - - def __init__(self, *args, exclude_readonly: bool = False, format: typing.Optional[str] = None, **kwargs): - super().__init__(*args, **kwargs) - self.exclude_readonly = exclude_readonly - self.format = format - - def default(self, o): # pylint: disable=too-many-return-statements - if _is_model(o): - if self.exclude_readonly: - readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] - return {k: v for k, v in o.items() if k not in readonly_props} - return dict(o.items()) - try: - return super(SdkJSONEncoder, self).default(o) - except TypeError: - if isinstance(o, _Null): - return None - if isinstance(o, decimal.Decimal): - return float(o) - if isinstance(o, (bytes, bytearray)): - return _serialize_bytes(o, self.format) - try: - # First try datetime.datetime - return _serialize_datetime(o, self.format) - except AttributeError: - pass - # Last, try datetime.timedelta - try: - return _timedelta_as_isostr(o) - except AttributeError: - # This will be raised when it hits value.total_seconds in the method above - pass - return super(SdkJSONEncoder, self).default(o) - - -_VALID_DATE = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" + r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") -_VALID_RFC7231 = re.compile( - r"(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s\d{2}\s" - r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT" -) - - -def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: - """Deserialize ISO-8601 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :rtype: ~datetime.datetime - :returns: The datetime object from that input - """ - if isinstance(attr, datetime): - # i'm already deserialized - return attr - attr = attr.upper() - match = _VALID_DATE.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - check_decimal = attr.split(".") - if len(check_decimal) > 1: - decimal_str = "" - for digit in check_decimal[1]: - if digit.isdigit(): - decimal_str += digit - else: - break - if len(decimal_str) > 6: - attr = attr.replace(decimal_str, decimal_str[0:6]) - - date_obj = isodate.parse_datetime(attr) - test_utc = date_obj.utctimetuple() - if test_utc.tm_year > 9999 or test_utc.tm_year < 1: - raise OverflowError("Hit max or min date") - return date_obj - - -def _deserialize_datetime_rfc7231(attr: typing.Union[str, datetime]) -> datetime: - """Deserialize RFC7231 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :rtype: ~datetime.datetime - :returns: The datetime object from that input - """ - if isinstance(attr, datetime): - # i'm already deserialized - return attr - match = _VALID_RFC7231.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - return email.utils.parsedate_to_datetime(attr) - - -def _deserialize_datetime_unix_timestamp(attr: typing.Union[float, datetime]) -> datetime: - """Deserialize unix timestamp into Datetime object. - - :param str attr: response string to be deserialized. - :rtype: ~datetime.datetime - :returns: The datetime object from that input - """ - if isinstance(attr, datetime): - # i'm already deserialized - return attr - return datetime.fromtimestamp(attr, TZ_UTC) - - -def _deserialize_date(attr: typing.Union[str, date]) -> date: - """Deserialize ISO-8601 formatted string into Date object. - :param str attr: response string to be deserialized. - :rtype: date - :returns: The date object from that input - """ - # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - if isinstance(attr, date): - return attr - return isodate.parse_date(attr, defaultmonth=None, defaultday=None) # type: ignore - - -def _deserialize_time(attr: typing.Union[str, time]) -> time: - """Deserialize ISO-8601 formatted string into time object. - - :param str attr: response string to be deserialized. - :rtype: datetime.time - :returns: The time object from that input - """ - if isinstance(attr, time): - return attr - return isodate.parse_time(attr) - - -def _deserialize_bytes(attr): - if isinstance(attr, (bytes, bytearray)): - return attr - return bytes(base64.b64decode(attr)) - - -def _deserialize_bytes_base64(attr): - if isinstance(attr, (bytes, bytearray)): - return attr - padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore - attr = attr + padding # type: ignore - encoded = attr.replace("-", "+").replace("_", "/") - return bytes(base64.b64decode(encoded)) - - -def _deserialize_duration(attr): - if isinstance(attr, timedelta): - return attr - return isodate.parse_duration(attr) - - -def _deserialize_decimal(attr): - if isinstance(attr, decimal.Decimal): - return attr - return decimal.Decimal(str(attr)) - - -def _deserialize_int_as_str(attr): - if isinstance(attr, int): - return attr - return int(attr) - - -_DESERIALIZE_MAPPING = { - datetime: _deserialize_datetime, - date: _deserialize_date, - time: _deserialize_time, - bytes: _deserialize_bytes, - bytearray: _deserialize_bytes, - timedelta: _deserialize_duration, - typing.Any: lambda x: x, - decimal.Decimal: _deserialize_decimal, -} - -_DESERIALIZE_MAPPING_WITHFORMAT = { - "rfc3339": _deserialize_datetime, - "rfc7231": _deserialize_datetime_rfc7231, - "unix-timestamp": _deserialize_datetime_unix_timestamp, - "base64": _deserialize_bytes, - "base64url": _deserialize_bytes_base64, -} - - -def get_deserializer(annotation: typing.Any, rf: typing.Optional["_RestField"] = None): - if annotation is int and rf and rf._format == "str": - return _deserialize_int_as_str - if rf and rf._format: - return _DESERIALIZE_MAPPING_WITHFORMAT.get(rf._format) - return _DESERIALIZE_MAPPING.get(annotation) # pyright: ignore - - -def _get_type_alias_type(module_name: str, alias_name: str): - types = { - k: v - for k, v in sys.modules[module_name].__dict__.items() - if isinstance(v, typing._GenericAlias) # type: ignore - } - if alias_name not in types: - return alias_name - return types[alias_name] - - -def _get_model(module_name: str, model_name: str): - models = {k: v for k, v in sys.modules[module_name].__dict__.items() if isinstance(v, type)} - module_end = module_name.rsplit(".", 1)[0] - models.update({k: v for k, v in sys.modules[module_end].__dict__.items() if isinstance(v, type)}) - if isinstance(model_name, str): - model_name = model_name.split(".")[-1] - if model_name not in models: - return model_name - return models[model_name] - - -_UNSET = object() - - -class _MyMutableMapping(MutableMapping[str, typing.Any]): # pylint: disable=unsubscriptable-object - def __init__(self, data: typing.Dict[str, typing.Any]) -> None: - self._data = data - - def __contains__(self, key: typing.Any) -> bool: - return key in self._data - - def __getitem__(self, key: str) -> typing.Any: - return self._data.__getitem__(key) - - def __setitem__(self, key: str, value: typing.Any) -> None: - self._data.__setitem__(key, value) - - def __delitem__(self, key: str) -> None: - self._data.__delitem__(key) - - def __iter__(self) -> typing.Iterator[typing.Any]: - return self._data.__iter__() - - def __len__(self) -> int: - return self._data.__len__() - - def __ne__(self, other: typing.Any) -> bool: - return not self.__eq__(other) - - def keys(self) -> typing.KeysView[str]: - """ - :returns: a set-like object providing a view on D's keys - :rtype: ~typing.KeysView - """ - return self._data.keys() - - def values(self) -> typing.ValuesView[typing.Any]: - """ - :returns: an object providing a view on D's values - :rtype: ~typing.ValuesView - """ - return self._data.values() - - def items(self) -> typing.ItemsView[str, typing.Any]: - """ - :returns: set-like object providing a view on D's items - :rtype: ~typing.ItemsView - """ - return self._data.items() - - def get(self, key: str, default: typing.Any = None) -> typing.Any: - """ - Get the value for key if key is in the dictionary, else default. - :param str key: The key to look up. - :param any default: The value to return if key is not in the dictionary. Defaults to None - :returns: D[k] if k in D, else d. - :rtype: any - """ - try: - return self[key] - except KeyError: - return default - - @typing.overload - def pop(self, key: str) -> typing.Any: ... - - @typing.overload - def pop(self, key: str, default: _T) -> _T: ... - - @typing.overload - def pop(self, key: str, default: typing.Any) -> typing.Any: ... - - def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: - """ - Removes specified key and return the corresponding value. - :param str key: The key to pop. - :param any default: The value to return if key is not in the dictionary - :returns: The value corresponding to the key. - :rtype: any - :raises KeyError: If key is not found and default is not given. - """ - if default is _UNSET: - return self._data.pop(key) - return self._data.pop(key, default) - - def popitem(self) -> typing.Tuple[str, typing.Any]: - """ - Removes and returns some (key, value) pair - :returns: The (key, value) pair. - :rtype: tuple - :raises KeyError: if D is empty. - """ - return self._data.popitem() - - def clear(self) -> None: - """ - Remove all items from D. - """ - self._data.clear() - - def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: - """ - Updates D from mapping/iterable E and F. - :param any args: Either a mapping object or an iterable of key-value pairs. - """ - self._data.update(*args, **kwargs) - - @typing.overload - def setdefault(self, key: str, default: None = None) -> None: ... - - @typing.overload - def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... - - def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: - """ - Same as calling D.get(k, d), and setting D[k]=d if k not found - :param str key: The key to look up. - :param any default: The value to set if key is not in the dictionary - :returns: D[k] if k in D, else d. - :rtype: any - """ - if default is _UNSET: - return self._data.setdefault(key) - return self._data.setdefault(key, default) - - def __eq__(self, other: typing.Any) -> bool: - try: - other_model = self.__class__(other) - except Exception: - return False - return self._data == other_model._data - - def __repr__(self) -> str: - return str(self._data) - - -def _is_model(obj: typing.Any) -> bool: - return getattr(obj, "_is_model", False) - - -def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-many-return-statements - if isinstance(o, list): - return [_serialize(x, format) for x in o] - if isinstance(o, dict): - return {k: _serialize(v, format) for k, v in o.items()} - if isinstance(o, set): - return {_serialize(x, format) for x in o} - if isinstance(o, tuple): - return tuple(_serialize(x, format) for x in o) - if isinstance(o, (bytes, bytearray)): - return _serialize_bytes(o, format) - if isinstance(o, decimal.Decimal): - return float(o) - if isinstance(o, enum.Enum): - return o.value - if isinstance(o, int): - if format == "str": - return str(o) - return o - try: - # First try datetime.datetime - return _serialize_datetime(o, format) - except AttributeError: - pass - # Last, try datetime.timedelta - try: - return _timedelta_as_isostr(o) - except AttributeError: - # This will be raised when it hits value.total_seconds in the method above - pass - return o - - -def _get_rest_field( - attr_to_rest_field: typing.Dict[str, "_RestField"], rest_name: str -) -> typing.Optional["_RestField"]: - try: - return next(rf for rf in attr_to_rest_field.values() if rf._rest_name == rest_name) - except StopIteration: - return None - - -def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typing.Any: - if not rf: - return _serialize(value, None) - if rf._is_multipart_file_input: - return value - if rf._is_model: - return _deserialize(rf._type, value) - if isinstance(value, ET.Element): - value = _deserialize(rf._type, value) - return _serialize(value, rf._format) - - -class Model(_MyMutableMapping): - _is_model = True - # label whether current class's _attr_to_rest_field has been calculated - # could not see _attr_to_rest_field directly because subclass inherits it from parent class - _calculated: typing.Set[str] = set() - - def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: - class_name = self.__class__.__name__ - if len(args) > 1: - raise TypeError(f"{class_name}.__init__() takes 2 positional arguments but {len(args) + 1} were given") - dict_to_pass = { - rest_field._rest_name: rest_field._default - for rest_field in self._attr_to_rest_field.values() - if rest_field._default is not _UNSET - } - if args: # pylint: disable=too-many-nested-blocks - if isinstance(args[0], ET.Element): - existed_attr_keys = [] - model_meta = getattr(self, "_xml", {}) - - for rf in self._attr_to_rest_field.values(): - prop_meta = getattr(rf, "_xml", {}) - xml_name = prop_meta.get("name", rf._rest_name) - xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) - if xml_ns: - xml_name = "{" + xml_ns + "}" + xml_name - - # attribute - if prop_meta.get("attribute", False) and args[0].get(xml_name) is not None: - existed_attr_keys.append(xml_name) - dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].get(xml_name)) - continue - - # unwrapped element is array - if prop_meta.get("unwrapped", False): - # unwrapped array could either use prop items meta/prop meta - if prop_meta.get("itemsName"): - xml_name = prop_meta.get("itemsName") - xml_ns = prop_meta.get("itemNs") - if xml_ns: - xml_name = "{" + xml_ns + "}" + xml_name - items = args[0].findall(xml_name) # pyright: ignore - if len(items) > 0: - existed_attr_keys.append(xml_name) - dict_to_pass[rf._rest_name] = _deserialize(rf._type, items) - continue - - # text element is primitive type - if prop_meta.get("text", False): - if args[0].text is not None: - dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].text) - continue - - # wrapped element could be normal property or array, it should only have one element - item = args[0].find(xml_name) - if item is not None: - existed_attr_keys.append(xml_name) - dict_to_pass[rf._rest_name] = _deserialize(rf._type, item) - - # rest thing is additional properties - for e in args[0]: - if e.tag not in existed_attr_keys: - dict_to_pass[e.tag] = _convert_element(e) - else: - dict_to_pass.update( - {k: _create_value(_get_rest_field(self._attr_to_rest_field, k), v) for k, v in args[0].items()} - ) - else: - non_attr_kwargs = [k for k in kwargs if k not in self._attr_to_rest_field] - if non_attr_kwargs: - # actual type errors only throw the first wrong keyword arg they see, so following that. - raise TypeError(f"{class_name}.__init__() got an unexpected keyword argument '{non_attr_kwargs[0]}'") - dict_to_pass.update( - { - self._attr_to_rest_field[k]._rest_name: _create_value(self._attr_to_rest_field[k], v) - for k, v in kwargs.items() - if v is not None - } - ) - super().__init__(dict_to_pass) - - def copy(self) -> "Model": - return Model(self.__dict__) - - def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: - if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated: - # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', - # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' - mros = cls.__mro__[:-9][::-1] # ignore parents, and reverse the mro order - attr_to_rest_field: typing.Dict[str, _RestField] = { # map attribute name to rest_field property - k: v for mro_class in mros for k, v in mro_class.__dict__.items() if k[0] != "_" and hasattr(v, "_type") - } - annotations = { - k: v - for mro_class in mros - if hasattr(mro_class, "__annotations__") - for k, v in mro_class.__annotations__.items() - } - for attr, rf in attr_to_rest_field.items(): - rf._module = cls.__module__ - if not rf._type: - rf._type = rf._get_deserialize_callable_from_annotation(annotations.get(attr, None)) - if not rf._rest_name_input: - rf._rest_name_input = attr - cls._attr_to_rest_field: typing.Dict[str, _RestField] = dict(attr_to_rest_field.items()) - cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") - - return super().__new__(cls) # pylint: disable=no-value-for-parameter - - def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: - for base in cls.__bases__: - if hasattr(base, "__mapping__"): - base.__mapping__[discriminator or cls.__name__] = cls # type: ignore - - @classmethod - def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]: - for v in cls.__dict__.values(): - if isinstance(v, _RestField) and v._is_discriminator and v._rest_name not in exist_discriminators: - return v - return None - - @classmethod - def _deserialize(cls, data, exist_discriminators): - if not hasattr(cls, "__mapping__"): - return cls(data) - discriminator = cls._get_discriminator(exist_discriminators) - if discriminator is None: - return cls(data) - exist_discriminators.append(discriminator._rest_name) - if isinstance(data, ET.Element): - model_meta = getattr(cls, "_xml", {}) - prop_meta = getattr(discriminator, "_xml", {}) - xml_name = prop_meta.get("name", discriminator._rest_name) - xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) - if xml_ns: - xml_name = "{" + xml_ns + "}" + xml_name - - if data.get(xml_name) is not None: - discriminator_value = data.get(xml_name) - else: - discriminator_value = data.find(xml_name).text # pyright: ignore - else: - discriminator_value = data.get(discriminator._rest_name) - mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore - return mapped_cls._deserialize(data, exist_discriminators) - - def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.Any]: - """Return a dict that can be turned into json using json.dump. - - :keyword bool exclude_readonly: Whether to remove the readonly properties. - :returns: A dict JSON compatible object - :rtype: dict - """ - - result = {} - readonly_props = [] - if exclude_readonly: - readonly_props = [p._rest_name for p in self._attr_to_rest_field.values() if _is_readonly(p)] - for k, v in self.items(): - if exclude_readonly and k in readonly_props: # pyright: ignore - continue - is_multipart_file_input = False - try: - is_multipart_file_input = next( - rf for rf in self._attr_to_rest_field.values() if rf._rest_name == k - )._is_multipart_file_input - except StopIteration: - pass - result[k] = v if is_multipart_file_input else Model._as_dict_value(v, exclude_readonly=exclude_readonly) - return result - - @staticmethod - def _as_dict_value(v: typing.Any, exclude_readonly: bool = False) -> typing.Any: - if v is None or isinstance(v, _Null): - return None - if isinstance(v, (list, tuple, set)): - return type(v)(Model._as_dict_value(x, exclude_readonly=exclude_readonly) for x in v) - if isinstance(v, dict): - return {dk: Model._as_dict_value(dv, exclude_readonly=exclude_readonly) for dk, dv in v.items()} - return v.as_dict(exclude_readonly=exclude_readonly) if hasattr(v, "as_dict") else v - - -def _deserialize_model(model_deserializer: typing.Optional[typing.Callable], obj): - if _is_model(obj): - return obj - return _deserialize(model_deserializer, obj) - - -def _deserialize_with_optional(if_obj_deserializer: typing.Optional[typing.Callable], obj): - if obj is None: - return obj - return _deserialize_with_callable(if_obj_deserializer, obj) - - -def _deserialize_with_union(deserializers, obj): - for deserializer in deserializers: - try: - return _deserialize(deserializer, obj) - except DeserializationError: - pass - raise DeserializationError() - - -def _deserialize_dict( - value_deserializer: typing.Optional[typing.Callable], - module: typing.Optional[str], - obj: typing.Dict[typing.Any, typing.Any], -): - if obj is None: - return obj - if isinstance(obj, ET.Element): - obj = {child.tag: child for child in obj} - return {k: _deserialize(value_deserializer, v, module) for k, v in obj.items()} - - -def _deserialize_multiple_sequence( - entry_deserializers: typing.List[typing.Optional[typing.Callable]], - module: typing.Optional[str], - obj, -): - if obj is None: - return obj - return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers)) - - -def _deserialize_sequence( - deserializer: typing.Optional[typing.Callable], - module: typing.Optional[str], - obj, -): - if obj is None: - return obj - if isinstance(obj, ET.Element): - obj = list(obj) - return type(obj)(_deserialize(deserializer, entry, module) for entry in obj) - - -def _sorted_annotations(types: typing.List[typing.Any]) -> typing.List[typing.Any]: - return sorted( - types, - key=lambda x: hasattr(x, "__name__") and x.__name__.lower() in ("str", "float", "int", "bool"), - ) - - -def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-branches - annotation: typing.Any, - module: typing.Optional[str], - rf: typing.Optional["_RestField"] = None, -) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: - if not annotation: - return None - - # is it a type alias? - if isinstance(annotation, str): - if module is not None: - annotation = _get_type_alias_type(module, annotation) - - # is it a forward ref / in quotes? - if isinstance(annotation, (str, typing.ForwardRef)): - try: - model_name = annotation.__forward_arg__ # type: ignore - except AttributeError: - model_name = annotation - if module is not None: - annotation = _get_model(module, model_name) # type: ignore - - try: - if module and _is_model(annotation): - if rf: - rf._is_model = True - - return functools.partial(_deserialize_model, annotation) # pyright: ignore - except Exception: - pass - - # is it a literal? - try: - if annotation.__origin__ is typing.Literal: # pyright: ignore - return None - except AttributeError: - pass - - # is it optional? - try: - if any(a for a in annotation.__args__ if a == type(None)): # pyright: ignore - if len(annotation.__args__) <= 2: # pyright: ignore - if_obj_deserializer = _get_deserialize_callable_from_annotation( - next(a for a in annotation.__args__ if a != type(None)), module, rf # pyright: ignore - ) - - return functools.partial(_deserialize_with_optional, if_obj_deserializer) - # the type is Optional[Union[...]], we need to remove the None type from the Union - annotation_copy = copy.copy(annotation) - annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a != type(None)] # pyright: ignore - return _get_deserialize_callable_from_annotation(annotation_copy, module, rf) - except AttributeError: - pass - - # is it union? - if getattr(annotation, "__origin__", None) is typing.Union: - # initial ordering is we make `string` the last deserialization option, because it is often them most generic - deserializers = [ - _get_deserialize_callable_from_annotation(arg, module, rf) - for arg in _sorted_annotations(annotation.__args__) # pyright: ignore - ] - - return functools.partial(_deserialize_with_union, deserializers) - - try: - if annotation._name == "Dict": # pyright: ignore - value_deserializer = _get_deserialize_callable_from_annotation( - annotation.__args__[1], module, rf # pyright: ignore - ) - - return functools.partial( - _deserialize_dict, - value_deserializer, - module, - ) - except (AttributeError, IndexError): - pass - try: - if annotation._name in ["List", "Set", "Tuple", "Sequence"]: # pyright: ignore - if len(annotation.__args__) > 1: # pyright: ignore - entry_deserializers = [ - _get_deserialize_callable_from_annotation(dt, module, rf) - for dt in annotation.__args__ # pyright: ignore - ] - return functools.partial(_deserialize_multiple_sequence, entry_deserializers, module) - deserializer = _get_deserialize_callable_from_annotation( - annotation.__args__[0], module, rf # pyright: ignore - ) - - return functools.partial(_deserialize_sequence, deserializer, module) - except (TypeError, IndexError, AttributeError, SyntaxError): - pass - - def _deserialize_default( - deserializer, - obj, - ): - if obj is None: - return obj - try: - return _deserialize_with_callable(deserializer, obj) - except Exception: - pass - return obj - - if get_deserializer(annotation, rf): - return functools.partial(_deserialize_default, get_deserializer(annotation, rf)) - - return functools.partial(_deserialize_default, annotation) - - -def _deserialize_with_callable( - deserializer: typing.Optional[typing.Callable[[typing.Any], typing.Any]], - value: typing.Any, -): # pylint: disable=too-many-return-statements - try: - if value is None or isinstance(value, _Null): - return None - if isinstance(value, ET.Element): - if deserializer is str: - return value.text or "" - if deserializer is int: - return int(value.text) if value.text else None - if deserializer is float: - return float(value.text) if value.text else None - if deserializer is bool: - return value.text == "true" if value.text else None - if deserializer is None: - return value - if deserializer in [int, float, bool]: - return deserializer(value) - if isinstance(deserializer, CaseInsensitiveEnumMeta): - try: - return deserializer(value) - except ValueError: - # for unknown value, return raw value - return value - if isinstance(deserializer, type) and issubclass(deserializer, Model): - return deserializer._deserialize(value, []) - return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value) - except Exception as e: - raise DeserializationError() from e - - -def _deserialize( - deserializer: typing.Any, - value: typing.Any, - module: typing.Optional[str] = None, - rf: typing.Optional["_RestField"] = None, - format: typing.Optional[str] = None, -) -> typing.Any: - if isinstance(value, PipelineResponse): - value = value.http_response.json() - if rf is None and format: - rf = _RestField(format=format) - if not isinstance(deserializer, functools.partial): - deserializer = _get_deserialize_callable_from_annotation(deserializer, module, rf) - return _deserialize_with_callable(deserializer, value) - - -def _failsafe_deserialize( - deserializer: typing.Any, - value: typing.Any, - module: typing.Optional[str] = None, - rf: typing.Optional["_RestField"] = None, - format: typing.Optional[str] = None, -) -> typing.Any: - try: - return _deserialize(deserializer, value, module, rf, format) - except DeserializationError: - _LOGGER.warning( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - -def _failsafe_deserialize_xml( - deserializer: typing.Any, - value: typing.Any, -) -> typing.Any: - try: - return _deserialize_xml(deserializer, value) - except DeserializationError: - _LOGGER.warning( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - -class _RestField: - def __init__( - self, - *, - name: typing.Optional[str] = None, - type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin - is_discriminator: bool = False, - visibility: typing.Optional[typing.List[str]] = None, - default: typing.Any = _UNSET, - format: typing.Optional[str] = None, - is_multipart_file_input: bool = False, - xml: typing.Optional[typing.Dict[str, typing.Any]] = None, - ): - self._type = type - self._rest_name_input = name - self._module: typing.Optional[str] = None - self._is_discriminator = is_discriminator - self._visibility = visibility - self._is_model = False - self._default = default - self._format = format - self._is_multipart_file_input = is_multipart_file_input - self._xml = xml if xml is not None else {} - - @property - def _class_type(self) -> typing.Any: - return getattr(self._type, "args", [None])[0] - - @property - def _rest_name(self) -> str: - if self._rest_name_input is None: - raise ValueError("Rest name was never set") - return self._rest_name_input - - def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin - # by this point, type and rest_name will have a value bc we default - # them in __new__ of the Model class - item = obj.get(self._rest_name) - if item is None: - return item - if self._is_model: - return item - return _deserialize(self._type, _serialize(item, self._format), rf=self) - - def __set__(self, obj: Model, value) -> None: - if value is None: - # we want to wipe out entries if users set attr to None - try: - obj.__delitem__(self._rest_name) - except KeyError: - pass - return - if self._is_model: - if not _is_model(value): - value = _deserialize(self._type, value) - obj.__setitem__(self._rest_name, value) - return - obj.__setitem__(self._rest_name, _serialize(value, self._format)) - - def _get_deserialize_callable_from_annotation( - self, annotation: typing.Any - ) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: - return _get_deserialize_callable_from_annotation(annotation, self._module, self) - - -def rest_field( - *, - name: typing.Optional[str] = None, - type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin - visibility: typing.Optional[typing.List[str]] = None, - default: typing.Any = _UNSET, - format: typing.Optional[str] = None, - is_multipart_file_input: bool = False, - xml: typing.Optional[typing.Dict[str, typing.Any]] = None, -) -> typing.Any: - return _RestField( - name=name, - type=type, - visibility=visibility, - default=default, - format=format, - is_multipart_file_input=is_multipart_file_input, - xml=xml, - ) - - -def rest_discriminator( - *, - name: typing.Optional[str] = None, - type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin - visibility: typing.Optional[typing.List[str]] = None, - xml: typing.Optional[typing.Dict[str, typing.Any]] = None, -) -> typing.Any: - return _RestField(name=name, type=type, is_discriminator=True, visibility=visibility, xml=xml) - - -def serialize_xml(model: Model, exclude_readonly: bool = False) -> str: - """Serialize a model to XML. - - :param Model model: The model to serialize. - :param bool exclude_readonly: Whether to exclude readonly properties. - :returns: The XML representation of the model. - :rtype: str - """ - return ET.tostring(_get_element(model, exclude_readonly), encoding="unicode") # type: ignore - - -def _get_element( - o: typing.Any, - exclude_readonly: bool = False, - parent_meta: typing.Optional[typing.Dict[str, typing.Any]] = None, - wrapped_element: typing.Optional[ET.Element] = None, -) -> typing.Union[ET.Element, typing.List[ET.Element]]: - if _is_model(o): - model_meta = getattr(o, "_xml", {}) - - # if prop is a model, then use the prop element directly, else generate a wrapper of model - if wrapped_element is None: - wrapped_element = _create_xml_element( - model_meta.get("name", o.__class__.__name__), - model_meta.get("prefix"), - model_meta.get("ns"), - ) - - readonly_props = [] - if exclude_readonly: - readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] - - for k, v in o.items(): - # do not serialize readonly properties - if exclude_readonly and k in readonly_props: - continue - - prop_rest_field = _get_rest_field(o._attr_to_rest_field, k) - if prop_rest_field: - prop_meta = getattr(prop_rest_field, "_xml").copy() - # use the wire name as xml name if no specific name is set - if prop_meta.get("name") is None: - prop_meta["name"] = k - else: - # additional properties will not have rest field, use the wire name as xml name - prop_meta = {"name": k} - - # if no ns for prop, use model's - if prop_meta.get("ns") is None and model_meta.get("ns"): - prop_meta["ns"] = model_meta.get("ns") - prop_meta["prefix"] = model_meta.get("prefix") - - if prop_meta.get("unwrapped", False): - # unwrapped could only set on array - wrapped_element.extend(_get_element(v, exclude_readonly, prop_meta)) - elif prop_meta.get("text", False): - # text could only set on primitive type - wrapped_element.text = _get_primitive_type_value(v) - elif prop_meta.get("attribute", False): - xml_name = prop_meta.get("name", k) - if prop_meta.get("ns"): - ET.register_namespace(prop_meta.get("prefix"), prop_meta.get("ns")) # pyright: ignore - xml_name = "{" + prop_meta.get("ns") + "}" + xml_name # pyright: ignore - # attribute should be primitive type - wrapped_element.set(xml_name, _get_primitive_type_value(v)) - else: - # other wrapped prop element - wrapped_element.append(_get_wrapped_element(v, exclude_readonly, prop_meta)) - return wrapped_element - if isinstance(o, list): - return [_get_element(x, exclude_readonly, parent_meta) for x in o] # type: ignore - if isinstance(o, dict): - result = [] - for k, v in o.items(): - result.append( - _get_wrapped_element( - v, - exclude_readonly, - { - "name": k, - "ns": parent_meta.get("ns") if parent_meta else None, - "prefix": parent_meta.get("prefix") if parent_meta else None, - }, - ) - ) - return result - - # primitive case need to create element based on parent_meta - if parent_meta: - return _get_wrapped_element( - o, - exclude_readonly, - { - "name": parent_meta.get("itemsName", parent_meta.get("name")), - "prefix": parent_meta.get("itemsPrefix", parent_meta.get("prefix")), - "ns": parent_meta.get("itemsNs", parent_meta.get("ns")), - }, - ) - - raise ValueError("Could not serialize value into xml: " + o) - - -def _get_wrapped_element( - v: typing.Any, - exclude_readonly: bool, - meta: typing.Optional[typing.Dict[str, typing.Any]], -) -> ET.Element: - wrapped_element = _create_xml_element( - meta.get("name") if meta else None, meta.get("prefix") if meta else None, meta.get("ns") if meta else None - ) - if isinstance(v, (dict, list)): - wrapped_element.extend(_get_element(v, exclude_readonly, meta)) - elif _is_model(v): - _get_element(v, exclude_readonly, meta, wrapped_element) - else: - wrapped_element.text = _get_primitive_type_value(v) - return wrapped_element - - -def _get_primitive_type_value(v) -> str: - if v is True: - return "true" - if v is False: - return "false" - if isinstance(v, _Null): - return "" - return str(v) - - -def _create_xml_element(tag, prefix=None, ns=None): - if prefix and ns: - ET.register_namespace(prefix, ns) - if ns: - return ET.Element("{" + ns + "}" + tag) - return ET.Element(tag) - - -def _deserialize_xml( - deserializer: typing.Any, - value: str, -) -> typing.Any: - element = ET.fromstring(value) # nosec - return _deserialize(deserializer, element) - - -def _convert_element(e: ET.Element): - # dict case - if len(e.attrib) > 0 or len({child.tag for child in e}) > 1: - dict_result: typing.Dict[str, typing.Any] = {} - for child in e: - if dict_result.get(child.tag) is not None: - if isinstance(dict_result[child.tag], list): - dict_result[child.tag].append(_convert_element(child)) - else: - dict_result[child.tag] = [dict_result[child.tag], _convert_element(child)] - else: - dict_result[child.tag] = _convert_element(child) - dict_result.update(e.attrib) - return dict_result - # array case - if len(e) > 0: - array_result: typing.List[typing.Any] = [] - for child in e: - array_result.append(_convert_element(child)) - return array_result - # primitive case - return e.text diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_operations/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_operations/__init__.py deleted file mode 100644 index 2674f45390d..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_operations/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import PathClientOperationsMixin # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "PathClientOperationsMixin", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_operations/_operations.py deleted file mode 100644 index b6825cddb2d..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_operations/_operations.py +++ /dev/null @@ -1,95 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace - -from .._serialization import Serializer -from .._vendor import PathClientMixinABC - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_path_path_api_version_request(**kwargs: Any) -> HttpRequest: - version: str = kwargs.pop("version", "2025-01-01") - # Construct URL - _url = "/azure/client-generator-core/api-version/path/{version}" - path_format_arguments = { - "version": _SERIALIZER.url("version", version, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - return HttpRequest(method="POST", url=_url, **kwargs) - - -class PathClientOperationsMixin(PathClientMixinABC): - - @distributed_trace - def path_api_version(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """Path api version parameter. - - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_path_path_api_version_request( - version=self._config.version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_operations/_patch.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_operations/_patch.py deleted file mode 100644 index f7dd3251033..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__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/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_patch.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_patch.py deleted file mode 100644 index f7dd3251033..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__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/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_serialization.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_serialization.py deleted file mode 100644 index e2a20b1d534..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_serialization.py +++ /dev/null @@ -1,2050 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# -------------------------------------------------------------------------- -# -# Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# 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. -# -# -------------------------------------------------------------------------- - -# pyright: reportUnnecessaryTypeIgnoreComment=false - -from base64 import b64decode, b64encode -import calendar -import datetime -import decimal -import email -from enum import Enum -import json -import logging -import re -import sys -import codecs -from typing import ( - Dict, - Any, - cast, - Optional, - Union, - AnyStr, - IO, - Mapping, - Callable, - MutableMapping, - List, -) - -try: - from urllib import quote # type: ignore -except ImportError: - from urllib.parse import quote -import xml.etree.ElementTree as ET - -import isodate # type: ignore -from typing_extensions import Self - -from azure.core.exceptions import DeserializationError, SerializationError -from azure.core.serialization import NULL as CoreNull - -_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") - -JSON = MutableMapping[str, Any] - - -class RawDeserializer: - - # Accept "text" because we're open minded people... - JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") - - # Name used in context - CONTEXT_NAME = "deserialized_data" - - @classmethod - def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: - """Decode data according to content-type. - - Accept a stream of data as well, but will be load at once in memory for now. - - If no content-type, will return the string version (not bytes, not stream) - - :param data: Input, could be bytes or stream (will be decoded with UTF8) or text - :type data: str or bytes or IO - :param str content_type: The content type. - :return: The deserialized data. - :rtype: object - """ - if hasattr(data, "read"): - # Assume a stream - data = cast(IO, data).read() - - if isinstance(data, bytes): - data_as_str = data.decode(encoding="utf-8-sig") - else: - # Explain to mypy the correct type. - data_as_str = cast(str, data) - - # Remove Byte Order Mark if present in string - data_as_str = data_as_str.lstrip(_BOM) - - if content_type is None: - return data - - if cls.JSON_REGEXP.match(content_type): - try: - return json.loads(data_as_str) - except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) from err - elif "xml" in (content_type or []): - try: - - try: - if isinstance(data, unicode): # type: ignore - # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string - data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore - except NameError: - pass - - return ET.fromstring(data_as_str) # nosec - except ET.ParseError as err: - # It might be because the server has an issue, and returned JSON with - # content-type XML.... - # So let's try a JSON load, and if it's still broken - # let's flow the initial exception - def _json_attemp(data): - try: - return True, json.loads(data) - except ValueError: - return False, None # Don't care about this one - - success, json_result = _json_attemp(data) - if success: - return json_result - # If i'm here, it's not JSON, it's not XML, let's scream - # and raise the last context in this block (the XML exception) - # The function hack is because Py2.7 messes up with exception - # context otherwise. - _LOGGER.critical("Wasn't XML not JSON, failing") - raise DeserializationError("XML is invalid") from err - elif content_type.startswith("text/"): - return data_as_str - raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) - - @classmethod - def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: - """Deserialize from HTTP response. - - Use bytes and headers to NOT use any requests/aiohttp or whatever - specific implementation. - Headers will tested for "content-type" - - :param bytes body_bytes: The body of the response. - :param dict headers: The headers of the response. - :returns: The deserialized data. - :rtype: object - """ - # Try to use content-type from headers if available - content_type = None - if "content-type" in headers: - content_type = headers["content-type"].split(";")[0].strip().lower() - # Ouch, this server did not declare what it sent... - # Let's guess it's JSON... - # Also, since Autorest was considering that an empty body was a valid JSON, - # need that test as well.... - else: - content_type = "application/json" - - if body_bytes: - return cls.deserialize_from_text(body_bytes, content_type) - return None - - -_LOGGER = logging.getLogger(__name__) - -try: - _long_type = long # type: ignore -except NameError: - _long_type = int - -TZ_UTC = datetime.timezone.utc - -_FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: # pylint: disable=consider-using-dict-items - if k not in self._attribute_map: - _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) - elif k in self._validation and self._validation[k].get("readonly", False): - _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) - else: - setattr(self, k, kwargs[k]) - - def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are equal - :rtype: bool - """ - if isinstance(other, self.__class__): - return self.__dict__ == other.__dict__ - return False - - def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are not equal - :rtype: bool - """ - return not self.__eq__(other) - - def __str__(self) -> str: - return str(self.__dict__) - - @classmethod - def enable_additional_properties_sending(cls) -> None: - cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} - - @classmethod - def is_xml_model(cls) -> bool: - try: - cls._xml_map # type: ignore - except AttributeError: - return False - return True - - @classmethod - def _create_xml_node(cls): - """Create XML node. - - :returns: The XML node - :rtype: xml.etree.ElementTree.Element - """ - try: - xml_map = cls._xml_map # type: ignore - except AttributeError: - xml_map = {} - - return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - - def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to server from this model. - - This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, keep_readonly=keep_readonly, **kwargs - ) - - def as_dict( - self, - keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, - **kwargs: Any - ) -> JSON: - """Return a dict that can be serialized using json.dump. - - Advanced usage might optionally use a callback as parameter: - - .. code::python - - def my_key_transformer(key, attr_desc, value): - return key - - Key is the attribute name used in Python. Attr_desc - is a dict of metadata. Currently contains 'type' with the - msrest type and 'key' with the RestAPI encoded key. - Value is the current value in this object. - - The string returned will be used to serialize the key. - If the return type is a list, this is considered hierarchical - result dict. - - See the three examples in this file: - - - attribute_transformer - - full_restapi_key_transformer - - last_restapi_key_transformer - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :param function key_transformer: A key transformer function. - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs - ) - - @classmethod - def _infer_class_models(cls): - try: - str_models = cls.__module__.rsplit(".", 1)[0] - models = sys.modules[str_models] - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - if cls.__name__ not in client_models: - raise ValueError("Not Autorest generated code") - except Exception: # pylint: disable=broad-exception-caught - # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. - client_models = {cls.__name__: cls} - return client_models - - @classmethod - def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: - """Parse a str using the RestAPI syntax and return a model. - - :param str data: A str using RestAPI structure. JSON by default. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def from_dict( - cls, - data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, - content_type: Optional[str] = None, - ) -> Self: - """Parse a dict using given key extractor return a model. - - By default consider key - extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor - and last_rest_key_case_insensitive_extractor) - - :param dict data: A dict using RestAPI structure - :param function key_extractors: A key extractor function. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises: DeserializationError if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( # type: ignore - [ # type: ignore - attribute_key_case_insensitive_extractor, - rest_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - if key_extractors is None - else key_extractors - ) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def _flatten_subtype(cls, key, objects): - if "_subtype_map" not in cls.__dict__: - return {} - result = dict(cls._subtype_map[key]) - for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access - return result - - @classmethod - def _classify(cls, response, objects): - """Check the class _subtype_map for any child classes. - We want to ignore any inherited _subtype_maps. - - :param dict response: The initial data - :param dict objects: The class objects - :returns: The class to be used - :rtype: class - """ - for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): - subtype_value = None - - if not isinstance(response, ET.Element): - rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) - else: - subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) - if subtype_value: - # Try to match base class. Can be class name only - # (bug to fix in Autorest to support x-ms-discriminator-name) - if cls.__name__ == subtype_value: - return cls - flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) - try: - return objects[flatten_mapping_type[subtype_value]] # type: ignore - except KeyError: - _LOGGER.warning( - "Subtype value %s has no mapping, use base class %s.", - subtype_value, - cls.__name__, - ) - break - else: - _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) - break - return cls - - @classmethod - def _get_rest_key_parts(cls, attr_key): - """Get the RestAPI key of this attr, split it and decode part - :param str attr_key: Attribute key must be in attribute_map. - :returns: A list of RestAPI part - :rtype: list - """ - rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) - return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] - - -def _decode_attribute_map_key(key): - """This decode a key in an _attribute_map to the actual key we want to look at - inside the received data. - - :param str key: A key string from the generated code - :returns: The decoded key - :rtype: str - """ - return key.replace("\\.", ".") - - -class Serializer: # pylint: disable=too-many-public-methods - """Request object model serializer.""" - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} - days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} - months = { - 1: "Jan", - 2: "Feb", - 3: "Mar", - 4: "Apr", - 5: "May", - 6: "Jun", - 7: "Jul", - 8: "Aug", - 9: "Sep", - 10: "Oct", - 11: "Nov", - 12: "Dec", - } - validation = { - "min_length": lambda x, y: len(x) < y, - "max_length": lambda x, y: len(x) > y, - "minimum": lambda x, y: x < y, - "maximum": lambda x, y: x > y, - "minimum_ex": lambda x, y: x <= y, - "maximum_ex": lambda x, y: x >= y, - "min_items": lambda x, y: len(x) < y, - "max_items": lambda x, y: len(x) > y, - "pattern": lambda x, y: not re.match(y, x, re.UNICODE), - "unique": lambda x, y: len(x) != len(set(x)), - "multiple": lambda x, y: x % y != 0, - } - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.serialize_type = { - "iso-8601": Serializer.serialize_iso, - "rfc-1123": Serializer.serialize_rfc, - "unix-time": Serializer.serialize_unix, - "duration": Serializer.serialize_duration, - "date": Serializer.serialize_date, - "time": Serializer.serialize_time, - "decimal": Serializer.serialize_decimal, - "long": Serializer.serialize_long, - "bytearray": Serializer.serialize_bytearray, - "base64": Serializer.serialize_base64, - "object": self.serialize_object, - "[]": self.serialize_iter, - "{}": self.serialize_dict, - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_transformer = full_restapi_key_transformer - self.client_side_validation = True - - def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals - self, target_obj, data_type=None, **kwargs - ): - """Serialize data into a string according to type. - - :param object target_obj: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, dict - :raises SerializationError: if serialization fails. - :returns: The serialized data. - """ - key_transformer = kwargs.get("key_transformer", self.key_transformer) - keep_readonly = kwargs.get("keep_readonly", False) - if target_obj is None: - return None - - attr_name = None - class_name = target_obj.__class__.__name__ - - if data_type: - return self.serialize_data(target_obj, data_type, **kwargs) - - if not hasattr(target_obj, "_attribute_map"): - data_type = type(target_obj).__name__ - if data_type in self.basic_types.values(): - return self.serialize_data(target_obj, data_type, **kwargs) - - # Force "is_xml" kwargs if we detect a XML model - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) - - serialized = {} - if is_xml_model_serialization: - serialized = target_obj._create_xml_node() # pylint: disable=protected-access - try: - attributes = target_obj._attribute_map # pylint: disable=protected-access - for attr, attr_desc in attributes.items(): - attr_name = attr - if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access - attr_name, {} - ).get("readonly", False): - continue - - if attr_name == "additional_properties" and attr_desc["key"] == "": - if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) - continue - try: - - orig_attr = getattr(target_obj, attr) - if is_xml_model_serialization: - pass # Don't provide "transformer" for XML for now. Keep "orig_attr" - else: # JSON - keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) - keys = keys if isinstance(keys, list) else [keys] - - kwargs["serialization_ctxt"] = attr_desc - new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) - - if is_xml_model_serialization: - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - xml_prefix = xml_desc.get("prefix", None) - xml_ns = xml_desc.get("ns", None) - if xml_desc.get("attr", False): - if xml_ns: - ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) # type: ignore - continue - if xml_desc.get("text", False): - serialized.text = new_attr # type: ignore - continue - if isinstance(new_attr, list): - serialized.extend(new_attr) # type: ignore - elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, - # we MUST replace the tag with the local tag. But keeping the namespaces. - if "name" not in getattr(orig_attr, "_xml_map", {}): - splitted_tag = new_attr.tag.split("}") - if len(splitted_tag) == 2: # Namespace - new_attr.tag = "}".join([splitted_tag[0], xml_name]) - else: - new_attr.tag = xml_name - serialized.append(new_attr) # type: ignore - else: # That's a basic type - # Integrate namespace if necessary - local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = str(new_attr) - serialized.append(local_node) # type: ignore - else: # JSON - for k in reversed(keys): # type: ignore - new_attr = {k: new_attr} - - _new_attr = new_attr - _serialized = serialized - for k in keys: # type: ignore - if k not in _serialized: - _serialized.update(_new_attr) # type: ignore - _new_attr = _new_attr[k] # type: ignore - _serialized = _serialized[k] - except ValueError as err: - if isinstance(err, SerializationError): - raise - - except (AttributeError, KeyError, TypeError) as err: - msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise SerializationError(msg) from err - return serialized - - def body(self, data, data_type, **kwargs): - """Serialize data intended for a request body. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: dict - :raises SerializationError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized request body - """ - - # Just in case this is a dict - internal_data_type_str = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type_str, None) - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - if internal_data_type and issubclass(internal_data_type, Model): - is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) - else: - is_xml_model_serialization = False - if internal_data_type and not isinstance(internal_data_type, Enum): - try: - deserializer = Deserializer(self.dependencies) - # Since it's on serialization, it's almost sure that format is not JSON REST - # We're not able to deal with additional properties for now. - deserializer.additional_properties_detection = False - if is_xml_model_serialization: - deserializer.key_extractors = [ # type: ignore - attribute_key_case_insensitive_extractor, - ] - else: - deserializer.key_extractors = [ - rest_key_case_insensitive_extractor, - attribute_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access - except DeserializationError as err: - raise SerializationError("Unable to build a model: " + str(err)) from err - - return self._serialize(data, data_type, **kwargs) - - def url(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL path. - - :param str name: The name of the URL path parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :returns: The serialized URL path - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - """ - try: - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - - if kwargs.get("skip_quote") is True: - output = str(output) - output = output.replace("{", quote("{")).replace("}", quote("}")) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return output - - def query(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL query. - - :param str name: The name of the query parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, list - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized query parameter - """ - try: - # Treat the list aside, since we don't want to encode the div separator - if data_type.startswith("["): - internal_data_type = data_type[1:-1] - do_quote = not kwargs.get("skip_quote", False) - return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) - - # Not a list, regular serialization - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - if kwargs.get("skip_quote") is True: - output = str(output) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def header(self, name, data, data_type, **kwargs): - """Serialize data intended for a request header. - - :param str name: The name of the header. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized header - """ - try: - if data_type in ["[str]"]: - data = ["" if d is None else d for d in data] - - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def serialize_data(self, data, data_type, **kwargs): - """Serialize generic data according to supplied data type. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :raises AttributeError: if required data is None. - :raises ValueError: if data is None - :raises SerializationError: if serialization fails. - :returns: The serialized data. - :rtype: str, int, float, bool, dict, list - """ - if data is None: - raise ValueError("No value for given attribute") - - try: - if data is CoreNull: - return None - if data_type in self.basic_types.values(): - return self.serialize_basic(data, data_type, **kwargs) - - if data_type in self.serialize_type: - return self.serialize_type[data_type](data, **kwargs) - - # If dependencies is empty, try with current data class - # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) - if issubclass(enum_type, Enum): - return Serializer.serialize_enum(data, enum_obj=enum_type) - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.serialize_type: - return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) - - except (ValueError, TypeError) as err: - msg = "Unable to serialize value: {!r} as type: {!r}." - raise SerializationError(msg.format(data, data_type)) from err - return self._serialize(data, **kwargs) - - @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements - custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) - if custom_serializer: - return custom_serializer - if kwargs.get("is_xml", False): - return cls._xml_basic_types_serializers.get(data_type) - - @classmethod - def serialize_basic(cls, data, data_type, **kwargs): - """Serialize basic builting data type. - Serializes objects to str, int, float or bool. - - Possible kwargs: - - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - - is_xml bool : If set, use xml_basic_types_serializers - - :param obj data: Object to be serialized. - :param str data_type: Type of object in the iterable. - :rtype: str, int, float, bool - :return: serialized object - """ - custom_serializer = cls._get_custom_serializers(data_type, **kwargs) - if custom_serializer: - return custom_serializer(data) - if data_type == "str": - return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used - - @classmethod - def serialize_unicode(cls, data): - """Special handling for serializing unicode strings in Py2. - Encode to UTF-8 if unicode, otherwise handle as a str. - - :param str data: Object to be serialized. - :rtype: str - :return: serialized object - """ - try: # If I received an enum, return its value - return data.value - except AttributeError: - pass - - try: - if isinstance(data, unicode): # type: ignore - # Don't change it, JSON and XML ElementTree are totally able - # to serialize correctly u'' strings - return data - except NameError: - return str(data) - return str(data) - - def serialize_iter(self, data, iter_type, div=None, **kwargs): - """Serialize iterable. - - Supported kwargs: - - serialization_ctxt dict : The current entry of _attribute_map, or same format. - serialization_ctxt['type'] should be same as data_type. - - is_xml bool : If set, serialize as XML - - :param list data: Object to be serialized. - :param str iter_type: Type of object in the iterable. - :param str div: If set, this str will be used to combine the elements - in the iterable into a combined string. Default is 'None'. - Defaults to False. - :rtype: list, str - :return: serialized iterable - """ - if isinstance(data, str): - raise SerializationError("Refuse str type as a valid iter type.") - - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - is_xml = kwargs.get("is_xml", False) - - serialized = [] - for d in data: - try: - serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized.append(None) - - if kwargs.get("do_quote", False): - serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] - - if div: - serialized = ["" if s is None else str(s) for s in serialized] - serialized = div.join(serialized) - - if "xml" in serialization_ctxt or is_xml: - # XML serialization is more complicated - xml_desc = serialization_ctxt.get("xml", {}) - xml_name = xml_desc.get("name") - if not xml_name: - xml_name = serialization_ctxt["key"] - - # Create a wrap node if necessary (use the fact that Element and list have "append") - is_wrapped = xml_desc.get("wrapped", False) - node_name = xml_desc.get("itemsName", xml_name) - if is_wrapped: - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - else: - final_result = [] - # All list elements to "local_node" - for el in serialized: - if isinstance(el, ET.Element): - el_node = el - else: - el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - if el is not None: # Otherwise it writes "None" :-p - el_node.text = str(el) - final_result.append(el_node) - return final_result - return serialized - - def serialize_dict(self, attr, dict_type, **kwargs): - """Serialize a dictionary of objects. - - :param dict attr: Object to be serialized. - :param str dict_type: Type of object in the dictionary. - :rtype: dict - :return: serialized dictionary - """ - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized[self.serialize_unicode(key)] = None - - if "xml" in serialization_ctxt: - # XML serialization is more complicated - xml_desc = serialization_ctxt["xml"] - xml_name = xml_desc["name"] - - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - for key, value in serialized.items(): - ET.SubElement(final_result, key).text = value - return final_result - - return serialized - - def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Serialize a generic object. - This will be handled as a dictionary. If object passed in is not - a basic type (str, int, float, dict, list) it will simply be - cast to str. - - :param dict attr: Object to be serialized. - :rtype: dict or str - :return: serialized object - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - return attr - obj_type = type(attr) - if obj_type in self.basic_types: - return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) - if obj_type is _long_type: - return self.serialize_long(attr) - if obj_type is str: - return self.serialize_unicode(attr) - if obj_type is datetime.datetime: - return self.serialize_iso(attr) - if obj_type is datetime.date: - return self.serialize_date(attr) - if obj_type is datetime.time: - return self.serialize_time(attr) - if obj_type is datetime.timedelta: - return self.serialize_duration(attr) - if obj_type is decimal.Decimal: - return self.serialize_decimal(attr) - - # If it's a model or I know this dependency, serialize as a Model - if obj_type in self.dependencies.values() or isinstance(attr, Model): - return self._serialize(attr) - - if obj_type == dict: - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) - except ValueError: - serialized[self.serialize_unicode(key)] = None - return serialized - - if obj_type == list: - serialized = [] - for obj in attr: - try: - serialized.append(self.serialize_object(obj, **kwargs)) - except ValueError: - pass - return serialized - return str(attr) - - @staticmethod - def serialize_enum(attr, enum_obj=None): - try: - result = attr.value - except AttributeError: - result = attr - try: - enum_obj(result) # type: ignore - return result - except ValueError as exc: - for enum_value in enum_obj: # type: ignore - if enum_value.value.lower() == str(attr).lower(): - return enum_value.value - error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) from exc - - @staticmethod - def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument - """Serialize bytearray into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - return b64encode(attr).decode() - - @staticmethod - def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument - """Serialize str into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - encoded = b64encode(attr).decode("ascii") - return encoded.strip("=").replace("+", "-").replace("/", "_") - - @staticmethod - def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Decimal object to float. - - :param decimal attr: Object to be serialized. - :rtype: float - :return: serialized decimal - """ - return float(attr) - - @staticmethod - def serialize_long(attr, **kwargs): # pylint: disable=unused-argument - """Serialize long (Py2) or int (Py3). - - :param int attr: Object to be serialized. - :rtype: int/long - :return: serialized long - """ - return _long_type(attr) - - @staticmethod - def serialize_date(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Date object into ISO-8601 formatted string. - - :param Date attr: Object to be serialized. - :rtype: str - :return: serialized date - """ - if isinstance(attr, str): - attr = isodate.parse_date(attr) - t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) - return t - - @staticmethod - def serialize_time(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Time object into ISO-8601 formatted string. - - :param datetime.time attr: Object to be serialized. - :rtype: str - :return: serialized time - """ - if isinstance(attr, str): - attr = isodate.parse_time(attr) - t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) - if attr.microsecond: - t += ".{:02}".format(attr.microsecond) - return t - - @staticmethod - def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument - """Serialize TimeDelta object into ISO-8601 formatted string. - - :param TimeDelta attr: Object to be serialized. - :rtype: str - :return: serialized duration - """ - if isinstance(attr, str): - attr = isodate.parse_duration(attr) - return isodate.duration_isoformat(attr) - - @staticmethod - def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into RFC-1123 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises TypeError: if format invalid. - :return: serialized rfc - """ - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - except AttributeError as exc: - raise TypeError("RFC1123 object must be valid Datetime object.") from exc - - return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( - Serializer.days[utc.tm_wday], - utc.tm_mday, - Serializer.months[utc.tm_mon], - utc.tm_year, - utc.tm_hour, - utc.tm_min, - utc.tm_sec, - ) - - @staticmethod - def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into ISO-8601 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises SerializationError: if format invalid. - :return: serialized iso - """ - if isinstance(attr, str): - attr = isodate.parse_datetime(attr) - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - if utc.tm_year > 9999 or utc.tm_year < 1: - raise OverflowError("Hit max or min date") - - microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") - if microseconds: - microseconds = "." + microseconds - date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( - utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec - ) - return date + microseconds + "Z" - except (ValueError, OverflowError) as err: - msg = "Unable to serialize datetime object." - raise SerializationError(msg) from err - except AttributeError as err: - msg = "ISO-8601 object must be valid Datetime object." - raise TypeError(msg) from err - - @staticmethod - def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param Datetime attr: Object to be serialized. - :rtype: int - :raises SerializationError: if format invalid - :return: serialied unix - """ - if isinstance(attr, int): - return attr - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - return int(calendar.timegm(attr.utctimetuple())) - except AttributeError as exc: - raise TypeError("Unix time object must be valid Datetime object.") from exc - - -def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - key = attr_desc["key"] - working_data = data - - while "." in key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = working_data.get(working_key, data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - return working_data.get(key) - - -def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements - attr, attr_desc, data -): - key = attr_desc["key"] - working_data = data - - while "." in key: - dict_keys = _FLATTEN.split(key) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - if working_data: - return attribute_key_case_insensitive_extractor(key, None, working_data) - - -def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_extractor(dict_keys[-1], None, data) - - -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - This is the case insensitive version of "last_rest_key_extractor" - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) - - -def attribute_key_extractor(attr, _, data): - return data.get(attr) - - -def attribute_key_case_insensitive_extractor(attr, _, data): - found_key = None - lower_attr = attr.lower() - for key in data: - if lower_attr == key.lower(): - found_key = key - break - - return data.get(found_key) - - -def _extract_name_from_internal_type(internal_type): - """Given an internal type XML description, extract correct XML name with namespace. - - :param dict internal_type: An model type - :rtype: tuple - :returns: A tuple XML name + namespace dict - """ - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - xml_name = internal_type_xml_map.get("name", internal_type.__name__) - xml_ns = internal_type_xml_map.get("ns", None) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - return xml_name - - -def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements - if isinstance(data, dict): - return None - - # Test if this model is XML ready first - if not isinstance(data, ET.Element): - return None - - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - - # Look for a children - is_iter_type = attr_desc["type"].startswith("[") - is_wrapped = xml_desc.get("wrapped", False) - internal_type = attr_desc.get("internalType", None) - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - - # Integrate namespace if necessary - xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - - # If it's an attribute, that's simple - if xml_desc.get("attr", False): - return data.get(xml_name) - - # If it's x-ms-text, that's simple too - if xml_desc.get("text", False): - return data.text - - # Scenario where I take the local name: - # - Wrapped node - # - Internal type is an enum (considered basic types) - # - Internal type has no XML/Name node - if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): - children = data.findall(xml_name) - # If internal type has a local name and it's not a list, I use that name - elif not is_iter_type and internal_type and "name" in internal_type_xml_map: - xml_name = _extract_name_from_internal_type(internal_type) - children = data.findall(xml_name) - # That's an array - else: - if internal_type: # Complex type, ignore itemsName and use the complex type name - items_name = _extract_name_from_internal_type(internal_type) - else: - items_name = xml_desc.get("itemsName", xml_name) - children = data.findall(items_name) - - if len(children) == 0: - if is_iter_type: - if is_wrapped: - return None # is_wrapped no node, we want None - return [] # not wrapped, assume empty list - return None # Assume it's not there, maybe an optional node. - - # If is_iter_type and not wrapped, return all found children - if is_iter_type: - if not is_wrapped: - return children - # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) - ) - return list(children[0]) # Might be empty list and that's ok. - - # Here it's not a itertype, we should have found one element only or empty - if len(children) > 1: - raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) - return children[0] - - -class Deserializer: - """Response object model deserializer. - - :param dict classes: Class type dictionary for deserializing complex types. - :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. - """ - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.deserialize_type = { - "iso-8601": Deserializer.deserialize_iso, - "rfc-1123": Deserializer.deserialize_rfc, - "unix-time": Deserializer.deserialize_unix, - "duration": Deserializer.deserialize_duration, - "date": Deserializer.deserialize_date, - "time": Deserializer.deserialize_time, - "decimal": Deserializer.deserialize_decimal, - "long": Deserializer.deserialize_long, - "bytearray": Deserializer.deserialize_bytearray, - "base64": Deserializer.deserialize_base64, - "object": self.deserialize_object, - "[]": self.deserialize_iter, - "{}": self.deserialize_dict, - } - self.deserialize_expected_types = { - "duration": (isodate.Duration, datetime.timedelta), - "iso-8601": (datetime.datetime), - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_extractors = [rest_key_extractor, xml_key_extractor] - # Additional properties only works if the "rest_key_extractor" is used to - # extract the keys. Making it to work whatever the key extractor is too much - # complicated, with no real scenario for now. - # So adding a flag to disable additional properties detection. This flag should be - # used if your expect the deserialization to NOT come from a JSON REST syntax. - # Otherwise, result are unexpected - self.additional_properties_detection = True - - def __call__(self, target_obj, response_data, content_type=None): - """Call the deserializer to process a REST response. - - :param str target_obj: Target data type to deserialize to. - :param requests.Response response_data: REST response object. - :param str content_type: Swagger "produces" if available. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - data = self._unpack_content(response_data, content_type) - return self._deserialize(target_obj, data) - - def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements - """Call the deserializer on a model. - - Data needs to be already deserialized as JSON or XML ElementTree - - :param str target_obj: Target data type to deserialize to. - :param object data: Object to deserialize. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - # This is already a model, go recursive just in case - if hasattr(data, "_attribute_map"): - constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] - try: - for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access - if attr in constants: - continue - value = getattr(data, attr) - if value is None: - continue - local_type = mapconfig["type"] - internal_data_type = local_type.strip("[]{}") - if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): - continue - setattr(data, attr, self._deserialize(local_type, value)) - return data - except AttributeError: - return - - response, class_name = self._classify_target(target_obj, data) - - if isinstance(response, str): - return self.deserialize_data(data, response) - if isinstance(response, type) and issubclass(response, Enum): - return self.deserialize_enum(data, response) - - if data is None or data is CoreNull: - return data - try: - attributes = response._attribute_map # type: ignore # pylint: disable=protected-access - d_attrs = {} - for attr, attr_desc in attributes.items(): - # Check empty string. If it's not empty, someone has a real "additionalProperties"... - if attr == "additional_properties" and attr_desc["key"] == "": - continue - raw_value = None - # Enhance attr_desc with some dynamic data - attr_desc = attr_desc.copy() # Do a copy, do not change the real one - internal_data_type = attr_desc["type"].strip("[]{}") - if internal_data_type in self.dependencies: - attr_desc["internalType"] = self.dependencies[internal_data_type] - - for key_extractor in self.key_extractors: - found_value = key_extractor(attr, attr_desc, data) - if found_value is not None: - if raw_value is not None and raw_value != found_value: - msg = ( - "Ignoring extracted value '%s' from %s for key '%s'" - " (duplicate extraction, follow extractors order)" - ) - _LOGGER.warning(msg, found_value, key_extractor, attr) - continue - raw_value = found_value - - value = self.deserialize_data(raw_value, attr_desc["type"]) - d_attrs[attr] = value - except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name # type: ignore - raise DeserializationError(msg) from err - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) - - def _build_additional_properties(self, attribute_map, data): - if not self.additional_properties_detection: - return None - if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": - # Check empty string. If it's not empty, someone has a real "additionalProperties" - return None - if isinstance(data, ET.Element): - data = {el.tag: el.text for el in data} - - known_keys = { - _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) - for desc in attribute_map.values() - if desc["key"] != "" - } - present_keys = set(data.keys()) - missing_keys = present_keys - known_keys - return {key: data[key] for key in missing_keys} - - def _classify_target(self, target, data): - """Check to see whether the deserialization target object can - be classified into a subclass. - Once classification has been determined, initialize object. - - :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :return: The classified target object and its class name. - :rtype: tuple - """ - if target is None: - return None, None - - if isinstance(target, str): - try: - target = self.dependencies[target] - except KeyError: - return target, target - - try: - target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access - except AttributeError: - pass # Target is not a Model, no classify - return target, target.__class__.__name__ # type: ignore - - def failsafe_deserialize(self, target_obj, data, content_type=None): - """Ignores any errors encountered in deserialization, - and falls back to not deserializing the object. Recommended - for use in error deserialization, as we want to return the - HttpResponseError to users, and not have them deal with - a deserialization error. - - :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :param str content_type: Swagger "produces" if available. - :return: Deserialized object. - :rtype: object - """ - try: - return self(target_obj, data, content_type=content_type) - except: # pylint: disable=bare-except - _LOGGER.debug( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - @staticmethod - def _unpack_content(raw_data, content_type=None): - """Extract the correct structure for deserialization. - - If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. - if we can't, raise. Your Pipeline should have a RawDeserializer. - - If not a pipeline response and raw_data is bytes or string, use content-type - to decode it. If no content-type, try JSON. - - If raw_data is something else, bypass all logic and return it directly. - - :param obj raw_data: Data to be processed. - :param str content_type: How to parse if raw_data is a string/bytes. - :raises JSONDecodeError: If JSON is requested and parsing is impossible. - :raises UnicodeDecodeError: If bytes is not UTF8 - :rtype: object - :return: Unpacked content. - """ - # Assume this is enough to detect a Pipeline Response without importing it - context = getattr(raw_data, "context", {}) - if context: - if RawDeserializer.CONTEXT_NAME in context: - return context[RawDeserializer.CONTEXT_NAME] - raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") - - # Assume this is enough to recognize universal_http.ClientResponse without importing it - if hasattr(raw_data, "body"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) - - # Assume this enough to recognize requests.Response without importing it. - if hasattr(raw_data, "_content_consumed"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - - if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore - return raw_data - - def _instantiate_model(self, response, attrs, additional_properties=None): - """Instantiate a response model passing in deserialized args. - - :param Response response: The response model class. - :param dict attrs: The deserialized response attributes. - :param dict additional_properties: Additional properties to be set. - :rtype: Response - :return: The instantiated response model. - """ - if callable(response): - subtype = getattr(response, "_subtype_map", {}) - try: - readonly = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("readonly") - ] - const = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("constant") - ] - kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} - response_obj = response(**kwargs) - for attr in readonly: - setattr(response_obj, attr, attrs.get(attr)) - if additional_properties: - response_obj.additional_properties = additional_properties # type: ignore - return response_obj - except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) from err - else: - try: - for attr, value in attrs.items(): - setattr(response, attr, value) - return response - except Exception as exp: - msg = "Unable to populate response model. " - msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) from exp - - def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements - """Process data for deserialization according to data type. - - :param str data: The response string to be deserialized. - :param str data_type: The type to deserialize to. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - if data is None: - return data - - try: - if not data_type: - return data - if data_type in self.basic_types.values(): - return self.deserialize_basic(data, data_type) - if data_type in self.deserialize_type: - if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): - return data - - is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment - "object", - "[]", - r"{}", - ] - if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: - return None - data_val = self.deserialize_type[data_type](data) - return data_val - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.deserialize_type: - return self.deserialize_type[iter_type](data, data_type[1:-1]) - - obj_type = self.dependencies[data_type] - if issubclass(obj_type, Enum): - if isinstance(data, ET.Element): - data = data.text - return self.deserialize_enum(data, obj_type) - - except (ValueError, TypeError, AttributeError) as err: - msg = "Unable to deserialize response data." - msg += " Data: {}, {}".format(data, data_type) - raise DeserializationError(msg) from err - return self._deserialize(obj_type, data) - - def deserialize_iter(self, attr, iter_type): - """Deserialize an iterable. - - :param list attr: Iterable to be deserialized. - :param str iter_type: The type of object in the iterable. - :return: Deserialized iterable. - :rtype: list - """ - if attr is None: - return None - if isinstance(attr, ET.Element): # If I receive an element here, get the children - attr = list(attr) - if not isinstance(attr, (list, set)): - raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) - return [self.deserialize_data(a, iter_type) for a in attr] - - def deserialize_dict(self, attr, dict_type): - """Deserialize a dictionary. - - :param dict/list attr: Dictionary to be deserialized. Also accepts - a list of key, value pairs. - :param str dict_type: The object type of the items in the dictionary. - :return: Deserialized dictionary. - :rtype: dict - """ - if isinstance(attr, list): - return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} - - if isinstance(attr, ET.Element): - # Transform value into {"Key": "value"} - attr = {el.tag: el.text for el in attr} - return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - - def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Deserialize a generic object. - This will be handled as a dictionary. - - :param dict attr: Dictionary to be deserialized. - :return: Deserialized object. - :rtype: dict - :raises TypeError: if non-builtin datatype encountered. - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - # Do no recurse on XML, just return the tree as-is - return attr - if isinstance(attr, str): - return self.deserialize_basic(attr, "str") - obj_type = type(attr) - if obj_type in self.basic_types: - return self.deserialize_basic(attr, self.basic_types[obj_type]) - if obj_type is _long_type: - return self.deserialize_long(attr) - - if obj_type == dict: - deserialized = {} - for key, value in attr.items(): - try: - deserialized[key] = self.deserialize_object(value, **kwargs) - except ValueError: - deserialized[key] = None - return deserialized - - if obj_type == list: - deserialized = [] - for obj in attr: - try: - deserialized.append(self.deserialize_object(obj, **kwargs)) - except ValueError: - pass - return deserialized - - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) - - def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements - """Deserialize basic builtin data type from string. - Will attempt to convert to str, int, float and bool. - This function will also accept '1', '0', 'true' and 'false' as - valid bool values. - - :param str attr: response string to be deserialized. - :param str data_type: deserialization data type. - :return: Deserialized basic type. - :rtype: str, int, float or bool - :raises TypeError: if string format is not valid. - """ - # If we're here, data is supposed to be a basic type. - # If it's still an XML node, take the text - if isinstance(attr, ET.Element): - attr = attr.text - if not attr: - if data_type == "str": - # None or '', node is empty string. - return "" - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None - - if data_type == "bool": - if attr in [True, False, 1, 0]: - return bool(attr) - if isinstance(attr, str): - if attr.lower() in ["true", "1"]: - return True - if attr.lower() in ["false", "0"]: - return False - raise TypeError("Invalid boolean value: {}".format(attr)) - - if data_type == "str": - return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used - - @staticmethod - def deserialize_unicode(data): - """Preserve unicode objects in Python 2, otherwise return data - as a string. - - :param str data: response string to be deserialized. - :return: Deserialized string. - :rtype: str or unicode - """ - # We might be here because we have an enum modeled as string, - # and we try to deserialize a partial dict with enum inside - if isinstance(data, Enum): - return data - - # Consider this is real string - try: - if isinstance(data, unicode): # type: ignore - return data - except NameError: - return str(data) - return str(data) - - @staticmethod - def deserialize_enum(data, enum_obj): - """Deserialize string into enum object. - - If the string is not a valid enum value it will be returned as-is - and a warning will be logged. - - :param str data: Response string to be deserialized. If this value is - None or invalid it will be returned as-is. - :param Enum enum_obj: Enum object to deserialize to. - :return: Deserialized enum object. - :rtype: Enum - """ - if isinstance(data, enum_obj) or data is None: - return data - if isinstance(data, Enum): - data = data.value - if isinstance(data, int): - # Workaround. We might consider remove it in the future. - try: - return list(enum_obj.__members__.values())[data] - except IndexError as exc: - error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) from exc - try: - return enum_obj(str(data)) - except ValueError: - for enum_value in enum_obj: - if enum_value.value.lower() == str(data).lower(): - return enum_value - # We don't fail anymore for unknown value, we deserialize as a string - _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) - return Deserializer.deserialize_unicode(data) - - @staticmethod - def deserialize_bytearray(attr): - """Deserialize string into bytearray. - - :param str attr: response string to be deserialized. - :return: Deserialized bytearray - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return bytearray(b64decode(attr)) # type: ignore - - @staticmethod - def deserialize_base64(attr): - """Deserialize base64 encoded string into string. - - :param str attr: response string to be deserialized. - :return: Deserialized base64 string - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore - attr = attr + padding # type: ignore - encoded = attr.replace("-", "+").replace("_", "/") - return b64decode(encoded) - - @staticmethod - def deserialize_decimal(attr): - """Deserialize string into Decimal object. - - :param str attr: response string to be deserialized. - :return: Deserialized decimal - :raises DeserializationError: if string format invalid. - :rtype: decimal - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - return decimal.Decimal(str(attr)) # type: ignore - except decimal.DecimalException as err: - msg = "Invalid decimal {}".format(attr) - raise DeserializationError(msg) from err - - @staticmethod - def deserialize_long(attr): - """Deserialize string into long (Py2) or int (Py3). - - :param str attr: response string to be deserialized. - :return: Deserialized int - :rtype: long or int - :raises ValueError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return _long_type(attr) # type: ignore - - @staticmethod - def deserialize_duration(attr): - """Deserialize ISO-8601 formatted string into TimeDelta object. - - :param str attr: response string to be deserialized. - :return: Deserialized duration - :rtype: TimeDelta - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - duration = isodate.parse_duration(attr) - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize duration object." - raise DeserializationError(msg) from err - return duration - - @staticmethod - def deserialize_date(attr): - """Deserialize ISO-8601 formatted string into Date object. - - :param str attr: response string to be deserialized. - :return: Deserialized date - :rtype: Date - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=0, defaultday=0) - - @staticmethod - def deserialize_time(attr): - """Deserialize ISO-8601 formatted string into time object. - - :param str attr: response string to be deserialized. - :return: Deserialized time - :rtype: datetime.time - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - return isodate.parse_time(attr) - - @staticmethod - def deserialize_rfc(attr): - """Deserialize RFC-1123 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized RFC datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - parsed_date = email.utils.parsedate_tz(attr) # type: ignore - date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) - ) - if not date_obj.tzinfo: - date_obj = date_obj.astimezone(tz=TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to rfc datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_iso(attr): - """Deserialize ISO-8601 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized ISO datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - attr = attr.upper() # type: ignore - match = Deserializer.valid_date.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - check_decimal = attr.split(".") - if len(check_decimal) > 1: - decimal_str = "" - for digit in check_decimal[1]: - if digit.isdigit(): - decimal_str += digit - else: - break - if len(decimal_str) > 6: - attr = attr.replace(decimal_str, decimal_str[0:6]) - - date_obj = isodate.parse_datetime(attr) - test_utc = date_obj.utctimetuple() - if test_utc.tm_year > 9999 or test_utc.tm_year < 1: - raise OverflowError("Hit max or min date") - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_unix(attr): - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param int attr: Object to be serialized. - :return: Deserialized datetime - :rtype: Datetime - :raises DeserializationError: if format invalid - """ - if isinstance(attr, ET.Element): - attr = int(attr.text) # type: ignore - try: - attr = int(attr) - date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to unix datetime object." - raise DeserializationError(msg) from err - return date_obj diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_vendor.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_vendor.py deleted file mode 100644 index 745b900e6f6..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_vendor.py +++ /dev/null @@ -1,25 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from abc import ABC -from typing import TYPE_CHECKING - -from ._configuration import PathClientConfiguration - -if TYPE_CHECKING: - from azure.core import PipelineClient - - from ._serialization import Deserializer, Serializer - - -class PathClientMixinABC(ABC): - """DO NOT use this class. It is for internal typing use only.""" - - _client: "PipelineClient" - _config: PathClientConfiguration - _serialize: "Serializer" - _deserialize: "Deserializer" diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_version.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_version.py deleted file mode 100644 index be71c81bd28..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -VERSION = "1.0.0b1" diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/__init__.py deleted file mode 100644 index c65d4008d6f..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._client import PathClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "PathClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore - -_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_client.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_client.py deleted file mode 100644 index 0ab501cb659..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_client.py +++ /dev/null @@ -1,96 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable -from typing_extensions import Self - -from azure.core import AsyncPipelineClient -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest - -from .._serialization import Deserializer, Serializer -from ._configuration import PathClientConfiguration -from ._operations import PathClientOperationsMixin - - -class PathClient(PathClientOperationsMixin): - """PathClient. - - :keyword endpoint: Service host. Default value is "http://localhost:3000". - :paramtype endpoint: str - :keyword version: Default value is "2025-01-01". Note that overriding this default value may - result in unsupported behavior. - :paramtype version: str - """ - - def __init__( # pylint: disable=missing-client-constructor-parameter-credential - self, *, endpoint: str = "http://localhost:3000", **kwargs: Any - ) -> None: - _endpoint = "{endpoint}" - self._config = PathClientConfiguration(endpoint=endpoint, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncPipelineClient = AsyncPipelineClient(base_url=_endpoint, policies=_policies, **kwargs) - - self._serialize = Serializer() - self._deserialize = Deserializer() - self._serialize.client_side_validation = False - - def send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client.send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_configuration.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_configuration.py deleted file mode 100644 index 6ee36588497..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_configuration.py +++ /dev/null @@ -1,47 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any - -from azure.core.pipeline import policies - -from .._version import VERSION - - -class PathClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for PathClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param endpoint: Service host. Default value is "http://localhost:3000". - :type endpoint: str - :keyword version: Default value is "2025-01-01". Note that overriding this default value may - result in unsupported behavior. - :paramtype version: str - """ - - def __init__(self, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None: - version: str = kwargs.pop("version", "2025-01-01") - - self.endpoint = endpoint - self.version = version - kwargs.setdefault("sdk_moniker", "client-alternateapiversion-service-path/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_operations/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_operations/__init__.py deleted file mode 100644 index 2674f45390d..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_operations/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import PathClientOperationsMixin # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "PathClientOperationsMixin", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_operations/_operations.py deleted file mode 100644 index b726db4b001..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_operations/_operations.py +++ /dev/null @@ -1,80 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ..._operations._operations import build_path_path_api_version_request -from .._vendor import PathClientMixinABC - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class PathClientOperationsMixin(PathClientMixinABC): - - @distributed_trace_async - async def path_api_version(self, **kwargs: Any) -> None: - """Path api version parameter. - - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_path_path_api_version_request( - version=self._config.version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_operations/_patch.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_operations/_patch.py deleted file mode 100644 index f7dd3251033..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__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/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_patch.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_patch.py deleted file mode 100644 index f7dd3251033..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__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/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_vendor.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_vendor.py deleted file mode 100644 index 1373fa6986b..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/aio/_vendor.py +++ /dev/null @@ -1,25 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from abc import ABC -from typing import TYPE_CHECKING - -from ._configuration import PathClientConfiguration - -if TYPE_CHECKING: - from azure.core import AsyncPipelineClient - - from .._serialization import Deserializer, Serializer - - -class PathClientMixinABC(ABC): - """DO NOT use this class. It is for internal typing use only.""" - - _client: "AsyncPipelineClient" - _config: PathClientConfiguration - _serialize: "Serializer" - _deserialize: "Deserializer" diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/py.typed b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/py.typed deleted file mode 100644 index e5aff4f83af..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/client/alternateapiversion/service/path/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/dev_requirements.txt b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/dev_requirements.txt deleted file mode 100644 index 10548647144..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/dev_requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ --e ../../../tools/azure-sdk-tools -../../core/azure-core -aiohttp \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/conftest.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/conftest.py deleted file mode 100644 index 5776acd6a2d..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/conftest.py +++ /dev/null @@ -1,35 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import os -import pytest -from dotenv import load_dotenv -from devtools_testutils import ( - test_proxy, - add_general_regex_sanitizer, - add_body_key_sanitizer, - add_header_regex_sanitizer, -) - -load_dotenv() - - -# For security, please avoid record sensitive identity information in recordings -@pytest.fixture(scope="session", autouse=True) -def add_sanitizers(test_proxy): - path_subscription_id = os.environ.get("PATH_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") - path_tenant_id = os.environ.get("PATH_TENANT_ID", "00000000-0000-0000-0000-000000000000") - path_client_id = os.environ.get("PATH_CLIENT_ID", "00000000-0000-0000-0000-000000000000") - path_client_secret = os.environ.get("PATH_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=path_subscription_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=path_tenant_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=path_client_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=path_client_secret, value="00000000-0000-0000-0000-000000000000") - - add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") - add_header_regex_sanitizer(key="Cookie", value="cookie;") - add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/test_path.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/test_path.py deleted file mode 100644 index 51c1715e851..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/test_path.py +++ /dev/null @@ -1,22 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import pytest -from devtools_testutils import recorded_by_proxy -from testpreparer import PathClientTestBase, PathPreparer - - -@pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestPath(PathClientTestBase): - @PathPreparer() - @recorded_by_proxy - def test_path_api_version(self, path_endpoint): - client = self.create_client(endpoint=path_endpoint) - response = client.path_api_version() - - # please add some check logic here by yourself - # ... diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/test_path_async.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/test_path_async.py deleted file mode 100644 index 6b87fc650df..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/test_path_async.py +++ /dev/null @@ -1,23 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import pytest -from devtools_testutils.aio import recorded_by_proxy_async -from testpreparer import PathPreparer -from testpreparer_async import PathClientTestBaseAsync - - -@pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestPathAsync(PathClientTestBaseAsync): - @PathPreparer() - @recorded_by_proxy_async - async def test_path_api_version(self, path_endpoint): - client = self.create_async_client(endpoint=path_endpoint) - response = await client.path_api_version() - - # please add some check logic here by yourself - # ... diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/testpreparer.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/testpreparer.py deleted file mode 100644 index a285609da20..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/testpreparer.py +++ /dev/null @@ -1,24 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from client.alternateapiversion.service.path import PathClient -from devtools_testutils import AzureRecordedTestCase, PowerShellPreparer -import functools - - -class PathClientTestBase(AzureRecordedTestCase): - - def create_client(self, endpoint): - credential = self.get_credential(PathClient) - return self.create_client_from_credential( - PathClient, - credential=credential, - endpoint=endpoint, - ) - - -PathPreparer = functools.partial(PowerShellPreparer, "path", path_endpoint="https://fake_path_endpoint.com") diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/testpreparer_async.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/testpreparer_async.py deleted file mode 100644 index cd94b8373de..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/generated_tests/testpreparer_async.py +++ /dev/null @@ -1,20 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from client.alternateapiversion.service.path.aio import PathClient -from devtools_testutils import AzureRecordedTestCase - - -class PathClientTestBaseAsync(AzureRecordedTestCase): - - def create_async_client(self, endpoint): - credential = self.get_credential(PathClient, is_async=True) - return self.create_client_from_credential( - PathClient, - credential=credential, - endpoint=endpoint, - ) diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/setup.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/setup.py deleted file mode 100644 index 585696cb6f2..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-path/setup.py +++ /dev/null @@ -1,72 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# coding: utf-8 - -import os -import re -from setuptools import setup, find_packages - - -PACKAGE_NAME = "client-alternateapiversion-service-path" -PACKAGE_PPRINT_NAME = "Client Alternateapiversion Service Path" - -# a-b-c => a/b/c -package_folder_path = PACKAGE_NAME.replace("-", "/") - -# Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, "_version.py"), "r") as fd: - version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) - -if not version: - raise RuntimeError("Cannot find version information") - - -setup( - name=PACKAGE_NAME, - version=version, - description="Microsoft {} Client Library for Python".format(PACKAGE_PPRINT_NAME), - long_description=open("README.md", "r").read(), - long_description_content_type="text/markdown", - license="MIT License", - author="Microsoft Corporation", - author_email="azpysdkhelp@microsoft.com", - url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk", - keywords="azure, azure sdk", - classifiers=[ - "Development Status :: 4 - Beta", - "Programming Language :: Python", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "License :: OSI Approved :: MIT License", - ], - zip_safe=False, - packages=find_packages( - exclude=[ - "tests", - # Exclude packages that will be covered by PEP420 or nspkg - "client", - "client.alternateapiversion", - "client.alternateapiversion.service", - ] - ), - include_package_data=True, - package_data={ - "client.alternateapiversion.service.path": ["py.typed"], - }, - install_requires=[ - "isodate>=0.6.1", - "azure-core>=1.30.0", - "typing-extensions>=4.6.0", - ], - python_requires=">=3.8", -) diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/CHANGELOG.md b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/CHANGELOG.md deleted file mode 100644 index 628743d283a..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/CHANGELOG.md +++ /dev/null @@ -1,5 +0,0 @@ -# Release History - -## 1.0.0b1 (1970-01-01) - -- Initial version diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/LICENSE b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/LICENSE deleted file mode 100644 index 63447fd8bbb..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -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. \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/MANIFEST.in b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/MANIFEST.in deleted file mode 100644 index 69f8c2d2885..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/MANIFEST.in +++ /dev/null @@ -1,8 +0,0 @@ -include *.md -include LICENSE -include client/alternateapiversion/service/query/py.typed -recursive-include tests *.py -recursive-include samples *.py *.md -include client/__init__.py -include client/alternateapiversion/__init__.py -include client/alternateapiversion/service/__init__.py \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/README.md b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/README.md deleted file mode 100644 index c2d5a37df3b..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/README.md +++ /dev/null @@ -1,45 +0,0 @@ - - -# Client Alternateapiversion Service Query client library for Python - - -## Getting started - -### Install the package - -```bash -python -m pip install client-alternateapiversion-service-query -``` - -#### 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 Client Alternateapiversion Service Query 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 opencode@microsoft.com with any -additional questions or comments. - - -[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/ - diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/apiview-properties.json b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/apiview-properties.json deleted file mode 100644 index e451ff24fd3..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/apiview-properties.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "CrossLanguagePackageId": "Client.AlternateApiVersion.Service.Query", - "CrossLanguageDefinitionId": { - "client.alternateapiversion.service.query.QueryClient.query_api_version": "Client.AlternateApiVersion.Service.Query.queryApiVersion" - } -} \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/__init__.py deleted file mode 100644 index d55ccad1f57..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/__init__.py deleted file mode 100644 index d55ccad1f57..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/__init__.py deleted file mode 100644 index d55ccad1f57..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/__init__.py deleted file mode 100644 index 56234fef3b6..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._client import QueryClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "QueryClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore - -_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_client.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_client.py deleted file mode 100644 index edb6298a458..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_client.py +++ /dev/null @@ -1,94 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any -from typing_extensions import Self - -from azure.core import PipelineClient -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse - -from ._configuration import QueryClientConfiguration -from ._operations import QueryClientOperationsMixin -from ._serialization import Deserializer, Serializer - - -class QueryClient(QueryClientOperationsMixin): - """QueryClient. - - :keyword endpoint: Service host. Default value is "http://localhost:3000". - :paramtype endpoint: str - :keyword version: Default value is "2025-01-01". Note that overriding this default value may - result in unsupported behavior. - :paramtype version: str - """ - - def __init__( # pylint: disable=missing-client-constructor-parameter-credential - self, *, endpoint: str = "http://localhost:3000", **kwargs: Any - ) -> None: - _endpoint = "{endpoint}" - self._config = QueryClientConfiguration(endpoint=endpoint, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs) - - self._serialize = Serializer() - self._deserialize = Deserializer() - self._serialize.client_side_validation = False - - def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = client.send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.HttpResponse - """ - - request_copy = deepcopy(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_configuration.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_configuration.py deleted file mode 100644 index d1f8b2e959c..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_configuration.py +++ /dev/null @@ -1,47 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any - -from azure.core.pipeline import policies - -from ._version import VERSION - - -class QueryClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for QueryClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param endpoint: Service host. Default value is "http://localhost:3000". - :type endpoint: str - :keyword version: Default value is "2025-01-01". Note that overriding this default value may - result in unsupported behavior. - :paramtype version: str - """ - - def __init__(self, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None: - version: str = kwargs.pop("version", "2025-01-01") - - self.endpoint = endpoint - self.version = version - kwargs.setdefault("sdk_moniker", "client-alternateapiversion-service-query/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_model_base.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_model_base.py deleted file mode 100644 index 3072ee252ed..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_model_base.py +++ /dev/null @@ -1,1235 +0,0 @@ -# pylint: disable=too-many-lines -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=protected-access, broad-except - -import copy -import calendar -import decimal -import functools -import sys -import logging -import base64 -import re -import typing -import enum -import email.utils -from datetime import datetime, date, time, timedelta, timezone -from json import JSONEncoder -import xml.etree.ElementTree as ET -from typing_extensions import Self -import isodate -from azure.core.exceptions import DeserializationError -from azure.core import CaseInsensitiveEnumMeta -from azure.core.pipeline import PipelineResponse -from azure.core.serialization import _Null - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping - -_LOGGER = logging.getLogger(__name__) - -__all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] - -TZ_UTC = timezone.utc -_T = typing.TypeVar("_T") - - -def _timedelta_as_isostr(td: timedelta) -> str: - """Converts a datetime.timedelta object into an ISO 8601 formatted string, e.g. 'P4DT12H30M05S' - - Function adapted from the Tin Can Python project: https://github.com/RusticiSoftware/TinCanPython - - :param timedelta td: The timedelta to convert - :rtype: str - :return: ISO8601 version of this timedelta - """ - - # Split seconds to larger units - seconds = td.total_seconds() - minutes, seconds = divmod(seconds, 60) - hours, minutes = divmod(minutes, 60) - days, hours = divmod(hours, 24) - - days, hours, minutes = list(map(int, (days, hours, minutes))) - seconds = round(seconds, 6) - - # Build date - date_str = "" - if days: - date_str = "%sD" % days - - if hours or minutes or seconds: - # Build time - time_str = "T" - - # Hours - bigger_exists = date_str or hours - if bigger_exists: - time_str += "{:02}H".format(hours) - - # Minutes - bigger_exists = bigger_exists or minutes - if bigger_exists: - time_str += "{:02}M".format(minutes) - - # Seconds - try: - if seconds.is_integer(): - seconds_string = "{:02}".format(int(seconds)) - else: - # 9 chars long w/ leading 0, 6 digits after decimal - seconds_string = "%09.6f" % seconds - # Remove trailing zeros - seconds_string = seconds_string.rstrip("0") - except AttributeError: # int.is_integer() raises - seconds_string = "{:02}".format(seconds) - - time_str += "{}S".format(seconds_string) - else: - time_str = "" - - return "P" + date_str + time_str - - -def _serialize_bytes(o, format: typing.Optional[str] = None) -> str: - encoded = base64.b64encode(o).decode() - if format == "base64url": - return encoded.strip("=").replace("+", "-").replace("/", "_") - return encoded - - -def _serialize_datetime(o, format: typing.Optional[str] = None): - if hasattr(o, "year") and hasattr(o, "hour"): - if format == "rfc7231": - return email.utils.format_datetime(o, usegmt=True) - if format == "unix-timestamp": - return int(calendar.timegm(o.utctimetuple())) - - # astimezone() fails for naive times in Python 2.7, so make make sure o is aware (tzinfo is set) - if not o.tzinfo: - iso_formatted = o.replace(tzinfo=TZ_UTC).isoformat() - else: - iso_formatted = o.astimezone(TZ_UTC).isoformat() - # Replace the trailing "+00:00" UTC offset with "Z" (RFC 3339: https://www.ietf.org/rfc/rfc3339.txt) - return iso_formatted.replace("+00:00", "Z") - # Next try datetime.date or datetime.time - return o.isoformat() - - -def _is_readonly(p): - try: - return p._visibility == ["read"] - except AttributeError: - return False - - -class SdkJSONEncoder(JSONEncoder): - """A JSON encoder that's capable of serializing datetime objects and bytes.""" - - def __init__(self, *args, exclude_readonly: bool = False, format: typing.Optional[str] = None, **kwargs): - super().__init__(*args, **kwargs) - self.exclude_readonly = exclude_readonly - self.format = format - - def default(self, o): # pylint: disable=too-many-return-statements - if _is_model(o): - if self.exclude_readonly: - readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] - return {k: v for k, v in o.items() if k not in readonly_props} - return dict(o.items()) - try: - return super(SdkJSONEncoder, self).default(o) - except TypeError: - if isinstance(o, _Null): - return None - if isinstance(o, decimal.Decimal): - return float(o) - if isinstance(o, (bytes, bytearray)): - return _serialize_bytes(o, self.format) - try: - # First try datetime.datetime - return _serialize_datetime(o, self.format) - except AttributeError: - pass - # Last, try datetime.timedelta - try: - return _timedelta_as_isostr(o) - except AttributeError: - # This will be raised when it hits value.total_seconds in the method above - pass - return super(SdkJSONEncoder, self).default(o) - - -_VALID_DATE = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" + r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") -_VALID_RFC7231 = re.compile( - r"(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s\d{2}\s" - r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT" -) - - -def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: - """Deserialize ISO-8601 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :rtype: ~datetime.datetime - :returns: The datetime object from that input - """ - if isinstance(attr, datetime): - # i'm already deserialized - return attr - attr = attr.upper() - match = _VALID_DATE.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - check_decimal = attr.split(".") - if len(check_decimal) > 1: - decimal_str = "" - for digit in check_decimal[1]: - if digit.isdigit(): - decimal_str += digit - else: - break - if len(decimal_str) > 6: - attr = attr.replace(decimal_str, decimal_str[0:6]) - - date_obj = isodate.parse_datetime(attr) - test_utc = date_obj.utctimetuple() - if test_utc.tm_year > 9999 or test_utc.tm_year < 1: - raise OverflowError("Hit max or min date") - return date_obj - - -def _deserialize_datetime_rfc7231(attr: typing.Union[str, datetime]) -> datetime: - """Deserialize RFC7231 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :rtype: ~datetime.datetime - :returns: The datetime object from that input - """ - if isinstance(attr, datetime): - # i'm already deserialized - return attr - match = _VALID_RFC7231.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - return email.utils.parsedate_to_datetime(attr) - - -def _deserialize_datetime_unix_timestamp(attr: typing.Union[float, datetime]) -> datetime: - """Deserialize unix timestamp into Datetime object. - - :param str attr: response string to be deserialized. - :rtype: ~datetime.datetime - :returns: The datetime object from that input - """ - if isinstance(attr, datetime): - # i'm already deserialized - return attr - return datetime.fromtimestamp(attr, TZ_UTC) - - -def _deserialize_date(attr: typing.Union[str, date]) -> date: - """Deserialize ISO-8601 formatted string into Date object. - :param str attr: response string to be deserialized. - :rtype: date - :returns: The date object from that input - """ - # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - if isinstance(attr, date): - return attr - return isodate.parse_date(attr, defaultmonth=None, defaultday=None) # type: ignore - - -def _deserialize_time(attr: typing.Union[str, time]) -> time: - """Deserialize ISO-8601 formatted string into time object. - - :param str attr: response string to be deserialized. - :rtype: datetime.time - :returns: The time object from that input - """ - if isinstance(attr, time): - return attr - return isodate.parse_time(attr) - - -def _deserialize_bytes(attr): - if isinstance(attr, (bytes, bytearray)): - return attr - return bytes(base64.b64decode(attr)) - - -def _deserialize_bytes_base64(attr): - if isinstance(attr, (bytes, bytearray)): - return attr - padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore - attr = attr + padding # type: ignore - encoded = attr.replace("-", "+").replace("_", "/") - return bytes(base64.b64decode(encoded)) - - -def _deserialize_duration(attr): - if isinstance(attr, timedelta): - return attr - return isodate.parse_duration(attr) - - -def _deserialize_decimal(attr): - if isinstance(attr, decimal.Decimal): - return attr - return decimal.Decimal(str(attr)) - - -def _deserialize_int_as_str(attr): - if isinstance(attr, int): - return attr - return int(attr) - - -_DESERIALIZE_MAPPING = { - datetime: _deserialize_datetime, - date: _deserialize_date, - time: _deserialize_time, - bytes: _deserialize_bytes, - bytearray: _deserialize_bytes, - timedelta: _deserialize_duration, - typing.Any: lambda x: x, - decimal.Decimal: _deserialize_decimal, -} - -_DESERIALIZE_MAPPING_WITHFORMAT = { - "rfc3339": _deserialize_datetime, - "rfc7231": _deserialize_datetime_rfc7231, - "unix-timestamp": _deserialize_datetime_unix_timestamp, - "base64": _deserialize_bytes, - "base64url": _deserialize_bytes_base64, -} - - -def get_deserializer(annotation: typing.Any, rf: typing.Optional["_RestField"] = None): - if annotation is int and rf and rf._format == "str": - return _deserialize_int_as_str - if rf and rf._format: - return _DESERIALIZE_MAPPING_WITHFORMAT.get(rf._format) - return _DESERIALIZE_MAPPING.get(annotation) # pyright: ignore - - -def _get_type_alias_type(module_name: str, alias_name: str): - types = { - k: v - for k, v in sys.modules[module_name].__dict__.items() - if isinstance(v, typing._GenericAlias) # type: ignore - } - if alias_name not in types: - return alias_name - return types[alias_name] - - -def _get_model(module_name: str, model_name: str): - models = {k: v for k, v in sys.modules[module_name].__dict__.items() if isinstance(v, type)} - module_end = module_name.rsplit(".", 1)[0] - models.update({k: v for k, v in sys.modules[module_end].__dict__.items() if isinstance(v, type)}) - if isinstance(model_name, str): - model_name = model_name.split(".")[-1] - if model_name not in models: - return model_name - return models[model_name] - - -_UNSET = object() - - -class _MyMutableMapping(MutableMapping[str, typing.Any]): # pylint: disable=unsubscriptable-object - def __init__(self, data: typing.Dict[str, typing.Any]) -> None: - self._data = data - - def __contains__(self, key: typing.Any) -> bool: - return key in self._data - - def __getitem__(self, key: str) -> typing.Any: - return self._data.__getitem__(key) - - def __setitem__(self, key: str, value: typing.Any) -> None: - self._data.__setitem__(key, value) - - def __delitem__(self, key: str) -> None: - self._data.__delitem__(key) - - def __iter__(self) -> typing.Iterator[typing.Any]: - return self._data.__iter__() - - def __len__(self) -> int: - return self._data.__len__() - - def __ne__(self, other: typing.Any) -> bool: - return not self.__eq__(other) - - def keys(self) -> typing.KeysView[str]: - """ - :returns: a set-like object providing a view on D's keys - :rtype: ~typing.KeysView - """ - return self._data.keys() - - def values(self) -> typing.ValuesView[typing.Any]: - """ - :returns: an object providing a view on D's values - :rtype: ~typing.ValuesView - """ - return self._data.values() - - def items(self) -> typing.ItemsView[str, typing.Any]: - """ - :returns: set-like object providing a view on D's items - :rtype: ~typing.ItemsView - """ - return self._data.items() - - def get(self, key: str, default: typing.Any = None) -> typing.Any: - """ - Get the value for key if key is in the dictionary, else default. - :param str key: The key to look up. - :param any default: The value to return if key is not in the dictionary. Defaults to None - :returns: D[k] if k in D, else d. - :rtype: any - """ - try: - return self[key] - except KeyError: - return default - - @typing.overload - def pop(self, key: str) -> typing.Any: ... - - @typing.overload - def pop(self, key: str, default: _T) -> _T: ... - - @typing.overload - def pop(self, key: str, default: typing.Any) -> typing.Any: ... - - def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: - """ - Removes specified key and return the corresponding value. - :param str key: The key to pop. - :param any default: The value to return if key is not in the dictionary - :returns: The value corresponding to the key. - :rtype: any - :raises KeyError: If key is not found and default is not given. - """ - if default is _UNSET: - return self._data.pop(key) - return self._data.pop(key, default) - - def popitem(self) -> typing.Tuple[str, typing.Any]: - """ - Removes and returns some (key, value) pair - :returns: The (key, value) pair. - :rtype: tuple - :raises KeyError: if D is empty. - """ - return self._data.popitem() - - def clear(self) -> None: - """ - Remove all items from D. - """ - self._data.clear() - - def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: - """ - Updates D from mapping/iterable E and F. - :param any args: Either a mapping object or an iterable of key-value pairs. - """ - self._data.update(*args, **kwargs) - - @typing.overload - def setdefault(self, key: str, default: None = None) -> None: ... - - @typing.overload - def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... - - def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: - """ - Same as calling D.get(k, d), and setting D[k]=d if k not found - :param str key: The key to look up. - :param any default: The value to set if key is not in the dictionary - :returns: D[k] if k in D, else d. - :rtype: any - """ - if default is _UNSET: - return self._data.setdefault(key) - return self._data.setdefault(key, default) - - def __eq__(self, other: typing.Any) -> bool: - try: - other_model = self.__class__(other) - except Exception: - return False - return self._data == other_model._data - - def __repr__(self) -> str: - return str(self._data) - - -def _is_model(obj: typing.Any) -> bool: - return getattr(obj, "_is_model", False) - - -def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-many-return-statements - if isinstance(o, list): - return [_serialize(x, format) for x in o] - if isinstance(o, dict): - return {k: _serialize(v, format) for k, v in o.items()} - if isinstance(o, set): - return {_serialize(x, format) for x in o} - if isinstance(o, tuple): - return tuple(_serialize(x, format) for x in o) - if isinstance(o, (bytes, bytearray)): - return _serialize_bytes(o, format) - if isinstance(o, decimal.Decimal): - return float(o) - if isinstance(o, enum.Enum): - return o.value - if isinstance(o, int): - if format == "str": - return str(o) - return o - try: - # First try datetime.datetime - return _serialize_datetime(o, format) - except AttributeError: - pass - # Last, try datetime.timedelta - try: - return _timedelta_as_isostr(o) - except AttributeError: - # This will be raised when it hits value.total_seconds in the method above - pass - return o - - -def _get_rest_field( - attr_to_rest_field: typing.Dict[str, "_RestField"], rest_name: str -) -> typing.Optional["_RestField"]: - try: - return next(rf for rf in attr_to_rest_field.values() if rf._rest_name == rest_name) - except StopIteration: - return None - - -def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typing.Any: - if not rf: - return _serialize(value, None) - if rf._is_multipart_file_input: - return value - if rf._is_model: - return _deserialize(rf._type, value) - if isinstance(value, ET.Element): - value = _deserialize(rf._type, value) - return _serialize(value, rf._format) - - -class Model(_MyMutableMapping): - _is_model = True - # label whether current class's _attr_to_rest_field has been calculated - # could not see _attr_to_rest_field directly because subclass inherits it from parent class - _calculated: typing.Set[str] = set() - - def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: - class_name = self.__class__.__name__ - if len(args) > 1: - raise TypeError(f"{class_name}.__init__() takes 2 positional arguments but {len(args) + 1} were given") - dict_to_pass = { - rest_field._rest_name: rest_field._default - for rest_field in self._attr_to_rest_field.values() - if rest_field._default is not _UNSET - } - if args: # pylint: disable=too-many-nested-blocks - if isinstance(args[0], ET.Element): - existed_attr_keys = [] - model_meta = getattr(self, "_xml", {}) - - for rf in self._attr_to_rest_field.values(): - prop_meta = getattr(rf, "_xml", {}) - xml_name = prop_meta.get("name", rf._rest_name) - xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) - if xml_ns: - xml_name = "{" + xml_ns + "}" + xml_name - - # attribute - if prop_meta.get("attribute", False) and args[0].get(xml_name) is not None: - existed_attr_keys.append(xml_name) - dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].get(xml_name)) - continue - - # unwrapped element is array - if prop_meta.get("unwrapped", False): - # unwrapped array could either use prop items meta/prop meta - if prop_meta.get("itemsName"): - xml_name = prop_meta.get("itemsName") - xml_ns = prop_meta.get("itemNs") - if xml_ns: - xml_name = "{" + xml_ns + "}" + xml_name - items = args[0].findall(xml_name) # pyright: ignore - if len(items) > 0: - existed_attr_keys.append(xml_name) - dict_to_pass[rf._rest_name] = _deserialize(rf._type, items) - continue - - # text element is primitive type - if prop_meta.get("text", False): - if args[0].text is not None: - dict_to_pass[rf._rest_name] = _deserialize(rf._type, args[0].text) - continue - - # wrapped element could be normal property or array, it should only have one element - item = args[0].find(xml_name) - if item is not None: - existed_attr_keys.append(xml_name) - dict_to_pass[rf._rest_name] = _deserialize(rf._type, item) - - # rest thing is additional properties - for e in args[0]: - if e.tag not in existed_attr_keys: - dict_to_pass[e.tag] = _convert_element(e) - else: - dict_to_pass.update( - {k: _create_value(_get_rest_field(self._attr_to_rest_field, k), v) for k, v in args[0].items()} - ) - else: - non_attr_kwargs = [k for k in kwargs if k not in self._attr_to_rest_field] - if non_attr_kwargs: - # actual type errors only throw the first wrong keyword arg they see, so following that. - raise TypeError(f"{class_name}.__init__() got an unexpected keyword argument '{non_attr_kwargs[0]}'") - dict_to_pass.update( - { - self._attr_to_rest_field[k]._rest_name: _create_value(self._attr_to_rest_field[k], v) - for k, v in kwargs.items() - if v is not None - } - ) - super().__init__(dict_to_pass) - - def copy(self) -> "Model": - return Model(self.__dict__) - - def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: - if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated: - # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', - # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' - mros = cls.__mro__[:-9][::-1] # ignore parents, and reverse the mro order - attr_to_rest_field: typing.Dict[str, _RestField] = { # map attribute name to rest_field property - k: v for mro_class in mros for k, v in mro_class.__dict__.items() if k[0] != "_" and hasattr(v, "_type") - } - annotations = { - k: v - for mro_class in mros - if hasattr(mro_class, "__annotations__") - for k, v in mro_class.__annotations__.items() - } - for attr, rf in attr_to_rest_field.items(): - rf._module = cls.__module__ - if not rf._type: - rf._type = rf._get_deserialize_callable_from_annotation(annotations.get(attr, None)) - if not rf._rest_name_input: - rf._rest_name_input = attr - cls._attr_to_rest_field: typing.Dict[str, _RestField] = dict(attr_to_rest_field.items()) - cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") - - return super().__new__(cls) # pylint: disable=no-value-for-parameter - - def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: - for base in cls.__bases__: - if hasattr(base, "__mapping__"): - base.__mapping__[discriminator or cls.__name__] = cls # type: ignore - - @classmethod - def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]: - for v in cls.__dict__.values(): - if isinstance(v, _RestField) and v._is_discriminator and v._rest_name not in exist_discriminators: - return v - return None - - @classmethod - def _deserialize(cls, data, exist_discriminators): - if not hasattr(cls, "__mapping__"): - return cls(data) - discriminator = cls._get_discriminator(exist_discriminators) - if discriminator is None: - return cls(data) - exist_discriminators.append(discriminator._rest_name) - if isinstance(data, ET.Element): - model_meta = getattr(cls, "_xml", {}) - prop_meta = getattr(discriminator, "_xml", {}) - xml_name = prop_meta.get("name", discriminator._rest_name) - xml_ns = prop_meta.get("ns", model_meta.get("ns", None)) - if xml_ns: - xml_name = "{" + xml_ns + "}" + xml_name - - if data.get(xml_name) is not None: - discriminator_value = data.get(xml_name) - else: - discriminator_value = data.find(xml_name).text # pyright: ignore - else: - discriminator_value = data.get(discriminator._rest_name) - mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore - return mapped_cls._deserialize(data, exist_discriminators) - - def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.Any]: - """Return a dict that can be turned into json using json.dump. - - :keyword bool exclude_readonly: Whether to remove the readonly properties. - :returns: A dict JSON compatible object - :rtype: dict - """ - - result = {} - readonly_props = [] - if exclude_readonly: - readonly_props = [p._rest_name for p in self._attr_to_rest_field.values() if _is_readonly(p)] - for k, v in self.items(): - if exclude_readonly and k in readonly_props: # pyright: ignore - continue - is_multipart_file_input = False - try: - is_multipart_file_input = next( - rf for rf in self._attr_to_rest_field.values() if rf._rest_name == k - )._is_multipart_file_input - except StopIteration: - pass - result[k] = v if is_multipart_file_input else Model._as_dict_value(v, exclude_readonly=exclude_readonly) - return result - - @staticmethod - def _as_dict_value(v: typing.Any, exclude_readonly: bool = False) -> typing.Any: - if v is None or isinstance(v, _Null): - return None - if isinstance(v, (list, tuple, set)): - return type(v)(Model._as_dict_value(x, exclude_readonly=exclude_readonly) for x in v) - if isinstance(v, dict): - return {dk: Model._as_dict_value(dv, exclude_readonly=exclude_readonly) for dk, dv in v.items()} - return v.as_dict(exclude_readonly=exclude_readonly) if hasattr(v, "as_dict") else v - - -def _deserialize_model(model_deserializer: typing.Optional[typing.Callable], obj): - if _is_model(obj): - return obj - return _deserialize(model_deserializer, obj) - - -def _deserialize_with_optional(if_obj_deserializer: typing.Optional[typing.Callable], obj): - if obj is None: - return obj - return _deserialize_with_callable(if_obj_deserializer, obj) - - -def _deserialize_with_union(deserializers, obj): - for deserializer in deserializers: - try: - return _deserialize(deserializer, obj) - except DeserializationError: - pass - raise DeserializationError() - - -def _deserialize_dict( - value_deserializer: typing.Optional[typing.Callable], - module: typing.Optional[str], - obj: typing.Dict[typing.Any, typing.Any], -): - if obj is None: - return obj - if isinstance(obj, ET.Element): - obj = {child.tag: child for child in obj} - return {k: _deserialize(value_deserializer, v, module) for k, v in obj.items()} - - -def _deserialize_multiple_sequence( - entry_deserializers: typing.List[typing.Optional[typing.Callable]], - module: typing.Optional[str], - obj, -): - if obj is None: - return obj - return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers)) - - -def _deserialize_sequence( - deserializer: typing.Optional[typing.Callable], - module: typing.Optional[str], - obj, -): - if obj is None: - return obj - if isinstance(obj, ET.Element): - obj = list(obj) - return type(obj)(_deserialize(deserializer, entry, module) for entry in obj) - - -def _sorted_annotations(types: typing.List[typing.Any]) -> typing.List[typing.Any]: - return sorted( - types, - key=lambda x: hasattr(x, "__name__") and x.__name__.lower() in ("str", "float", "int", "bool"), - ) - - -def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-branches - annotation: typing.Any, - module: typing.Optional[str], - rf: typing.Optional["_RestField"] = None, -) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: - if not annotation: - return None - - # is it a type alias? - if isinstance(annotation, str): - if module is not None: - annotation = _get_type_alias_type(module, annotation) - - # is it a forward ref / in quotes? - if isinstance(annotation, (str, typing.ForwardRef)): - try: - model_name = annotation.__forward_arg__ # type: ignore - except AttributeError: - model_name = annotation - if module is not None: - annotation = _get_model(module, model_name) # type: ignore - - try: - if module and _is_model(annotation): - if rf: - rf._is_model = True - - return functools.partial(_deserialize_model, annotation) # pyright: ignore - except Exception: - pass - - # is it a literal? - try: - if annotation.__origin__ is typing.Literal: # pyright: ignore - return None - except AttributeError: - pass - - # is it optional? - try: - if any(a for a in annotation.__args__ if a == type(None)): # pyright: ignore - if len(annotation.__args__) <= 2: # pyright: ignore - if_obj_deserializer = _get_deserialize_callable_from_annotation( - next(a for a in annotation.__args__ if a != type(None)), module, rf # pyright: ignore - ) - - return functools.partial(_deserialize_with_optional, if_obj_deserializer) - # the type is Optional[Union[...]], we need to remove the None type from the Union - annotation_copy = copy.copy(annotation) - annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a != type(None)] # pyright: ignore - return _get_deserialize_callable_from_annotation(annotation_copy, module, rf) - except AttributeError: - pass - - # is it union? - if getattr(annotation, "__origin__", None) is typing.Union: - # initial ordering is we make `string` the last deserialization option, because it is often them most generic - deserializers = [ - _get_deserialize_callable_from_annotation(arg, module, rf) - for arg in _sorted_annotations(annotation.__args__) # pyright: ignore - ] - - return functools.partial(_deserialize_with_union, deserializers) - - try: - if annotation._name == "Dict": # pyright: ignore - value_deserializer = _get_deserialize_callable_from_annotation( - annotation.__args__[1], module, rf # pyright: ignore - ) - - return functools.partial( - _deserialize_dict, - value_deserializer, - module, - ) - except (AttributeError, IndexError): - pass - try: - if annotation._name in ["List", "Set", "Tuple", "Sequence"]: # pyright: ignore - if len(annotation.__args__) > 1: # pyright: ignore - entry_deserializers = [ - _get_deserialize_callable_from_annotation(dt, module, rf) - for dt in annotation.__args__ # pyright: ignore - ] - return functools.partial(_deserialize_multiple_sequence, entry_deserializers, module) - deserializer = _get_deserialize_callable_from_annotation( - annotation.__args__[0], module, rf # pyright: ignore - ) - - return functools.partial(_deserialize_sequence, deserializer, module) - except (TypeError, IndexError, AttributeError, SyntaxError): - pass - - def _deserialize_default( - deserializer, - obj, - ): - if obj is None: - return obj - try: - return _deserialize_with_callable(deserializer, obj) - except Exception: - pass - return obj - - if get_deserializer(annotation, rf): - return functools.partial(_deserialize_default, get_deserializer(annotation, rf)) - - return functools.partial(_deserialize_default, annotation) - - -def _deserialize_with_callable( - deserializer: typing.Optional[typing.Callable[[typing.Any], typing.Any]], - value: typing.Any, -): # pylint: disable=too-many-return-statements - try: - if value is None or isinstance(value, _Null): - return None - if isinstance(value, ET.Element): - if deserializer is str: - return value.text or "" - if deserializer is int: - return int(value.text) if value.text else None - if deserializer is float: - return float(value.text) if value.text else None - if deserializer is bool: - return value.text == "true" if value.text else None - if deserializer is None: - return value - if deserializer in [int, float, bool]: - return deserializer(value) - if isinstance(deserializer, CaseInsensitiveEnumMeta): - try: - return deserializer(value) - except ValueError: - # for unknown value, return raw value - return value - if isinstance(deserializer, type) and issubclass(deserializer, Model): - return deserializer._deserialize(value, []) - return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value) - except Exception as e: - raise DeserializationError() from e - - -def _deserialize( - deserializer: typing.Any, - value: typing.Any, - module: typing.Optional[str] = None, - rf: typing.Optional["_RestField"] = None, - format: typing.Optional[str] = None, -) -> typing.Any: - if isinstance(value, PipelineResponse): - value = value.http_response.json() - if rf is None and format: - rf = _RestField(format=format) - if not isinstance(deserializer, functools.partial): - deserializer = _get_deserialize_callable_from_annotation(deserializer, module, rf) - return _deserialize_with_callable(deserializer, value) - - -def _failsafe_deserialize( - deserializer: typing.Any, - value: typing.Any, - module: typing.Optional[str] = None, - rf: typing.Optional["_RestField"] = None, - format: typing.Optional[str] = None, -) -> typing.Any: - try: - return _deserialize(deserializer, value, module, rf, format) - except DeserializationError: - _LOGGER.warning( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - -def _failsafe_deserialize_xml( - deserializer: typing.Any, - value: typing.Any, -) -> typing.Any: - try: - return _deserialize_xml(deserializer, value) - except DeserializationError: - _LOGGER.warning( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - -class _RestField: - def __init__( - self, - *, - name: typing.Optional[str] = None, - type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin - is_discriminator: bool = False, - visibility: typing.Optional[typing.List[str]] = None, - default: typing.Any = _UNSET, - format: typing.Optional[str] = None, - is_multipart_file_input: bool = False, - xml: typing.Optional[typing.Dict[str, typing.Any]] = None, - ): - self._type = type - self._rest_name_input = name - self._module: typing.Optional[str] = None - self._is_discriminator = is_discriminator - self._visibility = visibility - self._is_model = False - self._default = default - self._format = format - self._is_multipart_file_input = is_multipart_file_input - self._xml = xml if xml is not None else {} - - @property - def _class_type(self) -> typing.Any: - return getattr(self._type, "args", [None])[0] - - @property - def _rest_name(self) -> str: - if self._rest_name_input is None: - raise ValueError("Rest name was never set") - return self._rest_name_input - - def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin - # by this point, type and rest_name will have a value bc we default - # them in __new__ of the Model class - item = obj.get(self._rest_name) - if item is None: - return item - if self._is_model: - return item - return _deserialize(self._type, _serialize(item, self._format), rf=self) - - def __set__(self, obj: Model, value) -> None: - if value is None: - # we want to wipe out entries if users set attr to None - try: - obj.__delitem__(self._rest_name) - except KeyError: - pass - return - if self._is_model: - if not _is_model(value): - value = _deserialize(self._type, value) - obj.__setitem__(self._rest_name, value) - return - obj.__setitem__(self._rest_name, _serialize(value, self._format)) - - def _get_deserialize_callable_from_annotation( - self, annotation: typing.Any - ) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: - return _get_deserialize_callable_from_annotation(annotation, self._module, self) - - -def rest_field( - *, - name: typing.Optional[str] = None, - type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin - visibility: typing.Optional[typing.List[str]] = None, - default: typing.Any = _UNSET, - format: typing.Optional[str] = None, - is_multipart_file_input: bool = False, - xml: typing.Optional[typing.Dict[str, typing.Any]] = None, -) -> typing.Any: - return _RestField( - name=name, - type=type, - visibility=visibility, - default=default, - format=format, - is_multipart_file_input=is_multipart_file_input, - xml=xml, - ) - - -def rest_discriminator( - *, - name: typing.Optional[str] = None, - type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin - visibility: typing.Optional[typing.List[str]] = None, - xml: typing.Optional[typing.Dict[str, typing.Any]] = None, -) -> typing.Any: - return _RestField(name=name, type=type, is_discriminator=True, visibility=visibility, xml=xml) - - -def serialize_xml(model: Model, exclude_readonly: bool = False) -> str: - """Serialize a model to XML. - - :param Model model: The model to serialize. - :param bool exclude_readonly: Whether to exclude readonly properties. - :returns: The XML representation of the model. - :rtype: str - """ - return ET.tostring(_get_element(model, exclude_readonly), encoding="unicode") # type: ignore - - -def _get_element( - o: typing.Any, - exclude_readonly: bool = False, - parent_meta: typing.Optional[typing.Dict[str, typing.Any]] = None, - wrapped_element: typing.Optional[ET.Element] = None, -) -> typing.Union[ET.Element, typing.List[ET.Element]]: - if _is_model(o): - model_meta = getattr(o, "_xml", {}) - - # if prop is a model, then use the prop element directly, else generate a wrapper of model - if wrapped_element is None: - wrapped_element = _create_xml_element( - model_meta.get("name", o.__class__.__name__), - model_meta.get("prefix"), - model_meta.get("ns"), - ) - - readonly_props = [] - if exclude_readonly: - readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] - - for k, v in o.items(): - # do not serialize readonly properties - if exclude_readonly and k in readonly_props: - continue - - prop_rest_field = _get_rest_field(o._attr_to_rest_field, k) - if prop_rest_field: - prop_meta = getattr(prop_rest_field, "_xml").copy() - # use the wire name as xml name if no specific name is set - if prop_meta.get("name") is None: - prop_meta["name"] = k - else: - # additional properties will not have rest field, use the wire name as xml name - prop_meta = {"name": k} - - # if no ns for prop, use model's - if prop_meta.get("ns") is None and model_meta.get("ns"): - prop_meta["ns"] = model_meta.get("ns") - prop_meta["prefix"] = model_meta.get("prefix") - - if prop_meta.get("unwrapped", False): - # unwrapped could only set on array - wrapped_element.extend(_get_element(v, exclude_readonly, prop_meta)) - elif prop_meta.get("text", False): - # text could only set on primitive type - wrapped_element.text = _get_primitive_type_value(v) - elif prop_meta.get("attribute", False): - xml_name = prop_meta.get("name", k) - if prop_meta.get("ns"): - ET.register_namespace(prop_meta.get("prefix"), prop_meta.get("ns")) # pyright: ignore - xml_name = "{" + prop_meta.get("ns") + "}" + xml_name # pyright: ignore - # attribute should be primitive type - wrapped_element.set(xml_name, _get_primitive_type_value(v)) - else: - # other wrapped prop element - wrapped_element.append(_get_wrapped_element(v, exclude_readonly, prop_meta)) - return wrapped_element - if isinstance(o, list): - return [_get_element(x, exclude_readonly, parent_meta) for x in o] # type: ignore - if isinstance(o, dict): - result = [] - for k, v in o.items(): - result.append( - _get_wrapped_element( - v, - exclude_readonly, - { - "name": k, - "ns": parent_meta.get("ns") if parent_meta else None, - "prefix": parent_meta.get("prefix") if parent_meta else None, - }, - ) - ) - return result - - # primitive case need to create element based on parent_meta - if parent_meta: - return _get_wrapped_element( - o, - exclude_readonly, - { - "name": parent_meta.get("itemsName", parent_meta.get("name")), - "prefix": parent_meta.get("itemsPrefix", parent_meta.get("prefix")), - "ns": parent_meta.get("itemsNs", parent_meta.get("ns")), - }, - ) - - raise ValueError("Could not serialize value into xml: " + o) - - -def _get_wrapped_element( - v: typing.Any, - exclude_readonly: bool, - meta: typing.Optional[typing.Dict[str, typing.Any]], -) -> ET.Element: - wrapped_element = _create_xml_element( - meta.get("name") if meta else None, meta.get("prefix") if meta else None, meta.get("ns") if meta else None - ) - if isinstance(v, (dict, list)): - wrapped_element.extend(_get_element(v, exclude_readonly, meta)) - elif _is_model(v): - _get_element(v, exclude_readonly, meta, wrapped_element) - else: - wrapped_element.text = _get_primitive_type_value(v) - return wrapped_element - - -def _get_primitive_type_value(v) -> str: - if v is True: - return "true" - if v is False: - return "false" - if isinstance(v, _Null): - return "" - return str(v) - - -def _create_xml_element(tag, prefix=None, ns=None): - if prefix and ns: - ET.register_namespace(prefix, ns) - if ns: - return ET.Element("{" + ns + "}" + tag) - return ET.Element(tag) - - -def _deserialize_xml( - deserializer: typing.Any, - value: str, -) -> typing.Any: - element = ET.fromstring(value) # nosec - return _deserialize(deserializer, element) - - -def _convert_element(e: ET.Element): - # dict case - if len(e.attrib) > 0 or len({child.tag for child in e}) > 1: - dict_result: typing.Dict[str, typing.Any] = {} - for child in e: - if dict_result.get(child.tag) is not None: - if isinstance(dict_result[child.tag], list): - dict_result[child.tag].append(_convert_element(child)) - else: - dict_result[child.tag] = [dict_result[child.tag], _convert_element(child)] - else: - dict_result[child.tag] = _convert_element(child) - dict_result.update(e.attrib) - return dict_result - # array case - if len(e) > 0: - array_result: typing.List[typing.Any] = [] - for child in e: - array_result.append(_convert_element(child)) - return array_result - # primitive case - return e.text diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_operations/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_operations/__init__.py deleted file mode 100644 index 567607c23a2..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_operations/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import QueryClientOperationsMixin # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "QueryClientOperationsMixin", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_operations/_operations.py deleted file mode 100644 index 3fa86121a30..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_operations/_operations.py +++ /dev/null @@ -1,96 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict - -from .._serialization import Serializer -from .._vendor import QueryClientMixinABC - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_query_query_api_version_request(**kwargs: Any) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - version: str = kwargs.pop("version", _params.pop("version", "2025-01-01")) - # Construct URL - _url = "/azure/client-generator-core/api-version/query" - - # Construct parameters - _params["version"] = _SERIALIZER.query("version", version, "str") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -class QueryClientOperationsMixin(QueryClientMixinABC): - - @distributed_trace - def query_api_version(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """Query api version parameter. - - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_query_query_api_version_request( - version=self._config.version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_operations/_patch.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_operations/_patch.py deleted file mode 100644 index f7dd3251033..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__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/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_patch.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_patch.py deleted file mode 100644 index f7dd3251033..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__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/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_serialization.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_serialization.py deleted file mode 100644 index e2a20b1d534..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_serialization.py +++ /dev/null @@ -1,2050 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# -------------------------------------------------------------------------- -# -# Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# 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. -# -# -------------------------------------------------------------------------- - -# pyright: reportUnnecessaryTypeIgnoreComment=false - -from base64 import b64decode, b64encode -import calendar -import datetime -import decimal -import email -from enum import Enum -import json -import logging -import re -import sys -import codecs -from typing import ( - Dict, - Any, - cast, - Optional, - Union, - AnyStr, - IO, - Mapping, - Callable, - MutableMapping, - List, -) - -try: - from urllib import quote # type: ignore -except ImportError: - from urllib.parse import quote -import xml.etree.ElementTree as ET - -import isodate # type: ignore -from typing_extensions import Self - -from azure.core.exceptions import DeserializationError, SerializationError -from azure.core.serialization import NULL as CoreNull - -_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") - -JSON = MutableMapping[str, Any] - - -class RawDeserializer: - - # Accept "text" because we're open minded people... - JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") - - # Name used in context - CONTEXT_NAME = "deserialized_data" - - @classmethod - def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: - """Decode data according to content-type. - - Accept a stream of data as well, but will be load at once in memory for now. - - If no content-type, will return the string version (not bytes, not stream) - - :param data: Input, could be bytes or stream (will be decoded with UTF8) or text - :type data: str or bytes or IO - :param str content_type: The content type. - :return: The deserialized data. - :rtype: object - """ - if hasattr(data, "read"): - # Assume a stream - data = cast(IO, data).read() - - if isinstance(data, bytes): - data_as_str = data.decode(encoding="utf-8-sig") - else: - # Explain to mypy the correct type. - data_as_str = cast(str, data) - - # Remove Byte Order Mark if present in string - data_as_str = data_as_str.lstrip(_BOM) - - if content_type is None: - return data - - if cls.JSON_REGEXP.match(content_type): - try: - return json.loads(data_as_str) - except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) from err - elif "xml" in (content_type or []): - try: - - try: - if isinstance(data, unicode): # type: ignore - # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string - data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore - except NameError: - pass - - return ET.fromstring(data_as_str) # nosec - except ET.ParseError as err: - # It might be because the server has an issue, and returned JSON with - # content-type XML.... - # So let's try a JSON load, and if it's still broken - # let's flow the initial exception - def _json_attemp(data): - try: - return True, json.loads(data) - except ValueError: - return False, None # Don't care about this one - - success, json_result = _json_attemp(data) - if success: - return json_result - # If i'm here, it's not JSON, it's not XML, let's scream - # and raise the last context in this block (the XML exception) - # The function hack is because Py2.7 messes up with exception - # context otherwise. - _LOGGER.critical("Wasn't XML not JSON, failing") - raise DeserializationError("XML is invalid") from err - elif content_type.startswith("text/"): - return data_as_str - raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) - - @classmethod - def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: - """Deserialize from HTTP response. - - Use bytes and headers to NOT use any requests/aiohttp or whatever - specific implementation. - Headers will tested for "content-type" - - :param bytes body_bytes: The body of the response. - :param dict headers: The headers of the response. - :returns: The deserialized data. - :rtype: object - """ - # Try to use content-type from headers if available - content_type = None - if "content-type" in headers: - content_type = headers["content-type"].split(";")[0].strip().lower() - # Ouch, this server did not declare what it sent... - # Let's guess it's JSON... - # Also, since Autorest was considering that an empty body was a valid JSON, - # need that test as well.... - else: - content_type = "application/json" - - if body_bytes: - return cls.deserialize_from_text(body_bytes, content_type) - return None - - -_LOGGER = logging.getLogger(__name__) - -try: - _long_type = long # type: ignore -except NameError: - _long_type = int - -TZ_UTC = datetime.timezone.utc - -_FLATTEN = re.compile(r"(? None: - self.additional_properties: Optional[Dict[str, Any]] = {} - for k in kwargs: # pylint: disable=consider-using-dict-items - if k not in self._attribute_map: - _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) - elif k in self._validation and self._validation[k].get("readonly", False): - _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) - else: - setattr(self, k, kwargs[k]) - - def __eq__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are equal - :rtype: bool - """ - if isinstance(other, self.__class__): - return self.__dict__ == other.__dict__ - return False - - def __ne__(self, other: Any) -> bool: - """Compare objects by comparing all attributes. - - :param object other: The object to compare - :returns: True if objects are not equal - :rtype: bool - """ - return not self.__eq__(other) - - def __str__(self) -> str: - return str(self.__dict__) - - @classmethod - def enable_additional_properties_sending(cls) -> None: - cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} - - @classmethod - def is_xml_model(cls) -> bool: - try: - cls._xml_map # type: ignore - except AttributeError: - return False - return True - - @classmethod - def _create_xml_node(cls): - """Create XML node. - - :returns: The XML node - :rtype: xml.etree.ElementTree.Element - """ - try: - xml_map = cls._xml_map # type: ignore - except AttributeError: - xml_map = {} - - return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - - def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to server from this model. - - This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, keep_readonly=keep_readonly, **kwargs - ) - - def as_dict( - self, - keep_readonly: bool = True, - key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, - **kwargs: Any - ) -> JSON: - """Return a dict that can be serialized using json.dump. - - Advanced usage might optionally use a callback as parameter: - - .. code::python - - def my_key_transformer(key, attr_desc, value): - return key - - Key is the attribute name used in Python. Attr_desc - is a dict of metadata. Currently contains 'type' with the - msrest type and 'key' with the RestAPI encoded key. - Value is the current value in this object. - - The string returned will be used to serialize the key. - If the return type is a list, this is considered hierarchical - result dict. - - See the three examples in this file: - - - attribute_transformer - - full_restapi_key_transformer - - last_restapi_key_transformer - - If you want XML serialization, you can pass the kwargs is_xml=True. - - :param bool keep_readonly: If you want to serialize the readonly attributes - :param function key_transformer: A key transformer function. - :returns: A dict JSON compatible object - :rtype: dict - """ - serializer = Serializer(self._infer_class_models()) - return serializer._serialize( # type: ignore # pylint: disable=protected-access - self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs - ) - - @classmethod - def _infer_class_models(cls): - try: - str_models = cls.__module__.rsplit(".", 1)[0] - models = sys.modules[str_models] - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - if cls.__name__ not in client_models: - raise ValueError("Not Autorest generated code") - except Exception: # pylint: disable=broad-exception-caught - # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. - client_models = {cls.__name__: cls} - return client_models - - @classmethod - def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: - """Parse a str using the RestAPI syntax and return a model. - - :param str data: A str using RestAPI structure. JSON by default. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises DeserializationError: if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def from_dict( - cls, - data: Any, - key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, - content_type: Optional[str] = None, - ) -> Self: - """Parse a dict using given key extractor return a model. - - By default consider key - extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor - and last_rest_key_case_insensitive_extractor) - - :param dict data: A dict using RestAPI structure - :param function key_extractors: A key extractor function. - :param str content_type: JSON by default, set application/xml if XML. - :returns: An instance of this model - :raises: DeserializationError if something went wrong - :rtype: Self - """ - deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( # type: ignore - [ # type: ignore - attribute_key_case_insensitive_extractor, - rest_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - if key_extractors is None - else key_extractors - ) - return deserializer(cls.__name__, data, content_type=content_type) # type: ignore - - @classmethod - def _flatten_subtype(cls, key, objects): - if "_subtype_map" not in cls.__dict__: - return {} - result = dict(cls._subtype_map[key]) - for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access - return result - - @classmethod - def _classify(cls, response, objects): - """Check the class _subtype_map for any child classes. - We want to ignore any inherited _subtype_maps. - - :param dict response: The initial data - :param dict objects: The class objects - :returns: The class to be used - :rtype: class - """ - for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): - subtype_value = None - - if not isinstance(response, ET.Element): - rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) - else: - subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) - if subtype_value: - # Try to match base class. Can be class name only - # (bug to fix in Autorest to support x-ms-discriminator-name) - if cls.__name__ == subtype_value: - return cls - flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) - try: - return objects[flatten_mapping_type[subtype_value]] # type: ignore - except KeyError: - _LOGGER.warning( - "Subtype value %s has no mapping, use base class %s.", - subtype_value, - cls.__name__, - ) - break - else: - _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) - break - return cls - - @classmethod - def _get_rest_key_parts(cls, attr_key): - """Get the RestAPI key of this attr, split it and decode part - :param str attr_key: Attribute key must be in attribute_map. - :returns: A list of RestAPI part - :rtype: list - """ - rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) - return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] - - -def _decode_attribute_map_key(key): - """This decode a key in an _attribute_map to the actual key we want to look at - inside the received data. - - :param str key: A key string from the generated code - :returns: The decoded key - :rtype: str - """ - return key.replace("\\.", ".") - - -class Serializer: # pylint: disable=too-many-public-methods - """Request object model serializer.""" - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} - days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} - months = { - 1: "Jan", - 2: "Feb", - 3: "Mar", - 4: "Apr", - 5: "May", - 6: "Jun", - 7: "Jul", - 8: "Aug", - 9: "Sep", - 10: "Oct", - 11: "Nov", - 12: "Dec", - } - validation = { - "min_length": lambda x, y: len(x) < y, - "max_length": lambda x, y: len(x) > y, - "minimum": lambda x, y: x < y, - "maximum": lambda x, y: x > y, - "minimum_ex": lambda x, y: x <= y, - "maximum_ex": lambda x, y: x >= y, - "min_items": lambda x, y: len(x) < y, - "max_items": lambda x, y: len(x) > y, - "pattern": lambda x, y: not re.match(y, x, re.UNICODE), - "unique": lambda x, y: len(x) != len(set(x)), - "multiple": lambda x, y: x % y != 0, - } - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.serialize_type = { - "iso-8601": Serializer.serialize_iso, - "rfc-1123": Serializer.serialize_rfc, - "unix-time": Serializer.serialize_unix, - "duration": Serializer.serialize_duration, - "date": Serializer.serialize_date, - "time": Serializer.serialize_time, - "decimal": Serializer.serialize_decimal, - "long": Serializer.serialize_long, - "bytearray": Serializer.serialize_bytearray, - "base64": Serializer.serialize_base64, - "object": self.serialize_object, - "[]": self.serialize_iter, - "{}": self.serialize_dict, - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_transformer = full_restapi_key_transformer - self.client_side_validation = True - - def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals - self, target_obj, data_type=None, **kwargs - ): - """Serialize data into a string according to type. - - :param object target_obj: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, dict - :raises SerializationError: if serialization fails. - :returns: The serialized data. - """ - key_transformer = kwargs.get("key_transformer", self.key_transformer) - keep_readonly = kwargs.get("keep_readonly", False) - if target_obj is None: - return None - - attr_name = None - class_name = target_obj.__class__.__name__ - - if data_type: - return self.serialize_data(target_obj, data_type, **kwargs) - - if not hasattr(target_obj, "_attribute_map"): - data_type = type(target_obj).__name__ - if data_type in self.basic_types.values(): - return self.serialize_data(target_obj, data_type, **kwargs) - - # Force "is_xml" kwargs if we detect a XML model - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) - - serialized = {} - if is_xml_model_serialization: - serialized = target_obj._create_xml_node() # pylint: disable=protected-access - try: - attributes = target_obj._attribute_map # pylint: disable=protected-access - for attr, attr_desc in attributes.items(): - attr_name = attr - if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access - attr_name, {} - ).get("readonly", False): - continue - - if attr_name == "additional_properties" and attr_desc["key"] == "": - if target_obj.additional_properties is not None: - serialized.update(target_obj.additional_properties) - continue - try: - - orig_attr = getattr(target_obj, attr) - if is_xml_model_serialization: - pass # Don't provide "transformer" for XML for now. Keep "orig_attr" - else: # JSON - keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) - keys = keys if isinstance(keys, list) else [keys] - - kwargs["serialization_ctxt"] = attr_desc - new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) - - if is_xml_model_serialization: - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - xml_prefix = xml_desc.get("prefix", None) - xml_ns = xml_desc.get("ns", None) - if xml_desc.get("attr", False): - if xml_ns: - ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) # type: ignore - continue - if xml_desc.get("text", False): - serialized.text = new_attr # type: ignore - continue - if isinstance(new_attr, list): - serialized.extend(new_attr) # type: ignore - elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, - # we MUST replace the tag with the local tag. But keeping the namespaces. - if "name" not in getattr(orig_attr, "_xml_map", {}): - splitted_tag = new_attr.tag.split("}") - if len(splitted_tag) == 2: # Namespace - new_attr.tag = "}".join([splitted_tag[0], xml_name]) - else: - new_attr.tag = xml_name - serialized.append(new_attr) # type: ignore - else: # That's a basic type - # Integrate namespace if necessary - local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = str(new_attr) - serialized.append(local_node) # type: ignore - else: # JSON - for k in reversed(keys): # type: ignore - new_attr = {k: new_attr} - - _new_attr = new_attr - _serialized = serialized - for k in keys: # type: ignore - if k not in _serialized: - _serialized.update(_new_attr) # type: ignore - _new_attr = _new_attr[k] # type: ignore - _serialized = _serialized[k] - except ValueError as err: - if isinstance(err, SerializationError): - raise - - except (AttributeError, KeyError, TypeError) as err: - msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise SerializationError(msg) from err - return serialized - - def body(self, data, data_type, **kwargs): - """Serialize data intended for a request body. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: dict - :raises SerializationError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized request body - """ - - # Just in case this is a dict - internal_data_type_str = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type_str, None) - try: - is_xml_model_serialization = kwargs["is_xml"] - except KeyError: - if internal_data_type and issubclass(internal_data_type, Model): - is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) - else: - is_xml_model_serialization = False - if internal_data_type and not isinstance(internal_data_type, Enum): - try: - deserializer = Deserializer(self.dependencies) - # Since it's on serialization, it's almost sure that format is not JSON REST - # We're not able to deal with additional properties for now. - deserializer.additional_properties_detection = False - if is_xml_model_serialization: - deserializer.key_extractors = [ # type: ignore - attribute_key_case_insensitive_extractor, - ] - else: - deserializer.key_extractors = [ - rest_key_case_insensitive_extractor, - attribute_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor, - ] - data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access - except DeserializationError as err: - raise SerializationError("Unable to build a model: " + str(err)) from err - - return self._serialize(data, data_type, **kwargs) - - def url(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL path. - - :param str name: The name of the URL path parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :returns: The serialized URL path - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - """ - try: - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - - if kwargs.get("skip_quote") is True: - output = str(output) - output = output.replace("{", quote("{")).replace("}", quote("}")) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return output - - def query(self, name, data, data_type, **kwargs): - """Serialize data intended for a URL query. - - :param str name: The name of the query parameter. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str, list - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized query parameter - """ - try: - # Treat the list aside, since we don't want to encode the div separator - if data_type.startswith("["): - internal_data_type = data_type[1:-1] - do_quote = not kwargs.get("skip_quote", False) - return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) - - # Not a list, regular serialization - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - if kwargs.get("skip_quote") is True: - output = str(output) - else: - output = quote(str(output), safe="") - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def header(self, name, data, data_type, **kwargs): - """Serialize data intended for a request header. - - :param str name: The name of the header. - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :rtype: str - :raises TypeError: if serialization fails. - :raises ValueError: if data is None - :returns: The serialized header - """ - try: - if data_type in ["[str]"]: - data = ["" if d is None else d for d in data] - - output = self.serialize_data(data, data_type, **kwargs) - if data_type == "bool": - output = json.dumps(output) - except SerializationError as exc: - raise TypeError("{} must be type {}.".format(name, data_type)) from exc - return str(output) - - def serialize_data(self, data, data_type, **kwargs): - """Serialize generic data according to supplied data type. - - :param object data: The data to be serialized. - :param str data_type: The type to be serialized from. - :raises AttributeError: if required data is None. - :raises ValueError: if data is None - :raises SerializationError: if serialization fails. - :returns: The serialized data. - :rtype: str, int, float, bool, dict, list - """ - if data is None: - raise ValueError("No value for given attribute") - - try: - if data is CoreNull: - return None - if data_type in self.basic_types.values(): - return self.serialize_basic(data, data_type, **kwargs) - - if data_type in self.serialize_type: - return self.serialize_type[data_type](data, **kwargs) - - # If dependencies is empty, try with current data class - # It has to be a subclass of Enum anyway - enum_type = self.dependencies.get(data_type, data.__class__) - if issubclass(enum_type, Enum): - return Serializer.serialize_enum(data, enum_obj=enum_type) - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.serialize_type: - return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) - - except (ValueError, TypeError) as err: - msg = "Unable to serialize value: {!r} as type: {!r}." - raise SerializationError(msg.format(data, data_type)) from err - return self._serialize(data, **kwargs) - - @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements - custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) - if custom_serializer: - return custom_serializer - if kwargs.get("is_xml", False): - return cls._xml_basic_types_serializers.get(data_type) - - @classmethod - def serialize_basic(cls, data, data_type, **kwargs): - """Serialize basic builting data type. - Serializes objects to str, int, float or bool. - - Possible kwargs: - - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - - is_xml bool : If set, use xml_basic_types_serializers - - :param obj data: Object to be serialized. - :param str data_type: Type of object in the iterable. - :rtype: str, int, float, bool - :return: serialized object - """ - custom_serializer = cls._get_custom_serializers(data_type, **kwargs) - if custom_serializer: - return custom_serializer(data) - if data_type == "str": - return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec # pylint: disable=eval-used - - @classmethod - def serialize_unicode(cls, data): - """Special handling for serializing unicode strings in Py2. - Encode to UTF-8 if unicode, otherwise handle as a str. - - :param str data: Object to be serialized. - :rtype: str - :return: serialized object - """ - try: # If I received an enum, return its value - return data.value - except AttributeError: - pass - - try: - if isinstance(data, unicode): # type: ignore - # Don't change it, JSON and XML ElementTree are totally able - # to serialize correctly u'' strings - return data - except NameError: - return str(data) - return str(data) - - def serialize_iter(self, data, iter_type, div=None, **kwargs): - """Serialize iterable. - - Supported kwargs: - - serialization_ctxt dict : The current entry of _attribute_map, or same format. - serialization_ctxt['type'] should be same as data_type. - - is_xml bool : If set, serialize as XML - - :param list data: Object to be serialized. - :param str iter_type: Type of object in the iterable. - :param str div: If set, this str will be used to combine the elements - in the iterable into a combined string. Default is 'None'. - Defaults to False. - :rtype: list, str - :return: serialized iterable - """ - if isinstance(data, str): - raise SerializationError("Refuse str type as a valid iter type.") - - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - is_xml = kwargs.get("is_xml", False) - - serialized = [] - for d in data: - try: - serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized.append(None) - - if kwargs.get("do_quote", False): - serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] - - if div: - serialized = ["" if s is None else str(s) for s in serialized] - serialized = div.join(serialized) - - if "xml" in serialization_ctxt or is_xml: - # XML serialization is more complicated - xml_desc = serialization_ctxt.get("xml", {}) - xml_name = xml_desc.get("name") - if not xml_name: - xml_name = serialization_ctxt["key"] - - # Create a wrap node if necessary (use the fact that Element and list have "append") - is_wrapped = xml_desc.get("wrapped", False) - node_name = xml_desc.get("itemsName", xml_name) - if is_wrapped: - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - else: - final_result = [] - # All list elements to "local_node" - for el in serialized: - if isinstance(el, ET.Element): - el_node = el - else: - el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - if el is not None: # Otherwise it writes "None" :-p - el_node.text = str(el) - final_result.append(el_node) - return final_result - return serialized - - def serialize_dict(self, attr, dict_type, **kwargs): - """Serialize a dictionary of objects. - - :param dict attr: Object to be serialized. - :param str dict_type: Type of object in the dictionary. - :rtype: dict - :return: serialized dictionary - """ - serialization_ctxt = kwargs.get("serialization_ctxt", {}) - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError as err: - if isinstance(err, SerializationError): - raise - serialized[self.serialize_unicode(key)] = None - - if "xml" in serialization_ctxt: - # XML serialization is more complicated - xml_desc = serialization_ctxt["xml"] - xml_name = xml_desc["name"] - - final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) - for key, value in serialized.items(): - ET.SubElement(final_result, key).text = value - return final_result - - return serialized - - def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Serialize a generic object. - This will be handled as a dictionary. If object passed in is not - a basic type (str, int, float, dict, list) it will simply be - cast to str. - - :param dict attr: Object to be serialized. - :rtype: dict or str - :return: serialized object - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - return attr - obj_type = type(attr) - if obj_type in self.basic_types: - return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) - if obj_type is _long_type: - return self.serialize_long(attr) - if obj_type is str: - return self.serialize_unicode(attr) - if obj_type is datetime.datetime: - return self.serialize_iso(attr) - if obj_type is datetime.date: - return self.serialize_date(attr) - if obj_type is datetime.time: - return self.serialize_time(attr) - if obj_type is datetime.timedelta: - return self.serialize_duration(attr) - if obj_type is decimal.Decimal: - return self.serialize_decimal(attr) - - # If it's a model or I know this dependency, serialize as a Model - if obj_type in self.dependencies.values() or isinstance(attr, Model): - return self._serialize(attr) - - if obj_type == dict: - serialized = {} - for key, value in attr.items(): - try: - serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) - except ValueError: - serialized[self.serialize_unicode(key)] = None - return serialized - - if obj_type == list: - serialized = [] - for obj in attr: - try: - serialized.append(self.serialize_object(obj, **kwargs)) - except ValueError: - pass - return serialized - return str(attr) - - @staticmethod - def serialize_enum(attr, enum_obj=None): - try: - result = attr.value - except AttributeError: - result = attr - try: - enum_obj(result) # type: ignore - return result - except ValueError as exc: - for enum_value in enum_obj: # type: ignore - if enum_value.value.lower() == str(attr).lower(): - return enum_value.value - error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) from exc - - @staticmethod - def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument - """Serialize bytearray into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - return b64encode(attr).decode() - - @staticmethod - def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument - """Serialize str into base-64 string. - - :param str attr: Object to be serialized. - :rtype: str - :return: serialized base64 - """ - encoded = b64encode(attr).decode("ascii") - return encoded.strip("=").replace("+", "-").replace("/", "_") - - @staticmethod - def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Decimal object to float. - - :param decimal attr: Object to be serialized. - :rtype: float - :return: serialized decimal - """ - return float(attr) - - @staticmethod - def serialize_long(attr, **kwargs): # pylint: disable=unused-argument - """Serialize long (Py2) or int (Py3). - - :param int attr: Object to be serialized. - :rtype: int/long - :return: serialized long - """ - return _long_type(attr) - - @staticmethod - def serialize_date(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Date object into ISO-8601 formatted string. - - :param Date attr: Object to be serialized. - :rtype: str - :return: serialized date - """ - if isinstance(attr, str): - attr = isodate.parse_date(attr) - t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) - return t - - @staticmethod - def serialize_time(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Time object into ISO-8601 formatted string. - - :param datetime.time attr: Object to be serialized. - :rtype: str - :return: serialized time - """ - if isinstance(attr, str): - attr = isodate.parse_time(attr) - t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) - if attr.microsecond: - t += ".{:02}".format(attr.microsecond) - return t - - @staticmethod - def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument - """Serialize TimeDelta object into ISO-8601 formatted string. - - :param TimeDelta attr: Object to be serialized. - :rtype: str - :return: serialized duration - """ - if isinstance(attr, str): - attr = isodate.parse_duration(attr) - return isodate.duration_isoformat(attr) - - @staticmethod - def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into RFC-1123 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises TypeError: if format invalid. - :return: serialized rfc - """ - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - except AttributeError as exc: - raise TypeError("RFC1123 object must be valid Datetime object.") from exc - - return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( - Serializer.days[utc.tm_wday], - utc.tm_mday, - Serializer.months[utc.tm_mon], - utc.tm_year, - utc.tm_hour, - utc.tm_min, - utc.tm_sec, - ) - - @staticmethod - def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into ISO-8601 formatted string. - - :param Datetime attr: Object to be serialized. - :rtype: str - :raises SerializationError: if format invalid. - :return: serialized iso - """ - if isinstance(attr, str): - attr = isodate.parse_datetime(attr) - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - utc = attr.utctimetuple() - if utc.tm_year > 9999 or utc.tm_year < 1: - raise OverflowError("Hit max or min date") - - microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") - if microseconds: - microseconds = "." + microseconds - date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( - utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec - ) - return date + microseconds + "Z" - except (ValueError, OverflowError) as err: - msg = "Unable to serialize datetime object." - raise SerializationError(msg) from err - except AttributeError as err: - msg = "ISO-8601 object must be valid Datetime object." - raise TypeError(msg) from err - - @staticmethod - def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param Datetime attr: Object to be serialized. - :rtype: int - :raises SerializationError: if format invalid - :return: serialied unix - """ - if isinstance(attr, int): - return attr - try: - if not attr.tzinfo: - _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") - return int(calendar.timegm(attr.utctimetuple())) - except AttributeError as exc: - raise TypeError("Unix time object must be valid Datetime object.") from exc - - -def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - key = attr_desc["key"] - working_data = data - - while "." in key: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - dict_keys = cast(List[str], _FLATTEN.split(key)) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = working_data.get(working_key, data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - return working_data.get(key) - - -def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements - attr, attr_desc, data -): - key = attr_desc["key"] - working_data = data - - while "." in key: - dict_keys = _FLATTEN.split(key) - if len(dict_keys) == 1: - key = _decode_attribute_map_key(dict_keys[0]) - break - working_key = _decode_attribute_map_key(dict_keys[0]) - working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) - if working_data is None: - # If at any point while following flatten JSON path see None, it means - # that all properties under are None as well - return None - key = ".".join(dict_keys[1:]) - - if working_data: - return attribute_key_case_insensitive_extractor(key, None, working_data) - - -def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_extractor(dict_keys[-1], None, data) - - -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument - """Extract the attribute in "data" based on the last part of the JSON path key. - - This is the case insensitive version of "last_rest_key_extractor" - :param str attr: The attribute to extract - :param dict attr_desc: The attribute description - :param dict data: The data to extract from - :rtype: object - :returns: The extracted attribute - """ - key = attr_desc["key"] - dict_keys = _FLATTEN.split(key) - return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) - - -def attribute_key_extractor(attr, _, data): - return data.get(attr) - - -def attribute_key_case_insensitive_extractor(attr, _, data): - found_key = None - lower_attr = attr.lower() - for key in data: - if lower_attr == key.lower(): - found_key = key - break - - return data.get(found_key) - - -def _extract_name_from_internal_type(internal_type): - """Given an internal type XML description, extract correct XML name with namespace. - - :param dict internal_type: An model type - :rtype: tuple - :returns: A tuple XML name + namespace dict - """ - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - xml_name = internal_type_xml_map.get("name", internal_type.__name__) - xml_ns = internal_type_xml_map.get("ns", None) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - return xml_name - - -def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements - if isinstance(data, dict): - return None - - # Test if this model is XML ready first - if not isinstance(data, ET.Element): - return None - - xml_desc = attr_desc.get("xml", {}) - xml_name = xml_desc.get("name", attr_desc["key"]) - - # Look for a children - is_iter_type = attr_desc["type"].startswith("[") - is_wrapped = xml_desc.get("wrapped", False) - internal_type = attr_desc.get("internalType", None) - internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - - # Integrate namespace if necessary - xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) - if xml_ns: - xml_name = "{{{}}}{}".format(xml_ns, xml_name) - - # If it's an attribute, that's simple - if xml_desc.get("attr", False): - return data.get(xml_name) - - # If it's x-ms-text, that's simple too - if xml_desc.get("text", False): - return data.text - - # Scenario where I take the local name: - # - Wrapped node - # - Internal type is an enum (considered basic types) - # - Internal type has no XML/Name node - if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): - children = data.findall(xml_name) - # If internal type has a local name and it's not a list, I use that name - elif not is_iter_type and internal_type and "name" in internal_type_xml_map: - xml_name = _extract_name_from_internal_type(internal_type) - children = data.findall(xml_name) - # That's an array - else: - if internal_type: # Complex type, ignore itemsName and use the complex type name - items_name = _extract_name_from_internal_type(internal_type) - else: - items_name = xml_desc.get("itemsName", xml_name) - children = data.findall(items_name) - - if len(children) == 0: - if is_iter_type: - if is_wrapped: - return None # is_wrapped no node, we want None - return [] # not wrapped, assume empty list - return None # Assume it's not there, maybe an optional node. - - # If is_iter_type and not wrapped, return all found children - if is_iter_type: - if not is_wrapped: - return children - # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) - ) - return list(children[0]) # Might be empty list and that's ok. - - # Here it's not a itertype, we should have found one element only or empty - if len(children) > 1: - raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) - return children[0] - - -class Deserializer: - """Response object model deserializer. - - :param dict classes: Class type dictionary for deserializing complex types. - :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. - """ - - basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - - def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: - self.deserialize_type = { - "iso-8601": Deserializer.deserialize_iso, - "rfc-1123": Deserializer.deserialize_rfc, - "unix-time": Deserializer.deserialize_unix, - "duration": Deserializer.deserialize_duration, - "date": Deserializer.deserialize_date, - "time": Deserializer.deserialize_time, - "decimal": Deserializer.deserialize_decimal, - "long": Deserializer.deserialize_long, - "bytearray": Deserializer.deserialize_bytearray, - "base64": Deserializer.deserialize_base64, - "object": self.deserialize_object, - "[]": self.deserialize_iter, - "{}": self.deserialize_dict, - } - self.deserialize_expected_types = { - "duration": (isodate.Duration, datetime.timedelta), - "iso-8601": (datetime.datetime), - } - self.dependencies: Dict[str, type] = dict(classes) if classes else {} - self.key_extractors = [rest_key_extractor, xml_key_extractor] - # Additional properties only works if the "rest_key_extractor" is used to - # extract the keys. Making it to work whatever the key extractor is too much - # complicated, with no real scenario for now. - # So adding a flag to disable additional properties detection. This flag should be - # used if your expect the deserialization to NOT come from a JSON REST syntax. - # Otherwise, result are unexpected - self.additional_properties_detection = True - - def __call__(self, target_obj, response_data, content_type=None): - """Call the deserializer to process a REST response. - - :param str target_obj: Target data type to deserialize to. - :param requests.Response response_data: REST response object. - :param str content_type: Swagger "produces" if available. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - data = self._unpack_content(response_data, content_type) - return self._deserialize(target_obj, data) - - def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements - """Call the deserializer on a model. - - Data needs to be already deserialized as JSON or XML ElementTree - - :param str target_obj: Target data type to deserialize to. - :param object data: Object to deserialize. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - # This is already a model, go recursive just in case - if hasattr(data, "_attribute_map"): - constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] - try: - for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access - if attr in constants: - continue - value = getattr(data, attr) - if value is None: - continue - local_type = mapconfig["type"] - internal_data_type = local_type.strip("[]{}") - if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): - continue - setattr(data, attr, self._deserialize(local_type, value)) - return data - except AttributeError: - return - - response, class_name = self._classify_target(target_obj, data) - - if isinstance(response, str): - return self.deserialize_data(data, response) - if isinstance(response, type) and issubclass(response, Enum): - return self.deserialize_enum(data, response) - - if data is None or data is CoreNull: - return data - try: - attributes = response._attribute_map # type: ignore # pylint: disable=protected-access - d_attrs = {} - for attr, attr_desc in attributes.items(): - # Check empty string. If it's not empty, someone has a real "additionalProperties"... - if attr == "additional_properties" and attr_desc["key"] == "": - continue - raw_value = None - # Enhance attr_desc with some dynamic data - attr_desc = attr_desc.copy() # Do a copy, do not change the real one - internal_data_type = attr_desc["type"].strip("[]{}") - if internal_data_type in self.dependencies: - attr_desc["internalType"] = self.dependencies[internal_data_type] - - for key_extractor in self.key_extractors: - found_value = key_extractor(attr, attr_desc, data) - if found_value is not None: - if raw_value is not None and raw_value != found_value: - msg = ( - "Ignoring extracted value '%s' from %s for key '%s'" - " (duplicate extraction, follow extractors order)" - ) - _LOGGER.warning(msg, found_value, key_extractor, attr) - continue - raw_value = found_value - - value = self.deserialize_data(raw_value, attr_desc["type"]) - d_attrs[attr] = value - except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name # type: ignore - raise DeserializationError(msg) from err - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) - - def _build_additional_properties(self, attribute_map, data): - if not self.additional_properties_detection: - return None - if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": - # Check empty string. If it's not empty, someone has a real "additionalProperties" - return None - if isinstance(data, ET.Element): - data = {el.tag: el.text for el in data} - - known_keys = { - _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) - for desc in attribute_map.values() - if desc["key"] != "" - } - present_keys = set(data.keys()) - missing_keys = present_keys - known_keys - return {key: data[key] for key in missing_keys} - - def _classify_target(self, target, data): - """Check to see whether the deserialization target object can - be classified into a subclass. - Once classification has been determined, initialize object. - - :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :return: The classified target object and its class name. - :rtype: tuple - """ - if target is None: - return None, None - - if isinstance(target, str): - try: - target = self.dependencies[target] - except KeyError: - return target, target - - try: - target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access - except AttributeError: - pass # Target is not a Model, no classify - return target, target.__class__.__name__ # type: ignore - - def failsafe_deserialize(self, target_obj, data, content_type=None): - """Ignores any errors encountered in deserialization, - and falls back to not deserializing the object. Recommended - for use in error deserialization, as we want to return the - HttpResponseError to users, and not have them deal with - a deserialization error. - - :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deserialize. - :param str content_type: Swagger "produces" if available. - :return: Deserialized object. - :rtype: object - """ - try: - return self(target_obj, data, content_type=content_type) - except: # pylint: disable=bare-except - _LOGGER.debug( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True - ) - return None - - @staticmethod - def _unpack_content(raw_data, content_type=None): - """Extract the correct structure for deserialization. - - If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. - if we can't, raise. Your Pipeline should have a RawDeserializer. - - If not a pipeline response and raw_data is bytes or string, use content-type - to decode it. If no content-type, try JSON. - - If raw_data is something else, bypass all logic and return it directly. - - :param obj raw_data: Data to be processed. - :param str content_type: How to parse if raw_data is a string/bytes. - :raises JSONDecodeError: If JSON is requested and parsing is impossible. - :raises UnicodeDecodeError: If bytes is not UTF8 - :rtype: object - :return: Unpacked content. - """ - # Assume this is enough to detect a Pipeline Response without importing it - context = getattr(raw_data, "context", {}) - if context: - if RawDeserializer.CONTEXT_NAME in context: - return context[RawDeserializer.CONTEXT_NAME] - raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") - - # Assume this is enough to recognize universal_http.ClientResponse without importing it - if hasattr(raw_data, "body"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) - - # Assume this enough to recognize requests.Response without importing it. - if hasattr(raw_data, "_content_consumed"): - return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - - if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore - return raw_data - - def _instantiate_model(self, response, attrs, additional_properties=None): - """Instantiate a response model passing in deserialized args. - - :param Response response: The response model class. - :param dict attrs: The deserialized response attributes. - :param dict additional_properties: Additional properties to be set. - :rtype: Response - :return: The instantiated response model. - """ - if callable(response): - subtype = getattr(response, "_subtype_map", {}) - try: - readonly = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("readonly") - ] - const = [ - k - for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore - if v.get("constant") - ] - kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} - response_obj = response(**kwargs) - for attr in readonly: - setattr(response_obj, attr, attrs.get(attr)) - if additional_properties: - response_obj.additional_properties = additional_properties # type: ignore - return response_obj - except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) from err - else: - try: - for attr, value in attrs.items(): - setattr(response, attr, value) - return response - except Exception as exp: - msg = "Unable to populate response model. " - msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) from exp - - def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements - """Process data for deserialization according to data type. - - :param str data: The response string to be deserialized. - :param str data_type: The type to deserialize to. - :raises DeserializationError: if deserialization fails. - :return: Deserialized object. - :rtype: object - """ - if data is None: - return data - - try: - if not data_type: - return data - if data_type in self.basic_types.values(): - return self.deserialize_basic(data, data_type) - if data_type in self.deserialize_type: - if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): - return data - - is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment - "object", - "[]", - r"{}", - ] - if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: - return None - data_val = self.deserialize_type[data_type](data) - return data_val - - iter_type = data_type[0] + data_type[-1] - if iter_type in self.deserialize_type: - return self.deserialize_type[iter_type](data, data_type[1:-1]) - - obj_type = self.dependencies[data_type] - if issubclass(obj_type, Enum): - if isinstance(data, ET.Element): - data = data.text - return self.deserialize_enum(data, obj_type) - - except (ValueError, TypeError, AttributeError) as err: - msg = "Unable to deserialize response data." - msg += " Data: {}, {}".format(data, data_type) - raise DeserializationError(msg) from err - return self._deserialize(obj_type, data) - - def deserialize_iter(self, attr, iter_type): - """Deserialize an iterable. - - :param list attr: Iterable to be deserialized. - :param str iter_type: The type of object in the iterable. - :return: Deserialized iterable. - :rtype: list - """ - if attr is None: - return None - if isinstance(attr, ET.Element): # If I receive an element here, get the children - attr = list(attr) - if not isinstance(attr, (list, set)): - raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) - return [self.deserialize_data(a, iter_type) for a in attr] - - def deserialize_dict(self, attr, dict_type): - """Deserialize a dictionary. - - :param dict/list attr: Dictionary to be deserialized. Also accepts - a list of key, value pairs. - :param str dict_type: The object type of the items in the dictionary. - :return: Deserialized dictionary. - :rtype: dict - """ - if isinstance(attr, list): - return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} - - if isinstance(attr, ET.Element): - # Transform value into {"Key": "value"} - attr = {el.tag: el.text for el in attr} - return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - - def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements - """Deserialize a generic object. - This will be handled as a dictionary. - - :param dict attr: Dictionary to be deserialized. - :return: Deserialized object. - :rtype: dict - :raises TypeError: if non-builtin datatype encountered. - """ - if attr is None: - return None - if isinstance(attr, ET.Element): - # Do no recurse on XML, just return the tree as-is - return attr - if isinstance(attr, str): - return self.deserialize_basic(attr, "str") - obj_type = type(attr) - if obj_type in self.basic_types: - return self.deserialize_basic(attr, self.basic_types[obj_type]) - if obj_type is _long_type: - return self.deserialize_long(attr) - - if obj_type == dict: - deserialized = {} - for key, value in attr.items(): - try: - deserialized[key] = self.deserialize_object(value, **kwargs) - except ValueError: - deserialized[key] = None - return deserialized - - if obj_type == list: - deserialized = [] - for obj in attr: - try: - deserialized.append(self.deserialize_object(obj, **kwargs)) - except ValueError: - pass - return deserialized - - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) - - def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements - """Deserialize basic builtin data type from string. - Will attempt to convert to str, int, float and bool. - This function will also accept '1', '0', 'true' and 'false' as - valid bool values. - - :param str attr: response string to be deserialized. - :param str data_type: deserialization data type. - :return: Deserialized basic type. - :rtype: str, int, float or bool - :raises TypeError: if string format is not valid. - """ - # If we're here, data is supposed to be a basic type. - # If it's still an XML node, take the text - if isinstance(attr, ET.Element): - attr = attr.text - if not attr: - if data_type == "str": - # None or '', node is empty string. - return "" - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None - - if data_type == "bool": - if attr in [True, False, 1, 0]: - return bool(attr) - if isinstance(attr, str): - if attr.lower() in ["true", "1"]: - return True - if attr.lower() in ["false", "0"]: - return False - raise TypeError("Invalid boolean value: {}".format(attr)) - - if data_type == "str": - return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec # pylint: disable=eval-used - - @staticmethod - def deserialize_unicode(data): - """Preserve unicode objects in Python 2, otherwise return data - as a string. - - :param str data: response string to be deserialized. - :return: Deserialized string. - :rtype: str or unicode - """ - # We might be here because we have an enum modeled as string, - # and we try to deserialize a partial dict with enum inside - if isinstance(data, Enum): - return data - - # Consider this is real string - try: - if isinstance(data, unicode): # type: ignore - return data - except NameError: - return str(data) - return str(data) - - @staticmethod - def deserialize_enum(data, enum_obj): - """Deserialize string into enum object. - - If the string is not a valid enum value it will be returned as-is - and a warning will be logged. - - :param str data: Response string to be deserialized. If this value is - None or invalid it will be returned as-is. - :param Enum enum_obj: Enum object to deserialize to. - :return: Deserialized enum object. - :rtype: Enum - """ - if isinstance(data, enum_obj) or data is None: - return data - if isinstance(data, Enum): - data = data.value - if isinstance(data, int): - # Workaround. We might consider remove it in the future. - try: - return list(enum_obj.__members__.values())[data] - except IndexError as exc: - error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) from exc - try: - return enum_obj(str(data)) - except ValueError: - for enum_value in enum_obj: - if enum_value.value.lower() == str(data).lower(): - return enum_value - # We don't fail anymore for unknown value, we deserialize as a string - _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) - return Deserializer.deserialize_unicode(data) - - @staticmethod - def deserialize_bytearray(attr): - """Deserialize string into bytearray. - - :param str attr: response string to be deserialized. - :return: Deserialized bytearray - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return bytearray(b64decode(attr)) # type: ignore - - @staticmethod - def deserialize_base64(attr): - """Deserialize base64 encoded string into string. - - :param str attr: response string to be deserialized. - :return: Deserialized base64 string - :rtype: bytearray - :raises TypeError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore - attr = attr + padding # type: ignore - encoded = attr.replace("-", "+").replace("_", "/") - return b64decode(encoded) - - @staticmethod - def deserialize_decimal(attr): - """Deserialize string into Decimal object. - - :param str attr: response string to be deserialized. - :return: Deserialized decimal - :raises DeserializationError: if string format invalid. - :rtype: decimal - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - return decimal.Decimal(str(attr)) # type: ignore - except decimal.DecimalException as err: - msg = "Invalid decimal {}".format(attr) - raise DeserializationError(msg) from err - - @staticmethod - def deserialize_long(attr): - """Deserialize string into long (Py2) or int (Py3). - - :param str attr: response string to be deserialized. - :return: Deserialized int - :rtype: long or int - :raises ValueError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - return _long_type(attr) # type: ignore - - @staticmethod - def deserialize_duration(attr): - """Deserialize ISO-8601 formatted string into TimeDelta object. - - :param str attr: response string to be deserialized. - :return: Deserialized duration - :rtype: TimeDelta - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - duration = isodate.parse_duration(attr) - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize duration object." - raise DeserializationError(msg) from err - return duration - - @staticmethod - def deserialize_date(attr): - """Deserialize ISO-8601 formatted string into Date object. - - :param str attr: response string to be deserialized. - :return: Deserialized date - :rtype: Date - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=0, defaultday=0) - - @staticmethod - def deserialize_time(attr): - """Deserialize ISO-8601 formatted string into time object. - - :param str attr: response string to be deserialized. - :return: Deserialized time - :rtype: datetime.time - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore - raise DeserializationError("Date must have only digits and -. Received: %s" % attr) - return isodate.parse_time(attr) - - @staticmethod - def deserialize_rfc(attr): - """Deserialize RFC-1123 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized RFC datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - parsed_date = email.utils.parsedate_tz(attr) # type: ignore - date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) - ) - if not date_obj.tzinfo: - date_obj = date_obj.astimezone(tz=TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to rfc datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_iso(attr): - """Deserialize ISO-8601 formatted string into Datetime object. - - :param str attr: response string to be deserialized. - :return: Deserialized ISO datetime - :rtype: Datetime - :raises DeserializationError: if string format invalid. - """ - if isinstance(attr, ET.Element): - attr = attr.text - try: - attr = attr.upper() # type: ignore - match = Deserializer.valid_date.match(attr) - if not match: - raise ValueError("Invalid datetime string: " + attr) - - check_decimal = attr.split(".") - if len(check_decimal) > 1: - decimal_str = "" - for digit in check_decimal[1]: - if digit.isdigit(): - decimal_str += digit - else: - break - if len(decimal_str) > 6: - attr = attr.replace(decimal_str, decimal_str[0:6]) - - date_obj = isodate.parse_datetime(attr) - test_utc = date_obj.utctimetuple() - if test_utc.tm_year > 9999 or test_utc.tm_year < 1: - raise OverflowError("Hit max or min date") - except (ValueError, OverflowError, AttributeError) as err: - msg = "Cannot deserialize datetime object." - raise DeserializationError(msg) from err - return date_obj - - @staticmethod - def deserialize_unix(attr): - """Serialize Datetime object into IntTime format. - This is represented as seconds. - - :param int attr: Object to be serialized. - :return: Deserialized datetime - :rtype: Datetime - :raises DeserializationError: if format invalid - """ - if isinstance(attr, ET.Element): - attr = int(attr.text) # type: ignore - try: - attr = int(attr) - date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) - except ValueError as err: - msg = "Cannot deserialize to unix datetime object." - raise DeserializationError(msg) from err - return date_obj diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_vendor.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_vendor.py deleted file mode 100644 index da92612644d..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_vendor.py +++ /dev/null @@ -1,25 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from abc import ABC -from typing import TYPE_CHECKING - -from ._configuration import QueryClientConfiguration - -if TYPE_CHECKING: - from azure.core import PipelineClient - - from ._serialization import Deserializer, Serializer - - -class QueryClientMixinABC(ABC): - """DO NOT use this class. It is for internal typing use only.""" - - _client: "PipelineClient" - _config: QueryClientConfiguration - _serialize: "Serializer" - _deserialize: "Deserializer" diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_version.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_version.py deleted file mode 100644 index be71c81bd28..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -VERSION = "1.0.0b1" diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/__init__.py deleted file mode 100644 index 6f02bd9751f..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._client import QueryClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch import * -except ImportError: - _patch_all = [] -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "QueryClient", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore - -_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_client.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_client.py deleted file mode 100644 index 6044ef167b5..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_client.py +++ /dev/null @@ -1,96 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from copy import deepcopy -from typing import Any, Awaitable -from typing_extensions import Self - -from azure.core import AsyncPipelineClient -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest - -from .._serialization import Deserializer, Serializer -from ._configuration import QueryClientConfiguration -from ._operations import QueryClientOperationsMixin - - -class QueryClient(QueryClientOperationsMixin): - """QueryClient. - - :keyword endpoint: Service host. Default value is "http://localhost:3000". - :paramtype endpoint: str - :keyword version: Default value is "2025-01-01". Note that overriding this default value may - result in unsupported behavior. - :paramtype version: str - """ - - def __init__( # pylint: disable=missing-client-constructor-parameter-credential - self, *, endpoint: str = "http://localhost:3000", **kwargs: Any - ) -> None: - _endpoint = "{endpoint}" - self._config = QueryClientConfiguration(endpoint=endpoint, **kwargs) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncPipelineClient = AsyncPipelineClient(base_url=_endpoint, policies=_policies, **kwargs) - - self._serialize = Serializer() - self._deserialize = Deserializer() - self._serialize.client_side_validation = False - - def send_request( - self, request: HttpRequest, *, stream: bool = False, **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: - """Runs the network request through the client's chained policies. - - >>> from azure.core.rest import HttpRequest - >>> request = HttpRequest("GET", "https://www.example.org/") - - >>> response = await client.send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request - - :param request: The network request you want to make. Required. - :type request: ~azure.core.rest.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to False. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.rest.AsyncHttpResponse - """ - - request_copy = deepcopy(request) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - - request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) - return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_configuration.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_configuration.py deleted file mode 100644 index 21d105721de..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_configuration.py +++ /dev/null @@ -1,47 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any - -from azure.core.pipeline import policies - -from .._version import VERSION - - -class QueryClientConfiguration: # pylint: disable=too-many-instance-attributes - """Configuration for QueryClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param endpoint: Service host. Default value is "http://localhost:3000". - :type endpoint: str - :keyword version: Default value is "2025-01-01". Note that overriding this default value may - result in unsupported behavior. - :paramtype version: str - """ - - def __init__(self, endpoint: str = "http://localhost:3000", **kwargs: Any) -> None: - version: str = kwargs.pop("version", "2025-01-01") - - self.endpoint = endpoint - self.version = version - kwargs.setdefault("sdk_moniker", "client-alternateapiversion-service-query/{}".format(VERSION)) - self.polling_interval = kwargs.get("polling_interval", 30) - self._configure(**kwargs) - - def _configure(self, **kwargs: Any) -> None: - self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) - self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) - self.authentication_policy = kwargs.get("authentication_policy") diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_operations/__init__.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_operations/__init__.py deleted file mode 100644 index 567607c23a2..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_operations/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._operations import QueryClientOperationsMixin # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "QueryClientOperationsMixin", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_operations/_operations.py deleted file mode 100644 index 9f61b264ba0..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_operations/_operations.py +++ /dev/null @@ -1,80 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async - -from ..._operations._operations import build_query_query_api_version_request -from .._vendor import QueryClientMixinABC - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class QueryClientOperationsMixin(QueryClientMixinABC): - - @distributed_trace_async - async def query_api_version(self, **kwargs: Any) -> None: - """Query api version parameter. - - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_query_query_api_version_request( - version=self._config.version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_operations/_patch.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_operations/_patch.py deleted file mode 100644 index f7dd3251033..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__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/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_patch.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_patch.py deleted file mode 100644 index f7dd3251033..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ -"""Customize generated code here. - -Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize -""" -from typing import List - -__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/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_vendor.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_vendor.py deleted file mode 100644 index 8d960bcfde1..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/aio/_vendor.py +++ /dev/null @@ -1,25 +0,0 @@ -# -------------------------------------------------------------------------- -# 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. -# -------------------------------------------------------------------------- - -from abc import ABC -from typing import TYPE_CHECKING - -from ._configuration import QueryClientConfiguration - -if TYPE_CHECKING: - from azure.core import AsyncPipelineClient - - from .._serialization import Deserializer, Serializer - - -class QueryClientMixinABC(ABC): - """DO NOT use this class. It is for internal typing use only.""" - - _client: "AsyncPipelineClient" - _config: QueryClientConfiguration - _serialize: "Serializer" - _deserialize: "Deserializer" diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/py.typed b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/py.typed deleted file mode 100644 index e5aff4f83af..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/client/alternateapiversion/service/query/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/dev_requirements.txt b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/dev_requirements.txt deleted file mode 100644 index 10548647144..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/dev_requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ --e ../../../tools/azure-sdk-tools -../../core/azure-core -aiohttp \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/conftest.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/conftest.py deleted file mode 100644 index d32ba91cfc6..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/conftest.py +++ /dev/null @@ -1,35 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import os -import pytest -from dotenv import load_dotenv -from devtools_testutils import ( - test_proxy, - add_general_regex_sanitizer, - add_body_key_sanitizer, - add_header_regex_sanitizer, -) - -load_dotenv() - - -# For security, please avoid record sensitive identity information in recordings -@pytest.fixture(scope="session", autouse=True) -def add_sanitizers(test_proxy): - query_subscription_id = os.environ.get("QUERY_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") - query_tenant_id = os.environ.get("QUERY_TENANT_ID", "00000000-0000-0000-0000-000000000000") - query_client_id = os.environ.get("QUERY_CLIENT_ID", "00000000-0000-0000-0000-000000000000") - query_client_secret = os.environ.get("QUERY_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=query_subscription_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=query_tenant_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=query_client_id, value="00000000-0000-0000-0000-000000000000") - add_general_regex_sanitizer(regex=query_client_secret, value="00000000-0000-0000-0000-000000000000") - - add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") - add_header_regex_sanitizer(key="Cookie", value="cookie;") - add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/test_query.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/test_query.py deleted file mode 100644 index c0f33e0ef31..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/test_query.py +++ /dev/null @@ -1,22 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import pytest -from devtools_testutils import recorded_by_proxy -from testpreparer import QueryClientTestBase, QueryPreparer - - -@pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestQuery(QueryClientTestBase): - @QueryPreparer() - @recorded_by_proxy - def test_query_api_version(self, query_endpoint): - client = self.create_client(endpoint=query_endpoint) - response = client.query_api_version() - - # please add some check logic here by yourself - # ... diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/test_query_async.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/test_query_async.py deleted file mode 100644 index 55a81e5ce69..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/test_query_async.py +++ /dev/null @@ -1,23 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -import pytest -from devtools_testutils.aio import recorded_by_proxy_async -from testpreparer import QueryPreparer -from testpreparer_async import QueryClientTestBaseAsync - - -@pytest.mark.skip("you may need to update the auto-generated test case before run it") -class TestQueryAsync(QueryClientTestBaseAsync): - @QueryPreparer() - @recorded_by_proxy_async - async def test_query_api_version(self, query_endpoint): - client = self.create_async_client(endpoint=query_endpoint) - response = await client.query_api_version() - - # please add some check logic here by yourself - # ... diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/testpreparer.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/testpreparer.py deleted file mode 100644 index 7e19deda400..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/testpreparer.py +++ /dev/null @@ -1,24 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from client.alternateapiversion.service.query import QueryClient -from devtools_testutils import AzureRecordedTestCase, PowerShellPreparer -import functools - - -class QueryClientTestBase(AzureRecordedTestCase): - - def create_client(self, endpoint): - credential = self.get_credential(QueryClient) - return self.create_client_from_credential( - QueryClient, - credential=credential, - endpoint=endpoint, - ) - - -QueryPreparer = functools.partial(PowerShellPreparer, "query", query_endpoint="https://fake_query_endpoint.com") diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/testpreparer_async.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/testpreparer_async.py deleted file mode 100644 index 27fa3c9e341..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/generated_tests/testpreparer_async.py +++ /dev/null @@ -1,20 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -from client.alternateapiversion.service.query.aio import QueryClient -from devtools_testutils import AzureRecordedTestCase - - -class QueryClientTestBaseAsync(AzureRecordedTestCase): - - def create_async_client(self, endpoint): - credential = self.get_credential(QueryClient, is_async=True) - return self.create_client_from_credential( - QueryClient, - credential=credential, - endpoint=endpoint, - ) diff --git a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/setup.py b/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/setup.py deleted file mode 100644 index 0851e70a2bb..00000000000 --- a/packages/typespec-python/test/azure/generated/azure-client-generator-core-api-version-query/setup.py +++ /dev/null @@ -1,72 +0,0 @@ -# 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. -# Code generated by Microsoft (R) Python Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- -# coding: utf-8 - -import os -import re -from setuptools import setup, find_packages - - -PACKAGE_NAME = "client-alternateapiversion-service-query" -PACKAGE_PPRINT_NAME = "Client Alternateapiversion Service Query" - -# a-b-c => a/b/c -package_folder_path = PACKAGE_NAME.replace("-", "/") - -# Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, "_version.py"), "r") as fd: - version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) - -if not version: - raise RuntimeError("Cannot find version information") - - -setup( - name=PACKAGE_NAME, - version=version, - description="Microsoft {} Client Library for Python".format(PACKAGE_PPRINT_NAME), - long_description=open("README.md", "r").read(), - long_description_content_type="text/markdown", - license="MIT License", - author="Microsoft Corporation", - author_email="azpysdkhelp@microsoft.com", - url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk", - keywords="azure, azure sdk", - classifiers=[ - "Development Status :: 4 - Beta", - "Programming Language :: Python", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "License :: OSI Approved :: MIT License", - ], - zip_safe=False, - packages=find_packages( - exclude=[ - "tests", - # Exclude packages that will be covered by PEP420 or nspkg - "client", - "client.alternateapiversion", - "client.alternateapiversion.service", - ] - ), - include_package_data=True, - package_data={ - "client.alternateapiversion.service.query": ["py.typed"], - }, - install_requires=[ - "isodate>=0.6.1", - "azure-core>=1.30.0", - "typing-extensions>=4.6.0", - ], - python_requires=">=3.8", -) From da7ec9cac0dbf98ecee22c4af7f4e1f66314ff1f Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Fri, 14 Feb 2025 14:53:55 +0800 Subject: [PATCH 14/14] update version --- packages/autorest.python/package.json | 4 ++-- packages/typespec-python/package.json | 4 ++-- pnpm-lock.yaml | 15 +++++++-------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/packages/autorest.python/package.json b/packages/autorest.python/package.json index 7c1afb60bd9..847f59fe2f5 100644 --- a/packages/autorest.python/package.json +++ b/packages/autorest.python/package.json @@ -29,7 +29,7 @@ }, "homepage": "https://github.com/Azure/autorest.python/blob/main/README.md", "dependencies": { - "@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU2MDY0NC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz", + "@typespec/http-client-python": "~0.6.11", "@autorest/system-requirements": "~1.0.2", "fs-extra": "~11.2.0", "tsx": "~4.19.1" @@ -47,4 +47,4 @@ "requirements.txt", "generator/" ] -} \ No newline at end of file +} diff --git a/packages/typespec-python/package.json b/packages/typespec-python/package.json index 14e9262c2a2..40a1a3eb551 100644 --- a/packages/typespec-python/package.json +++ b/packages/typespec-python/package.json @@ -60,7 +60,7 @@ "js-yaml": "~4.1.0", "semver": "~7.6.2", "tsx": "~4.19.1", - "@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU2MDY0NC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz", + "@typespec/http-client-python": "~0.6.11", "fs-extra": "~11.2.0" }, "devDependencies": { @@ -89,4 +89,4 @@ "chalk": "5.3.0", "@types/fs-extra": "11.0.4" } -} \ No newline at end of file +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index faf15c567a6..98ae714ddc0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -57,8 +57,8 @@ importers: specifier: ~1.0.2 version: 1.0.2 '@typespec/http-client-python': - specifier: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU2MDY0NC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz - version: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU2MDY0NC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz(5dspuyrtxidbihsk6ixub7kbfm) + specifier: ~0.6.11 + version: 0.6.11(5dspuyrtxidbihsk6ixub7kbfm) fs-extra: specifier: ~11.2.0 version: 11.2.0 @@ -79,8 +79,8 @@ importers: packages/typespec-python: dependencies: '@typespec/http-client-python': - specifier: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU2MDY0NC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz - version: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU2MDY0NC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz(5dspuyrtxidbihsk6ixub7kbfm) + specifier: ~0.6.11 + version: 0.6.11(5dspuyrtxidbihsk6ixub7kbfm) fs-extra: specifier: ~11.2.0 version: 11.2.0 @@ -1500,9 +1500,8 @@ packages: engines: {node: '>=18.0.0'} hasBin: true - '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU2MDY0NC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz': - resolution: {tarball: https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU2MDY0NC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz} - version: 0.6.11 + '@typespec/http-client-python@0.6.11': + resolution: {integrity: sha512-3FRsfZgaWTF7xVTtLPRyeTz1Qoh+PPbVhn1V/SMQBqMzpli0r53UpNBbEMkSLWubWb0iXAtjP47ZPw/RcTtzlw==} engines: {node: '>=18.0.0'} peerDependencies: '@azure-tools/typespec-autorest': '>=0.51.0 <1.0.0' @@ -6003,7 +6002,7 @@ snapshots: - bluebird - supports-color - '@typespec/http-client-python@https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNDU2MDY0NC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.6.11.tgz(5dspuyrtxidbihsk6ixub7kbfm)': + '@typespec/http-client-python@0.6.11(5dspuyrtxidbihsk6ixub7kbfm)': dependencies: '@azure-tools/typespec-autorest': 0.51.0(jam7mnjbyunevglidmcn4r37mu) '@azure-tools/typespec-azure-core': 0.51.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0))(@typespec/rest@0.65.0(@typespec/compiler@0.65.0)(@typespec/http@0.65.0(@typespec/compiler@0.65.0)))