* [libgpiod][PATCH 2/9] bindings: python: build_tests: simplify the Distribution
2026-04-01 0:14 [libgpiod][PATCH 1/9] bindings: python: build_tests: do not fallback to distutils Vincent Fazio
@ 2026-04-01 0:14 ` Vincent Fazio
2026-04-01 0:14 ` [libgpiod][PATCH 3/9] bindings: python: setup: add type annotations Vincent Fazio
` (7 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Vincent Fazio @ 2026-04-01 0:14 UTC (permalink / raw)
To: linux-gpio; +Cc: Vincent Fazio
The version, package, and platform information is not necessary to
compile and stage the extensions, so drop that information.
If we need to add it back, we can use `dist.parse_config_files()` to
parse information from the pyproject.toml.
Signed-off-by: Vincent Fazio <vfazio@gmail.com>
---
bindings/python/build_tests.py | 6 ------
1 file changed, 6 deletions(-)
diff --git a/bindings/python/build_tests.py b/bindings/python/build_tests.py
index 6375b29..77e38ba 100644
--- a/bindings/python/build_tests.py
+++ b/bindings/python/build_tests.py
@@ -27,9 +27,6 @@ logging.configure()
TOP_SRCDIR = getenv("TOP_SRCDIR", "../../")
TOP_BUILDDIR = getenv("TOP_BUILDDIR", "../../")
-# __version__
-with open("gpiod/version.py", "r") as fd:
- exec(fd.read())
# The tests are run in-place with PYTHONPATH set to bindings/python
# so we need the gpiod extension module too.
@@ -72,10 +69,7 @@ system_ext = Extension(
dist = Distribution(
{
- "name": "gpiod",
"ext_modules": [gpiosim_ext, system_ext, gpiod_ext],
- "version": __version__,
- "platforms": ["linux"],
}
)
--
2.43.0
^ permalink raw reply related [flat|nested] 16+ messages in thread* [libgpiod][PATCH 3/9] bindings: python: setup: add type annotations
2026-04-01 0:14 [libgpiod][PATCH 1/9] bindings: python: build_tests: do not fallback to distutils Vincent Fazio
2026-04-01 0:14 ` [libgpiod][PATCH 2/9] bindings: python: build_tests: simplify the Distribution Vincent Fazio
@ 2026-04-01 0:14 ` Vincent Fazio
2026-04-01 0:14 ` [libgpiod][PATCH 4/9] bindings: python: setup: apply linter recommendations Vincent Fazio
` (6 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Vincent Fazio @ 2026-04-01 0:14 UTC (permalink / raw)
To: linux-gpio; +Cc: Vincent Fazio
Add type annotations to help with lint checks.
Signed-off-by: Vincent Fazio <vfazio@gmail.com>
---
bindings/python/setup.py | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/bindings/python/setup.py b/bindings/python/setup.py
index 7bf9246..4061328 100644
--- a/bindings/python/setup.py
+++ b/bindings/python/setup.py
@@ -1,8 +1,10 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
+from collections.abc import Callable
from os import getenv, path, unlink
from shutil import copy, copytree, rmtree
+from typing import TypeVar
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext as orig_build_ext
@@ -10,6 +12,8 @@ from setuptools.command.sdist import log
from setuptools.command.sdist import sdist as orig_sdist
from setuptools.errors import BaseError
+T = TypeVar("T", "sdist", "build_ext")
+
LINK_SYSTEM_LIBGPIOD = getenv("LINK_SYSTEM_LIBGPIOD") == "1"
LIBGPIOD_MINIMUM_VERSION = "2.1"
LIBGPIOD_VERSION = getenv("LIBGPIOD_VERSION")
@@ -20,7 +24,7 @@ SHA256_CHUNK_SIZE = 2048
LICENSE_FILE = "LICENSE"
-def sha256(filename):
+def sha256(filename: str) -> str:
"""
Return a sha256sum for a specific filename, loading the file in chunks
to avoid potentially excessive memory use.
@@ -35,7 +39,7 @@ def sha256(filename):
return sha256sum.hexdigest()
-def find_sha256sum(asc_file, tar_filename):
+def find_sha256sum(asc_file: str, tar_filename: str) -> str:
"""
Search through a local copy of sha256sums.asc for a specific filename
and return the associated sha256 sum.
@@ -49,7 +53,7 @@ def find_sha256sum(asc_file, tar_filename):
raise BaseError(f"no signature found for {tar_filename}")
-def fetch_tarball(command):
+def fetch_tarball(func: Callable[[T], None]) -> Callable[[T], None]:
"""
Verify the requested LIBGPIOD_VERSION tarball exists in sha256sums.asc,
fetch it from https://mirrors.edge.kernel.org/pub/software/libs/libgpiod/
@@ -61,10 +65,10 @@ def fetch_tarball(command):
# If no LIBGPIOD_VERSION is specified in env, just run the command
if LIBGPIOD_VERSION is None:
- return command
+ return func
# If LIBGPIOD_VERSION is specified, apply the tarball wrapper
- def wrapper(self):
+ def wrapper(cmd: T) -> None:
# Just-in-time import of tarfile and urllib.request so these are
# not required for Yocto to build a vendored or linked package
import sys
@@ -83,7 +87,7 @@ def fetch_tarball(command):
try:
if open("libgpiod-version.txt", "r").read() == LIBGPIOD_VERSION:
log.info(f"skipping tarball fetch")
- command(self)
+ func(cmd)
return
except OSError:
pass
@@ -175,13 +179,13 @@ def fetch_tarball(command):
# For further details, see `egg_info.find_sources` and
# `manifest_maker.add_license_files`
copy(_path, LICENSE_FILE)
- self.distribution.metadata.license_files = [LICENSE_FILE]
+ cmd.distribution.metadata.license_files = [LICENSE_FILE] # type: ignore[attr-defined]
# Save the libgpiod version for sdist
open("libgpiod-version.txt", "w").write(LIBGPIOD_VERSION)
# Run the command
- command(self)
+ func(cmd)
# Clean up the build directory
if path.exists(LICENSE_FILE):
@@ -206,8 +210,9 @@ class build_ext(orig_build_ext):
"""
@fetch_tarball
- def run(self):
+ def run(self) -> None:
# Try to get the gpiod version from the .txt file included in sdist
+ libgpiod_version: str | None
try:
libgpiod_version = open("libgpiod-version.txt", "r").read()
except OSError:
@@ -251,7 +256,7 @@ class sdist(orig_sdist):
"""
@fetch_tarball
- def run(self):
+ def run(self) -> None:
super().run()
--
2.43.0
^ permalink raw reply related [flat|nested] 16+ messages in thread* [libgpiod][PATCH 4/9] bindings: python: setup: apply linter recommendations
2026-04-01 0:14 [libgpiod][PATCH 1/9] bindings: python: build_tests: do not fallback to distutils Vincent Fazio
2026-04-01 0:14 ` [libgpiod][PATCH 2/9] bindings: python: build_tests: simplify the Distribution Vincent Fazio
2026-04-01 0:14 ` [libgpiod][PATCH 3/9] bindings: python: setup: add type annotations Vincent Fazio
@ 2026-04-01 0:14 ` Vincent Fazio
2026-04-01 0:14 ` [libgpiod][PATCH 5/9] bindings: python: setup: use logging module Vincent Fazio
` (5 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Vincent Fazio @ 2026-04-01 0:14 UTC (permalink / raw)
To: linux-gpio; +Cc: Vincent Fazio
* Drop unneeded mode parameters
* Cast toml parsing result to dict[str, str] for expected license value
* Disambiguate the `line` variable type for parsing the .asc file
Signed-off-by: Vincent Fazio <vfazio@gmail.com>
---
bindings/python/setup.py | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/bindings/python/setup.py b/bindings/python/setup.py
index 4061328..5f5950e 100644
--- a/bindings/python/setup.py
+++ b/bindings/python/setup.py
@@ -4,7 +4,7 @@
from collections.abc import Callable
from os import getenv, path, unlink
from shutil import copy, copytree, rmtree
-from typing import TypeVar
+from typing import TypeVar, cast
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext as orig_build_ext
@@ -44,11 +44,11 @@ def find_sha256sum(asc_file: str, tar_filename: str) -> str:
Search through a local copy of sha256sums.asc for a specific filename
and return the associated sha256 sum.
"""
- with open(asc_file, "r") as f:
+ with open(asc_file) as f:
for line in f:
- line = line.strip().split(" ")
- if len(line) == 2 and line[1] == tar_filename:
- return line[0]
+ _line = line.strip().split(" ")
+ if len(_line) == 2 and _line[1] == tar_filename:
+ return _line[0]
raise BaseError(f"no signature found for {tar_filename}")
@@ -85,8 +85,8 @@ def fetch_tarball(func: Callable[[T], None]) -> Callable[[T], None]:
# If the version in "libgpiod-version.txt" already matches our
# requested tarball, then skip the fetch altogether.
try:
- if open("libgpiod-version.txt", "r").read() == LIBGPIOD_VERSION:
- log.info(f"skipping tarball fetch")
+ if open("libgpiod-version.txt").read() == LIBGPIOD_VERSION:
+ log.info("skipping tarball fetch")
func(cmd)
return
except OSError:
@@ -161,7 +161,8 @@ def fetch_tarball(func: Callable[[T], None]) -> Callable[[T], None]:
if sys.version_info >= (3, 11):
import tomllib
- license_file = tomllib.load(f).get("project").get("license")
+ project = cast("dict[str,str]", tomllib.load(f).get("project"))
+ license_file = project.get("license")
else: # tomllib isn't standard, fall back to parsing by line
for line in f.readlines():
_line = line.decode()
@@ -214,7 +215,7 @@ class build_ext(orig_build_ext):
# Try to get the gpiod version from the .txt file included in sdist
libgpiod_version: str | None
try:
- libgpiod_version = open("libgpiod-version.txt", "r").read()
+ libgpiod_version = open("libgpiod-version.txt").read()
except OSError:
libgpiod_version = LIBGPIOD_VERSION
--
2.43.0
^ permalink raw reply related [flat|nested] 16+ messages in thread* [libgpiod][PATCH 5/9] bindings: python: setup: use logging module
2026-04-01 0:14 [libgpiod][PATCH 1/9] bindings: python: build_tests: do not fallback to distutils Vincent Fazio
` (2 preceding siblings ...)
2026-04-01 0:14 ` [libgpiod][PATCH 4/9] bindings: python: setup: apply linter recommendations Vincent Fazio
@ 2026-04-01 0:14 ` Vincent Fazio
2026-04-01 0:14 ` [libgpiod][PATCH 6/9] bindings: python: examples: add type annotations Vincent Fazio
` (4 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Vincent Fazio @ 2026-04-01 0:14 UTC (permalink / raw)
To: linux-gpio; +Cc: Vincent Fazio
Use the `logging` module to conform to setuptools' recommendations [0].
[0]: https://setuptools.pypa.io/en/latest/deprecated/distutils-legacy.html#prefer-setuptools
Signed-off-by: Vincent Fazio <vfazio@gmail.com>
---
bindings/python/setup.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/bindings/python/setup.py b/bindings/python/setup.py
index 5f5950e..cd50a8c 100644
--- a/bindings/python/setup.py
+++ b/bindings/python/setup.py
@@ -2,18 +2,20 @@
# SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <brgl@bgdev.pl>
from collections.abc import Callable
+from logging import getLogger
from os import getenv, path, unlink
from shutil import copy, copytree, rmtree
from typing import TypeVar, cast
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext as orig_build_ext
-from setuptools.command.sdist import log
from setuptools.command.sdist import sdist as orig_sdist
from setuptools.errors import BaseError
T = TypeVar("T", "sdist", "build_ext")
+log = getLogger(__name__)
+
LINK_SYSTEM_LIBGPIOD = getenv("LINK_SYSTEM_LIBGPIOD") == "1"
LIBGPIOD_MINIMUM_VERSION = "2.1"
LIBGPIOD_VERSION = getenv("LIBGPIOD_VERSION")
--
2.43.0
^ permalink raw reply related [flat|nested] 16+ messages in thread* [libgpiod][PATCH 6/9] bindings: python: examples: add type annotations
2026-04-01 0:14 [libgpiod][PATCH 1/9] bindings: python: build_tests: do not fallback to distutils Vincent Fazio
` (3 preceding siblings ...)
2026-04-01 0:14 ` [libgpiod][PATCH 5/9] bindings: python: setup: use logging module Vincent Fazio
@ 2026-04-01 0:14 ` Vincent Fazio
2026-04-01 0:14 ` [libgpiod][PATCH 7/9] bindings: python: examples: apply linter recommendations Vincent Fazio
` (3 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Vincent Fazio @ 2026-04-01 0:14 UTC (permalink / raw)
To: linux-gpio; +Cc: Vincent Fazio
Add type annotations to help with lint checks.
Signed-off-by: Vincent Fazio <vfazio@gmail.com>
---
bindings/python/examples/async_watch_line_value.py | 8 +++++---
bindings/python/examples/find_line_by_name.py | 5 +++--
bindings/python/examples/get_chip_info.py | 2 +-
bindings/python/examples/get_line_info.py | 2 +-
bindings/python/examples/get_line_value.py | 2 +-
bindings/python/examples/get_multiple_line_values.py | 4 +++-
bindings/python/examples/reconfigure_input_to_output.py | 2 +-
bindings/python/examples/toggle_line_value.py | 4 ++--
bindings/python/examples/toggle_multiple_line_values.py | 6 ++++--
bindings/python/examples/watch_line_info.py | 4 +++-
bindings/python/examples/watch_line_rising.py | 2 +-
bindings/python/examples/watch_line_value.py | 5 +++--
bindings/python/examples/watch_multiple_line_values.py | 8 +++++---
13 files changed, 33 insertions(+), 21 deletions(-)
diff --git a/bindings/python/examples/async_watch_line_value.py b/bindings/python/examples/async_watch_line_value.py
index ec42e04..640a4c5 100755
--- a/bindings/python/examples/async_watch_line_value.py
+++ b/bindings/python/examples/async_watch_line_value.py
@@ -8,10 +8,12 @@ import gpiod
import select
from datetime import timedelta
+
+from gpiod.edge_event import EdgeEvent
from gpiod.line import Bias, Edge
-def edge_type_str(event):
+def edge_type_str(event: EdgeEvent) -> str:
if event.event_type is event.Type.RISING_EDGE:
return "Rising"
if event.event_type is event.Type.FALLING_EDGE:
@@ -19,7 +21,7 @@ def edge_type_str(event):
return "Unknown"
-def async_watch_line_value(chip_path, line_offset, done_fd):
+def async_watch_line_value(chip_path: str, line_offset: int, done_fd: int) -> None:
# Assume a button connecting the pin to ground,
# so pull it up and provide some debounce.
with gpiod.request_lines(
@@ -59,7 +61,7 @@ if __name__ == "__main__":
# run the async executor (select.poll) in a thread to demonstrate a graceful exit.
done_fd = os.eventfd(0)
- def bg_thread():
+ def bg_thread() -> None:
try:
async_watch_line_value("/dev/gpiochip0", 5, done_fd)
except OSError as ex:
diff --git a/bindings/python/examples/find_line_by_name.py b/bindings/python/examples/find_line_by_name.py
index ac798a9..4ed3848 100755
--- a/bindings/python/examples/find_line_by_name.py
+++ b/bindings/python/examples/find_line_by_name.py
@@ -6,15 +6,16 @@
import gpiod
import os
+from collections.abc import Generator
-def generate_gpio_chips():
+def generate_gpio_chips() -> Generator[str]:
for entry in os.scandir("/dev/"):
if gpiod.is_gpiochip_device(entry.path):
yield entry.path
-def find_line_by_name(line_name):
+def find_line_by_name(line_name: str) -> None:
# Names are not guaranteed unique, so this finds the first line with
# the given name.
for path in generate_gpio_chips():
diff --git a/bindings/python/examples/get_chip_info.py b/bindings/python/examples/get_chip_info.py
index 7dc76fb..037e424 100755
--- a/bindings/python/examples/get_chip_info.py
+++ b/bindings/python/examples/get_chip_info.py
@@ -7,7 +7,7 @@
import gpiod
-def get_chip_info(chip_path):
+def get_chip_info(chip_path: str) -> None:
with gpiod.Chip(chip_path) as chip:
info = chip.get_info()
print("{} [{}] ({} lines)".format(info.name, info.label, info.num_lines))
diff --git a/bindings/python/examples/get_line_info.py b/bindings/python/examples/get_line_info.py
index cd4ebcc..8e7283e 100755
--- a/bindings/python/examples/get_line_info.py
+++ b/bindings/python/examples/get_line_info.py
@@ -7,7 +7,7 @@
import gpiod
-def get_line_info(chip_path, line_offset):
+def get_line_info(chip_path: str, line_offset: int) -> None:
with gpiod.Chip(chip_path) as chip:
info = chip.get_line_info(line_offset)
is_input = info.direction == gpiod.line.Direction.INPUT
diff --git a/bindings/python/examples/get_line_value.py b/bindings/python/examples/get_line_value.py
index f3ca13b..5ca952b 100755
--- a/bindings/python/examples/get_line_value.py
+++ b/bindings/python/examples/get_line_value.py
@@ -9,7 +9,7 @@ import gpiod
from gpiod.line import Direction
-def get_line_value(chip_path, line_offset):
+def get_line_value(chip_path: str, line_offset: int) -> None:
with gpiod.request_lines(
chip_path,
consumer="get-line-value",
diff --git a/bindings/python/examples/get_multiple_line_values.py b/bindings/python/examples/get_multiple_line_values.py
index 46cf0b2..f70369f 100755
--- a/bindings/python/examples/get_multiple_line_values.py
+++ b/bindings/python/examples/get_multiple_line_values.py
@@ -4,12 +4,14 @@
"""Minimal example of reading multiple lines."""
+from collections.abc import Iterable
+
import gpiod
from gpiod.line import Direction
-def get_multiple_line_values(chip_path, line_offsets):
+def get_multiple_line_values(chip_path: str, line_offsets: Iterable[int]) -> None:
with gpiod.request_lines(
chip_path,
consumer="get-multiple-line-values",
diff --git a/bindings/python/examples/reconfigure_input_to_output.py b/bindings/python/examples/reconfigure_input_to_output.py
index 0f2e358..feb5f0b 100755
--- a/bindings/python/examples/reconfigure_input_to_output.py
+++ b/bindings/python/examples/reconfigure_input_to_output.py
@@ -9,7 +9,7 @@ import gpiod
from gpiod.line import Direction, Value
-def reconfigure_input_to_output(chip_path, line_offset):
+def reconfigure_input_to_output(chip_path: str, line_offset: int) -> None:
# request the line initially as an input
with gpiod.request_lines(
chip_path,
diff --git a/bindings/python/examples/toggle_line_value.py b/bindings/python/examples/toggle_line_value.py
index e0de8fb..bc948de 100755
--- a/bindings/python/examples/toggle_line_value.py
+++ b/bindings/python/examples/toggle_line_value.py
@@ -10,13 +10,13 @@ import time
from gpiod.line import Direction, Value
-def toggle_value(value):
+def toggle_value(value: Value) -> Value:
if value == Value.INACTIVE:
return Value.ACTIVE
return Value.INACTIVE
-def toggle_line_value(chip_path, line_offset):
+def toggle_line_value(chip_path: str, line_offset: int) -> None:
value_str = {Value.ACTIVE: "Active", Value.INACTIVE: "Inactive"}
value = Value.ACTIVE
diff --git a/bindings/python/examples/toggle_multiple_line_values.py b/bindings/python/examples/toggle_multiple_line_values.py
index 12b968d..74ff587 100755
--- a/bindings/python/examples/toggle_multiple_line_values.py
+++ b/bindings/python/examples/toggle_multiple_line_values.py
@@ -10,13 +10,15 @@ import time
from gpiod.line import Direction, Value
-def toggle_value(value):
+def toggle_value(value: Value) -> Value:
if value == Value.INACTIVE:
return Value.ACTIVE
return Value.INACTIVE
-def toggle_multiple_line_values(chip_path, line_values):
+def toggle_multiple_line_values(
+ chip_path: str, line_values: dict[int | str, Value]
+) -> None:
value_str = {Value.ACTIVE: "Active", Value.INACTIVE: "Inactive"}
request = gpiod.request_lines(
diff --git a/bindings/python/examples/watch_line_info.py b/bindings/python/examples/watch_line_info.py
index e49a669..8ae5ac0 100755
--- a/bindings/python/examples/watch_line_info.py
+++ b/bindings/python/examples/watch_line_info.py
@@ -4,10 +4,12 @@
"""Minimal example of watching for info changes on particular lines."""
+from collections.abc import Iterable
+
import gpiod
-def watch_line_info(chip_path, line_offsets):
+def watch_line_info(chip_path: str, line_offsets: Iterable[int]) -> None:
with gpiod.Chip(chip_path) as chip:
for offset in line_offsets:
chip.watch_line_info(offset)
diff --git a/bindings/python/examples/watch_line_rising.py b/bindings/python/examples/watch_line_rising.py
index 7b1c6b0..2f7f25f 100755
--- a/bindings/python/examples/watch_line_rising.py
+++ b/bindings/python/examples/watch_line_rising.py
@@ -9,7 +9,7 @@ import gpiod
from gpiod.line import Edge
-def watch_line_rising(chip_path, line_offset):
+def watch_line_rising(chip_path: str, line_offset: int) -> None:
with gpiod.request_lines(
chip_path,
consumer="watch-line-rising",
diff --git a/bindings/python/examples/watch_line_value.py b/bindings/python/examples/watch_line_value.py
index 171a67c..9b84d29 100755
--- a/bindings/python/examples/watch_line_value.py
+++ b/bindings/python/examples/watch_line_value.py
@@ -7,10 +7,11 @@
import gpiod
from datetime import timedelta
+from gpiod.edge_event import EdgeEvent
from gpiod.line import Bias, Edge
-def edge_type_str(event):
+def edge_type_str(event: EdgeEvent) -> str:
if event.event_type is event.Type.RISING_EDGE:
return "Rising"
if event.event_type is event.Type.FALLING_EDGE:
@@ -18,7 +19,7 @@ def edge_type_str(event):
return "Unknown"
-def watch_line_value(chip_path, line_offset):
+def watch_line_value(chip_path: str, line_offset: int) -> None:
# Assume a button connecting the pin to ground,
# so pull it up and provide some debounce.
with gpiod.request_lines(
diff --git a/bindings/python/examples/watch_multiple_line_values.py b/bindings/python/examples/watch_multiple_line_values.py
index 5906b7d..d0ee35a 100755
--- a/bindings/python/examples/watch_multiple_line_values.py
+++ b/bindings/python/examples/watch_multiple_line_values.py
@@ -4,12 +4,14 @@
"""Minimal example of watching for edges on multiple lines."""
-import gpiod
+from collections.abc import Iterable
+import gpiod
+from gpiod.edge_event import EdgeEvent
from gpiod.line import Edge
-def edge_type_str(event):
+def edge_type_str(event: EdgeEvent) -> str:
if event.event_type is event.Type.RISING_EDGE:
return "Rising"
if event.event_type is event.Type.FALLING_EDGE:
@@ -17,7 +19,7 @@ def edge_type_str(event):
return "Unknown"
-def watch_multiple_line_values(chip_path, line_offsets):
+def watch_multiple_line_values(chip_path: str, line_offsets: Iterable[int]) -> None:
with gpiod.request_lines(
chip_path,
consumer="watch-multiple-line-values",
--
2.43.0
^ permalink raw reply related [flat|nested] 16+ messages in thread* [libgpiod][PATCH 7/9] bindings: python: examples: apply linter recommendations
2026-04-01 0:14 [libgpiod][PATCH 1/9] bindings: python: build_tests: do not fallback to distutils Vincent Fazio
` (4 preceding siblings ...)
2026-04-01 0:14 ` [libgpiod][PATCH 6/9] bindings: python: examples: add type annotations Vincent Fazio
@ 2026-04-01 0:14 ` Vincent Fazio
2026-04-01 0:14 ` [libgpiod][PATCH 8/9] bindings: python: add a lint dependency group Vincent Fazio
` (2 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Vincent Fazio @ 2026-04-01 0:14 UTC (permalink / raw)
To: linux-gpio; +Cc: Vincent Fazio
* Sort imports
* Use f-strings where possible
* Remove usage of `tuple` for config key values
Signed-off-by: Vincent Fazio <vfazio@gmail.com>
---
bindings/python/examples/async_watch_line_value.py | 9 ++++-----
bindings/python/examples/find_line_by_name.py | 7 ++++---
bindings/python/examples/get_chip_info.py | 2 +-
bindings/python/examples/get_line_info.py | 12 +++++-------
bindings/python/examples/get_line_value.py | 3 +--
bindings/python/examples/get_multiple_line_values.py | 7 +++----
.../python/examples/reconfigure_input_to_output.py | 5 ++---
bindings/python/examples/toggle_line_value.py | 4 ++--
.../python/examples/toggle_multiple_line_values.py | 12 ++++--------
bindings/python/examples/watch_line_rising.py | 7 +++----
bindings/python/examples/watch_line_value.py | 10 +++++-----
.../python/examples/watch_multiple_line_values.py | 12 +++++-------
12 files changed, 39 insertions(+), 51 deletions(-)
diff --git a/bindings/python/examples/async_watch_line_value.py b/bindings/python/examples/async_watch_line_value.py
index 640a4c5..68c8b28 100755
--- a/bindings/python/examples/async_watch_line_value.py
+++ b/bindings/python/examples/async_watch_line_value.py
@@ -4,11 +4,10 @@
"""Minimal example of asynchronously watching for edges on a single line."""
-import gpiod
import select
-
from datetime import timedelta
+import gpiod
from gpiod.edge_event import EdgeEvent
from gpiod.line import Bias, Edge
@@ -48,9 +47,9 @@ def async_watch_line_value(chip_path: str, line_offset: int, done_fd: int) -> No
# handle any edge events
for event in request.read_edge_events():
print(
- "offset: {} type: {:<7} event #{}".format(
- event.line_offset, edge_type_str(event), event.line_seqno
- )
+ f"offset: {event.line_offset}"
+ f" type: {edge_type_str(event):<7}"
+ f" event #{event.line_seqno}"
)
diff --git a/bindings/python/examples/find_line_by_name.py b/bindings/python/examples/find_line_by_name.py
index 4ed3848..9523c1c 100755
--- a/bindings/python/examples/find_line_by_name.py
+++ b/bindings/python/examples/find_line_by_name.py
@@ -4,10 +4,11 @@
"""Minimal example of finding a line with the given name."""
-import gpiod
import os
from collections.abc import Generator
+import gpiod
+
def generate_gpio_chips() -> Generator[str]:
for entry in os.scandir("/dev/"):
@@ -22,13 +23,13 @@ def find_line_by_name(line_name: str) -> None:
with gpiod.Chip(path) as chip:
try:
offset = chip.line_offset_from_id(line_name)
- print("{}: {} {}".format(line_name, chip.get_info().name, offset))
+ print(f"{line_name}: {chip.get_info().name} {offset}")
return
except OSError:
# An OSError is raised if the name is not found.
continue
- print("line '{}' not found".format(line_name))
+ print(f"line '{line_name}' not found")
if __name__ == "__main__":
diff --git a/bindings/python/examples/get_chip_info.py b/bindings/python/examples/get_chip_info.py
index 037e424..addad5c 100755
--- a/bindings/python/examples/get_chip_info.py
+++ b/bindings/python/examples/get_chip_info.py
@@ -10,7 +10,7 @@ import gpiod
def get_chip_info(chip_path: str) -> None:
with gpiod.Chip(chip_path) as chip:
info = chip.get_info()
- print("{} [{}] ({} lines)".format(info.name, info.label, info.num_lines))
+ print(f"{info.name} [{info.label}] ({info.num_lines} lines)")
if __name__ == "__main__":
diff --git a/bindings/python/examples/get_line_info.py b/bindings/python/examples/get_line_info.py
index 8e7283e..4d9ba76 100755
--- a/bindings/python/examples/get_line_info.py
+++ b/bindings/python/examples/get_line_info.py
@@ -12,13 +12,11 @@ def get_line_info(chip_path: str, line_offset: int) -> None:
info = chip.get_line_info(line_offset)
is_input = info.direction == gpiod.line.Direction.INPUT
print(
- "line {:>3}: {:>12} {:>12} {:>8} {:>10}".format(
- info.offset,
- info.name or "unnamed",
- info.consumer or "unused",
- "input" if is_input else "output",
- "active-low" if info.active_low else "active-high",
- )
+ f"line {info.offset:>3}:"
+ f" {info.name or 'unnamed':>12}"
+ f" {info.consumer or 'unused':>12}"
+ f" {'input' if is_input else 'output':>8}"
+ f" {'active-low' if info.active_low else 'active-high':>10}"
)
diff --git a/bindings/python/examples/get_line_value.py b/bindings/python/examples/get_line_value.py
index 5ca952b..3984802 100755
--- a/bindings/python/examples/get_line_value.py
+++ b/bindings/python/examples/get_line_value.py
@@ -5,7 +5,6 @@
"""Minimal example of reading a single line."""
import gpiod
-
from gpiod.line import Direction
@@ -16,7 +15,7 @@ def get_line_value(chip_path: str, line_offset: int) -> None:
config={line_offset: gpiod.LineSettings(direction=Direction.INPUT)},
) as request:
value = request.get_value(line_offset)
- print("{}={}".format(line_offset, value))
+ print(f"{line_offset}={value}")
if __name__ == "__main__":
diff --git a/bindings/python/examples/get_multiple_line_values.py b/bindings/python/examples/get_multiple_line_values.py
index f70369f..66148a3 100755
--- a/bindings/python/examples/get_multiple_line_values.py
+++ b/bindings/python/examples/get_multiple_line_values.py
@@ -7,7 +7,6 @@
from collections.abc import Iterable
import gpiod
-
from gpiod.line import Direction
@@ -15,12 +14,12 @@ def get_multiple_line_values(chip_path: str, line_offsets: Iterable[int]) -> Non
with gpiod.request_lines(
chip_path,
consumer="get-multiple-line-values",
- config={tuple(line_offsets): gpiod.LineSettings(direction=Direction.INPUT)},
+ config={line_offsets: gpiod.LineSettings(direction=Direction.INPUT)},
) as request:
vals = request.get_values()
- for offset, val in zip(line_offsets, vals):
- print("{}={} ".format(offset, val), end="")
+ for offset, val in zip(line_offsets, vals, strict=True):
+ print(f"{offset}={val} ", end="")
print()
diff --git a/bindings/python/examples/reconfigure_input_to_output.py b/bindings/python/examples/reconfigure_input_to_output.py
index feb5f0b..a2224e8 100755
--- a/bindings/python/examples/reconfigure_input_to_output.py
+++ b/bindings/python/examples/reconfigure_input_to_output.py
@@ -5,7 +5,6 @@
"""Example of a bi-directional line requested as input and then switched to output."""
import gpiod
-
from gpiod.line import Direction, Value
@@ -18,7 +17,7 @@ def reconfigure_input_to_output(chip_path: str, line_offset: int) -> None:
) as request:
# read the current line value
value = request.get_value(line_offset)
- print("{}={} (input)".format(line_offset, value))
+ print(f"{line_offset}={value} (input)")
# switch the line to an output and drive it low
request.reconfigure_lines(
config={
@@ -29,7 +28,7 @@ def reconfigure_input_to_output(chip_path: str, line_offset: int) -> None:
)
# report the current driven value
value = request.get_value(line_offset)
- print("{}={} (output)".format(line_offset, value))
+ print(f"{line_offset}={value} (output)")
if __name__ == "__main__":
diff --git a/bindings/python/examples/toggle_line_value.py b/bindings/python/examples/toggle_line_value.py
index bc948de..bfd1585 100755
--- a/bindings/python/examples/toggle_line_value.py
+++ b/bindings/python/examples/toggle_line_value.py
@@ -4,9 +4,9 @@
"""Minimal example of toggling a single line."""
-import gpiod
import time
+import gpiod
from gpiod.line import Direction, Value
@@ -30,7 +30,7 @@ def toggle_line_value(chip_path: str, line_offset: int) -> None:
},
) as request:
while True:
- print("{}={}".format(line_offset, value_str[value]))
+ print(f"{line_offset}={value_str[value]}")
time.sleep(1)
value = toggle_value(value)
request.set_value(line_offset, value)
diff --git a/bindings/python/examples/toggle_multiple_line_values.py b/bindings/python/examples/toggle_multiple_line_values.py
index 74ff587..8c973f8 100755
--- a/bindings/python/examples/toggle_multiple_line_values.py
+++ b/bindings/python/examples/toggle_multiple_line_values.py
@@ -4,9 +4,9 @@
"""Minimal example of toggling multiple lines."""
-import gpiod
import time
+import gpiod
from gpiod.line import Direction, Value
@@ -24,18 +24,14 @@ def toggle_multiple_line_values(
request = gpiod.request_lines(
chip_path,
consumer="toggle-multiple-line-values",
- config={
- tuple(line_values.keys()): gpiod.LineSettings(direction=Direction.OUTPUT)
- },
+ config={line_values.keys(): gpiod.LineSettings(direction=Direction.OUTPUT)},
output_values=line_values,
)
while True:
- print(
- " ".join("{}={}".format(l, value_str[v]) for (l, v) in line_values.items())
- )
+ print(" ".join(f"{l}={value_str[v]}" for (l, v) in line_values.items())) # noqa: E741
time.sleep(1)
- for l, v in line_values.items():
+ for l, v in line_values.items(): # noqa: E741
line_values[l] = toggle_value(v)
request.set_values(line_values)
diff --git a/bindings/python/examples/watch_line_rising.py b/bindings/python/examples/watch_line_rising.py
index 2f7f25f..59977c4 100755
--- a/bindings/python/examples/watch_line_rising.py
+++ b/bindings/python/examples/watch_line_rising.py
@@ -5,7 +5,6 @@
"""Minimal example of watching for rising edges on a single line."""
import gpiod
-
from gpiod.line import Edge
@@ -19,9 +18,9 @@ def watch_line_rising(chip_path: str, line_offset: int) -> None:
# Blocks until at least one event is available
for event in request.read_edge_events():
print(
- "line: {} type: Rising event #{}".format(
- event.line_offset, event.line_seqno
- )
+ f"line: {event.line_offset}"
+ " type: Rising"
+ f" event #{event.line_seqno}"
)
diff --git a/bindings/python/examples/watch_line_value.py b/bindings/python/examples/watch_line_value.py
index 9b84d29..3140ea2 100755
--- a/bindings/python/examples/watch_line_value.py
+++ b/bindings/python/examples/watch_line_value.py
@@ -4,9 +4,9 @@
"""Minimal example of watching for edges on a single line."""
-import gpiod
-
from datetime import timedelta
+
+import gpiod
from gpiod.edge_event import EdgeEvent
from gpiod.line import Bias, Edge
@@ -37,9 +37,9 @@ def watch_line_value(chip_path: str, line_offset: int) -> None:
# Blocks until at least one event is available
for event in request.read_edge_events():
print(
- "line: {} type: {:<7} event #{}".format(
- event.line_offset, edge_type_str(event), event.line_seqno
- )
+ f"line: {event.line_offset}"
+ f" type: {edge_type_str(event):<7}"
+ f" event #{event.line_seqno}"
)
diff --git a/bindings/python/examples/watch_multiple_line_values.py b/bindings/python/examples/watch_multiple_line_values.py
index d0ee35a..2c308bb 100755
--- a/bindings/python/examples/watch_multiple_line_values.py
+++ b/bindings/python/examples/watch_multiple_line_values.py
@@ -23,17 +23,15 @@ def watch_multiple_line_values(chip_path: str, line_offsets: Iterable[int]) -> N
with gpiod.request_lines(
chip_path,
consumer="watch-multiple-line-values",
- config={tuple(line_offsets): gpiod.LineSettings(edge_detection=Edge.BOTH)},
+ config={line_offsets: gpiod.LineSettings(edge_detection=Edge.BOTH)},
) as request:
while True:
for event in request.read_edge_events():
print(
- "offset: {} type: {:<7} event #{} line event #{}".format(
- event.line_offset,
- edge_type_str(event),
- event.global_seqno,
- event.line_seqno,
- )
+ f"offset: {event.line_offset}"
+ f" type: {edge_type_str(event):<7}"
+ f" event #{event.global_seqno}"
+ f" line event #{event.line_seqno}"
)
--
2.43.0
^ permalink raw reply related [flat|nested] 16+ messages in thread* [libgpiod][PATCH 8/9] bindings: python: add a lint dependency group
2026-04-01 0:14 [libgpiod][PATCH 1/9] bindings: python: build_tests: do not fallback to distutils Vincent Fazio
` (5 preceding siblings ...)
2026-04-01 0:14 ` [libgpiod][PATCH 7/9] bindings: python: examples: apply linter recommendations Vincent Fazio
@ 2026-04-01 0:14 ` Vincent Fazio
2026-04-01 0:14 ` [libgpiod][PATCH 9/9] bindings: python: update linter configuration Vincent Fazio
2026-04-03 9:01 ` [libgpiod][PATCH 1/9] bindings: python: build_tests: do not fallback to distutils Bartosz Golaszewski
8 siblings, 0 replies; 16+ messages in thread
From: Vincent Fazio @ 2026-04-01 0:14 UTC (permalink / raw)
To: linux-gpio; +Cc: Vincent Fazio
Specify useful dependencies for linting the bindings and related code.
The group can be installed with `pip install --group lint`.
As part of this group, specify version ranges for mypy and ruff to keep
linting consistent until new minimal versions of Python are targeted or
until the new annual style introduced by ruff is chosen.
Signed-off-by: Vincent Fazio <vfazio@gmail.com>
---
bindings/python/README.md | 4 +++-
bindings/python/pyproject.toml | 3 +++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/bindings/python/README.md b/bindings/python/README.md
index 89c824c..70428c0 100644
--- a/bindings/python/README.md
+++ b/bindings/python/README.md
@@ -120,10 +120,12 @@ When making changes, ensure type checks and linting still pass:
```
python3 -m venv venv
. venv/bin/activate
-pip install mypy ruff
+pip install --group lint
mypy; ruff format; ruff check
```
+Note that pip >=25.1 is necessary for `--group` support.
+
Ideally the gpiod library will continue to pass strict checks:
```
diff --git a/bindings/python/pyproject.toml b/bindings/python/pyproject.toml
index 9961f3c..3255e89 100644
--- a/bindings/python/pyproject.toml
+++ b/bindings/python/pyproject.toml
@@ -33,6 +33,9 @@ classifiers = [
Homepage = "https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git"
Issues = "https://github.com/brgl/libgpiod/issues/"
+[dependency-groups]
+lint = ["mypy>=1.18.1", "ruff~=0.15.0", "types-setuptools", "packaging"]
+
[tool.setuptools]
platforms = ["linux"]
include-package-data = false
--
2.43.0
^ permalink raw reply related [flat|nested] 16+ messages in thread* [libgpiod][PATCH 9/9] bindings: python: update linter configuration
2026-04-01 0:14 [libgpiod][PATCH 1/9] bindings: python: build_tests: do not fallback to distutils Vincent Fazio
` (6 preceding siblings ...)
2026-04-01 0:14 ` [libgpiod][PATCH 8/9] bindings: python: add a lint dependency group Vincent Fazio
@ 2026-04-01 0:14 ` Vincent Fazio
2026-04-02 14:37 ` Bartosz Golaszewski
2026-04-03 9:01 ` [libgpiod][PATCH 1/9] bindings: python: build_tests: do not fallback to distutils Bartosz Golaszewski
8 siblings, 1 reply; 16+ messages in thread
From: Vincent Fazio @ 2026-04-01 0:14 UTC (permalink / raw)
To: linux-gpio; +Cc: Vincent Fazio
Simplify linter configuration to check all files in the bindings
directory while excluding files in .gitignore.
With a minimum mypy version of 1.18.1, the `strict_equality` knob can
be removed as it was a work around a known issue [0] that is now fixed.
With a minimum ruff version of 15.x, rename the TCH check to TC since
it was renamed in v0.8.0 [1].
[0]: https://github.com/python/mypy/issues/10910
[1]: https://github.com/astral-sh/ruff/releases/tag/0.8.0
Signed-off-by: Vincent Fazio <vfazio@gmail.com>
---
bindings/python/pyproject.toml | 19 +++----------------
1 file changed, 3 insertions(+), 16 deletions(-)
diff --git a/bindings/python/pyproject.toml b/bindings/python/pyproject.toml
index 3255e89..98bb44c 100644
--- a/bindings/python/pyproject.toml
+++ b/bindings/python/pyproject.toml
@@ -49,26 +49,13 @@ namespaces = false
[tool.mypy]
python_version = "3.10"
+exclude_gitignore = true
files = [
- "gpiod/",
- "tests/",
-]
-
-[[tool.mypy.overrides]]
-module = "gpiod.line.*"
-strict_equality = false # Ignore Enum comparison-overlap: https://github.com/python/mypy/issues/17317
-
-[tool.ruff]
-target-version = "py310"
-include = [
- "gpiod/**/*.py",
- "gpiod/**/*.pyi",
- "tests/**/*.py",
- "tests/**/*.pyi",
+ ".",
]
[tool.ruff.lint]
-select = ["B", "E", "F", "I", "TCH", "UP"]
+select = ["B", "E", "F", "I", "TC", "UP"]
ignore=[
# Ignore chained exception warnings for now: https://docs.astral.sh/ruff/rules/raise-without-from-inside-except/
"B904",
--
2.43.0
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [libgpiod][PATCH 9/9] bindings: python: update linter configuration
2026-04-01 0:14 ` [libgpiod][PATCH 9/9] bindings: python: update linter configuration Vincent Fazio
@ 2026-04-02 14:37 ` Bartosz Golaszewski
2026-04-02 15:55 ` Vincent Fazio
0 siblings, 1 reply; 16+ messages in thread
From: Bartosz Golaszewski @ 2026-04-02 14:37 UTC (permalink / raw)
To: Vincent Fazio; +Cc: linux-gpio
On Wed, 1 Apr 2026 02:14:58 +0200, Vincent Fazio <vfazio@gmail.com> said:
> Simplify linter configuration to check all files in the bindings
> directory while excluding files in .gitignore.
>
> With a minimum mypy version of 1.18.1, the `strict_equality` knob can
> be removed as it was a work around a known issue [0] that is now fixed.
>
> With a minimum ruff version of 15.x, rename the TCH check to TC since
> it was renamed in v0.8.0 [1].
>
> [0]: https://github.com/python/mypy/issues/10910
> [1]: https://github.com/astral-sh/ruff/releases/tag/0.8.0
> Signed-off-by: Vincent Fazio <vfazio@gmail.com>
> ---
Ruff checks work fine but I'm seeing this with mypy:
$ mypy
build_tests.py:22: error: Library stubs not installed for "setuptools"
[import-untyped]
build_tests.py:23: error: Library stubs not installed for
"setuptools.command.build_ext" [import-untyped]
build_tests.py:23: note: Hint: "python3 -m pip install types-setuptools"
build_tests.py:23: note: (or run "mypy --install-types" to install all
missing stub packages)
build_tests.py:23: note: See
https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
setup.py:10: error: Library stubs not installed for "setuptools"
[import-untyped]
setup.py:11: error: Library stubs not installed for
"setuptools.command.build_ext" [import-untyped]
setup.py:12: error: Library stubs not installed for
"setuptools.command.sdist" [import-untyped]
setup.py:13: error: Library stubs not installed for
"setuptools.errors" [import-untyped]
Found 6 errors in 2 files (checked 45 source files)
I'm using mypy v1.20.0. Is this something with my environment?
Bart
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [libgpiod][PATCH 9/9] bindings: python: update linter configuration
2026-04-02 14:37 ` Bartosz Golaszewski
@ 2026-04-02 15:55 ` Vincent Fazio
2026-04-02 16:42 ` Bartosz Golaszewski
0 siblings, 1 reply; 16+ messages in thread
From: Vincent Fazio @ 2026-04-02 15:55 UTC (permalink / raw)
To: Bartosz Golaszewski; +Cc: linux-gpio
On Thu, Apr 2, 2026 at 9:37 AM Bartosz Golaszewski <brgl@kernel.org> wrote:
> Ruff checks work fine but I'm seeing this with mypy:
>
> $ mypy
> build_tests.py:22: error: Library stubs not installed for "setuptools"
> [import-untyped]
> build_tests.py:23: error: Library stubs not installed for
> "setuptools.command.build_ext" [import-untyped]
> build_tests.py:23: note: Hint: "python3 -m pip install types-setuptools"
> build_tests.py:23: note: (or run "mypy --install-types" to install all
> missing stub packages)
> build_tests.py:23: note: See
> https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
> setup.py:10: error: Library stubs not installed for "setuptools"
> [import-untyped]
> setup.py:11: error: Library stubs not installed for
> "setuptools.command.build_ext" [import-untyped]
> setup.py:12: error: Library stubs not installed for
> "setuptools.command.sdist" [import-untyped]
> setup.py:13: error: Library stubs not installed for
> "setuptools.errors" [import-untyped]
> Found 6 errors in 2 files (checked 45 source files)
>
> I'm using mypy v1.20.0. Is this something with my environment?
Yes, slightly. I guess maybe I didn't state it explicitly, but when I
added patch 8, I included a list of required dependencies for type
checking and called out the group in documentaiton:
https://lore.kernel.org/linux-gpio/20260401001459.19159-8-vfazio@gmail.com/T/#u
If you're running mypy from within a virtual environment, you'll need
to make sure that the dependencies in that group are installed for a
clean check and can use the dependency group to help with that.
If you're running mypy from the system level and outside of a virtual
environment, you will have to install the distribution packages that
provide the typing information.
My typical workflow for ensuring that linter checks pass:
* cd bindings/python
* python3 -m venv venv
* .venv/bin/activate
* pip install -U pip
* (now) pip install --group lint
* mypy --strict; ruff format; ruff check
Some repositories try to implement these checks as part of pre-commit
hooks but I wasn't sure if we wanted to go so far as requiring these
checks
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [libgpiod][PATCH 9/9] bindings: python: update linter configuration
2026-04-02 15:55 ` Vincent Fazio
@ 2026-04-02 16:42 ` Bartosz Golaszewski
2026-04-02 17:01 ` Vincent Fazio
0 siblings, 1 reply; 16+ messages in thread
From: Bartosz Golaszewski @ 2026-04-02 16:42 UTC (permalink / raw)
To: Vincent Fazio; +Cc: linux-gpio
On Thu, Apr 2, 2026 at 5:55 PM Vincent Fazio <vfazio@gmail.com> wrote:
>
> My typical workflow for ensuring that linter checks pass:
> * cd bindings/python
> * python3 -m venv venv
> * .venv/bin/activate
> * pip install -U pip
> * (now) pip install --group lint
> * mypy --strict; ruff format; ruff check
>
Thanks, that works.
> Some repositories try to implement these checks as part of pre-commit
> hooks but I wasn't sure if we wanted to go so far as requiring these
> checks
How about making it part of the dist package generation?
Bart
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [libgpiod][PATCH 9/9] bindings: python: update linter configuration
2026-04-02 16:42 ` Bartosz Golaszewski
@ 2026-04-02 17:01 ` Vincent Fazio
2026-04-03 9:02 ` Bartosz Golaszewski
0 siblings, 1 reply; 16+ messages in thread
From: Vincent Fazio @ 2026-04-02 17:01 UTC (permalink / raw)
To: Bartosz Golaszewski; +Cc: linux-gpio
On Thu, Apr 2, 2026 at 11:43 AM Bartosz Golaszewski <brgl@kernel.org> wrote:
> > Some repositories try to implement these checks as part of pre-commit
> > hooks but I wasn't sure if we wanted to go so far as requiring these
> > checks
>
> How about making it part of the dist package generation?
If you think it would be valuable, that seems reasonable? I don't know
what that entails however.
It may be "late" in the development flow, as in, at the time you want
to make a dist package, the lint checks now say that there are
suggested modifications or fixes necessary preventing you from
building the distribution.
Ideally the lint checks are done prior to patch submission to inform
users that they may have overlooked something.
It wouldn't surprise me if I'm the only one that really cares about
the strict type checking and formatting. They're obviously not
performing logic analysis; they just make sure that data types are
correct/accounted for and all code is consistent in format.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [libgpiod][PATCH 9/9] bindings: python: update linter configuration
2026-04-02 17:01 ` Vincent Fazio
@ 2026-04-03 9:02 ` Bartosz Golaszewski
2026-04-03 13:09 ` Vincent Fazio
0 siblings, 1 reply; 16+ messages in thread
From: Bartosz Golaszewski @ 2026-04-03 9:02 UTC (permalink / raw)
To: Vincent Fazio; +Cc: linux-gpio
On Thu, Apr 2, 2026 at 7:01 PM Vincent Fazio <vfazio@gmail.com> wrote:
>
> On Thu, Apr 2, 2026 at 11:43 AM Bartosz Golaszewski <brgl@kernel.org> wrote:
> > > Some repositories try to implement these checks as part of pre-commit
> > > hooks but I wasn't sure if we wanted to go so far as requiring these
> > > checks
> >
> > How about making it part of the dist package generation?
>
> If you think it would be valuable, that seems reasonable? I don't know
> what that entails however.
>
> It may be "late" in the development flow, as in, at the time you want
> to make a dist package, the lint checks now say that there are
> suggested modifications or fixes necessary preventing you from
> building the distribution.
>
> Ideally the lint checks are done prior to patch submission to inform
> users that they may have overlooked something.
>
> It wouldn't surprise me if I'm the only one that really cares about
> the strict type checking and formatting. They're obviously not
> performing logic analysis; they just make sure that data types are
> correct/accounted for and all code is consistent in format.
I do run them but don't necessarily want them as a commit hook since
not everyone is working on python side of libgpiod.
I queued the patches, thanks! I have to say: it's crazy how much
faster ruff is compared to mypy.
Bartosz
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [libgpiod][PATCH 1/9] bindings: python: build_tests: do not fallback to distutils
2026-04-01 0:14 [libgpiod][PATCH 1/9] bindings: python: build_tests: do not fallback to distutils Vincent Fazio
` (7 preceding siblings ...)
2026-04-01 0:14 ` [libgpiod][PATCH 9/9] bindings: python: update linter configuration Vincent Fazio
@ 2026-04-03 9:01 ` Bartosz Golaszewski
8 siblings, 0 replies; 16+ messages in thread
From: Bartosz Golaszewski @ 2026-04-03 9:01 UTC (permalink / raw)
To: linux-gpio, Vincent Fazio; +Cc: Bartosz Golaszewski
On Tue, 31 Mar 2026 19:14:50 -0500, Vincent Fazio wrote:
> Make the assumption that the build host has setuptools>=60.2.0 which
> exposes the logging module and remove references to distutils.
>
> This conforms to setuptools' logging recommendation [0].
>
> [0]: https://setuptools.pypa.io/en/latest/deprecated/distutils-legacy.html#prefer-setuptools
>
> [...]
Applied, thanks!
[1/9] bindings: python: build_tests: do not fallback to distutils
https://git.kernel.org/brgl/c/f53d6c882553198593d63e10af93ff6bbcb8a823
[2/9] bindings: python: build_tests: simplify the Distribution
https://git.kernel.org/brgl/c/ddca805d92001eaaeaa86540211056f17ea0df3f
[3/9] bindings: python: setup: add type annotations
https://git.kernel.org/brgl/c/0bb990a59eef3191d7c1ed6a7254f935568f8b84
[4/9] bindings: python: setup: apply linter recommendations
https://git.kernel.org/brgl/c/49843b8c701f7c61674912875e0dc2cb5bdb4186
[5/9] bindings: python: setup: use logging module
https://git.kernel.org/brgl/c/0c466480e7791834c15458ae87cbd21fc6d608e4
[6/9] bindings: python: examples: add type annotations
https://git.kernel.org/brgl/c/d130ec7666e3a5871f6b7aa261b7a305397ea28e
[7/9] bindings: python: examples: apply linter recommendations
https://git.kernel.org/brgl/c/485b81cd4bd5f8e9450c4587ff4a06ebae209962
[8/9] bindings: python: add a lint dependency group
https://git.kernel.org/brgl/c/5efa9e8144dafa47b0ddf9366e149ddee50b6211
[9/9] bindings: python: update linter configuration
https://git.kernel.org/brgl/c/530fa7823b12f91cf64bc1a9b755857049d5c2e5
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 16+ messages in thread