Open
Description
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
# example.py
from pydantic import BaseModel
class Foo(BaseModel):
abc: int = 1
xyz: str = "abc"
Should produce
Expected Behavior
# example.pyi
from pydantic import BaseModel
class Foo(BaseModel):
abc: int = ...
xyz: str = ...
stubgen
should be populating the default annotation with ellipses, instead they are missing.
Actual Behavior
# example.pyi
from pydantic import BaseModel
class Foo(BaseModel):
abc: int
xyz: str
Your Environment
- Mypy version used:
mypy 1.8.0 (compiled: yes)
- Mypy command-line flags:
stubgen -m example
- Mypy configuration options from
mypy.ini
(and other config files):N/A
- Python version used:
3.11.8
Activity
BrunoRomes commentedon Mar 19, 2024
Seeing the exact same behavior on a different environment:
Mypy version used:
mypy 1.9.0 (compiled: yes)
Mypy command-line flags:
stubgen -m example
Mypy configuration options from mypy.ini (and other config files):
Python version used:
3.10.13
ggeorge-pros commentedon May 18, 2024
Also seeing this in my environment. I see it happening regardless if I define the class using either of these two
Version information:
Stubs are created using
and my
pyproject.toml
has the following:adxl commentedon Jun 5, 2024
I don't think it is related to
pydantic
because it also happens for basic classes like:... which generates these stubs:
mypy 1.10.0 (compiled: yes)
Python 3.12.2
teplandr commentedon May 12, 2025
Hi @jborman-stonex! Could you please share an idea on how you resolved this issue in your project?
jborman-stonex commentedon May 12, 2025
My solution was manually adding the elipses
stubgen
#19095