Skip to content

Add support for Pydantic models in stubgen #19095

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 7 commits into
base: master
Choose a base branch
from

Conversation

teplandr
Copy link

@teplandr teplandr commented May 16, 2025

This PR adds support for generating stubs for Pydantic models in stubgen.

Changes

  • Added detection of classes that inherit from pydantic.BaseModel directly or indirectly
  • Enhanced the stub generation process to add appropriate initializers (= ...) to field annotations in Pydantic models
  • Added comprehensive test cases for different Pydantic model scenarios

Fixes #16968

@teplandr teplandr changed the title Add support for Pydantic models in ASTStubGenerator Add support for Pydantic models in stubgen May 20, 2025
@teplandr teplandr marked this pull request as ready for review May 20, 2025 11:03
@teplandr
Copy link
Author

Hello @JelleZijlstra! Hope you're doing well 🙂
I saw that you recently reviewed PR with stubgen improvements. Could you please take a look at proposed changes?
Thanks in advance!

@teplandr
Copy link
Author

Hello @hauntsaninja! Hope you're doing well!
Could you please review the proposed changes, or suggest someone who can?

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.

Incorrect stub generation for subclasses of pydantic.BaseModel
1 participant