koxudaxi / pydantic-pycharm-plugin

PyCharm plugin for pydantic. This plugin provides autocompletion, inspection, type-checking, inserting unfilled argument, and more.
https://koxudaxi.github.io/pydantic-pycharm-plugin/
MIT License
451 stars 16 forks source link

Plugin not working for decorated BaseModel classes #673

Open OfekEngelClaroty opened 1 year ago

OfekEngelClaroty commented 1 year ago

Describe the bug Plugin looses signature when a BaseModel class is decorated.

To Reproduce

from typing import TypeVar

from pydantic import BaseModel

_T = TypeVar("_T")

def deco(obj: _T) -> _T:
    return obj

@deco
class Model(BaseModel):
    foo: int

if __name__ == '__main__':
    a = Model()

Expected behavior Plugin to infer type correctly and add auto completions to pycharm

Screenshots

image

Environments (please complete the following information):

Additional context Without decorator, plugin works as inteneded

koxudaxi commented 1 year ago

Thank you for creating the issue. I will fix it.

OfekEngelClaroty commented 1 year ago

@koxudaxi is there an eta for fix?

koxudaxi commented 1 year ago

Last week, I checked the code. But I couldn't find a good solution at the time. I will investigate again.

koxudaxi commented 1 year ago

Your example doesn't work with @dataclass.dataclass too. It may be a hard fix without changing PyCharm side :thinking:

OfekEngelClaroty commented 1 year ago

perhaps its related to this issue