Describe the bug
Ever since upgrading to Pycharm 2024.3, fields declared with an Annotated
style do not have their default_factory
argument recognized. Calling the model's constructor will report an error if I don't provide a value to the field, although it has a default factory.
To Reproduce
Steps to reproduce the behavior:
Annotated
style.Expected behavior
No error or warnings should be shown. Although we didn't pass a value to our field, it has a default factory so it's fine.
Environments (please complete the following information):
Additional context
Pycharm 2024.3 added support for dataclass_transform
classes (like pydantic.BaseModel) which seems to have caused a false-positive for models which declare fields with a default factory using Annotated
style.
I couldn't find anything in the spec mentioning the use of Annotated
, so it seems appropriate from Pycharm's side of things, to not recognize default_factory
in this way.
However, something about their way of implementing may have overridden this plugin's previous behavior.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too