Find answers from the community

Updated 7 months ago

Pydantic question!

Pydantic question!

Llama Index uses a try/except strategy when importing pydantic.v1 vs pydantic as seen in
https://github.com/run-llama/llama_index/blob/main/llama-index-core/llama_index/core/bridge/pydantic.py

This makes pyright's type checking unhappy. I presume it's unable to statically determine which pydantic is used (because the import is essentially dynamic) and complains, forcing us to add the dreaded # type:ignore comment to anything that touches this pydantic bridge.

Has anyone found an eloquent solution for this?
L
3 comments
Are you important from the bridge in your code, or you just mean in general?
If its an import in your code, I would use the v1 import directly
Otherwise, not sure I have a solution for that πŸ˜… Besides removing v1 support (which will probably happen in a few months hopefully)
Add a reply
Sign up and join the conversation on Discord