pydantic-pycharm-plugin
pydantic-pycharm-plugin copied to clipboard
Validator's first agument warning when using @pydantic.validator
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:
- Define a pydantic model
- Define avalidator function using
@pydantic.validator(...)
as a decorator instead of using@validator(...)
- See error
Expected behavior
PyCharm should not warn about using self
instead cls
since validator()
returns class method
Screenshots
Environments (please complete the following information):
- IDE: PyCharm Professional 2021.1
- OS: macOS Big Sur
- Pydantic Version: 1.8.2
- Plugin version: 0.3.4
Additional context None
@earthpyy Thank you for reporting this issue. I don't expect the parrtern. I will fix it.
@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!
@earthpyy I'm sorry for my late reply. I can't reproduce your warning.
Would you please give me the code?
@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!
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.
Thanks for your help!