bindings: python: explicitly type gpiod.request_lines
authorVincent Fazio <vfazio@xes-inc.com>
Thu, 14 Nov 2024 14:50:57 +0000 (08:50 -0600)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Tue, 19 Nov 2024 14:21:01 +0000 (15:21 +0100)
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@xes-inc.com>
Link: https://lore.kernel.org/r/20241114145116.2123714-5-vfazio@xes-inc.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
bindings/python/gpiod/__init__.py

index aaa0474f79c557ec71d492cb82af459a32de9606..817c7552814c7d13b4f56ae645bedd4ecc709302 100644 (file)
@@ -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,
+        )