8000 typing: Union type for 'any kind of display-like object' · Issue #47 · adafruit/Adafruit_CircuitPython_Typing · GitHub
[go: up one dir, main page]

Skip to content

typing: Union type for 'any kind of display-like object' #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jepler opened this issue Apr 25, 2023 · 5 comments
Open

typing: Union type for 'any kind of display-like object' #47

jepler opened this issue Apr 25, 2023 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@jepler
Copy link
Contributor
jepler commented Apr 25, 2023

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.

@jepler jepler added the enhancement New feature or request label Apr 25, 2023
@tannewt tannewt added the documentation Improvements or additions to documentation label Apr 26, 2023
@tekktrik
Copy link
Member

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?

@jepler
Copy link
Contributor Author
jepler commented Apr 28, 2023

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:                                                                      

@tekktrik tekktrik self-assigned this Apr 28, 2023
@tekktrik
Copy link
Member

Assigning to myself so I don't forget about this!

@jepler jepler changed the title Union type for 'any kind of display-like object' typing: Union type for 'any kind of display-like object' Jun 28, 2023
@dhalbert dhalbert transferred this issue from adafruit/circuitpython Mar 21, 2025
@dhalbert dhalbert removed the documentation Improvements or additions to documentation label Mar 21, 2025
@dhalbert
Copy link
Contributor

Moving this to https://github.com/adafruit/Adafruit_CircuitPython_Typing

Related to:

@jepler could the helpers you introduced in adafruit/circuitpython#10109 be defined in circuitpython_typing? Would they still be defined both places?

@jepler
Copy link
Contributor Author
jepler commented Mar 21, 2025

I don't know whether its needed in both places. I think having it in t 64A1 he core might suffice?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants
0