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?
types.FrameType
is what you are looking for.