18
18
try :
19
19
"""Needed for type annotations"""
20
20
from typing import Any , Union , Callable , Optional
21
+ from typing_extensions import Literal
21
22
from busio import SPI
22
23
from digitalio import DigitalInOut
23
24
from circuitpython_typing .pil import Image
@@ -247,7 +248,7 @@ def set_ram_address(self, x: int, y: int) -> None:
247
248
"""Set the RAM address location, must be implemented in subclass"""
248
249
raise NotImplementedError ()
249
250
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 :
251
252
"""Set the index for the black buffer data (0 or 1) and whether its inverted"""
252
253
if index == 0 :
253
254
self ._blackframebuf = self ._framebuf1
@@ -257,7 +258,7 @@ def set_black_buffer(self, index: Union[0, 1], inverted: bool) -> None:
257
258
raise RuntimeError ("Buffer index must be 0 or 1" )
258
259
self ._black_inverted = inverted
259
260
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 :
261
262
"""Set the index for the color buffer data (0 or 1) and whether its inverted"""
262
263
if index == 0 :
263
264
self ._colorframebuf = self ._framebuf1
@@ -271,7 +272,7 @@ def _color_dup(
271
272
self ,
272
273
func : Callable ,
273
274
args : Any ,
274
- color : Union [0 , 1 , 2 , 3 , 4 , 5 ],
275
+ color : Literal [0 , 1 , 2 , 3 , 4 , 5 ],
275
276
) -> None :
276
277
black = getattr (self ._blackframebuf , func )
277
278
red = getattr (self ._colorframebuf , func )
@@ -368,7 +369,7 @@ def height(self) -> int:
368
369
return self ._width
369
370
370
371
@property
371
- def rotation (self ) -> Union [0 , 1 , 2 , 3 ]:
372
+ def rotation (self ) -> Literal [0 , 1 , 2 , 3 ]:
372
373
"""The rotation of the display, can be one of (0, 1, 2, 3)"""
373
374
return self ._framebuf1 .rotation
374
375
0 commit comments