Why this matters
Reduces downstream errors and improves error messages for callers.
Validate presence, type, and range of critical inputs at boundaries (API, CLI, jobs) and fail fast with clear messages.
Reduces downstream errors and improves error messages for callers.
Side-by-side examples engineers can pattern-match during review.
def charge(amount):
return gateway.charge(amount)def charge(amount: int) -> str:
if not isinstance(amount, int) or amount <= 0:
raise ValueError('amount must be a positive integer')
return gateway.charge(amount)def run(p): ... # no checksif not p: raise ValueError('p required')From the same buckets as this rule.