[libgpiod][PATCH 03/22] bindings: python: fix annotation of variable length tuples

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Both `Chip.request_lines` and `LineRequest.reconfigure_lines` accept a
config argument that is allowed to be either a variable length tuple
of int | str, a str, or an int.

Python documentation [0] points out that variable length tuples need a
trailing ellipsis in their annotation.

[0]: https://docs.python.org/3/library/typing.html#annotating-tuples
Signed-off-by: Vincent Fazio <vfazio@xxxxxxxxxxx>
---
 bindings/python/gpiod/chip.py         | 4 +++-
 bindings/python/gpiod/line_request.py | 5 ++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/bindings/python/gpiod/chip.py b/bindings/python/gpiod/chip.py
index 1a1bba4d6dd9e840a60394f1b74903f6ad15a0f4..93556b6ea6aa35b9ad6dc0cb840c33cb95170048 100644
--- a/bindings/python/gpiod/chip.py
+++ b/bindings/python/gpiod/chip.py
@@ -222,7 +222,9 @@ class Chip:
 
     def request_lines(
         self,
-        config: dict[tuple[Union[int, str]], Optional[LineSettings]],
+        config: dict[
+            Union[tuple[Union[int, str], ...], int, str], Optional[LineSettings]
+        ],
         consumer: Optional[str] = None,
         event_buffer_size: Optional[int] = None,
         output_values: Optional[dict[Union[int, str], Value]] = None,
diff --git a/bindings/python/gpiod/line_request.py b/bindings/python/gpiod/line_request.py
index 154174872e488fa478b27f5e83d65e6040aca367..f4e3f06d984d751d842b3c0e77a8db2e0e9a7a60 100644
--- a/bindings/python/gpiod/line_request.py
+++ b/bindings/python/gpiod/line_request.py
@@ -144,7 +144,10 @@ class LineRequest:
         self._req.set_values(mapped)
 
     def reconfigure_lines(
-        self, config: dict[tuple[Union[int, str]], LineSettings]
+        self,
+        config: dict[
+            Union[tuple[Union[int, str], ...], int, str], Optional[LineSettings]
+        ],
     ) -> None:
         """
         Reconfigure requested lines.

-- 
2.34.1




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux