
"""A thin wrapper around Python's builtin signal.signal()."""
import signal
import types
from typing import Any, Callable

_Handler = Callable[[], Any]


def add_handler(signo: signal.Signals, fn: _Handler):
  def _wrapped(signo: signal.Signals, frame: types.FrameType):
    del signo, frame
    return fn()

  signal.signal(signo, _wrapped)


"""A thin wrapper around Python's builtin signal.signal()."""
import signal
import types
from typing import Any, Callable

_Handler = Callable[[], Any]


def add_handler(signo: signal.Signals, fn: _Handler):

  # The function signal.signal expects the handler to take an int rather than a
  # signal.Signals.
  def _wrapped(signo: int, frame: types.FrameType):
    del signo, frame
    return fn()

  signal.signal(signo.value, _wrapped)

Fix pytype issue in signal handling code.
Fix pytype issue in signal handling code.

PiperOrigin-RevId: 408605103
Change-Id: If724504629a50d5cb7a099cf0263ba642e95345d

  
  """A thin wrapper around Python's builtin signal.signal()."""
  import signal
  import types
  from typing import Any, Callable
  
  _Handler = Callable[[], Any]
  
  
  def add_handler(signo: signal.Signals, fn: _Handler):
+ 
+   # The function signal.signal expects the handler to take an int rather than a
+   # signal.Signals.
-   def _wrapped(signo: signal.Signals, frame: types.FrameType):
+   def _wrapped(signo: int, frame: types.FrameType):
      del signo, frame
      return fn()
  
-   signal.signal(signo, _wrapped)
+   signal.signal(signo.value, _wrapped)
  
Fix pytype issue in signal handling code.
## Code Before:

"""A thin wrapper around Python's builtin signal.signal()."""
import signal
import types
from typing import Any, Callable

_Handler = Callable[[], Any]


def add_handler(signo: signal.Signals, fn: _Handler):
  def _wrapped(signo: signal.Signals, frame: types.FrameType):
    del signo, frame
    return fn()

  signal.signal(signo, _wrapped)

## Instruction:
Fix pytype issue in signal handling code.
## Code After:

"""A thin wrapper around Python's builtin signal.signal()."""
import signal
import types
from typing import Any, Callable

_Handler = Callable[[], Any]


def add_handler(signo: signal.Signals, fn: _Handler):

  # The function signal.signal expects the handler to take an int rather than a
  # signal.Signals.
  def _wrapped(signo: int, frame: types.FrameType):
    del signo, frame
    return fn()

  signal.signal(signo.value, _wrapped)
