From 3123ed896d704560dcb332334024f14a3a95078b Mon Sep 17 00:00:00 2001 From: Jeferson Daniel Date: Wed, 24 Apr 2024 23:51:42 -0300 Subject: [PATCH] Fix type errors --- pydantic_mongo/abstract_repository.py | 4 ++-- requirements_test.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pydantic_mongo/abstract_repository.py b/pydantic_mongo/abstract_repository.py index d8d28da..112f961 100644 --- a/pydantic_mongo/abstract_repository.py +++ b/pydantic_mongo/abstract_repository.py @@ -121,7 +121,7 @@ def save(self, model: T) -> Union[InsertOneResult, UpdateResult]: ) result = self.get_collection().insert_one(document) - model.id = result.inserted_id + model_with_id.id = result.inserted_id return result def save_many(self, models: Iterable[T]): @@ -143,7 +143,7 @@ def save_many(self, models: Iterable[T]): ) for idx, inserted_id in enumerate(result.inserted_ids): - models_to_insert[idx].id = inserted_id + cast(ModelWithId, models_to_insert[idx]).id = inserted_id if len(models_to_update) == 0: return diff --git a/requirements_test.txt b/requirements_test.txt index ad30968..b369ae6 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -7,7 +7,7 @@ pytest==8.1.1 pytest-cov==4.1.0 pytest-mock==3.12.0 mongomock==4.1.2 -pydantic>=2.0.2 +pydantic==2.7.1 pymongo==4.6.3 mypy==1.10.0 mypy-extensions==1.0.0