Skip to content

What is signal type? #1042

Answered by Akuli
dineshbvadhia asked this question in Q&A
Jan 21, 2022 · 2 comments · 5 replies
Discussion options

You must be logged in to vote

In typeshed, stdlib/signal.pyi defines signal.signal() here: https://github.com/python/typeshed/blob/3a22bf2411c7357bffb2fe1dc675486a8da97177/stdlib/signal.pyi#L68

Your function is passed as a _HANDLER, and the definition of _HANDLER just above is: Union[Callable[[int, Optional[FrameType]], Any], int, Handlers, None]

You are passing in the function, so we can ignore everything except the Callable, and your function should match Callable[[int, Optional[FrameType]], Any]. This means a function that takes an int as first argument, and Optional[FrameType] as second argument, and can return anything it wants.

import typing
from types import FrameType

def signal_handler(signal: int, frame: Opt…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by dineshbvadhia
Comment options

You must be logged in to vote
5 replies
@Akuli
Comment options

@hauntsaninja
Comment options

@dineshbvadhia
Comment options

@dineshbvadhia
Comment options

@Gobot1234
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants