Skip to content

False positive - "Parameter unfilled" since Pycharm 2024.3 #1020

@UltimateLobster

Description

@UltimateLobster

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:

  1. Install Pycharm 2024.3+
  2. Create a model with a field declared with the Annotated style.
  3. Add a default factory to the field
  4. 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
image

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions