Thank you for your interest in contributing to this project! This document provides guidelines and information for contributors.
- Code of Conduct
- Getting Started
- Development Setup
- Code Style
- Testing
- Submitting Changes
- Pull Request Process
By participating in this project, you agree to maintain a respectful and inclusive environment. Please:
- Use welcoming and inclusive language
- Be respectful of differing viewpoints and experiences
- Gracefully accept constructive criticism
- Focus on what is best for the community
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/python-template.git cd python-template - Add the upstream repository as a remote:
git remote add upstream https://github.com/JacobPEvans/python-template.git
- Python 3.11 or higher
- Git
- Make (optional, but recommended)
Important: Always use a virtual environment to isolate project dependencies from your system Python.
-
Create and activate a virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install development dependencies (inside the activated virtual environment):
# Using make (recommended) make install-dev # Or manually pip install -e ".[dev]" pre-commit install
-
Verify your setup:
make check # Or: pytest && ruff check src/ tests/
Note: All make and pytest commands should be run within the activated virtual environment.
This project enforces strict code quality standards using multiple tools:
- Ruff: Fast all-in-one linter and formatter (handles formatting and import sorting)
- Ruff: Comprehensive linting (pyflakes, pycodestyle, pylint rules, isort, and many more)
- mypy: Static type checking (strict mode)
- bandit: Security linting
- All public functions, classes, and modules must have docstrings
- Use Google-style docstrings
- Include type hints for all function parameters and return values
def greet(name: str | None = None) -> str:
"""Generate a greeting message.
Args:
name: The name to greet. Defaults to "World" if None.
Returns:
A formatted greeting string.
Raises:
ValidationError: If the name contains invalid characters.
Examples:
>>> greet("Alice")
'Hello, Alice!'
>>> greet()
'Hello, World!'
"""
...# Format code
make format
# Run all linters
make lint
# Run type checker
make type-check
# Run security checks
make security
# Run all checks at once
make all- 100% code coverage is required - All pull requests must maintain 100% coverage
- Tests must pass on Python 3.11 or higher
- Use pytest for all tests
- Place tests in the
tests/directory - Name test files with
test_prefix - Use descriptive test names that explain what is being tested
- Use fixtures from
conftest.pywhen appropriate - Mark tests appropriately (
@pytest.mark.unit,@pytest.mark.integration)
# Run all tests
make test
# Run with coverage (required before PR)
make test-cov
# Run tests in parallel (faster)
make test-fast
# Run only unit tests
make test-unit
# Run specific test file
pytest tests/test_main.py -vWe use Hypothesis for property-based testing. When appropriate, add hypothesis tests:
from hypothesis import given, strategies as st
@given(st.text(min_size=1, max_size=50))
def test_function_with_hypothesis(value: str) -> None:
"""Property-based test for function."""
result = some_function(value)
assert some_property(result)Use descriptive branch names:
feature/add-new-validationfix/handle-empty-inputdocs/update-readmerefactor/simplify-greet-function
Follow conventional commit format:
type(scope): description
[optional body]
[optional footer]
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringtest: Adding or updating testschore: Maintenance tasks
Examples:
feat(validators): add email validation function
fix(greet): handle None input correctly
docs(readme): update installation instructions
test(main): add hypothesis tests for greet function
-
Ensure all tests pass with 100% coverage:
make test-cov
-
Run all quality checks:
make all
-
Update documentation if needed
-
Add yourself to contributors (if applicable)
-
Create a descriptive PR title following the commit message format
-
Fill out the PR template with:
- Description of changes
- Related issue numbers
- Testing performed
- Checklist completion
-
Ensure CI passes - All GitHub Actions checks must pass
-
Request review from maintainers
-
Address feedback - Make requested changes and push updates
-
Merge - Once approved and CI passes, a maintainer will merge your PR
- Code follows the project's style guidelines
- Self-review of code completed
- Comments added for complex logic
- Documentation updated (if applicable)
- Tests added/updated with 100% coverage
- All CI checks passing
- No merge conflicts with main branch
If you have questions, feel free to:
- Open an issue for discussion
- Check existing issues and PRs for similar topics
- Review the project documentation
Thank you for contributing! 🎉