11from asyncio import sleep
22from dataclasses import dataclass
3- from typing import Dict , List
43from uuid import UUID
54
65from polyfactory import AsyncPersistenceProtocol , SyncPersistenceProtocol
@@ -14,7 +13,7 @@ class Person:
1413
1514
1615# we will use a dictionary to persist values for the example
17- mock_db : Dict [UUID , Person ] = {}
16+ mock_db : dict [UUID , Person ] = {}
1817
1918
2019class SyncPersistenceHandler (SyncPersistenceProtocol [Person ]):
@@ -24,7 +23,7 @@ def save(self, data: Person) -> Person:
2423 mock_db [data .id ] = data
2524 return data
2625
27- def save_many (self , data : List [Person ]) -> List [Person ]:
26+ def save_many (self , data : list [Person ]) -> list [Person ]:
2827 # same as for save, here we should store the list in persistence.
2928 # in this case, we use the same dictionary.
3029 for person in data :
@@ -40,7 +39,7 @@ async def save(self, data: Person) -> Person:
4039 await sleep (0.0001 )
4140 return data
4241
43- async def save_many (self , data : List [Person ]) -> List [Person ]:
42+ async def save_many (self , data : list [Person ]) -> list [Person ]:
4443 # same as for the async save, here we should store the list in persistence using async logic.
4544 # we again store in dict, and mock async using sleep.
4645 for person in data :
0 commit comments