python icon indicating copy to clipboard operation
python copied to clipboard

Incorrect type declaration in `openapi_types` for `dict`

Open vit-zikmund opened this issue 2 months ago • 2 comments

What happened (please include outputs or screenshots): I created a Pydantic converter/adapter for the generated client models and used the openapi_types dict to infer the fields types (I wanted to include some of the fields in my Pydantic-based configuration). That works pretty well - one can use that type string directly for the Pydantic fields, with one exception - where the type is a literal dict of something (and not a forward reference to an existing model), because the dict type is declared as dict(str, str) (see this example).

What you expected to happen: I believe this type declaration should follow the current python typing syntax, which is dict[str, str] (with square brackets). Interestingly enough, the list in the example already uses square brackets. This alone leaves me with the assumption this inconsistency is a bug.

I've just written a simple wrapper to convert the parentheses to square brackets, but I'm thinking this might as well get fixed downstream. I've also looked through how the code is generated, but I couldn't find it.

How to reproduce it (as minimally and precisely as possible): n/a

Anything else we need to know?: You're great! 🙂

Environment:

  • Kubernetes version (kubectl version): 1.34
  • OS (e.g., MacOS 10.13.6): Fedora Linux 41
  • Python version (python --version): 3.13
  • Python client version (pip list | grep kubernetes): 34.1.0

vit-zikmund avatar Oct 23 '25 12:10 vit-zikmund

/assign @mohsinm-dev

roycaihw avatar Nov 20 '25 21:11 roycaihw

@roycaihw: GitHub didn't allow me to assign the following users: mohsinm-dev.

Note that only kubernetes-client members with read permissions, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time. For more information please see the contributor guide

In response to this:

/assign @mohsinm-dev

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

k8s-ci-robot avatar Nov 20 '25 21:11 k8s-ci-robot