Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds one consistent deprecation mechanism and makes new code fail its tests if it calls a deprecated name. No real name is deprecated here: the behaviour is shown on stand-ins defined in the tests.
Deprecation utility (
lettucedetect/detectors/_deprecation.py, from #135)LettuceDetectDeprecationWarning(DeprecationWarning), exported fromlettucedetect.detectors.deprecated(replacement)decorator for classes, functions and methods. It wrapstyping_extensions.deprecated, so each use warns once per call site, attributed to the caller's line, and sets__deprecated__(PEP 702). Type checkers see it as the standard decorator._UNSETsentinel andwarn_if_passed(value, name, replacement)for deprecated arguments; they warn only when the caller passed the argument.DEPRECATED_SINCEandREMOVED_IN.lettucedetectorlettucedetect.*stay silent, so internal callers such as theHallucinationDetectorfacade do not warn.typing_extensions>=4.5.0is added as a dependency inpyproject.toml... deprecated::docstring note is a convention for whoever deprecates a name (documented in the module docstring); the decorator does not add it automatically.Warning as a test error (#136)
pyproject.toml: addfilterwarnings = ["error::lettucedetect.detectors._deprecation.LettuceDetectDeprecationWarning"]to the pytest config.pytestmarkthat ignores the warning to each of the five modules that call old names:test_inference_pytest.py,test_llm_detector_pytest.py,test_llm_client_pytest.py,test_custom_taxonomy_pytest.py,test_factory_pytest.py. No other edits in them.tests/test_deprecation_pytest.py: tests for the helper on stand-ins, including that an unmarked call raises under the filter andpytest.warnsstill records the warning.Related issue
Closes #135 and #136. Part of #134 (epic #126).
Type of change
Testing
ruff format --check lettucedetect/ lettucedetect_api/ tests/ruff check lettucedetect/ lettucedetect_api/ tests/ --extend-exclude lettucedetect/integrations/python -m pytestuv run --extra dev pytest tests -qgives 216 passed.Checklist
Rights & sign-off (required)
distributed under the repository's MIT license
(see CONTRIBUTING).