1
1
from asyncio import sleep
2
2
from dataclasses import dataclass
3
- from typing import Dict , List
4
3
from uuid import UUID
5
4
6
5
from polyfactory import AsyncPersistenceProtocol , SyncPersistenceProtocol
@@ -14,7 +13,7 @@ class Person:
14
13
15
14
16
15
# we will use a dictionary to persist values for the example
17
- mock_db : Dict [UUID , Person ] = {}
16
+ mock_db : dict [UUID , Person ] = {}
18
17
19
18
20
19
class SyncPersistenceHandler (SyncPersistenceProtocol [Person ]):
@@ -24,7 +23,7 @@ def save(self, data: Person) -> Person:
24
23
mock_db [data .id ] = data
25
24
return data
26
25
27
- def save_many (self , data : List [Person ]) -> List [Person ]:
26
+ def save_many (self , data : list [Person ]) -> list [Person ]:
28
27
# same as for save, here we should store the list in persistence.
29
28
# in this case, we use the same dictionary.
30
29
for person in data :
@@ -40,7 +39,7 @@ async def save(self, data: Person) -> Person:
40
39
await sleep (0.0001 )
41
40
return data
42
41
43
- async def save_many (self , data : List [Person ]) -> List [Person ]:
42
+ async def save_many (self , data : list [Person ]) -> list [Person ]:
44
43
# same as for the async save, here we should store the list in persistence using async logic.
45
44
# we again store in dict, and mock async using sleep.
46
45
for person in data :
0 commit comments