You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 Annotated style.
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.
Screenshots
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.
The text was updated successfully, but these errors were encountered:
Describe the bug
Ever since upgrading to Pycharm 2024.3, fields declared with an
Annotated
style do not have theirdefault_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.
Screenshots
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 usingAnnotated
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 recognizedefault_factory
in this way.However, something about their way of implementing may have overridden this plugin's previous behavior.
The text was updated successfully, but these errors were encountered: