Contributing
Thank you for your interest in contributing to this modern Python package template! This guide will help you get started.
๐ฏ Overview
This cookiecutter template helps developers create modern Python packages with best practices built-in. We welcome contributions that:
- Improve the template quality and usability
- Add support for new tools and practices
- Fix bugs and issues
- Enhance documentation
- Add comprehensive tests
๐ Quick Start
-
Fork and Clone
-
Set Up Development Environment
-
Install Pre-commit Hooks
-
Run Tests
๐ ๏ธ Development Workflow
Making Changes
-
Create a Feature Branch
-
Make Your Changes
- Template files are in
{{cookiecutter.project_slug}}/
- Template configuration is in
cookiecutter.json
- Hooks are in
hooks/
-
Tests are in
tests/
-
Test Your Changes
-
Commit Your Changes
Testing Template Changes
When modifying the template, always test:
-
Template Generation
-
Different Configurations
-
Generated Project Quality
๐ Types of Contributions
๐ง Template Improvements
- Adding New Tools: Update
cookiecutter.json
, template files, and documentation - Improving Configurations: Enhance tool configurations for better defaults
- File Structure: Improve the generated project structure
๐งช Testing
- Template Tests: Add tests for template generation and validation
- Generated Project Tests: Ensure generated projects work correctly
- Edge Cases: Test unusual configurations and inputs
๐ Documentation
- Usage Examples: Add more usage examples and configurations
- Tool Explanations: Improve documentation with better explanations
- README Updates: Keep documentation current and comprehensive
๐ Bug Fixes
- Template Issues: Fix problems with template generation
- Configuration Bugs: Fix issues with tool configurations
- Cross-platform Issues: Ensure template works on Windows, macOS, Linux
๐จ Code Style
Template Files
- Use 4 spaces for indentation in Python files
- Use double quotes for strings (Ruff default)
- Follow PEP 8 guidelines
- Include type hints where appropriate
Jinja2 Templates
- Use clear, readable Jinja2 syntax
- Add comments for complex conditionals
- Keep template logic simple and maintainable
Example:
{%- if cookiecutter.use_ruff == 'y' %}
# Ruff configuration
[tool.ruff]
line-length = 88
{%- endif %}
Test Code
- Write clear, descriptive test names
- Include docstrings explaining test purpose
- Use fixtures for common setup
- Add parametrized tests for multiple scenarios
๐ Commit Convention
We use Conventional Commits and enforce this format with a pre-commit hook:
feat:
- New featuresfix:
- Bug fixesdocs:
- Documentation changestest:
- Test additions/changesrefactor:
- Code refactoringstyle:
- Code style changesci:
- CI/CD changeschore:
- Build, dependencies, tools
Examples:
feat: add support for Poetry as build backend
fix: resolve Windows path issues in hooks
docs: update tools guide with MyPy explanation
test: add integration tests for CLI generation
Note: The commitizen pre-commit hook will automatically validate your commit messages. Non-conventional commits will be rejected.
๐ Review Process
Before Submitting
-
Run Full Test Suite
-
Update Documentation
- Update documentation for new tools
- Update README for new features
-
Add docstrings and comments
-
Test Multiple Configurations
- Test with different Python versions
- Test on different operating systems
- Test various tool combinations
Pull Request Guidelines
- Clear Description
- Explain what changes were made
- Include motivation and context
-
Link to related issues
-
Test Coverage
- Include tests for new features
- Ensure existing tests pass
-
Add integration tests where needed
-
Documentation
- Update relevant documentation
- Include examples for new features
- Update changelog if applicable
๐ฆ CI/CD Pipeline
Our CI pipeline runs:
- Linting and Formatting
- Ruff for code quality
- MyPy for type checking
-
Bandit for security
-
Testing
- Unit tests for template logic
- Integration tests for generation
-
Cross-platform testing
-
Template Validation
- Generate projects with different configs
- Test generated project quality
- Verify all features work
๐๏ธ Template Architecture
Directory Structure
cookiecutter-python-package/
โโโ cookiecutter.json # Template configuration
โโโ hooks/ # Post-generation hooks
โ โโโ post_gen_project.py # Cleanup and setup script
โโโ tests/ # Template tests
โ โโโ test_template.py # Template generation tests
โ โโโ test_validation.py # Validation tests
โ โโโ test_hooks.py # Hook tests
โโโ {{cookiecutter.project_slug}}/ # Main template
โ โโโ src/ # Source code structure
โ โโโ tests/ # Test structure
โ โโโ pyproject.toml # Python project configuration
โ โโโ ... # Other project files
โโโ docs/ # Template documentation
Key Files
cookiecutter.json
: Defines all template variables and optionshooks/post_gen_project.py
: Cleans up unused files based on configuration{{cookiecutter.project_slug}}/pyproject.toml
: Modern Python project configuration- Template tests: Ensure template works correctly
๐ค Getting Help
Questions and Discussions
- GitHub Discussions: For questions and ideas
- Issues: For bug reports and feature requests
- Email: Contact maintainers directly
Resources
๐ Recognition
Contributors are recognized:
- In the project README
- In release notes
- In the contributor's guide
Thank you for contributing to making Python development better for everyone! ๐โจ