All of lore.kernel.org
 help / color / mirror / Atom feed
* [libgpiod][PATCH v2 09/14] bindings: python: chip: use literals for dict/list and declare types
@ 2026-10-24 20:00 Vincent Fazio
  2026-10-24 20:00 ` [libgpiod][PATCH v2 10/14] bindings: python: bump ruff linter dependency Vincent Fazio
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Vincent Fazio @ 2026-10-24 20:00 UTC (permalink / raw)
  To: linux-gpio; +Cc: brgl, Vincent Fazio

Per linter recommendation [0], use the literal form of the dict and list
constructors. The long form is not common in typical Python code so it
stays as readable for someone familiar with the short form syntax and it
has a very negligible performance benefit.

While making this change, specify type annotations for the collections
to reflect their contents so type checkers do not try to determine their
contents implicitly based on assignments.

[0]: https://docs.astral.sh/ruff/rules/unnecessary-collection-call/

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
---
Changes in v2:
- Reword commit message to provide better rationale (Bartosz)
---
 bindings/python/gpiod/chip.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/bindings/python/gpiod/chip.py b/bindings/python/gpiod/chip.py
index 8712b2b..94c432a 100644
--- a/bindings/python/gpiod/chip.py
+++ b/bindings/python/gpiod/chip.py
@@ -275,13 +275,13 @@ class Chip:
                 for line, value in output_values.items()
             }
 
-        name_map = dict()
-        requested_lines = list()
-        global_output_values = list()
-        seen_offsets = set()
+        name_map: dict[str, int] = {}
+        requested_lines: list[int | str] = []
+        global_output_values: list[Value] = []
+        seen_offsets: set[int] = set()
 
         for line, settings in config_iter(config):
-            offsets = list()
+            offsets: list[int] = []
 
             offset = self.line_offset_from_id(line)
             # don't allow offset repetitions or offset-name conflicts.
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-10-28  9:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [libgpiod][PATCH v2 10/14] bindings: python: bump ruff linter dependency Vincent Fazio
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

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.