From: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx> Currently, for the output of LineSettings.__repr__() to be eval()able, the user must have pulled all the relevant definitions from gpiod.line within the scope where it is used. Modify the output so that all the user needs is `import gpiod`. Reported-by: Vincent Fazio <vfazio@xxxxxxxxx> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx> --- bindings/python/gpiod/line_settings.py | 2 +- bindings/python/tests/tests_line_settings.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bindings/python/gpiod/line_settings.py b/bindings/python/gpiod/line_settings.py index 41712cc..5e32194 100644 --- a/bindings/python/gpiod/line_settings.py +++ b/bindings/python/gpiod/line_settings.py @@ -27,7 +27,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): - return "gpiod.LineSettings(direction={}, edge_detection={}, bias={}, drive={}, active_low={}, debounce_period={}, event_clock={}, output_value={})".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( str(self.direction), str(self.edge_detection), str(self.bias), diff --git a/bindings/python/tests/tests_line_settings.py b/bindings/python/tests/tests_line_settings.py index c6ca720..83be3d9 100644 --- a/bindings/python/tests/tests_line_settings.py +++ b/bindings/python/tests/tests_line_settings.py @@ -69,7 +69,7 @@ class LineSettingsStringRepresentation(TestCase): def test_repr(self): self.assertEqual( repr(self.settings), - "gpiod.LineSettings(direction=Direction.OUTPUT, edge_detection=Edge.NONE, bias=Bias.AS_IS, drive=Drive.OPEN_SOURCE, active_low=True, debounce_period=datetime.timedelta(0), event_clock=Clock.MONOTONIC, output_value=Value.INACTIVE)", + "gpiod.LineSettings(direction=gpiod.line.Direction.OUTPUT, edge_detection=gpiod.line.Edge.NONE, bias=gpiod.line.Bias.AS_IS, drive=gpiod.line.Drive.OPEN_SOURCE, active_low=True, debounce_period=datetime.timedelta(0), event_clock=gpiod.line.Clock.MONOTONIC, output_value=gpiod.line.Value.INACTIVE)", ) cmp = eval(repr(self.settings)) -- 2.43.0