Skip to content

Incorrect type declaration in openapi_types for dict #2463

@vit-zikmund

Description

@vit-zikmund

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions