typing: make `bundlerepository` subclass `localrepository` while type checking
Currently, `mercurial/bundlerepo.py` is excluded from pytype, mostly because it
complains that various `ui` and `vfs` fields in `localrepository` are missing.
(`bundlerepository` dynamically subclasses `localrepository` when it is
instantiated, so it works at runtime.) This makes that class hierarchy known to
pytype.
Having a protocol for `Repository` is probably the right thing to do, but that
will be a lot of work and this still reflects the class at runtime. Subclassing
also has the benefit of making sure any method overrides have a matching
signature, so maybe this is a situation where we do both of these things. (I'm
not sure how clear the diagnostics are if a class *almost* implements a
protocol, but is missing a method argument or similar.) The subclassing is not
done outside of type checking runs to avoid any side effects on already complex
code.
# showstack.py - extension to dump a Python stack trace on signal
#
# binds to both SIGQUIT (Ctrl-\) and SIGINFO (Ctrl-T on BSDs)
r"""dump stack trace when receiving SIGQUIT (Ctrl-\) or SIGINFO (Ctrl-T on BSDs)
"""
import signal
import sys
import traceback
def sigshow(*args):
sys.stderr.write("\n")
traceback.print_stack(args[1], limit=10, file=sys.stderr)
sys.stderr.write("----\n")
def sigexit(*args):
sigshow(*args)
print('alarm!')
sys.exit(1)
def extsetup(ui):
signal.signal(signal.SIGQUIT, sigshow)
signal.signal(signal.SIGALRM, sigexit)
try:
signal.signal(signal.SIGINFO, sigshow)
except AttributeError:
pass