Repository navigation
Closed
Labels
ready-for-agentScoped and ready for a contributor or agent to pick up
Milestone
Description
Parent: #134 · Epic: #126 · Blocked by: none (follow 02 once merged)
Work on branch 134-see-one-consistent-warning-*; commit the changes and close the ticket.
Problem
Later tickets deprecate TransformerDetector, LLMDetector, make_detector, CacheManager, the predict* methods and two arguments. Each must warn the same way, with the same docstring note and the same type-checker marking. No such mechanism exists, and no real name is deprecated in this ticket.
Current behavior
lettucedetect/detectors/__init__.py:1-15exports detectors only; there is no warning class and no deprecation code anywhere inlettucedetect/detectors/.HallucinationDetector(outside this package) callsmake_detectorandpredict*, so deprecated names called from insidelettucedetectmust stay silent.
Steps
- Add
lettucedetect/detectors/_deprecation.py:LettuceDetectDeprecationWarning(DeprecationWarning), constantsDEPRECATED_SINCEandREMOVED_IN(clearly marked placeholders), adeprecated(replacement)decorator for classes, functions and methods, and a_UNSETsentinel plus a helper for deprecated arguments. - The message reads exactly "X is deprecated since S and will be removed in R. Use U." using the constants.
- The decorator sets
__deprecated__(PEP 702), appends a.. deprecated::note (replacement and removal version) to the docstring, and warns on each use with the caller's line as the attribution (stacklevel). - A deprecated argument defaults to the sentinel; the helper warns only when the caller passed it.
- Skip the warning when the caller's module
__name__islettucedetector starts withlettucedetect.. - Export
LettuceDetectDeprecationWarningfromlettucedetect.detectors. - Test on stand-ins defined in the test module.
Acceptance criteria
- Subclass of
DeprecationWarning; filtering other libraries'DeprecationWarningdoesn't hide it and vice versa. - Messages are built from the constants in tests; no literal version numbers in tests.
- Class, function and method uses warn once per call site under the default filter, attributed to the caller's line.
-
__deprecated__and the docstring note are present. - Deprecated argument warns only when passed.
- A call from a module named
lettucedetect.*does not warn; the same call from a test module does. - A fresh-interpreter
import lettucedetect.detectorsemits noLettuceDetectDeprecationWarning. - Follows CONTRIBUTING "Errors and logging" (
warnings.warnonly for deprecations); existing tests pass.
Start here
uv run --extra dev pytest tests -q -x
Metadata
Metadata
Assignees
Labels
ready-for-agentScoped and ready for a contributor or agent to pick up
Activity
chore: add LettuceDetectDeprecationWarning and a deprecation helper (#…
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.