You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When creating a model that has a field type hinted with "typing.ClassVar", it is ignored / not recognized.
To Reproduce
fromtypingimportClassVarfrompydanticimportBaseModelclassFooModel(BaseModel):
special_name_a: ClassVar[str] ='CEO'_special_name_b='CFO'__special_name_c__='Janitor'name: strFooModel.|# cursor at the pipe# PyCharm does not show existence of `special_name_a` field.# PyCharm does not show existence of `_special_name_b` field.# PyCharm does show existence of `__special_name_c__` field.# Pydantic recognizes the type hint and does not make a model field named 'special_name_a'.# Pydantic recognizes the leading underscore and does not make a model field named '_special_name_b'.# Pydantic recognizes the leading and trailing underscores and does not make a model field named '__special_name_c__'.
Expected behavior
I expect PyCharm (the plug-in) to recognize the class level fields. Both 'special_name_a' and 'special_name_c' should be presented in auto-complete. I don't expect the "protected" field of _special_name_b to show up but PyCharm should be made aware of it so people who want to show protected fields will also see it.
You already recognize the magics (__magic__) as class level. You should be able to make use of that code.
Environments (please complete the following information):
IDE: PyCharm Pro 2020.2.1
OS: PopOS 20.04
Pydantic Version 1.4
Plugin version 0.1.11
The text was updated successfully, but these errors were encountered:
Wow, that was super fast and I was so excited I closed down everything to try it out and like you said it works!
Thanks, so much. It will make a rather large difference in the code base I am working in.
I am excited to share the good news with my co-workers as well.
Thank you so much for the time you have put into this fix and the plug-in.
Describe the bug
When creating a model that has a field type hinted with "typing.ClassVar", it is ignored / not recognized.
To Reproduce
Expected behavior
I expect PyCharm (the plug-in) to recognize the class level fields. Both 'special_name_a' and 'special_name_c' should be presented in auto-complete. I don't expect the "protected" field of
_special_name_b
to show up but PyCharm should be made aware of it so people who want to show protected fields will also see it.You already recognize the magics (
__magic__
) as class level. You should be able to make use of that code.Environments (please complete the following information):
The text was updated successfully, but these errors were encountered: