contextvars.ContextVar, sowith sf.errstateis per thread and per task.- An
errstateobject keeps its entry tokens in a context-local stack, so the same object (including the one a decorator holds) can be entered from many threads or tasks at once. The decorator wrapsasync deffunctions with anasyncwrapper that holds the policy acrossawait; generator functions are rejected withTypeError(the policy would not cover the body). - Warnings carry a
stacklevelthat walks out of the package to the user’s frame, so-W errorandwarnings.catch_warningspoint at the right line. - The test suite runs with
filterwarnings = error::sf.SFWarning, so an unexpected warning fails a test.
Design decisions
Error policy mechanics
Decision log: error policy mechanics