"""Tiny math helpers. Imported by tests/test_add.py.

Rewritten by the 'rewrite' branch with explicit type handling.
"""


def add(a, b):
    # Be explicit about the int contract; defensive against the
    # subtle bug a previous version had (it returned a - b).
    if not isinstance(a, (int, float)) or not isinstance(b, (int, float)):
        raise TypeError(f"add expects numeric inputs, got {type(a)} and {type(b)}")
    return a + b


def double(x):
    return x * 2

