]> Repositories - hackapet/Adafruit_Blinka_Displayio.git/commitdiff
Fix stuff from review
authorMelissa LeBlanc-Williams <melissa@adafruit.com>
Sat, 18 Dec 2021 19:03:36 +0000 (11:03 -0800)
committerMelissa LeBlanc-Williams <melissa@adafruit.com>
Sat, 18 Dec 2021 19:03:36 +0000 (11:03 -0800)
_typing.py
displayio/_epaperdisplay.py
displayio/_group.py

index fb3bac0cb9c457848aa22e9bf665aa2b41c02097..85cb393de05cc18c0f34e5f6d057600702dd13fb 100644 (file)
@@ -17,13 +17,12 @@ Type aliases for Blinka
 
 """
 
+from typing import Union
 
 __version__ = "0.0.0-auto.0"
 __repo__ = "https://github.com/adafruit/Adafruit_Blinka_Displayio.git"
 
 
-from typing import Union
-
 WriteableBuffer = Union[
     bytearray,
     memoryview,
index 2751c942edc3ec81c0ce58567e07177d6dfb2e86..29f8a54d840e9f1d7d08dfb991abe82be3616905 100644 (file)
@@ -62,10 +62,10 @@ class EPaperDisplay:
         color_bits_inverted: bool = False,
         highlight_color: int = 0x000000,
         refresh_display_command: int,
-        refresh_time: float = 40,
+        refresh_time: float = 40.0,
         busy_pin: Optional[microcontroller.Pin] = None,
         busy_state: bool = True,
-        seconds_per_frame: float = 180,
+        seconds_per_frame: float = 180.0,
         always_toggle_chip_select: bool = False,
         grayscale: bool = False,
     ):
index abfe80795a5370460fbdecb4fe26256e16f26c14..6be7c6fb0974602d98e54a0becb6e1d1cd83f018 100644 (file)
@@ -111,32 +111,36 @@ class Group:
         """
         return self._layers.index(layer)
 
-    def pop(self, index=-1) -> Union[Group, TileGrid]:
+    def pop(self, index: int = -1) -> Union[Group, TileGrid]:
         """Remove the ith item and return it."""
         self._removal_cleanup(index)
         return self._layers.pop(index)
 
-    def remove(self, layer) -> None:
+    def remove(self, layer: Union[Group, TileGrid]) -> None:
         """Remove the first copy of layer. Raises ValueError
         if it is not present."""
         index = self.index(layer)
         self._layers.pop(index)
 
+    def __bool__(self) -> bool:
+        """Returns if there are any layers"""
+        return len(self._layers) > 0
+
     def __len__(self) -> int:
         """Returns the number of layers in a Group"""
         return len(self._layers)
 
-    def __getitem__(self, index) -> Union[Group, TileGrid]:
+    def __getitem__(self, index: int) -> Union[Group, TileGrid]:
         """Returns the value at the given index."""
         return self._layers[index]
 
-    def __setitem__(self, index, value) -> None:
+    def __setitem__(self, index: int, value: Union[Group, TileGrid]) -> None:
         """Sets the value at the given index."""
         self._removal_cleanup(index)
         self._layers[index] = value
         self._layer_update(index)
 
-    def __delitem__(self, index) -> None:
+    def __delitem__(self, index: int) -> None:
         """Deletes the value at the given index."""
         del self._layers[index]
 
@@ -154,8 +158,8 @@ class Group:
 
     @property
     def hidden(self) -> bool:
-        """True when the Group and all of its layers are not visible. When False, the
-        Group’s layers are visible if they havent been hidden.
+        """True when the Group and all of it's layers are not visible. When False, the
+        Group’s layers are visible if they haven't been hidden.
         """
         return self._hidden_group