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 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ddf3354
remove pydantic v1 references
sethbuff Apr 18, 2025
49077bb
set validate_default=True
sethbuff Apr 21, 2025
9ffa5ed
Remove unused imports
jmmenard Apr 21, 2025
3676634
update models to specify when a model is final
sethbuff Apr 24, 2025
e0f3b12
fix knn setup
sethbuff Apr 24, 2025
298f2e1
Update KNN test query
jmmenard Apr 25, 2025
721d91e
Update KNN results include score
jmmenard Apr 25, 2025
8bc61a1
remove use of alias for queries
sethbuff Apr 25, 2025
d6e9b23
fix lint issues
sethbuff Apr 25, 2025
ad07cee
fix lint issues
sethbuff Apr 25, 2025
623f714
fix annotations for python < 3.10
sethbuff Apr 25, 2025
fc66b80
fix annotations for python < 3.10
sethbuff Apr 25, 2025
3ed225c
fix issue where certain fields were unintentionally being indexed
sethbuff Apr 28, 2025
23213af
remove vscode settings
sethbuff Apr 28, 2025
b45ffd5
dynamically set index based on other fields that require indexes
sethbuff Apr 28, 2025
48a092b
fix inheritance from indexed model
sethbuff Apr 28, 2025
d5520ed
fix linting errors
sethbuff Apr 28, 2025
064065b
change version to beta
sethbuff Apr 29, 2025
02b7b4b
make default a positional arg on Field
sethbuff Apr 29, 2025
055a084
Include knn in model construction
jmmenard Apr 29, 2025
0040e7f
add warning for auto indexing
sethbuff Apr 29, 2025
df8433e
Merge branch 'triage/pydantic-v2' of https://github.com/Triage-Staffi…
sethbuff Apr 29, 2025
1d23b27
use field info args without default to prevent overlapping values
sethbuff Apr 29, 2025
412c267
update typing to support older python versions
sethbuff Apr 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading