Thanks for considering contributing to backon!
git clone https://github.com/Llucs/backon.git
cd backon
pip install pdm
pdm install- Run
ruff check backon/ tests/— zero warnings allowed. - Run
mypy backon/— zero errors allowed. - Run
pytest tests/ -q— all tests must pass. - If you added a feature, add tests for it.
- If you fixed a bug, add a test that would have caught it.
- Target Python 3.10+. Use modern syntax:
|for unions,TypeVarbounds. - Type hints on every function signature — no
Anyunless unavoidable. - Zero comments in code. Code must be self-documenting.
- No docstrings unless the API is public and non-obvious.
- Line length: 88 characters.
- Use ruff with default rules (E, F, W, I).
- Every test must be fast (< 100ms per test). Use
jitter=Noneand small intervals. - Cover: sync, async, exceptions, predicates, jitter, handlers, all wait generators.
- Cover edge cases: 0 max_tries, max_time expiry, giveup callbacks, global disable/enable.
- Async tests use
pytest-asynciowithasyncio_mode = auto.
Source layout:
| File | Purpose |
|---|---|
backon/_sync.py |
Synchronous retry logic |
backon/_async.py |
Async retry logic |
backon/_decorator.py |
Decorator API (on_exception, on_predicate) |
backon/_retry.py |
Functional API (retry(), Retrying) |
backon/_common.py |
Shared helpers, global disable/enable |
backon/_wait_gen.py |
Wait generators (expo, constant, fibo, etc.) |
backon/_jitter.py |
Jitter functions |
backon/_typing.py |
Internal type aliases |
backon/types.py |
Public types (Details) |
tests/ |
Tests mirror the source structure |
- Keep every function backoff had. Never remove, only add.
- New features must make backon easier to use than tenacity.
- The details dict passed to handlers must include
target,args,kwargs,tries,elapsed, and relevant extras (value,exception,wait). - Decorators must handle both sync and async functions transparently.
- Support
staticmethodwrapping (order:@decorator @staticmethod). - Export everything public in
__all__in__init__.py.
README.mdis the single source of truth for users. Every feature exported in__all__must be documented.- After adding a new feature, wait generator, condition, or public symbol:
- Add it to the appropriate README section.
- If it needs a code example, add one.
- Run
python3 -c "import backon; assert '<your_feature>' in dir(backon)"to confirm it's exported. - Verify the README badge is still accurate (e.g., coverage percentage).
- Update
versioninpyproject.tomlon every change. __version__inbackon/__init__.pyis read dynamically fromimportlib.metadata.- Follow SemVer: bump major for breaking changes, minor for features, patch for fixes.
- Bump
versioninpyproject.toml. - Update
CHANGELOG.mdwith the new version, date, and changes. - Commit with message
Release vX.Y.Z. - Push to
main. - Create a GitHub Release from the tag.
- The
Releaseworkflow auto-publishes to PyPI via trusted publishing (OIDC). - Verify at https://pypi.org/project/backon/.
By contributing, you agree that your contributions will be licensed under the MIT License.