-
Notifications
You must be signed in to change notification settings - Fork 395
Allow suppressing Python no-client warnings #11823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e58dbf5
Fix Python no-client warning suppression
msyyc e44febc
Address no-client warning review feedback
msyyc 7fab879
refactor(emitter): inline no-client diagnostic target
eaa15e8
fix(emitter): remove unused program import
4fed492
fix(emitter): address diagnostic review feedback
f6cedca
Potential fix for pull request finding
iscai-msft e8db650
test(emitter): cover model-only generation
09c7c72
fix(python): test model-only generation
f49c7fc
test(python): assert code model instead of running generator
80e05f0
fix(python): target first SDK model for no-sdk-clients diagnostic
516407f
chore(python): format emitter changes
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
.chronus/changes/fix-python-no-sdk-clients-suppression-2026-09-02.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| changeKind: fix | ||
| packages: | ||
| - "@typespec/http-client-python" | ||
| --- | ||
|
|
||
| Allow `no-sdk-clients` warnings to be suppressed by reporting them on the TypeSpec service namespace. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import { expectDiagnostics, t } from "@typespec/compiler/testing"; | ||
| import { mkdtemp, readFile, rm } from "fs/promises"; | ||
| import { tmpdir } from "os"; | ||
| import { join } from "path"; | ||
| import { expect, it } from "vitest"; | ||
| import { EmitterTester } from "./test-host.js"; | ||
|
|
||
| it("targets the service namespace when no SDK clients are found", async () => { | ||
| const [, diagnostics] = await EmitterTester.compileAndDiagnose( | ||
| t.code` | ||
| #suppress "@typespec/http-client-python/no-sdk-clients" "This service intentionally has no client." | ||
| @service namespace ${t.namespace("Service")} {} | ||
| `, | ||
| { | ||
| compilerOptions: { | ||
| options: { | ||
| "@typespec/http-client-python": { | ||
| "emit-yaml-only": true, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| ); | ||
|
|
||
| expectDiagnostics(diagnostics, []); | ||
| }); | ||
|
|
||
| it("generates models when no service exists", async () => { | ||
| const outputDir = await mkdtemp(join(tmpdir(), "typespec-python-models-")); | ||
| try { | ||
|
iscai-msft marked this conversation as resolved.
Outdated
|
||
| const [, diagnostics] = await EmitterTester.compileAndDiagnose( | ||
|
iscai-msft marked this conversation as resolved.
Outdated
|
||
| ` | ||
| import "@azure-tools/typespec-client-generator-core"; | ||
| using Azure.ClientGenerator.Core; | ||
|
|
||
| #suppress "@typespec/http-client-python/no-sdk-clients" "This model-only package intentionally has no client." | ||
| @access(Access.public) | ||
| @usage(Usage.input | Usage.output) | ||
| @clientNamespace("Models") | ||
| model Widget {} | ||
| `, | ||
| { | ||
| compilerOptions: { | ||
|
iscai-msft marked this conversation as resolved.
Outdated
|
||
| options: { | ||
| "@typespec/http-client-python": { | ||
| "emitter-output-dir": outputDir, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| ); | ||
|
|
||
| expectDiagnostics(diagnostics, []); | ||
| const model = await readFile( | ||
| join(outputDir, "models", "models", "_models.py"), | ||
| "utf-8", | ||
| ); | ||
| expect(model).toContain("class Widget"); | ||
| } finally { | ||
| await rm(outputDir, { recursive: true, force: true }); | ||
| } | ||
| }, 30_000); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { resolvePath } from "@typespec/compiler"; | ||
| import { createTester, mockFile } from "@typespec/compiler/testing"; | ||
| import { $onEmit } from "../src/emitter.js"; | ||
|
|
||
| const PythonTester = createTester(resolvePath(import.meta.dirname, "../.."), { | ||
| libraries: ["@azure-tools/typespec-client-generator-core"], | ||
| }); | ||
|
|
||
| export const Tester = PythonTester; | ||
| export const EmitterTester = PythonTester.files({ | ||
| "node_modules/@typespec/http-client-python/package.json": JSON.stringify({ | ||
|
iscai-msft marked this conversation as resolved.
|
||
| name: "@typespec/http-client-python", | ||
| version: "0.0.0", | ||
| exports: { ".": "./index.js" }, | ||
| }), | ||
| "node_modules/@typespec/http-client-python/index.js": mockFile.js({ | ||
| $onEmit, | ||
| }), | ||
| }).emit("@typespec/http-client-python", { | ||
| "generate-packaging-files": false, | ||
| "use-pyodide": true, | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.