24
24
from dapr .conf import settings
25
25
26
26
# Actor factory Callable type hint.
27
- ACTOR_FACTORY_CALLBACK = Callable [[ActorInterface , str , str ], " ActorProxy" ]
27
+ ACTOR_FACTORY_CALLBACK = Callable [[ActorInterface , str , str ], ' ActorProxy' ]
28
28
29
29
30
30
class ActorFactoryBase (ABC ):
@@ -34,7 +34,7 @@ def create(
34
34
actor_type : str ,
35
35
actor_id : ActorId ,
36
36
actor_interface : Optional [Type [ActorInterface ]] = None ,
37
- ) -> " ActorProxy" :
37
+ ) -> ' ActorProxy' :
38
38
...
39
39
40
40
@@ -60,23 +60,23 @@ def create(
60
60
actor_type : str ,
61
61
actor_id : ActorId ,
62
62
actor_interface : Optional [Type [ActorInterface ]] = None ,
63
- ) -> " ActorProxy" :
63
+ ) -> ' ActorProxy' :
64
64
return ActorProxy (
65
65
self ._dapr_client , actor_type , actor_id , actor_interface , self ._message_serializer
66
66
)
67
67
68
68
69
69
class CallableProxy :
70
70
def __init__ (
71
- self , proxy : " ActorProxy" , attr_call_type : Dict [str , Any ], message_serializer : Serializer
71
+ self , proxy : ' ActorProxy' , attr_call_type : Dict [str , Any ], message_serializer : Serializer
72
72
):
73
73
self ._proxy = proxy
74
74
self ._attr_call_type = attr_call_type
75
75
self ._message_serializer = message_serializer
76
76
77
77
async def __call__ (self , * args , ** kwargs ) -> Any :
78
78
if len (args ) > 1 :
79
- raise ValueError (" does not support multiple arguments" )
79
+ raise ValueError (' does not support multiple arguments' )
80
80
81
81
bytes_data = None
82
82
if len (args ) > 0 :
@@ -85,9 +85,9 @@ async def __call__(self, *args, **kwargs) -> Any:
85
85
else :
86
86
bytes_data = self ._message_serializer .serialize (args [0 ])
87
87
88
- rtnval = await self ._proxy .invoke_method (self ._attr_call_type [" actor_method" ], bytes_data )
88
+ rtnval = await self ._proxy .invoke_method (self ._attr_call_type [' actor_method' ], bytes_data )
89
89
90
- return self ._message_serializer .deserialize (rtnval , self ._attr_call_type [" return_types" ])
90
+ return self ._message_serializer .deserialize (rtnval , self ._attr_call_type [' return_types' ])
91
91
92
92
93
93
class ActorProxy :
@@ -134,7 +134,7 @@ def create(
134
134
actor_id : ActorId ,
135
135
actor_interface : Optional [Type [ActorInterface ]] = None ,
136
136
actor_proxy_factory : Optional [ActorFactoryBase ] = None ,
137
- ) -> " ActorProxy" :
137
+ ) -> ' ActorProxy' :
138
138
"""Creates ActorProxy client to call actor.
139
139
140
140
Args:
@@ -168,7 +168,7 @@ async def invoke_method(self, method: str, raw_body: Optional[bytes] = None) ->
168
168
"""
169
169
170
170
if raw_body is not None and not isinstance (raw_body , bytes ):
171
- raise ValueError (f" raw_body { type (raw_body )} is not bytes type" )
171
+ raise ValueError (f' raw_body { type (raw_body )} is not bytes type' )
172
172
173
173
return await self ._dapr_client .invoke_method (
174
174
self ._actor_type , str (self ._actor_id ), method , raw_body
@@ -189,14 +189,14 @@ def __getattr__(self, name: str) -> CallableProxy:
189
189
AttributeError: method is not defined in Actor interface.
190
190
"""
191
191
if not self ._actor_interface :
192
- raise ValueError (" actor_interface is not set. use invoke method." )
192
+ raise ValueError (' actor_interface is not set. use invoke method.' )
193
193
194
194
if name not in self ._dispatchable_attr :
195
195
get_dispatchable_attrs_from_interface (self ._actor_interface , self ._dispatchable_attr )
196
196
197
197
attr_call_type = self ._dispatchable_attr .get (name )
198
198
if attr_call_type is None :
199
- raise AttributeError (f" { self ._actor_interface .__class__ } has no attribute { name } " )
199
+ raise AttributeError (f' { self ._actor_interface .__class__ } has no attribute { name } ' )
200
200
201
201
if name not in self ._callable_proxies :
202
202
self ._callable_proxies [name ] = CallableProxy (
0 commit comments