bindings: python: cast return value of LineRequest.get_values
authorVincent Fazio <vfazio@xes-inc.com>
Thu, 14 Nov 2024 14:51:06 +0000 (08:51 -0600)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Tue, 19 Nov 2024 14:21:01 +0000 (15:21 +0100)
commitf3444341f4964b47f8e72f4ef697fad535d9dcc6
tree2fa63f5c9b63d881d21e8ea9c2393cfcdda78832
parentfcddb71b45e7bf7dde3eb0c6849acba7bc609462
bindings: python: cast return value of LineRequest.get_values

The `values` argument of `_ext.Request.get_values` uses a preallocated
`list[None]` as a buffer that is populated with `Value`s by the external
module that are then returned from the function.

Use `cast` to inform the type checker it's a `list[Value]` despite how
it's allocated.

Also, as `lines` is typed as an `Iterable`, there is no guarantee it has
a `__len__` method. Instead, use the size of the `offsets` array to
allocate the buffer.

Signed-off-by: Vincent Fazio <vfazio@xes-inc.com>
Link: https://lore.kernel.org/r/20241114145116.2123714-14-vfazio@xes-inc.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
bindings/python/gpiod/line_request.py