Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
UltimateLobster opened this issue Nov 20, 2024 · 0 comments
Open

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

UltimateLobster opened this issue Nov 20, 2024 · 0 comments

Comments

@UltimateLobster
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant