Stability decorators¶
The geno_lewm.api module provides the two decorators that govern
public-surface lifetime per RFC-0014.
Public-API lifetime decorators (RFC-0014 §3.3, §3.6).
Two decorators mark stability on the public surface:
- :func:
experimental— wraps a function or class that may change without notice. Emits :class:FutureWarningonce per process per decorated object on first call / instantiation. - :func:
deprecated— wraps a function or class scheduled for removal. Emits :class:DeprecationWarningonce per process per call site (i.e. once per(file, line)of the calling code). Takes a free-textreasondescribing what replaces the deprecated API.
Both decorators preserve __name__, __doc__, __module__,
__qualname__, __wrapped__, and (for classes) the original
attribute surface, so mypy and IDE introspection are unaffected.
experimental
¶
Mark obj (a function or class) as experimental.
Usage::
@experimental
def f(...): ...
@experimental(reason="API shape under review")
class C: ...
Emits :class:FutureWarning once per process when the decorated
object is first invoked (function) or instantiated (class). Later
calls are silent.
Source code in geno_lewm/api.py
deprecated
¶
Mark obj as deprecated.
Usage::
@deprecated("use new_thing() instead; removed in v0.3")
def old_thing(...): ...
Emits :class:DeprecationWarning once per process per call
site — that is, once per (filename, lineno) of the calling
code. Multiple call sites all warn; the same site warns only once.
reason is appended to the warning message; pass a short
actionable string ("use X instead").
Source code in geno_lewm/api.py
Behavioural contract¶
@experimentalemits a singleFutureWarningper process on the first call (function) or instantiation (class). Later calls are silent. The decorated callable retains__name__,__doc__,__module__,__qualname__, and__wrapped__.@deprecated(reason)emits a singleDeprecationWarningper call site — that is, once per(filename, lineno)of the calling code. Distinct call sites each receive one warning.
The warnings module sees the project-defined filters (pyproject.toml
[tool.pytest.ini_options].filterwarnings) so tests opt-in via
warnings.simplefilter("always") blocks.
When to apply¶
@experimental— symbols that are not yet locked into the stability contract. New public surface lands experimental by default; promotion to stable is a separate PR with a CHANGELOG entry.@deprecated— symbols scheduled for removal in the next MAJOR. Pair with a removal target in the CHANGELOG.
See the public-API spec for stability classes.