Contributing to Daflip¶
Thank you for your interest in contributing to Daflip! This guide will help you get started.
Development Setup¶
Prerequisites¶
- Python 3.9 or higher
- Git
- uv
Getting Started¶
-
Fork and clone the repository
-
Install dependencies
-
Install pre-commit hooks
-
Verify setup
Development Workflow¶
1. Create a Feature Branch¶
2. Make Your Changes¶
- Write your code
- Add tests for new functionality
- Update documentation if needed
3. Run Tests¶
# Run all tests
pytest
# Run with coverage
pytest --cov=src/daflip
# Run specific test file
pytest tests/test_services.py
# Run linting
ruff check .
ruff format .
4. Commit Your Changes¶
5. Push and Create Pull Request¶
Then create a pull request on GitHub.
Code Style¶
We use Ruff for linting and formatting.
Running Ruff¶
# Check for issues
ruff check .
# Fix auto-fixable issues
ruff check . --fix
# Format code
ruff format .
Pre-commit Hooks¶
We use pre-commit hooks to ensure code quality and consistency. The hooks run automatically before each commit and include:
- Code formatting with Ruff
- Linting with Ruff
- Type checking with MyPy
- Basic file checks (trailing whitespace, YAML validation, etc.)
Setup¶
Usage¶
The hooks run automatically on commit, but you can also run them manually:
# Run all hooks on all files
uv run pre-commit run --all-files
# Run specific hook
uv run pre-commit run ruff --all-files
# Run hooks on staged files only
pre-commit run
## Testing
### Running Tests
```bash
# All tests
uv run pytest
# With coverage
uv run pytest --cov=src/daflip --cov-report=html
# Specific test
uv run pytest tests/test_services.py::test_convert_roundtrip
# Verbose output
uv run pytest -v
Writing Tests¶
- Tests should be in the
tests/
directory - Use descriptive test names
- Test both success and failure cases
- Use pytest fixtures for common setup
Test Structure¶
def test_feature_name():
"""Test description."""
# Arrange
input_data = "test"
# Act
result = function_to_test(input_data)
# Assert
assert result == expected_output
Documentation¶
Building Documentation¶
# Install docs dependencies
uv add mkdocs mkdocs-material
# Build docs
uv run mkdocs build
# Serve docs locally
uv run mkdocs serve
Documentation Guidelines¶
- Write clear, concise documentation
- Include examples for all features
- Update API documentation when changing functions
- Use proper markdown formatting
Pull Request Guidelines¶
Before Submitting¶
- Tests pass: All tests should pass
- Linting passes: No ruff errors
- Documentation updated: Update docs for new features
- Commit messages: Use conventional commit format
Commit Message Format¶
Types:
- feat
: New feature
- fix
: Bug fix
- docs
: Documentation changes
- style
: Code style changes
- refactor
: Code refactoring
- test
: Test changes
- chore
: Build/tooling changes
Examples:
feat(services): add support for new file format
fix(cli): handle missing input file gracefully
docs(api): update CLI reference with new options
Pull Request Template¶
When creating a PR, include:
- Description of changes
- Related issue (if any)
- Testing performed
- Breaking changes (if any)
Getting Help¶
- Issues: Use GitHub issues for bugs and feature requests
- Discussions: Use GitHub discussions for questions
- Code Review: All PRs require review before merging
Release Process¶
- Update version in
pyproject.toml
- Update changelog
- Create release tag
- GitHub Actions will build and publish
Thank you for contributing to Daflip! 🚀