1818try :
1919 """Needed for type annotations"""
2020 from typing import Any , Union , Callable , Optional
21+ from typing_extensions import Literal
2122 from busio import SPI
2223 from digitalio import DigitalInOut
2324 from circuitpython_typing .pil import Image
@@ -247,7 +248,7 @@ def set_ram_address(self, x: int, y: int) -> None:
247248 """Set the RAM address location, must be implemented in subclass"""
248249 raise NotImplementedError ()
249250
250- def set_black_buffer (self , index : Union [0 , 1 ], inverted : bool ) -> None :
251+ def set_black_buffer (self , index : Literal [0 , 1 ], inverted : bool ) -> None :
251252 """Set the index for the black buffer data (0 or 1) and whether its inverted"""
252253 if index == 0 :
253254 self ._blackframebuf = self ._framebuf1
@@ -257,7 +258,7 @@ def set_black_buffer(self, index: Union[0, 1], inverted: bool) -> None:
257258 raise RuntimeError ("Buffer index must be 0 or 1" )
258259 self ._black_inverted = inverted
259260
260- def set_color_buffer (self , index : Union [0 , 1 ], inverted : bool ) -> None :
261+ def set_color_buffer (self , index : Literal [0 , 1 ], inverted : bool ) -> None :
261262 """Set the index for the color buffer data (0 or 1) and whether its inverted"""
262263 if index == 0 :
263264 self ._colorframebuf = self ._framebuf1
@@ -271,7 +272,7 @@ def _color_dup(
271272 self ,
272273 func : Callable ,
273274 args : Any ,
274- color : Union [0 , 1 , 2 , 3 , 4 , 5 ],
275+ color : Literal [0 , 1 , 2 , 3 , 4 , 5 ],
275276 ) -> None :
276277 black = getattr (self ._blackframebuf , func )
277278 red = getattr (self ._colorframebuf , func )
@@ -368,7 +369,7 @@ def height(self) -> int:
368369 return self ._width
369370
370371 @property
371- def rotation (self ) -> Union [0 , 1 , 2 , 3 ]:
372+ def rotation (self ) -> Literal [0 , 1 , 2 , 3 ]:
372373 """The rotation of the display, can be one of (0, 1, 2, 3)"""
373374 return self ._framebuf1 .rotation
374375
0 commit comments