The project implements a pluggable caching architecture for Python programs.
Follow these instructions strictly.
- PEP 8.
- Maximum line length is 79 characters.
You must:
- Use type annotations.
- Use
str | Noneand built-in generics such aslist[T]. - Prefix module-local objects with
_, exceptlogger. - Add all imports at the top of modules, unless requested for lazy loading.
- Use
pathlib.Pathinternally; public APIs should acceptstr | Pathand convert accordingly.
You must not:
- Add imports inside functions or methods, or between non import statements.
- Make unrelated refactors or move logic across layers unnecessarily.
- Add
# noqa, fix the underlying issue instead. Exceptions:PLC0415when lazy loading of modules is required.E501on long multi-line strings.V107onProtocolsubclass method arguments.
- Add
# type: ignoreor usecast()undersrc/; stop and ask for guidance if unavoidable. - Leave internal passthrough functions behind after refactors.
Public APIs must include PEP 257 docstrings following Google standard.
Docstrings should describe behavior, not implementation details.
The file ADAPTER_SPEC.md contains the specification for external adapter developers to create adapters for cache backends that can be used with this API.
- The document must have everything an external developer needs to develop a backend adapter without looking at this project's codebase.
- Do not add any internal implementation details from this codebase to the developer spec.
- Always update the spec when adding/updating the codebase and the changes you make are important to adapter developers.
This project adheres to Semantic Versioning.
- Do not test internal functions/methods; test observable behaviour only.
- Avoid brittle tests.
You must:
- Make minimal, focused edits
- Avoid large refactors unless explicitly requested
- Preserve existing API behavior
Follow Keep a Changelog (>=1.1.0).
Sections names:
- Added
- Changed
- Deprecated
- Removed
- Fixed
- Security
You must:
- Keep
CHANGELOG.mdupdated for end user-visible changes. - Write entries for humans.
- Group by change type.
- Wrap lines at 80 columns.
- Update the changelog in the same change as version bumps.
- Be concise, do not just replicate details already in the
README.mdfile.
You must not:
- Change past entries under released versions.
- Document internal development or non end-user visible changes.
Only read-only Git commands are allowed.
Do not:
- Rewrite history.
- Force push.
- Use destructive Git commands.
- Commit unless explicitly requested, even if committed before.
You must follow this workflow, no exceptions:
- Inspect existing patterns and conventions.
- Implement changes.
- Auto-fix and format changed Python files.
- Run global code QA.
- Run relevant targeted tests.
- Run full test suite with coverage
- add tests if coverage is below threshold and repeat.
Important:
- Fix all QA and test issues before proceeding to the next step.
- Do not run QA/tests on non code changes.
- Do not skip steps.
- Do not change order.
- All non-private APIs have Google Style docstrings.
- QA passes.
- Full test suite passes.
- Test coverage meets project's threshold.
- Changelog updated with user-visible changes.
- Documentation and docstrings updated.
Auto-fix and format:
ruff check --fix
ruff formatQA checks:
ruff check
vulture
mypyTargeted file test:
python -m unittest --failfast --buffer --quiet tests.test_cacheTargeted class test:
python -m unittest --failfast --buffer --quiet tests.test_cache.TestCacheSingle function test:
python -m unittest --failfast --buffer --quiet tests.test_cache.TestCache.test_add_getFull test suite with coverage:
coverage run -m unittest --failfast --buffer --quietGet coverage percentage:
coverage report --format=totalShow missing coverage report:
coverage report --skip-covered --show-missing