@@ -281,9 +281,7 @@ class Chip:
).items():
if count != 1:
raise ValueError(
- "line must be configured exactly once - offset {} repeats".format(
- offset
- )
+ f"line must be configured exactly once - offset {offset} repeats"
)
# If we have global output values - map line names to offsets
@@ -350,7 +348,7 @@ class Chip:
if not self._chip:
return "<Chip CLOSED>"
- return 'gpiod.Chip("{}")'.format(self.path)
+ return f'gpiod.Chip("{self.path}")'
def __str__(self) -> str:
"""
@@ -359,7 +357,7 @@ class Chip:
if not self._chip:
return "<Chip CLOSED>"
- return '<Chip path="{}" fd={} info={}>'.format(
+ return '<Chip path="{}" fd={} info={}>'.format( # noqa: UP032
self.path, self.fd, self.get_info()
)
@@ -18,6 +18,6 @@ class ChipInfo:
num_lines: int
def __str__(self) -> str:
- return '<ChipInfo name="{}" label="{}" num_lines={}>'.format(
+ return '<ChipInfo name="{}" label="{}" num_lines={}>'.format( # noqa: UP032
self.name, self.label, self.num_lines
)
@@ -40,7 +40,7 @@ class EdgeEvent:
object.__setattr__(self, "line_seqno", line_seqno)
def __str__(self) -> str:
- return "<EdgeEvent type={} timestamp_ns={} line_offset={} global_seqno={} line_seqno={}>".format(
+ return "<EdgeEvent type={} timestamp_ns={} line_offset={} global_seqno={} line_seqno={}>".format( # noqa: UP032
self.event_type,
self.timestamp_ns,
self.line_offset,
@@ -31,6 +31,6 @@ class InfoEvent:
object.__setattr__(self, "line_info", line_info)
def __str__(self) -> str:
- return "<InfoEvent type={} timestamp_ns={} line_info={}>".format(
+ return "<InfoEvent type={} timestamp_ns={} line_info={}>".format( # noqa: UP032
self.event_type, self.timestamp_ns, self.line_info
)
@@ -59,7 +59,7 @@ class LineInfo:
)
def __str__(self) -> str:
- return '<LineInfo offset={} name="{}" used={} consumer="{}" direction={} active_low={} bias={} drive={} edge_detection={} event_clock={} debounced={} debounce_period={}>'.format(
+ return '<LineInfo offset={} name="{}" used={} consumer="{}" direction={} active_low={} bias={} drive={} edge_detection={} event_clock={} debounced={} debounce_period={}>'.format( # noqa: UP032
self.offset,
self.name,
self.used,
@@ -232,7 +232,7 @@ class LineRequest:
if not self._req:
return "<LineRequest RELEASED>"
- return '<LineRequest chip="{}" num_lines={} offsets={} fd={}>'.format(
+ return '<LineRequest chip="{}" num_lines={} offsets={} fd={}>'.format( # noqa: UP032
self.chip_name, self.num_lines, self.offsets, self.fd
)
@@ -28,7 +28,7 @@ class LineSettings:
# __repr__ generated by @dataclass uses repr for enum members resulting in
# an unusable representation as those are of the form: <NAME: $value>
def __repr__(self) -> str:
- return "gpiod.LineSettings(direction=gpiod.line.{}, edge_detection=gpiod.line.{}, bias=gpiod.line.{}, drive=gpiod.line.{}, active_low={}, debounce_period={}, event_clock=gpiod.line.{}, output_value=gpiod.line.{})".format(
+ return "gpiod.LineSettings(direction=gpiod.line.{}, edge_detection=gpiod.line.{}, bias=gpiod.line.{}, drive=gpiod.line.{}, active_low={}, debounce_period={}, event_clock=gpiod.line.{}, output_value=gpiod.line.{})".format( # noqa: UP032
str(self.direction),
str(self.edge_detection),
str(self.bias),
@@ -40,7 +40,7 @@ class LineSettings:
)
def __str__(self) -> str:
- return "<LineSettings direction={} edge_detection={} bias={} drive={} active_low={} debounce_period={} event_clock={} output_value={}>".format(
+ return "<LineSettings direction={} edge_detection={} bias={} drive={} active_low={} debounce_period={} event_clock={} output_value={}>".format( # noqa: UP032
self.direction,
self.edge_detection,
self.bias,
Dataclasses are not migrated to f-strings so readability isn't impacted. Signed-off-by: Vincent Fazio <vfazio@xes-inc.com> --- bindings/python/gpiod/chip.py | 8 +++----- bindings/python/gpiod/chip_info.py | 2 +- bindings/python/gpiod/edge_event.py | 2 +- bindings/python/gpiod/info_event.py | 2 +- bindings/python/gpiod/line_info.py | 2 +- bindings/python/gpiod/line_request.py | 2 +- bindings/python/gpiod/line_settings.py | 4 ++-- 7 files changed, 10 insertions(+), 12 deletions(-)