pydantic v1 uses `root_validator` and pydantic v2 uses `model_validator`.
pydantic v2 emits a warning when `root_validator` is used. E.g.:
```
litellm/proxy/_types.py:225
/Users/abramowi/Code/OpenSource/litellm/litellm/proxy/_types.py:225:
PydanticDeprecatedSince20: Pydantic V1 style `@root_validator`
validators are deprecated.
You should migrate to Pydantic V2 style `@model_validator` validators,
see the migration guide for more details.
Deprecated in Pydantic V2.0 to be removed in V3.0.
See Pydantic V2 Migration Guide at
https://errors.pydantic.dev/2.7/migration/
@root_validator(pre=True)
```
This change eliminates those warnings with pydantic v2, while retaining
compatibility with pydantic v1.
pydantic 2.7.1 before
```
$ env -i PATH=$PATH poetry run pytest litellm/tests/test_proxy_server.py
...
litellm/proxy/_types.py:225
/Users/abramowi/Code/OpenSource/litellm/litellm/proxy/_types.py:225: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.7/migration/
@root_validator(pre=True)
...
========================== 10 passed, 2 skipped, 39 warnings in 8.67s ===========================
```
pydantic 2.7.1 after
```
$ env -i PATH=$PATH poetry run pytest litellm/tests/test_proxy_server.py
...
========================== 10 passed, 2 skipped, 27 warnings in 9.85s ===========================
```
pydantic 1.10.5 after
```
$ poetry run pip install 'pydantic<2'
...
Successfully installed pydantic-1.10.15
$ env -i PATH=$PATH poetry run pytest litellm/tests/test_proxy_server.py
...
=========================== 10 passed, 2 skipped, 1 warning in 8.13s ============================
```
by mocking the necessary things in the test.
Now all the tests in `test_proxy_server.py` pass! 🎉
```shell
$ env -i PATH=$PATH poetry run pytest litellm/tests/test_proxy_server.py --disable-warnings
====================================== test session starts ======================================
platform darwin -- Python 3.12.3, pytest-7.4.4, pluggy-1.5.0
rootdir: /Users/abramowi/Code/OpenSource/litellm
plugins: anyio-4.3.0, asyncio-0.23.6, mock-3.14.0
asyncio: mode=Mode.STRICT
collected 12 items
litellm/tests/test_proxy_server.py s..........s [100%]
========================== 10 passed, 2 skipped, 48 warnings in 10.70s ==========================
```