diff --git a/.chronus/changes/python-fix-ci-2026-3-10-2-43-42.md b/.chronus/changes/python-fix-ci-2026-3-10-2-43-42.md new file mode 100644 index 0000000000..705c928a19 --- /dev/null +++ b/.chronus/changes/python-fix-ci-2026-3-10-2-43-42.md @@ -0,0 +1,8 @@ +--- +changeKind: internal +packages: + - "@autorest/python" + - "@azure-tools/typespec-python" +--- + +fix ci to add lint check for generated sdk code \ No newline at end of file diff --git a/packages/typespec-python/eng/scripts/regenerate-common.ts b/packages/typespec-python/eng/scripts/regenerate-common.ts index d040b2add3..6f8c0e090f 100644 --- a/packages/typespec-python/eng/scripts/regenerate-common.ts +++ b/packages/typespec-python/eng/scripts/regenerate-common.ts @@ -3,7 +3,7 @@ import { dirname, join, relative, resolve } from "path"; // ---- Shared constants ---- -export const SKIP_SPECS: string[] = ["type/file"]; +export const SKIP_SPECS: string[] = ["type/file", "service/multiple-services"]; export const SpecialFlags: Record> = { azure: { @@ -212,6 +212,7 @@ export const BASE_EMITTER_OPTIONS: Record | Recor "package-name": "generation-subdir", "namespace": "generation.subdir", "generation-subdir": "_generated", + "generate-test": "false", "clear-output-folder": "true", }, ], @@ -280,6 +281,7 @@ export const BASE_EMITTER_OPTIONS: Record | Recor { "package-name": "generation-subdir2", "namespace": "generation.subdir2", + "generate-test": "false", "generation-subdir": "_generated", }, ], @@ -307,11 +309,6 @@ export interface RegenerateFlags { pyodide?: boolean; } -export interface ProcessedEmitterOption { - options: Record; - outputDir: string; -} - export interface RegenerateConfig { azureHttpSpecs: string; httpSpecs: string; @@ -385,48 +382,6 @@ export async function getSubdirectories(baseDir: string, flags: RegenerateFlags) return subdirectories; } -export function defaultPackageName(spec: string, config: RegenerateConfig): string { - const specDir = spec.includes("azure") ? config.azureHttpSpecs : config.httpSpecs; - return toPosix(relative(specDir, dirname(spec))) - .replace(/\//g, "-") - .toLowerCase(); -} - -export function buildOptions( - spec: string, - generatedFolder: string, - flags: RegenerateFlags, - config: RegenerateConfig, -): ProcessedEmitterOption[] { - const results: ProcessedEmitterOption[] = []; - for (const emitterConfig of getEmitterOption(spec, flags.flavor, config)) { - const options: Record = { ...emitterConfig }; - if (flags.pyodide) { - options["use-pyodide"] = "true"; - } - options["flavor"] = flags.flavor; - for (const [k, v] of Object.entries(SpecialFlags[flags.flavor] ?? {})) { - options[k] = v; - } - if (options["emitter-output-dir"] === undefined) { - const packageName = options["package-name"] || defaultPackageName(spec, config); - // Output to new tests/generated// structure - options["emitter-output-dir"] = toPosix( - `${generatedFolder}/../tests/generated/${flags.flavor}/${packageName}`, - ); - } - if (flags.debug) { - options["debug"] = "true"; - } - options["examples-dir"] = toPosix(join(dirname(spec), "examples")); - results.push({ - options, - outputDir: options["emitter-output-dir"], - }); - } - return results; -} - export async function runTaskPool(tasks: Array<() => Promise>, poolLimit: number): Promise { const executing: Set> = new Set(); diff --git a/packages/typespec-python/tests/mock_api/azure/test_clear_output_folder.py b/packages/typespec-python/tests/mock_api/azure/test_clear_output_folder.py index 00125fde0d..9ae9307c19 100644 --- a/packages/typespec-python/tests/mock_api/azure/test_clear_output_folder.py +++ b/packages/typespec-python/tests/mock_api/azure/test_clear_output_folder.py @@ -14,7 +14,6 @@ def test_clear_output_folder(): assert not (folder / "to_be_deleted.py").exists(), "File to_be_deleted.py should be deleted after regeneration" if (GENERATED_PATH / "generation-subdir").exists(): - assert (GENERATED_PATH / "generation-subdir/generated_tests").exists() assert not (GENERATED_PATH / "generation-subdir/generated_tests/to_be_deleted.py").exists() assert (GENERATED_PATH / "generation-subdir/generation/subdir/_generated").exists() diff --git a/packages/typespec-python/tests/mock_api/shared/asynctests/test_generation_subdir2_for_customized_code_async.py b/packages/typespec-python/tests/mock_api/shared/asynctests/test_generation_subdir2_for_customized_code_async.py index 990ff6fd45..bbc02dba59 100644 --- a/packages/typespec-python/tests/mock_api/shared/asynctests/test_generation_subdir2_for_customized_code_async.py +++ b/packages/typespec-python/tests/mock_api/shared/asynctests/test_generation_subdir2_for_customized_code_async.py @@ -34,4 +34,4 @@ async def test_v2(client: AddedClient): async def test_interface_v2(client: AddedClient): assert await client.interface_v2.v2_in_interface( ModelV2(prop="foo", enum_prop=EnumV2.ENUM_MEMBER, union_prop="bar") - ) == ModelV2(prop="foo", enum_prop=EnumV2.ENUM_MEMBER, union_prop="bar") \ No newline at end of file + ) == ModelV2(prop="foo", enum_prop=EnumV2.ENUM_MEMBER, union_prop="bar") diff --git a/packages/typespec-python/tests/mock_api/shared/test_generation_subdir2_for_customized_code.py b/packages/typespec-python/tests/mock_api/shared/test_generation_subdir2_for_customized_code.py index 5569867dde..9a90f290d3 100644 --- a/packages/typespec-python/tests/mock_api/shared/test_generation_subdir2_for_customized_code.py +++ b/packages/typespec-python/tests/mock_api/shared/test_generation_subdir2_for_customized_code.py @@ -4,7 +4,7 @@ # license information. # -------------------------------------------------------------------------- import pytest -from generation.subdir2 import AddedClient, ModelV1, ModelV2, EnumV1, EnumV2 +from generation.subdir2 import AddedClient, ModelV1, ModelV2, EnumV1, EnumV2 @pytest.fixture @@ -29,4 +29,4 @@ def test_v2(client: AddedClient): def test_interface_v2(client: AddedClient): assert client.interface_v2.v2_in_interface( ModelV2(prop="foo", enum_prop=EnumV2.ENUM_MEMBER, union_prop="bar") - ) == ModelV2(prop="foo", enum_prop=EnumV2.ENUM_MEMBER, union_prop="bar") \ No newline at end of file + ) == ModelV2(prop="foo", enum_prop=EnumV2.ENUM_MEMBER, union_prop="bar") diff --git a/packages/typespec-python/tests/requirements/azure.txt b/packages/typespec-python/tests/requirements/azure.txt index 7dd647dfe0..ca59fac7d9 100644 --- a/packages/typespec-python/tests/requirements/azure.txt +++ b/packages/typespec-python/tests/requirements/azure.txt @@ -1,5 +1,5 @@ # Azure SDK dependencies -r base.txt -azure-core>=1.30.0 -azure-mgmt-core>=1.6.0 +azure-core>=1.37.0 +azure-mgmt-core==1.6.0 geojson>=3.0.0