[libgpiod][PATCH v2 04/23] bindings: python: explicitly type gpiod.request_lines

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

 



Explicitly define the arguments for `gpiod.request_lines` so there is a
clearer linkage with the underlying `Chip.request_lines` interface.

Signed-off-by: Vincent Fazio <vfazio@xxxxxxxxxxx>
---
 bindings/python/gpiod/__init__.py | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/bindings/python/gpiod/__init__.py b/bindings/python/gpiod/__init__.py
index aaa0474..817c755 100644
--- a/bindings/python/gpiod/__init__.py
+++ b/bindings/python/gpiod/__init__.py
@@ -7,6 +7,9 @@ Python bindings for libgpiod.
 This module wraps the native C API of libgpiod in a set of python classes.
 """
 
+from collections.abc import Iterable
+from typing import Optional, Union
+
 from . import (
     _ext,
     chip,
@@ -82,7 +85,13 @@ def is_gpiochip_device(path: str) -> bool:
     return _ext.is_gpiochip_device(path)
 
 
-def request_lines(path: str, *args, **kwargs) -> LineRequest:
+def request_lines(
+    path: str,
+    config: dict[Union[Iterable[Union[int, str]], int, str], Optional[LineSettings]],
+    consumer: Optional[str] = None,
+    event_buffer_size: Optional[int] = None,
+    output_values: Optional[dict[Union[int, str], line.Value]] = None,
+) -> LineRequest:
     """
     Open a GPIO chip pointed to by 'path', request lines according to the
     configuration arguments, close the chip and return the request object.
@@ -98,4 +107,9 @@ def request_lines(path: str, *args, **kwargs) -> LineRequest:
       Returns a new LineRequest object.
     """
     with Chip(path) as chip:
-        return chip.request_lines(*args, **kwargs)
+        return chip.request_lines(
+            config=config,
+            consumer=consumer,
+            event_buffer_size=event_buffer_size,
+            output_values=output_values,
+        )
-- 
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