OpenAPITools / OpenAPITools/openapi-generator

[BUG] Python - IDE Debug/Type Checking fails on configuration generated code - Typing issue

Open
#20,844 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

In the Python (after version 7.10), a type-checking issue occurs when running in debug mode in an IDE. The type check on configuration generation fails due to typing.Self being used incorrectly.

Error Trace:

../../../.pixi/envs/default/lib/python3.10/site-packages/dedak_meser/configuration.py:133: in <module>
    class Configuration:
../../../.pixi/envs/default/lib/python3.10/site-packages/dedak_meser/configuration.py:166: in Configuration
    _default: ClassVar[Optional[Self]] = None
../../../.pixi/envs/default/lib/python3.10/typing.py:309: in inner
    return func(*args, **kwds)
../../../.pixi/envs/default/lib/python3.10/typing.py:400: in __getitem__
    return self._getitem(self, parameters)
../../../.pixi/envs/default/lib/python3.10/typing.py:525: in Optional
    arg = _type_check(parameters, f"{self} requires a single type.")
../../../.pixi/envs/default/lib/python3.10/typing.py:169: in _type_check
    raise TypeError(f"Plain {arg} is not valid as type argument")
E   TypeError: Plain typing.Self is not valid as type argument
openapi-generator version

7.10.0

Generation Details
`openapi-generator-cli generate -g python -i openapi.json -o .generated/openapi -p packageVersion=$VERSION -p packageName=$PIXI_PROJECT_NAME`
Steps to reproduce
  1. Use openapi genertor cli to generate
  2. Use IDE (Pycharm 2024-2025) Debug mode with the generated package in code base imported
Related issues/PRs

In 7.10 they did this:
https://github.com/OpenAPITools/openapi-generator/pull/20014

Transition to backward-compatible typing for Python 3.10+.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the shown openapi-generator-cli command and the generated Python package in an IDE using Python 3.10. Read the Python generator changes from related PR #20014 and trace the generated configuration.py typing; done means the generated package imports and debug/type checking no longer raises the reported TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, python
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.