Skip to content

See one consistent warning for every deprecated name #134

Closed
2 of 2 issues completed
Closed

Description

@hslev

Parent

#126

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

  • LettuceDetectDeprecationWarning is a subclass of DeprecationWarning and is exported from lettucedetect.detectors; filtering DeprecationWarning for 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 lettucedetect or starts with lettucedetect. emits no warning; the same call from a test module emits one.
  • Importing lettucedetect.detectors in a fresh interpreter emits no LettuceDetectDeprecationWarning.
  • The pytest configuration turns LettuceDetectDeprecationWarning into 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 with pytest.warns still works.
  • The existing tests pass.
  • The changed code follows the Errors and logging section of CONTRIBUTING.md (warnings.warn only for deprecations).

Blocked by

None, can start immediately.

User stories covered

41, 42, 43, 58

Sub-issues

Sub-issues

2 of 2 Issues completed
Loading 2 sub-issues

Activity

  1. added
    ready-for-agent
    on Nov 5, 2026
  2. added theissue type on Nov 5, 2026
  3. hslev commented on Nov 6, 2026

    @hslev
    ContributorAuthor

    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.

  4. added a commit that references this issue on Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ready-for-agent

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions