-
Notifications
You must be signed in to change notification settings - Fork 259
Open
Labels
Description
Describe the bug
There are many Pydantic v2 deprecation warnings triggered by beanie code.
To Reproduce
run python code using beanie 1.21 with -W error
to stop at the first warning.
Example:
../../../Library/Caches/pypoetry/virtualenvs/companion-mgXvcyvA-py3.11/lib/python3.11/site-packages/pydantic/_internal/_config.py:219: in prepare_config
warnings.warn(DEPRECATION_MESSAGE, DeprecationWarning)
E pydantic.warnings.PydanticDeprecatedSince20: Support for class-based `config` is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.3/migration/
Triggered by this code in beanie/odm/bulk.py
:
class Operation(BaseModel):
operation: Union[
Type[InsertOne],
Type[DeleteOne],
Type[DeleteMany],
Type[ReplaceOne],
Type[UpdateOne],
Type[UpdateMany],
]
first_query: Mapping[str, Any]
second_query: Optional[Dict[str, Any]] = None
pymongo_kwargs: Dict[str, Any] = Field(default_factory=dict)
object_class: Type
class Config:
arbitrary_types_allowed = True
Expected behavior
Clean run with no deprecations.
Additional context
I see primarily these 4 types of deprecation warnings:
/Users/bcs/Library/Caches/pypoetry/virtualenvs/companion-mgXvcyvA-py3.11/lib/python3.11/site-packages/beanie/odm/utils/init.py:386: PydanticDeprecatedSince20: The `__fields__` attribute is deprecated, use `model_fields` instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.3/migration/
/Users/bcs/Library/Caches/pypoetry/virtualenvs/companion-mgXvcyvA-py3.11/lib/python3.11/site-packages/pydantic/fields.py:792: PydanticDeprecatedSince20: Using extra keyword arguments on `Field` is deprecated and will be removed. Use `json_schema_extra` instead. (Extra keys: 'hidden'). Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.3/migration/
/Users/bcs/Library/Caches/pypoetry/virtualenvs/companion-mgXvcyvA-py3.11/lib/python3.11/site-packages/beanie/odm/documents.py:210: 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.3/migration/
/Users/bcs/Library/Caches/pypoetry/virtualenvs/companion-mgXvcyvA-py3.11/lib/python3.11/site-packages/beanie/odm/utils/encoder.py:113: PydanticDeprecatedSince20: The private method `_iter` will be removed and should no longer be used. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.3/migration/
Cyclone5 and slingshotsys