Open Jasonnor opened 1 year ago
I'm finding the same thing, I can't believe this was already logged! I'm getting this using the LangChain package which deals with LLMs, so has lots of model_*
arguments.
You could maybe just exclude from this list explicitly.
>>> [x for x in dir(BaseModel) if x.startswith('model_')]
['model_computed_fields',
'model_config',
'model_construct',
'model_copy',
'model_dump',
'model_dump_json',
'model_extra',
'model_fields',
'model_fields_set',
'model_json_schema',
'model_parametrized_name',
'model_post_init',
'model_rebuild',
'model_validate',
'model_validate_json',
'model_validate_strings']
But I don't fully understand why one would focus just on the model_*
stuff, shouldn't the same logic be applied to anything returned from dir(BaseModel)
?
(I never realised Pydantic had such a polluted namespace before looking into this!)
Describe the bug
I get unexpected argument warning for
model_*
attributes, and attribute names not start withmodel_
correctly.I set
protected_namespaces
to empty to avoid Pydantic v2 warning.But it seems that
pydantic-pycharm-plugin
will automatically filter out the attributes starting withmodel_*
, in order to avoid display the original members ofBaseModel
. Do not know any better solution? If there is no other way, I can only consider renaming the attribute.Thanks!
To Reproduce
Here is an example:
Expected behavior Without warning.
Screenshots
Environments (please complete the following information):
Additional context Add any other context about the problem here.
Funding