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
437 stars 14 forks source link

Validator's first agument warning when using @pydantic.validator #335

Open earthpyy opened 2 years ago

earthpyy commented 2 years ago

Describe the bug PyCharm is not seeing validator function as a class method when using @pydantic.validator instead of @validator

To Reproduce Steps to reproduce the behavior:

  1. Define a pydantic model
  2. Define avalidator function using @pydantic.validator(...) as a decorator instead of using @validator(...)
  3. See error

Expected behavior PyCharm should not warn about using self instead cls since validator() returns class method

Screenshots image

image

Environments (please complete the following information):

Additional context None

koxudaxi commented 2 years ago

@earthpyy Thank you for reporting this issue. I don't expect the parrtern. I will fix it.

earthpyy commented 2 years ago

@earthpyy Thank you for reporting this issue. I don't expect the parrtern. I will fix it.

@koxudaxi Thanks very much! Also thanks for this great work as well!

koxudaxi commented 2 years ago

@earthpyy I'm sorry for my late reply. I can't reproduce your warning.

Would you please give me the code? Screenshot from 2021-08-04 02-43-27

earthpyy commented 2 years ago

@koxudaxi Hello, I just tried to reproduce and found that the import statement was import pydantic.generics instead of import pydantic. I think because the other place in the same file was using pydantic.generics.Generic.

I also found that it isn't practical to import like that and using pydantic.validator later. Changing the import statement back to import pydantic works. I'm not sure if there is anything to fix in this case. Thanks!

koxudaxi commented 2 years ago

That's good news. I'm happy to resolve your problem.

I don't close this issue now. If I get the time then I will check the problem deeply.

earthpyy commented 2 years ago

Thanks for your help!