Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .chronus/changes/python-fix-ci-2026-3-10-2-43-42.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
changeKind: internal
packages:
- "@autorest/python"
- "@azure-tools/typespec-python"
---

fix ci to add lint check for generated sdk code
51 changes: 3 additions & 48 deletions packages/typespec-python/eng/scripts/regenerate-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, Record<string, any>> = {
azure: {
Expand Down Expand Up @@ -212,6 +212,7 @@ export const BASE_EMITTER_OPTIONS: Record<string, Record<string, string> | Recor
"package-name": "generation-subdir",
"namespace": "generation.subdir",
"generation-subdir": "_generated",
"generate-test": "false",
"clear-output-folder": "true",
},
],
Expand Down Expand Up @@ -280,6 +281,7 @@ export const BASE_EMITTER_OPTIONS: Record<string, Record<string, string> | Recor
{
"package-name": "generation-subdir2",
"namespace": "generation.subdir2",
"generate-test": "false",
"generation-subdir": "_generated",
},
],
Expand Down Expand Up @@ -307,11 +309,6 @@ export interface RegenerateFlags {
pyodide?: boolean;
}

export interface ProcessedEmitterOption {
options: Record<string, string>;
outputDir: string;
}

export interface RegenerateConfig {
azureHttpSpecs: string;
httpSpecs: string;
Expand Down Expand Up @@ -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<string, string> = { ...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/<flavor>/<package> 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<void>>, poolLimit: number): Promise<void> {
const executing: Set<Promise<void>> = new Set();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
) == ModelV2(prop="foo", enum_prop=EnumV2.ENUM_MEMBER, union_prop="bar")
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
) == ModelV2(prop="foo", enum_prop=EnumV2.ENUM_MEMBER, union_prop="bar")
4 changes: 2 additions & 2 deletions packages/typespec-python/tests/requirements/azure.txt
Original file line number Diff line number Diff line change
@@ -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
Loading