Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I type hint a frame object in Python?

I’m type hinting a large existing Python codebase, and in one part it sets a signal handler using signal.signal. The signal handler is a custom function defined in the codebase, so I need to type hint it myself. However, while I can guess based on the description of signal.signal that the first parameter is an integer, the second one is just described as "None or a frame object" in the documentation.

I have no idea what a frame object is, but thankfully the aforementioned documentation links to a section called "Frame objects" and the inspect module documentation. However, after looking through both of these, I still don’t really find any information about how to actually type hint a frame object, just information that might be useful to someone writing code that interacts with frame objects without typing it.

So, what type do I use for frame object type hints in Python?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

types.FrameType is what you are looking for.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading