- Add a runtime dependency:
uv add <package-name> - Add a development dependency:
uv add --dev <package-name> - Lock dependencies:
uv lock - Sync after manual edits to pyproject.toml:
uv sync
To use ruff for code quality, first add it as a dev dependency: uv add --dev ruff
- Format code:
uv run ruff format . - Check formatting without changes:
uv run ruff format --check . - Run linter:
uv run ruff check . - Run linter with auto-fix:
uv run ruff check --fix . - Run all checks:
uv run ruff check . && uv run ruff format --check .
To use mypy for type checking, first add it as a dev dependency: uv add --dev mypy
- Run mypy for type checking:
uv run mypy src/ - Run mypy on specific file:
uv run mypy path/to/file.py
To use pytest for testing, first add it as a dev dependency: uv add --dev pytest
- Run all tests:
uv run pytest - Run specific test file:
uv run pytest tests/test_module.py - Run tests matching pattern:
uv run pytest -k "test_pattern" - Run with coverage:
uv run pytest --cov=src --cov-report=term-missing(requiresuv add --dev pytest-cov) - Run with verbose output:
uv run pytest -v
- All tests go in the
tests/directory - Test files must start with
test_and end with.py - Test functions must start with
test_ - Use descriptive test names that explain what is being tested
- Follow PEP 8 conventions
- Use type hints for function signatures
- Prefer explicit over implicit
The expected order is:
- Standard library imports
- Third-party imports
- Local application imports
Blank lines separate each group.
Use Google-style docstrings for public modules, classes, methods, and functions.
Example function docstring:
def process_data(items: list[str], timeout: int = 30) -> dict[str, str]:
"""Process a list of items and return results.
Args:
items: List of items to process.
timeout: Maximum time in seconds. Defaults to 30.
Returns:
Dictionary containing processed results.
Raises:
ValueError: If items list is empty.
"""- Public functions and methods should have type hints
- Use modern Python type syntax (e.g.,
list[int]instead ofList[int]) - Use
T | Nonefor nullable types
- Classes:
PascalCase - Functions/methods:
snake_case - Constants:
UPPER_SNAKE_CASE - Private methods/attributes: prefix with single underscore
_private_method
- Source code lives in
src/agent_tools/ - The package has a CLI entrypoint defined as
agent-toolsin pyproject.toml
- Run the CLI:
uv run agent-tools - Or use:
uv run python -m agent_tools
Project settings are in pyproject.toml. Add tool-specific configuration sections as needed (e.g., [tool.ruff], [tool.mypy], [tool.pytest]).