-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Incorrect stub generation for subclasses of pydantic.BaseModel
#16968
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
Comments
Seeing the exact same behavior on a different environment: Mypy version used:
Python version used: |
Also seeing this in my environment. I see it happening regardless if I define the class using either of these two class A(BaseModel):
foo: Optional[str] = "bar"
class B(BaseModel):
foo: Optional[str] = Field(default="bar") Version information:
Stubs are created using
and my
|
I don't think it is related to # .py
class A:
foo: str = "bar" ... which generates these stubs: # .pyi
class A:
foo: str mypy 1.10.0 (compiled: yes) |
Hi @jborman-stonex! Could you please share an idea on how you resolved this issue in your project? |
My solution was manually adding the elipses |
Bug Report
stubgen
does not properly generate ellipses for default values set in the scope of the class body of a Pydantic model.To Reproduce
Running
stubgen -m example
Should produce
Expected Behavior
stubgen
should be populating the default annotation with ellipses, instead they are missing.Actual Behavior
Your Environment
mypy 1.8.0 (compiled: yes)
stubgen -m example
mypy.ini
(and other config files):N/A
3.11.8
The text was updated successfully, but these errors were encountered: