Skip to content

python: Reinstate lazy imports #21486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

bachorp
Copy link
Contributor

@bachorp bachorp commented Jun 29, 2025

Addresses #19635, #18144
Depends on #21352
Critical commit: 94e39d6

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 is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@cbornet @tomplus @krjakbrjak @fa0311 @multani

@wing328
Copy link
Member

wing328 commented Jun 29, 2025

thanks for the pr

let me know if you need help updating the samples https://github.com/OpenAPITools/openapi-generator/actions/runs/15953926978/job/44997747683?pr=21486

@bachorp
Copy link
Contributor Author

bachorp commented Jul 2, 2025

@wing328 Done.

@wing328 wing328 marked this pull request as ready for review July 3, 2025 15:00
@wing328
Copy link
Member

wing328 commented Jul 3, 2025

thanks. will review and try to get it merged this weekend.

is it correct to say you've used this fix in your production environment and it's working as expected?

@bachorp
Copy link
Contributor Author

bachorp commented Jul 3, 2025

No. I have tested this of course but I'm currently not using openapi-generator in a production setting. I originally wanted this feature to generate usable bindings for the Kubernetes API (the official python client, which is based on a very old version of openapi-generator, is rather poorly maintained) but by now more comprehensive libraries exist. So I don't know whether I will actually need this feature for myself. I have the patch ready nonetheless.

@bachorp
Copy link
Contributor Author

bachorp commented Jul 3, 2025

Maybe some of the other users who reported problems with long import times want to have a look.
@fingon @lawrence-witt @fopinappb

@fopina
Copy link

fopina commented Jul 3, 2025

In my case, I experimented very hacky lazy imports but turned into hell dealing with LazyObject so I went with fopina/defectdojo-api-generated#21

Validate_call being the heaviest thing done during import time, I just removed all of them and living happily ever since!

@wing328
Copy link
Member

wing328 commented Jul 6, 2025

@bachorp thanks for sharing more with us

in this case, i'll let the Python Technical Committee decides whether to accept this enhancement or not.

@cbornet @tomplus @krjakbrjak @fa0311 @multani

@multani
Copy link
Contributor

multani commented Jul 6, 2025

I'm happy to take a look, but can we clean up the change first? It touches it seems all the generators, although only the Python generator is (should be) changed.

@wing328
Copy link
Member

wing328 commented Jul 6, 2025

Agreed with @multani

@bachorp Can you please update this one or file a new one with just the changes related to the Python client generator?

@bachorp
Copy link
Contributor Author

bachorp commented Jul 6, 2025

This patch in it's current form is based and dependent on #21352, so I would like to discuss that one first. @wing328 you can find me on Slack.

(I thought I had filed this one as a draft, but apparently not, sorry!)

@bachorp bachorp marked this pull request as draft July 6, 2025 11:19
@wing328
Copy link
Member

wing328 commented Jul 7, 2025

update: #21352 has been merged. thank you for your contribution.

@bachorp
Copy link
Contributor Author

bachorp commented Jul 7, 2025

This PR now has a clean base.

@bachorp bachorp marked this pull request as ready for review July 7, 2025 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants