Open jepler opened 1 year ago
circuitpython_typing
could add a typing.Protocol
for displays (or multiple kinds) if we want to duck type it. Can you link to an example of where it would be used to know what methods/attributes are required?
I didn't take note of which repo the author was working on. However, adafruit_bitmapsaver
looks like one such:
def save_pixels(
file_or_filename: Union[str, BufferedWriter],
pixel_source: Union[Display, Bitmap] = None,
palette: Optional[Palette] = None,
) -> None:
Assigning to myself so I don't forget about this!
During PyCon sprints, a participant raised the issue of needing to type an argument as 'any kind of displayio display'. It would be nice if the core (or maybe circuitpython-typing?) had a Union type that included all these types, for libraries to refer to.