Skip to content

Make CacheManager a deprecated subclass of FileCache #147

Closed

Description

@hslev

Parent: #144 · Epic: #126 · Blocked by: #146, #135
Work on branch 144-pass-a-responsecache-to-a-detector; commit the changes and close the ticket.

Problem

CacheManager and FileCache would otherwise be two implementations of the same file format that can drift apart.

Current behavior

  • lettucedetect/detectors/cache.py:12-47 is a standalone class: get, set, delete, _hash (static), path. It is imported by llm.py:12.

Steps

  1. Rewrite CacheManager(file_path) as a subclass of FileCache keeping get, set, delete, _hash and path. It inherits aget, aset and adelete from FileCache and adds no override; the async pairs are new names, so they don't warn on their own.
  2. Mark it deprecated with the helper from Add LettuceDetectDeprecationWarning and a deprecation helper #135, naming FileCache. Calls from inside lettucedetect (including llm.py) don't warn.
  3. Update the CacheManager golden fixtures from Pin make_detector, HallucinationDetector and CacheManager behavior #131 only where the directory is no longer created by the constructor (an intended change; say so in the PR).

Acceptance criteria

  • isinstance(CacheManager(p), FileCache); constructing from a test module warns LettuceDetectDeprecationWarning naming FileCache.
  • CacheManager has working aget, aset and adelete equal to get, set and delete (a value set with set reads via aget); calling them emits no extra warning beyond the one from construction.
  • _hash still returns the recorded strings; get/set/delete/path behave as before.
  • Docstring has the .. deprecated:: note.
  • Existing tests pass.

Start here

uv run --extra dev pytest tests/test_golden_factory_cache_pytest.py tests/test_llm_detector_pytest.py -q

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agent

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions