-
-
Notifications
You must be signed in to change notification settings - Fork 22
Description
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:
- Install Pycharm 2024.3+
- Create a model with a field declared with the
Annotatedstyle. - Add a default factory to the field
- Create an instance of the model without any arguments
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):
- IDE: Pycharm Professional - 2024.3
- OS: Windows 11
- Pydantic Version: 2.9.2
- Plugin Version: 0.4.6
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.
