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

Class property incorrectly parsed

Open caniko opened this issue 3 years ago • 1 comments

Describe the bug @classmethod and @property combined can define a class property since Python 3.9. This is incorrectly parsed by the pydantic plugin.

To Reproduce The parser will expect cls to be self.

from typing import ClassVar

from pydantic import BaseModel


class A(BaseModel):
    a: ClassVar[int] = 4

    @classmethod
    @property
    def test_prop(cls):
        return cls.a

Expected behavior The syntax is correct, there should be no highlight.

Screenshots image

Environments (please complete the following information): pydantic version: 1.8.2 pydantic compiled: True install path: /home/can/.cache/pypoetry/virtualenvs/bikipy-hzbIcTjf-py3.9/lib/python3.9/site-packages/pydantic python version: 3.9.9 (main, Dec 9 2021, 11:30:30) [GCC 11.1.0] platform: Linux-5.15.8-zen1-1-zen-x86_64-with-glibc2.33 optional deps. installed: ['typing-extensions']

caniko avatar Dec 20 '21 09:12 caniko

@caniko Thank you for creating this issue. Is the problem related to the pydantic plugin? I can reproduce the problem without pydantic. Screenshot 2022-01-14 at 10 08 40

koxudaxi avatar Jan 14 '22 01:01 koxudaxi

no response :(

koxudaxi avatar Mar 02 '23 14:03 koxudaxi

Yes, sorry, you are correct.

caniko avatar Mar 02 '23 14:03 caniko