Skip to content

Generate typed Python DELETE results - #313

Open
tamird wants to merge 1 commit into
kubernetes-client:masterfrom
tamird:python-typed-delete-results
Open

tamird wants to merge 1 commit into
kubernetes-client:masterfrom
tamird:python-typed-delete-results

Conversation

@tamird

@tamird tamird commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

A successful Pod DELETE can return kind: Status. The generated Python client currently tries to deserialize that body as a Pod and raises a validation error. ConfigMap DELETE has the opposite problem: callers get a dictionary regardless of which object the server returns. Python issue #2752 shows what this looks like to a caller.

Generate a resource-or-V1Status union for individual built-in DELETEs in the synchronous and asyncio Python clients. Swagger 2 names only one response model, but Kubernetes identifies the target resource by group, version, and kind. At runtime the generated client selects one of the allowed models using the JSON body's apiVersion and kind. Collection deletes and generic custom-object methods keep their existing behavior.

For methods that returned dictionaries after #309, callers must switch to model attributes. #312 tracks replacing the Swagger 2 inference with explicit response alternatives when the generator consumes Kubernetes’ v3 schemas. The Python return types can stay the same.

Prepared with Codex assistance.

Kubernetes can return the resource or Status for the same successful
DELETE. Swagger 2 named only one model, so the Python clients returned
dictionaries on some methods and tried to decode Status as the resource
on others [1].

Match the operation to its resource definition by group, version, and
kind. Generate the resource-or-Status union on individual DELETE
methods and select the model from the returned JSON. Callers that
previously received dictionaries must use model attributes instead.

[1]: kubernetes-client/python#2752
@kubernetes-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: tamird
Once this PR has been reviewed and has the lgtm label, please assign yliaog for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow kubernetes-prow Bot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 28, 2026
@tamird

tamird commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

@yliaog, #309 preserved both response shapes by returning dictionaries. Does inferring the two models from the Swagger 2 operation look reasonable until we can read them from v3? The Python client PR shows what would change for callers in the next major release.

— with Codex assistance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant