Skip to content

Commit fe873f2

Browse files
committed
Merge type annotations from typeshed
1 parent 0c88f25 commit fe873f2

29 files changed

+662
-480
lines changed

boltons/cacheutils.py

+84-57
Large diffs are not rendered by default.

boltons/debugutils.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
built-in Python debugger.
3535
"""
3636

37+
from __future__ import annotations
38+
39+
from collections.abc import Callable
3740
import sys
3841
import time
3942
from reprlib import Repr
@@ -47,7 +50,7 @@
4750
__all__ = ['pdb_on_signal', 'pdb_on_exception', 'wrap_trace']
4851

4952

50-
def pdb_on_signal(signalnum=None):
53+
def pdb_on_signal(signalnum: int | None = None) -> None:
5154
"""Installs a signal handler for *signalnum*, which defaults to
5255
``SIGINT``, or keyboard interrupt/ctrl-c. This signal handler
5356
launches a :mod:`pdb` breakpoint. Results vary in concurrent
@@ -75,7 +78,7 @@ def pdb_int_handler(sig, frame):
7578
return
7679

7780

78-
def pdb_on_exception(limit=100):
81+
def pdb_on_exception(limit: int = 100) -> None:
7982
"""Installs a handler which, instead of exiting, attaches a
8083
post-mortem pdb console whenever an unhandled exception is
8184
encountered.
@@ -138,8 +141,8 @@ def trace_print_hook(event, label, obj, attr_name,
138141
return
139142

140143

141-
def wrap_trace(obj, hook=trace_print_hook,
142-
which=None, events=None, label=None):
144+
def wrap_trace(obj, hook: Callable = trace_print_hook,
145+
which: str | None = None, events: str | None = None, label: str | None = None):
143146
"""Monitor an object for interactions. Whenever code calls a method,
144147
gets an attribute, or sets an attribute, an event is called. By
145148
default the trace output is printed, but a custom tracing *hook*

boltons/deprutils.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,19 @@
3131

3232
import sys
3333
from types import ModuleType
34+
from typing import Any
3435
from warnings import warn
3536

3637
# todo: only warn once
3738

3839

3940
class DeprecatableModule(ModuleType):
40-
def __init__(self, module):
41+
def __init__(self, module: ModuleType):
4142
name = module.__name__
4243
super().__init__(name=name)
4344
self.__dict__.update(module.__dict__)
4445

45-
def __getattribute__(self, name):
46+
def __getattribute__(self, name: str) -> Any:
4647
get_attribute = super().__getattribute__
4748
try:
4849
depros = get_attribute('_deprecated_members')
@@ -55,7 +56,7 @@ def __getattribute__(self, name):
5556
return ret
5657

5758

58-
def deprecate_module_member(mod_name, name, message):
59+
def deprecate_module_member(mod_name: str, name: str, message: str) -> None:
5960
module = sys.modules[mod_name]
6061
if not isinstance(module, DeprecatableModule):
6162
sys.modules[mod_name] = module = DeprecatableModule(module)

0 commit comments

Comments
 (0)