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

Pycharm IDE don't see class field with populate_by_name = True #937

Open
MikkoArtik opened this issue May 8, 2024 · 2 comments
Open

Pycharm IDE don't see class field with populate_by_name = True #937

MikkoArtik opened this issue May 8, 2024 · 2 comments

Comments

@MikkoArtik
Copy link

Describe the bug
Can't use pydantic class fields in code only aliases

To Reproduce

from pydantic import BaseModel, Field, ConfigDict
from typing import Tuple


class CustomBaseModel(BaseModel):

    model_config = ConfigDict(
        populate_by_name=True,
        arbitrary_types_allowed=True
    )


class Range(CustomBaseModel):
    min_: int | float = Field(alias='Min')
    max_: int | float = Field(alias='Max')

    def format_to_tuple(self) -> Tuple[int | float, int | float]:
        return self.min_, self.max_


p = Range(min_=0, max_=5)

Expected behavior
I expected I can write p = Range(min_=0, max=5) without IDE warnings

Screenshots
image

Environments (please complete the following information):

  • IDE: PyCharm Community 2024.1.1
  • OS: Ubuntu 22.04
  • Pydantic Version 2.7.1
  • Plugin version 0.4.13
@aaron-nall
Copy link

When I have encountered this, inside the plugin's getFieldName function:

  • pydanticVersion is null
  • config is null

@zeamir
Copy link

zeamir commented Sep 25, 2024

same here. happens also in version 2024.2.2

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

3 participants