Use f-strings instead of % and .format()
parent
145fbf38d8
commit
0bc4d3a030
|
@ -26,16 +26,12 @@ class PinConfig(config.ConfigValue):
|
||||||
|
|
||||||
if event not in self.valid_events:
|
if event not in self.valid_events:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"invalid event for pin config {:s} (Must be {})".format(
|
f"invalid event for pin config {event} (Must be {', '.join(self.valid_events)})"
|
||||||
event, ", ".join(self.valid_events)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if active not in self.valid_modes:
|
if active not in self.valid_modes:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"invalid mode for pin config {:s} (Must be {})".format(
|
f"invalid event for pin config {active} (Must be {', '.join(self.valid_modes)})"
|
||||||
event, ", ".join(self.valid_events)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -50,7 +46,5 @@ class PinConfig(config.ConfigValue):
|
||||||
def serialize(self, value, display=False):
|
def serialize(self, value, display=False):
|
||||||
if value is None:
|
if value is None:
|
||||||
return ""
|
return ""
|
||||||
value = "{:s},{:s},{:d}".format(
|
value = f"{value.event},{value.active},{value.bouncetime}"
|
||||||
value.event, value.active, value.bouncetime
|
|
||||||
)
|
|
||||||
return config.encode(value)
|
return config.encode(value)
|
||||||
|
|
Loading…
Reference in New Issue