Skip to content

Conversation

@artem-ilin
Copy link
Contributor

@artem-ilin artem-ilin commented Sep 9, 2025

Fixes #21936

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR solves a reported issue, reference it using GitHub's linking syntax (e.g., having "fixes #123" present in the PR description)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Steps to verify:

git clone [email protected]:artem-ilin/openapi-generator.git
git checkout fix-python-type-checks
cd openapi-generator/samples/client/echo_api/python
docker run -v .:/io --rm ghcr.io/astral-sh/ruff check --fix

output:

Found 55 errors (55 fixed, 0 remaining).

output before fix (from master branch):

warning: Invalid rule code provided to `# noqa` at setup.py:16: H301
E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
   --> openapi_client/api_client.py:459:14
    |
457 |         if klass in self.PRIMITIVE_TYPES:
458 |             return self.__deserialize_primitive(data, klass)
459 |         elif klass == object:
    |              ^^^^^^^^^^^^^^^
460 |             return self.__deserialize_object(data)
461 |         elif klass == datetime.date:
    |

Found 56 errors (55 fixed, 1 remaining).

@artem-ilin artem-ilin force-pushed the fix-python-type-checks branch from c0e4d9d to ab15981 Compare September 9, 2025 18:57
@artem-ilin artem-ilin force-pushed the fix-python-type-checks branch from ab15981 to 2dcb9c5 Compare September 9, 2025 20:01
@artem-ilin artem-ilin marked this pull request as ready for review September 9, 2025 20:20
@artem-ilin artem-ilin changed the title [python] fix api client type checks [python] fix #21936 api client type checks Sep 9, 2025
@artem-ilin
Copy link
Contributor Author

artem-ilin commented Sep 9, 2025

Python committee @cbornet @tomplus @krjakbrjak @fa0311 @multani @wing328 please take a look.
The same issue actually persists in python-pydantic-v1 generator, but I decided not to touch it in this PR.

@wing328
Copy link
Member

wing328 commented Sep 10, 2025

thanks for the PR. please review the test failure when you've time.

@artem-ilin artem-ilin force-pushed the fix-python-type-checks branch from 4899523 to 0e0262d Compare September 10, 2025 09:02
@artem-ilin artem-ilin force-pushed the fix-python-type-checks branch from 0e0262d to 11bd615 Compare September 10, 2025 09:03
@artem-ilin
Copy link
Contributor Author

@wing328 thank you! I updated the PR, please review.

@wing328
Copy link
Member

wing328 commented Sep 10, 2025

all tests passed

if no one has further feedback, i'll merge it this weekend.

thanks for the contribution

Copy link
Contributor

@multani multani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@wing328 wing328 added this to the 7.16.0 milestone Sep 10, 2025
@wing328 wing328 merged commit 5f647b8 into OpenAPITools:master Sep 10, 2025
36 checks passed
@artem-ilin artem-ilin deleted the fix-python-type-checks branch September 11, 2025 07:51
Goopher pushed a commit to Goopher/openapi-generator that referenced this pull request Sep 16, 2025
@wing328 wing328 changed the title [python] fix #21936 api client type checks [python] api client type checks Sep 28, 2025
rajvesh pushed a commit to rajvesh/openapi-generator that referenced this pull request Dec 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Python client doesn't pass style checks

3 participants