This project is a CLI application that discovers and exposes Click commands from pre-defined locations and other delfino plugins. It provides a unified interface for managing and executing commands.
- Languages: Python 3.10-3.13
- Testing: pytest, pytest.mark.parametrize, pytest-mock, pytest fixtures, pytest-httpx (https://colin-b.github.io/pytest_httpx/)
- Dependency management: uv
- CI/CD: CircleCI
├── CHANGELOG.md - changelog for the project. ├── dist - distribution files for the package. ├── documentation - documentation files for thing that do not fit into the top level README.md. ├── LICENSE - license file for the project. ├── uv.lock - UV lock file for dependency management. ├── pyproject.toml - Project configuration file. ├── README.md - main README file for the project. ├── reports - generated reports and documentation. ├── src - source code of the project. └── tests - automated testing suite that uses pytest. ├── integration - integration tests. └── unit - unit tests.
- Use Pydantic models for data validation and serialization
- Follow type hints throughout the codebase
- Use async/await for asynchronous operations
- Use dependency injection where appropriate
- All imports must be absolute imports and on top of the file
- Use Python's built-in logging module for structured logging. Create a logger in each module as
logger = logging.getLogger(__name__). - Compose log messages with f-strings but put variable context information, such as request IDs, into
extradict. - Never log secrets/PII.
- See also: logging.json
DEBUGfor detailed debugging information, not to be used in production.INFOfor general operational messages. Should not be logged more than once per second.WARNINGfor fixable issues and possible data inconsistencies that do not stop the application.ERRORfor errors and clear data inconsistencies that require attention, but do not stop the application.CRITICALfor critical errors that stop the application. Must be logged into Sentry as well.
- Keep README.md up to date
- Document changes in CHANGELOG.md in the "Unreleased" section.
- Use
uv run <COMMAND>to run commands in the virtual environment - Use
delfino verifyfor linting and formatting - Write comprehensive tests for new features
matchstatements instead of longif/elif/elsechains where appropriate:=assignment operator for inline assignments in expressions
Use Python 3.10 type annotations:
- Optional -> | None
- Dict -> dict
- List -> list
- Generator[None, None, None] -> Iterator[None]
- Final[...] for constants
Use library-specific types where applicable, e.g.:
mocker: MockerFixture(from pytest_mock import MockerFixture)httpx_mock: HTTPXMock(from pytest_httpx import HTTPXMock)caplog: LogCaptureFixture(from pytest import LogCaptureFixture)
- Write unit tests for functions and classes. The folder structure should mirror the
srcfolder. If a file with tests is over 500 lines long, consider splitting it into multiple files, with package name same as the file being tested. - Write integration tests for commands
- Use pytest fixtures for test setup
- Use parameterized tests with
pytest.mark.parametrizefor testing multiple scenarios - Use
pytest.param(.., id="test name")to label parameterized tests with custom names - Mock external dependencies in unit tests
Use "GIVEN/WHEN/THEN/AND " comments to annotate setup, test and checks. For example:
# GIVEN event happens
# WHEN it is processed by the endpoint
# THEN a Slack message is sent
# AND success response is sent back- Based on the changes in the "Unreleased" section of CHANGELOG.md, run
uv version --bump major/minor/patchto update the version in pyproject.toml (breaking changes = major, features = minor, fixes = patch). - Update the "Unreleased" section in CHANGELOG.md to the new version with today's date.
- Commit the changes in a new branch called "release/$(uv version --short)" with a message "Release X.Y.Z".
- Push the branch to the remote repository.