Linux GPIO subsystem development
 help / color / mirror / Atom feed
From: Vincent Fazio <vfazio@gmail.com>
To: linux-gpio@vger.kernel.org
Cc: brgl@kernel.org, Vincent Fazio <vfazio@gmail.com>
Subject: [libgpiod][PATCH v2 10/14] bindings: python: bump ruff linter dependency
Date: Sat, 24 Oct 2026 15:00:44 -0500	[thread overview]
Message-ID: <20261024200048.25987-2-vfazio@gmail.com> (raw)
In-Reply-To: <20261024200048.25987-1-vfazio@gmail.com>

Bump ruff to the recently released 0.17. Most of the important changes
are from 0.16, but there were no incompatibilities found during testing.

Of note is the expansion of the default ruleset [0] which is now
leveraged over the previously selected rules and simplifies the tool
configuration section significantly.

Two things are explicitly disabled as part of this migration:

  * Formating of Python blocks in markdown files is disabled [1]
  * The typing-extensions flag is set to false since the bindings do not
    depend on this package [2] so appropriate lint rules get disabled

As part of this change:

  * Unused error suppression flags were removed from
    examples/toggle_multiple_line_values.py
  * tests/tests_line_requests.py was reformatted to bring it in line
    with the rest of the bindings
  * The `readlines` call in setup.py has FURB129 [3] suppressed since it
    only affects builds (edge case) on 3.10 (now EOL). When the minimal
    version is bumped to 3.11, the entire block will go away.

[0]: https://astral.sh/blog/ruff-v0.16.0#better-default-rule-set
[1]: https://docs.astral.sh/ruff/formatter/#markdown-code-formatting
[2]: https://docs.astral.sh/ruff/settings/#lint_typing-extensions
[3]: https://docs.astral.sh/ruff/rules/readlines-in-for/#readlines-in-for-furb129

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
---
 .../examples/toggle_multiple_line_values.py     |  4 ++--
 bindings/python/pyproject.toml                  | 17 ++++++-----------
 bindings/python/setup.py                        |  2 +-
 bindings/python/tests/tests_line_request.py     |  3 ++-
 4 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/bindings/python/examples/toggle_multiple_line_values.py b/bindings/python/examples/toggle_multiple_line_values.py
index 8c973f8..e5fbcd9 100755
--- a/bindings/python/examples/toggle_multiple_line_values.py
+++ b/bindings/python/examples/toggle_multiple_line_values.py
@@ -29,9 +29,9 @@ def toggle_multiple_line_values(
     )
 
     while True:
-        print(" ".join(f"{l}={value_str[v]}" for (l, v) in line_values.items()))  # noqa: E741
+        print(" ".join(f"{l}={value_str[v]}" for (l, v) in line_values.items()))
         time.sleep(1)
-        for l, v in line_values.items():  # noqa: E741
+        for l, v in line_values.items():
             line_values[l] = toggle_value(v)
         request.set_values(line_values)
 
diff --git a/bindings/python/pyproject.toml b/bindings/python/pyproject.toml
index 3337306..7d1c777 100644
--- a/bindings/python/pyproject.toml
+++ b/bindings/python/pyproject.toml
@@ -36,7 +36,7 @@ Issues = "https://github.com/brgl/libgpiod/issues/"
 Changelog = "https://github.com/brgl/libgpiod/blob/master/bindings/python/CHANGELOG.md"
 
 [dependency-groups]
-lint = ["mypy>=1.18.1", "ruff~=0.15.0", "types-setuptools", "packaging"]
+lint = ["mypy>=1.18.1", "ruff~=0.17.0", "types-setuptools", "packaging"]
 
 [tool.setuptools]
 platforms = ["linux"]
@@ -56,19 +56,14 @@ files = [
   ".",
 ]
 
+[tool.ruff]
+extend-exclude = ["*.md"]
+
 [tool.ruff.lint]
-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",
-  # Never enforce line length violations. Let the formatter handle it: https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
-  "E501",
-]
+typing-extensions = false
 
 [tool.ruff.lint.per-file-ignores]
-"gpiod/__init__.py" = ["F403", "F405"]  # ignore warnings about star imports
-"tests/__main__.py" = ["F403"]
-"tests/**.py" = ["F841"]  # ignore warnings about unused variables
+"tests/**.py" = ["F841", "SIM117"]  # ignore warnings about unused variables and chaining context managers
 
 [tool.cibuildwheel]
 build = "cp*"
diff --git a/bindings/python/setup.py b/bindings/python/setup.py
index 4297615..af922c8 100644
--- a/bindings/python/setup.py
+++ b/bindings/python/setup.py
@@ -167,7 +167,7 @@ def fetch_tarball(func: Callable[[T], None]) -> Callable[[T], None]:
                     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():
+                    for line in f.readlines():  # noqa: FURB129
                         _line = line.decode()
                         if _line.startswith("license = "):
                             license_file = _line.split("=")[1].strip(' \r\n"')
diff --git a/bindings/python/tests/tests_line_request.py b/bindings/python/tests/tests_line_request.py
index bc85eba..8e74490 100644
--- a/bindings/python/tests/tests_line_request.py
+++ b/bindings/python/tests/tests_line_request.py
@@ -692,7 +692,8 @@ class UsingMoreLinesThanRequestedNotAllowed(TestCase):
 
     def test_line_set_more_values_than_requested_lines(self) -> None:
         with gpiod.request_lines(
-            self.sim.dev_path, config={0: gpiod.LineSettings(direction=Direction.OUTPUT)}
+            self.sim.dev_path,
+            config={0: gpiod.LineSettings(direction=Direction.OUTPUT)},
         ) as req:
             with self.assertRaises(ValueError):
                 req.set_values({i: Value.ACTIVE for i in range(64)})
-- 
2.43.0


  reply	other threads:[~2026-10-24 20:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-24 20:00 [libgpiod][PATCH v2 09/14] bindings: python: chip: use literals for dict/list and declare types Vincent Fazio
2026-10-24 20:00 ` Vincent Fazio [this message]
2026-10-24 20:00 ` [libgpiod][PATCH v2 11/14] bindings: python: include Python.h before other headers Vincent Fazio
2026-10-24 20:00 ` [libgpiod][PATCH v2 12/14] bindings: python: advertise Python 3.15 support Vincent Fazio
2026-10-24 20:00 ` [libgpiod][PATCH v2 13/14] bindings: python: fix directory validation in artifact script Vincent Fazio
2026-10-24 20:00 ` [libgpiod][PATCH v2 14/14] bindings: python: bump dependencies " Vincent Fazio
2026-10-28  9:19 ` [libgpiod][PATCH v2 09/14] bindings: python: chip: use literals for dict/list and declare types Bartosz Golaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261024200048.25987-2-vfazio@gmail.com \
    --to=vfazio@gmail.com \
    --cc=brgl@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox