Skip to content

Commit 460f7ba

Browse files
committed
ofono: Wrap multi-line strings in parens
Fixes > ISC004 Unparenthesized implicit string concatenation in collection with latest ruff.
1 parent 1ce6196 commit 460f7ba

1 file changed

Lines changed: 53 additions & 39 deletions

File tree

dbusmock/templates/ofono.py

Lines changed: 53 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,11 @@ def AddModem(self, name, _properties):
109109
"SetProperty",
110110
"sv",
111111
"",
112-
'self.Set("org.ofono.Modem", args[0], args[1]); '
113-
'self.EmitSignal("org.ofono.Modem", "PropertyChanged",'
114-
' "sv", [args[0], args[1]])',
112+
(
113+
'self.Set("org.ofono.Modem", args[0], args[1]); '
114+
'self.EmitSignal("org.ofono.Modem", "PropertyChanged",'
115+
' "sv", [args[0], args[1]])'
116+
),
115117
),
116118
],
117119
)
@@ -235,9 +237,11 @@ def Dial(self, number, _hide_callerid):
235237
"Hangup",
236238
"",
237239
"",
238-
"self.parent.calls.remove(self._object_path);"
239-
"self.parent.RemoveObject(self._object_path);"
240-
'self.EmitSignal("org.ofono.VoiceCallManager", "CallRemoved", "o", [self._object_path])',
240+
(
241+
"self.parent.calls.remove(self._object_path);"
242+
"self.parent.RemoveObject(self._object_path);"
243+
'self.EmitSignal("org.ofono.VoiceCallManager", "CallRemoved", "o", [self._object_path])'
244+
),
241245
),
242246
("Answer", "", "", NOT_IMPLEMENTED),
243247
],
@@ -331,8 +335,10 @@ def add_netreg_api(mock):
331335
"SetProperty",
332336
"sv",
333337
"",
334-
'self.Set("org.ofono.NetworkRegistration", args[0], args[1]); '
335-
'self.EmitSignal("org.ofono.NetworkRegistration", "PropertyChanged", "sv", [args[0], args[1]])',
338+
(
339+
'self.Set("org.ofono.NetworkRegistration", args[0], args[1]); '
340+
'self.EmitSignal("org.ofono.NetworkRegistration", "PropertyChanged", "sv", [args[0], args[1]])'
341+
),
336342
),
337343
("Register", "", "", ""),
338344
("GetOperators", "", "a(oa{sv})", get_all_operators(mock)),
@@ -395,46 +401,52 @@ def add_simmanager_api(self, mock):
395401
"SetProperty",
396402
"sv",
397403
"",
398-
f'self.Set("{iface}", args[0], args[1]); '
399-
f'self.EmitSignal("{iface}", "PropertyChanged", "sv", [args[0], args[1]])',
404+
(
405+
f'self.Set("{iface}", args[0], args[1]); '
406+
f'self.EmitSignal("{iface}", "PropertyChanged", "sv", [args[0], args[1]])'
407+
),
400408
),
401409
("ChangePin", "sss", "", ""),
402410
(
403411
"EnterPin",
404412
"ss",
405413
"",
406-
'correctPin = "1234"\n'
407-
f'iface = "{iface}"\n'
408-
'newRetries = self.Get(iface, "Retries")\n'
409-
'if args[0] == "pin" and args[1] != correctPin:\n'
410-
' newRetries["pin"] = dbus.Byte(newRetries["pin"] - 1)\n'
411-
'elif args[0] == "pin":\n'
412-
' newRetries["pin"] = dbus.Byte(3)\n'
413-
'self.Set(iface, "Retries", newRetries)\n'
414-
'self.EmitSignal(iface, "PropertyChanged", "sv", ["Retries", newRetries])\n'
415-
'if args[0] == "pin" and args[1] != correctPin:\n'
416-
" class Failed(dbus.exceptions.DBusException):\n"
417-
' _dbus_error_name = "org.ofono.Error.Failed"\n'
418-
' raise Failed("Operation failed")',
414+
(
415+
'correctPin = "1234"\n'
416+
f'iface = "{iface}"\n'
417+
'newRetries = self.Get(iface, "Retries")\n'
418+
'if args[0] == "pin" and args[1] != correctPin:\n'
419+
' newRetries["pin"] = dbus.Byte(newRetries["pin"] - 1)\n'
420+
'elif args[0] == "pin":\n'
421+
' newRetries["pin"] = dbus.Byte(3)\n'
422+
'self.Set(iface, "Retries", newRetries)\n'
423+
'self.EmitSignal(iface, "PropertyChanged", "sv", ["Retries", newRetries])\n'
424+
'if args[0] == "pin" and args[1] != correctPin:\n'
425+
" class Failed(dbus.exceptions.DBusException):\n"
426+
' _dbus_error_name = "org.ofono.Error.Failed"\n'
427+
' raise Failed("Operation failed")'
428+
),
419429
),
420430
(
421431
"ResetPin",
422432
"sss",
423433
"",
424-
'correctPuk = "12345678"\n'
425-
f'iface = "{iface}"\n'
426-
'newRetries = self.Get(iface, "Retries")\n'
427-
'if args[0] == "puk" and args[1] != correctPuk:\n'
428-
' newRetries["puk"] = dbus.Byte(newRetries["puk"] - 1)\n'
429-
'elif args[0] == "puk":\n'
430-
' newRetries["pin"] = dbus.Byte(3)\n'
431-
' newRetries["puk"] = dbus.Byte(10)\n'
432-
'self.Set(iface, "Retries", newRetries)\n'
433-
'self.EmitSignal(iface, "PropertyChanged", "sv", ["Retries", newRetries])\n'
434-
'if args[0] == "puk" and args[1] != correctPuk:\n'
435-
" class Failed(dbus.exceptions.DBusException):\n"
436-
' _dbus_error_name = "org.ofono.Error.Failed"\n'
437-
' raise Failed("Operation failed")',
434+
(
435+
'correctPuk = "12345678"\n'
436+
f'iface = "{iface}"\n'
437+
'newRetries = self.Get(iface, "Retries")\n'
438+
'if args[0] == "puk" and args[1] != correctPuk:\n'
439+
' newRetries["puk"] = dbus.Byte(newRetries["puk"] - 1)\n'
440+
'elif args[0] == "puk":\n'
441+
' newRetries["pin"] = dbus.Byte(3)\n'
442+
' newRetries["puk"] = dbus.Byte(10)\n'
443+
'self.Set(iface, "Retries", newRetries)\n'
444+
'self.EmitSignal(iface, "PropertyChanged", "sv", ["Retries", newRetries])\n'
445+
'if args[0] == "puk" and args[1] != correctPuk:\n'
446+
" class Failed(dbus.exceptions.DBusException):\n"
447+
' _dbus_error_name = "org.ofono.Error.Failed"\n'
448+
' raise Failed("Operation failed")'
449+
),
438450
),
439451
("LockPin", "ss", "", ""),
440452
("UnlockPin", "ss", "", ""),
@@ -480,8 +492,10 @@ def add_connectionmanager_api(mock):
480492
"SetProperty",
481493
"sv",
482494
"",
483-
f'self.Set("{iface}", args[0], args[1]); '
484-
f'self.EmitSignal("{iface}", "PropertyChanged", "sv", [args[0], args[1]])',
495+
(
496+
f'self.Set("{iface}", args[0], args[1]); '
497+
f'self.EmitSignal("{iface}", "PropertyChanged", "sv", [args[0], args[1]])'
498+
),
485499
),
486500
("AddContext", "s", "o", 'ret = "/"'),
487501
("RemoveContext", "o", "", ""),

0 commit comments

Comments
 (0)