From: Vincent Fazio <vfazio@gmail.com>
To: linux-gpio@vger.kernel.org
Cc: Vincent Fazio <vfazio@gmail.com>
Subject: [libgpiod][PATCH 4/9] bindings: python: setup: apply linter recommendations
Date: Tue, 31 Mar 2026 19:14:53 -0500 [thread overview]
Message-ID: <20260401001459.19159-4-vfazio@gmail.com> (raw)
In-Reply-To: <20260401001459.19159-1-vfazio@gmail.com>
* 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
next prev parent reply other threads:[~2026-04-01 0:18 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2026-04-01 0:14 ` [libgpiod][PATCH 5/9] bindings: python: setup: use logging module Vincent Fazio
2026-04-01 0:14 ` [libgpiod][PATCH 6/9] bindings: python: examples: add type annotations Vincent Fazio
2026-04-01 0:14 ` [libgpiod][PATCH 7/9] bindings: python: examples: apply linter recommendations Vincent Fazio
2026-04-01 0:14 ` [libgpiod][PATCH 8/9] bindings: python: add a lint dependency group Vincent Fazio
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
2026-04-02 16:42 ` Bartosz Golaszewski
2026-04-02 17:01 ` Vincent Fazio
2026-04-03 9:02 ` Bartosz Golaszewski
2026-04-03 13:09 ` Vincent Fazio
2026-04-03 9:01 ` [libgpiod][PATCH 1/9] bindings: python: build_tests: do not fallback to distutils 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=20260401001459.19159-4-vfazio@gmail.com \
--to=vfazio@gmail.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.