- Source code lives in
tfworker/; CLI entrypoints intfworker/commands/. - Tests mirror the source tree in
tests/(e.g.,tfworker/foo/bar.py→tests/foo/test_bar.py). - Keep modules single‑purpose, use
snake_case.pyfilenames, and avoid mixed responsibilities.
- Install tooling:
poetry install --with dev - Run tests:
make test(usespytestwith coverage viapytest-cov). - Lint:
make lint - Format:
make format - Type check:
make typecheck - Use
poetry run <tool>when invoking tools directly (e.g.,poetry run pytest -k my_test).
- Python with 4‑space indents and explicit type hints on public APIs.
- Naming:
snake_casefor modules/functions,PascalCasefor classes,UPPER_SNAKEfor constants. - Follow the existing style; prefer minimal diffs over rewrites. Keep functions focused and small.
- Frameworks:
pytestorganized withunittest.TestCaseclasses; mock usingpytest-mockorunittest.mock. - Coverage: >98% for new/changed code, >90% overall (enforced via
pytest-cov). - Structure: mirror
tfworker/intests/; test files namedtest_<module>.py. - Run locally with
make testorpoetry run pytest. Write fast, isolated tests and use dependency injection for seams.
- Add annotations to all new modules and public functions; keep them precise.
- Use
reveal_type()to clarify uncertain types during development when helpful.
- Commits: imperative mood (“Add X”, not “Added X”); concise subject, descriptive body when needed.
- PRs must include tests, reference relevant
maketargets run (test/lint/format/typecheck), and briefly explain the rationale and scope. Link issues when applicable. - Document notable design decisions or trade‑offs in the PR description.
- Never commit secrets or credentials; prefer environment variables for configuration.
- Follow
.gitignore; sanitize logs and error messages in tests and code.