Re: [libgpiod][PATCH 04/22] bindings: python: add missing method type annotations

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

 



On Fri, Sep 27, 2024 at 9:05 PM Vincent Fazio <vfazio@xxxxxxxxxxx> wrote:
>
> 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      | 17 +++++++++++++++--
>  bindings/python/gpiod/chip.py          | 12 ++++++++++--
>  bindings/python/gpiod/chip_info.py     |  2 +-
>  bindings/python/gpiod/edge_event.py    |  2 +-
>  bindings/python/gpiod/exception.py     |  4 ++--
>  bindings/python/gpiod/info_event.py    |  2 +-
>  bindings/python/gpiod/line.py          |  2 +-
>  bindings/python/gpiod/line_info.py     |  2 +-
>  bindings/python/gpiod/line_request.py  | 16 ++++++++++++----
>  bindings/python/gpiod/line_settings.py |  4 ++--
>  10 files changed, 46 insertions(+), 17 deletions(-)
>
> diff --git a/bindings/python/gpiod/__init__.py b/bindings/python/gpiod/__init__.py
> index 4d916f7f1a4eabd8ad1b2844262c20ed01a0798c..3cf39d61f64c3888584cd2518787b8e17e185ed2 100644
> --- a/bindings/python/gpiod/__init__.py
> +++ b/bindings/python/gpiod/__init__.py
> @@ -7,6 +7,8 @@ Python bindings for libgpiod.
>  This module wraps the native C API of libgpiod in a set of python classes.
>  """
>
> +from typing import Optional, Union
> +
>  from . import (
>      _ext,
>      chip,
> @@ -83,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[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], 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.
> @@ -99,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,
> +        )

IMO this and the rest of this patch should become separate commits.
Otherwise looks good.

Bart





[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