Skip to content

Commit 3555605

Browse files
committed
Update Ruff config to use single quotes
Signed-off-by: Bernd Verst <[email protected]>
1 parent 9660735 commit 3555605

File tree

142 files changed

+2635
-2633
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+2635
-2633
lines changed

dapr/actor/__init__.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222

2323

2424
__all__ = [
25-
"ActorInterface",
26-
"ActorProxy",
27-
"ActorProxyFactory",
28-
"ActorId",
29-
"Actor",
30-
"ActorRuntime",
31-
"Remindable",
32-
"actormethod",
25+
'ActorInterface',
26+
'ActorProxy',
27+
'ActorProxyFactory',
28+
'ActorId',
29+
'Actor',
30+
'ActorRuntime',
31+
'Remindable',
32+
'actormethod',
3333
]

dapr/actor/client/proxy.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from dapr.conf import settings
2525

2626
# Actor factory Callable type hint.
27-
ACTOR_FACTORY_CALLBACK = Callable[[ActorInterface, str, str], "ActorProxy"]
27+
ACTOR_FACTORY_CALLBACK = Callable[[ActorInterface, str, str], 'ActorProxy']
2828

2929

3030
class ActorFactoryBase(ABC):
@@ -34,7 +34,7 @@ def create(
3434
actor_type: str,
3535
actor_id: ActorId,
3636
actor_interface: Optional[Type[ActorInterface]] = None,
37-
) -> "ActorProxy":
37+
) -> 'ActorProxy':
3838
...
3939

4040

@@ -60,23 +60,23 @@ def create(
6060
actor_type: str,
6161
actor_id: ActorId,
6262
actor_interface: Optional[Type[ActorInterface]] = None,
63-
) -> "ActorProxy":
63+
) -> 'ActorProxy':
6464
return ActorProxy(
6565
self._dapr_client, actor_type, actor_id, actor_interface, self._message_serializer
6666
)
6767

6868

6969
class CallableProxy:
7070
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
7272
):
7373
self._proxy = proxy
7474
self._attr_call_type = attr_call_type
7575
self._message_serializer = message_serializer
7676

7777
async def __call__(self, *args, **kwargs) -> Any:
7878
if len(args) > 1:
79-
raise ValueError("does not support multiple arguments")
79+
raise ValueError('does not support multiple arguments')
8080

8181
bytes_data = None
8282
if len(args) > 0:
@@ -85,9 +85,9 @@ async def __call__(self, *args, **kwargs) -> Any:
8585
else:
8686
bytes_data = self._message_serializer.serialize(args[0])
8787

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)
8989

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'])
9191

9292

9393
class ActorProxy:
@@ -134,7 +134,7 @@ def create(
134134
actor_id: ActorId,
135135
actor_interface: Optional[Type[ActorInterface]] = None,
136136
actor_proxy_factory: Optional[ActorFactoryBase] = None,
137-
) -> "ActorProxy":
137+
) -> 'ActorProxy':
138138
"""Creates ActorProxy client to call actor.
139139
140140
Args:
@@ -168,7 +168,7 @@ async def invoke_method(self, method: str, raw_body: Optional[bytes] = None) ->
168168
"""
169169

170170
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')
172172

173173
return await self._dapr_client.invoke_method(
174174
self._actor_type, str(self._actor_id), method, raw_body
@@ -189,14 +189,14 @@ def __getattr__(self, name: str) -> CallableProxy:
189189
AttributeError: method is not defined in Actor interface.
190190
"""
191191
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.')
193193

194194
if name not in self._dispatchable_attr:
195195
get_dispatchable_attrs_from_interface(self._actor_interface, self._dispatchable_attr)
196196

197197
attr_call_type = self._dispatchable_attr.get(name)
198198
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}')
200200

201201
if name not in self._callable_proxies:
202202
self._callable_proxies[name] = CallableProxy(

dapr/actor/id.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ActorId:
3131

3232
def __init__(self, actor_id: str):
3333
if not isinstance(actor_id, str):
34-
raise TypeError(f"Argument actor_id must be of type str, not {type(actor_id)}")
34+
raise TypeError(f'Argument actor_id must be of type str, not {type(actor_id)}')
3535
self._id = actor_id
3636

3737
@classmethod

dapr/actor/runtime/_reminder_data.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def __init__(
5757
self._ttl = ttl
5858

5959
if not isinstance(state, bytes):
60-
raise ValueError(f"only bytes are allowed for state: {type(state)}")
60+
raise ValueError(f'only bytes are allowed for state: {type(state)}')
6161

6262
self._state = state
6363

@@ -92,27 +92,27 @@ def as_dict(self) -> Dict[str, Any]:
9292
if self._state is not None:
9393
encoded_state = base64.b64encode(self._state)
9494
reminderDict: Dict[str, Any] = {
95-
"reminderName": self._reminder_name,
96-
"dueTime": self._due_time,
97-
"period": self._period,
98-
"data": encoded_state.decode("utf-8"),
95+
'reminderName': self._reminder_name,
96+
'dueTime': self._due_time,
97+
'period': self._period,
98+
'data': encoded_state.decode('utf-8'),
9999
}
100100

101101
if self._ttl is not None:
102-
reminderDict.update({"ttl": self._ttl})
102+
reminderDict.update({'ttl': self._ttl})
103103

104104
return reminderDict
105105

106106
@classmethod
107-
def from_dict(cls, reminder_name: str, obj: Dict[str, Any]) -> "ActorReminderData":
107+
def from_dict(cls, reminder_name: str, obj: Dict[str, Any]) -> 'ActorReminderData':
108108
"""Creates :class:`ActorReminderData` object from dict object."""
109-
b64encoded_state = obj.get("data")
109+
b64encoded_state = obj.get('data')
110110
state_bytes = None
111111
if b64encoded_state is not None and len(b64encoded_state) > 0:
112112
state_bytes = base64.b64decode(b64encoded_state)
113-
if "ttl" in obj:
113+
if 'ttl' in obj:
114114
return ActorReminderData(
115-
reminder_name, state_bytes, obj["dueTime"], obj["period"], obj["ttl"]
115+
reminder_name, state_bytes, obj['dueTime'], obj['period'], obj['ttl']
116116
)
117117
else:
118-
return ActorReminderData(reminder_name, state_bytes, obj["dueTime"], obj["period"])
118+
return ActorReminderData(reminder_name, state_bytes, obj['dueTime'], obj['period'])

dapr/actor/runtime/_state_provider.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323

2424
# Mapping StateChangeKind to Dapr State Operation
2525
_MAP_CHANGE_KIND_TO_OPERATION = {
26-
StateChangeKind.remove: b"delete",
27-
StateChangeKind.add: b"upsert",
28-
StateChangeKind.update: b"upsert",
26+
StateChangeKind.remove: b'delete',
27+
StateChangeKind.add: b'upsert',
28+
StateChangeKind.update: b'upsert',
2929
}
3030

3131

@@ -79,24 +79,24 @@ async def save_state(
7979
"""
8080

8181
json_output = io.BytesIO()
82-
json_output.write(b"[")
82+
json_output.write(b'[')
8383
first_state = True
8484
for state in state_changes:
8585
if not first_state:
86-
json_output.write(b",")
87-
operation = _MAP_CHANGE_KIND_TO_OPERATION.get(state.change_kind) or b""
86+
json_output.write(b',')
87+
operation = _MAP_CHANGE_KIND_TO_OPERATION.get(state.change_kind) or b''
8888
json_output.write(b'{"operation":"')
8989
json_output.write(operation)
9090
json_output.write(b'","request":{"key":"')
91-
json_output.write(state.state_name.encode("utf-8"))
91+
json_output.write(state.state_name.encode('utf-8'))
9292
json_output.write(b'"')
9393
if state.value is not None:
9494
serialized = self._state_serializer.serialize(state.value)
9595
json_output.write(b',"value":')
9696
json_output.write(serialized)
97-
json_output.write(b"}}")
97+
json_output.write(b'}}')
9898
first_state = False
99-
json_output.write(b"]")
99+
json_output.write(b']')
100100
data = json_output.getvalue()
101101
json_output.close()
102102
await self._state_client.save_state_transactionally(actor_type, actor_id, data)

dapr/actor/runtime/_timer_data.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ def as_dict(self) -> Dict[str, Any]:
9797
"""
9898

9999
timerDict: Dict[str, Any] = {
100-
"callback": self._callback,
101-
"data": self._state,
102-
"dueTime": self._due_time,
103-
"period": self._period,
100+
'callback': self._callback,
101+
'data': self._state,
102+
'dueTime': self._due_time,
103+
'period': self._period,
104104
}
105105

106106
if self._ttl:
107-
timerDict.update({"ttl": self._ttl})
107+
timerDict.update({'ttl': self._ttl})
108108

109109
return timerDict

dapr/actor/runtime/_type_information.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ class ActorTypeInformation:
3131
def __init__(
3232
self,
3333
name: str,
34-
implementation_class: Type["Actor"],
35-
actor_bases: List[Type["ActorInterface"]],
34+
implementation_class: Type['Actor'],
35+
actor_bases: List[Type['ActorInterface']],
3636
):
3737
self._name = name
3838
self._impl_type = implementation_class
@@ -44,12 +44,12 @@ def type_name(self) -> str:
4444
return self._name
4545

4646
@property
47-
def implementation_type(self) -> Type["Actor"]:
47+
def implementation_type(self) -> Type['Actor']:
4848
"""Returns Actor implementation type."""
4949
return self._impl_type
5050

5151
@property
52-
def actor_interfaces(self) -> List[Type["ActorInterface"]]:
52+
def actor_interfaces(self) -> List[Type['ActorInterface']]:
5353
"""Returns the list of :class:`ActorInterface` of this type."""
5454
return self._actor_bases
5555

@@ -58,7 +58,7 @@ def is_remindable(self) -> bool:
5858
return Remindable in self._impl_type.__bases__
5959

6060
@classmethod
61-
def create(cls, actor_class: Type["Actor"]) -> "ActorTypeInformation":
61+
def create(cls, actor_class: Type['Actor']) -> 'ActorTypeInformation':
6262
"""Creates :class:`ActorTypeInformation` for actor_class.
6363
6464
Args:
@@ -69,10 +69,10 @@ def create(cls, actor_class: Type["Actor"]) -> "ActorTypeInformation":
6969
and actor base class deriving :class:`ActorInterface`
7070
"""
7171
if not is_dapr_actor(actor_class):
72-
raise ValueError(f"{actor_class.__name__} is not actor")
72+
raise ValueError(f'{actor_class.__name__} is not actor')
7373

7474
actors = get_actor_interfaces(actor_class)
7575
if len(actors) == 0:
76-
raise ValueError(f"{actor_class.__name__} does not implement ActorInterface")
76+
raise ValueError(f'{actor_class.__name__} does not implement ActorInterface')
7777

7878
return ActorTypeInformation(actor_class.__name__, actor_class, actors)

dapr/actor/runtime/_type_utils.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ def get_class_method_args(func: Any) -> List[str]:
2323
args = func.__code__.co_varnames[: func.__code__.co_argcount]
2424

2525
# Exclude self, cls arguments
26-
if args[0] == "self" or args[0] == "cls":
26+
if args[0] == 'self' or args[0] == 'cls':
2727
args = args[1:]
2828
return list(args)
2929

3030

3131
def get_method_arg_types(func: Any) -> List[Type]:
32-
annotations = getattr(func, "__annotations__")
32+
annotations = getattr(func, '__annotations__')
3333
args = get_class_method_args(func)
3434
arg_types = []
3535
for arg_name in args:
@@ -39,26 +39,26 @@ def get_method_arg_types(func: Any) -> List[Type]:
3939

4040

4141
def get_method_return_types(func: Any) -> Type:
42-
annotations = getattr(func, "__annotations__")
43-
if len(annotations) == 0 or not annotations["return"]:
42+
annotations = getattr(func, '__annotations__')
43+
if len(annotations) == 0 or not annotations['return']:
4444
return object
45-
return annotations["return"]
45+
return annotations['return']
4646

4747

4848
def get_dispatchable_attrs_from_interface(
4949
actor_interface: Type[ActorInterface], dispatch_map: Dict[str, Any]
5050
) -> None:
5151
for attr, v in actor_interface.__dict__.items():
52-
if attr.startswith("_") or not callable(v):
52+
if attr.startswith('_') or not callable(v):
5353
continue
54-
actor_method_name = getattr(v, "__actormethod__") if hasattr(v, "__actormethod__") else attr
54+
actor_method_name = getattr(v, '__actormethod__') if hasattr(v, '__actormethod__') else attr
5555

5656
dispatch_map[actor_method_name] = {
57-
"actor_method": actor_method_name,
58-
"method_name": attr,
59-
"arg_names": get_class_method_args(v),
60-
"arg_types": get_method_arg_types(v),
61-
"return_types": get_method_return_types(v),
57+
'actor_method': actor_method_name,
58+
'method_name': attr,
59+
'arg_names': get_class_method_args(v),
60+
'arg_types': get_method_arg_types(v),
61+
'return_types': get_method_return_types(v),
6262
}
6363

6464

@@ -77,7 +77,7 @@ def get_dispatchable_attrs(actor_class: Type[Actor]) -> Dict[str, Any]:
7777
# Find all user actor interfaces derived from ActorInterface
7878
actor_interfaces = get_actor_interfaces(actor_class)
7979
if len(actor_interfaces) == 0:
80-
raise ValueError(f"{actor_class.__name__} has not inherited from ActorInterface")
80+
raise ValueError(f'{actor_class.__name__} has not inherited from ActorInterface')
8181

8282
# Find all dispatchable attributes
8383
dispatch_map: Dict[str, Any] = {}

dapr/actor/runtime/actor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def runtime_ctx(self) -> ActorRuntimeContext:
6464
return self._runtime_ctx
6565

6666
def __get_new_timer_name(self):
67-
return f"{self.id}_Timer_{uuid.uuid4()}"
67+
return f'{self.id}_Timer_{uuid.uuid4()}'
6868

6969
async def register_timer(
7070
self,

0 commit comments

Comments
 (0)