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

Private attributes are not handled well #910

Open
wallneradam opened this issue Mar 29, 2024 · 0 comments
Open

Private attributes are not handled well #910

wallneradam opened this issue Mar 29, 2024 · 0 comments

Comments

@wallneradam
Copy link

wallneradam commented Mar 29, 2024

Describe the bug
In the latest version if I use underscored attributes, which are private attributes, when I try to use them like self._private_attr, the IDE shows Unresolved attribute reference error.
The same if I use PrivateAttr(default).

To Reproduce

class Test(BaseModel):
    _private_attr: int = 42

    def get(self):
        print(self._private_attr)  # Unresolved attribute reference '_private_attr' for class 'Test' 

    @classmethod
    def test(cls):
        print(cls._private_attr.defaut)  # Unresolved attribute reference 'default' for class 'int'

Expected behavior
It shoud not show errors.

Environments (please complete the following information):

  • IDE: PyCharm Professional 2023.3.5
  • OS: e.g. macOS 14.4.1
  • Pydantic Version: 2.6.3
  • Plugin version 0.4.12
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