Skip to content

Full Pydantic 2.0 Support + Bug Fixes #691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
99 changes: 0 additions & 99 deletions aredis_om/_compat.py

This file was deleted.

1 change: 0 additions & 1 deletion aredis_om/checks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from functools import lru_cache
from typing import List

from aredis_om.connections import get_redis_connection

Expand Down
7 changes: 5 additions & 2 deletions aredis_om/model/encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
from types import GeneratorType
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union

from .._compat import ENCODERS_BY_TYPE, BaseModel
from pydantic import BaseModel
from pydantic.deprecated.json import ENCODERS_BY_TYPE
from pydantic_core import PydanticUndefined


SetIntStr = Set[Union[int, str]]
Expand Down Expand Up @@ -72,7 +74,7 @@ def jsonable_encoder(
encoder = getattr(obj.__config__, "json_encoders", {})
if custom_encoder:
encoder.update(custom_encoder)
obj_dict = obj.dict(
obj_dict = obj.model_dump(
include=include, # type: ignore # in Pydantic
exclude=exclude, # type: ignore # in Pydantic
by_alias=by_alias,
Expand Down Expand Up @@ -106,6 +108,7 @@ def jsonable_encoder(
or (not isinstance(key, str))
or (not key.startswith("_sa"))
)
and value is not PydanticUndefined
and (value is not None or not exclude_none)
and ((include and key in include) or not exclude or key not in exclude)
):
Expand Down
2 changes: 1 addition & 1 deletion aredis_om/model/migrations/migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ async def detect_migrations(self):

stored_hash = await conn.get(hash_key)
if isinstance(stored_hash, bytes):
stored_hash = stored_hash.decode('utf-8')
stored_hash = stored_hash.decode("utf-8")

schema_out_of_date = current_hash != stored_hash

Expand Down
Loading