pydantic-pycharm-plugin icon indicating copy to clipboard operation
pydantic-pycharm-plugin copied to clipboard

Private attributes are not handled well

Open wallneradam opened this issue 3 months ago • 0 comments

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

wallneradam avatar Mar 29 '24 17:03 wallneradam