bindings: python: add type hints for Chip's internal members
authorVincent Fazio <vfazio@xes-inc.com>
Thu, 14 Nov 2024 14:51:01 +0000 (08:51 -0600)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Tue, 19 Nov 2024 14:21:01 +0000 (15:21 +0100)
Add type hints for Chip's internal members so type checkers can ensure
the code properly constrains to these types and accounts for scenarios
where the values are `None`.

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

index bf38c7f4210ced9c12529321c67c84e392bf3736..69ea777fa27bb4fa45b57be14727241eb24dd887 100644 (file)
@@ -61,8 +61,8 @@ class Chip:
           path:
             Path to the GPIO character device file.
         """
-        self._chip = _ext.Chip(path)
-        self._info = None
+        self._chip: Union[_ext.Chip, None] = _ext.Chip(path)
+        self._info: Union[ChipInfo, None] = None
 
     def __bool__(self) -> bool:
         """