Repository navigation
Description
Parent
Branch
Branch from stateless_core and open the pull request against it, not main. Close this ticket by hand once its pull request merges there: GitHub only closes issues automatically on merges into main.
What to build
One mechanism that marks a class, function, method or argument as deprecated and gives every use the same warning, the same docstring note and the same type-checker marking. No real name is deprecated in this task: the behaviour is demonstrated on stand-ins defined in the tests. The task also turns the new warning into a test failure for new code, and keeps the existing tests that call old names green with one module-level mark each.
A deprecated name called from a module inside the lettucedetect package does not warn (see the deprecation rule in Implementation Decisions), so the unchanged HallucinationDetector facade stays silent. Calls from anywhere else warn.
Acceptance criteria
-
LettuceDetectDeprecationWarningis a subclass ofDeprecationWarningand is exported fromlettucedetect.detectors; filteringDeprecationWarningfor another library does not hide it, and filtering it does not hide another library's warnings. - Every message reads exactly "X is deprecated since S and will be removed in R. Use U.", where S and R come from two module constants (
DEPRECATED_SINCE,REMOVED_IN). The tests build the expected message from the constants and contain no literal version numbers. The constants hold a clearly marked placeholder until the release decision supplies the values. - Marking a class, function or method makes each use (constructing the class, calling the function or method) warn once per call site under Python's default filter, with the warning attributed to the caller's line, and sets
__deprecated__so that type checkers can mark uses (PEP 702). - The marked object's docstring gains a
.. deprecated::note with the replacement and the removal version. - A deprecated argument defaults to a sentinel, and the function warns only when the caller passed the argument.
- A marked name called from a module whose name is
lettucedetector starts withlettucedetect.emits no warning; the same call from a test module emits one. - Importing
lettucedetect.detectorsin a fresh interpreter emits noLettuceDetectDeprecationWarning. - The pytest configuration turns
LettuceDetectDeprecationWarninginto an error. The five existing test modules that call old names (the inference, LLM detector, LLM client, custom taxonomy and factory tests) each get one module-level mark that ignores it, and no other change. A test that records the warning withpytest.warnsstill works. - The existing tests pass.
- The changed code follows the Errors and logging section of
CONTRIBUTING.md(warnings.warnonly for deprecations).
Blocked by
None, can start immediately.
User stories covered
41, 42, 43, 58
Activity
hslev commentedon Nov 6, 2026
The decorator does not add the
.. deprecated::docstring note automatically; the module docstring treats it as a convention for whoever deprecates a name. A note appended to__doc__at runtime would not reach the generated documentation or editor hovers, because both read docstrings from the source rather than from the imported object. That is why this change introduces a convention of writing the note explicitly into the docstring instead.Merge pull request #186 from KRLabsOrg/134-see-one-consistent-warning…