Contributing
Thank you for your interest in contributing to django-honeyguard!
Getting Started
Fork the repository on GitHub
Clone your fork:
git clone https://github.com/yourusername/django-honeyguard.git cd django-honeyguard
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
Install dependencies:
pip install -e ".[dev]"
Run tests:
pytest
Development Setup
Install development dependencies:
pip install -e ".[dev]"
This installs:
Django and required dependencies
pytest and pytest-django for testing
Coverage tools
Linting tools
Running Tests
Run all tests:
pytest
Run with coverage:
pytest --cov=django_honeyguard --cov-report=html
Run specific test file:
pytest tests/test_models.py
Run specific test:
pytest tests/test_models.py::TestHoneyGuardLogModel::test_risk_score_calculation
Code Style
We follow PEP 8 style guidelines. Use black for formatting:
black django_honeyguard tests
And isort for import sorting:
isort django_honeyguard tests
Check with flake8:
flake8 django_honeyguard tests
Type Hints
We use type hints throughout the codebase. Always add type hints to:
Function parameters
Return values
Class attributes
Example:
def process_request(request: HttpRequest, data: Dict[str, Any]) -> HttpResponse:
"""Process honeypot request."""
pass
Writing Tests
All new features must include tests
Aim for at least 95% code coverage
Use descriptive test names
Group related tests in classes
Use fixtures from
conftest.pywhen available
Example:
def test_honeypot_detection_with_custom_field(self, sample_request):
"""Test that custom honeypot field is detected."""
data = {"custom_hp": "filled"}
service = HoneyGuardService(sample_request, data)
assert service.data["honeypot_triggered"] is True
Documentation
Update relevant documentation files
Add docstrings to all public functions and classes
Use Google-style docstrings
Update examples if behavior changes
Commit Messages
Follow conventional commits:
feat:- New featurefix:- Bug fixdocs:- Documentation changestest:- Test additions/changesrefactor:- Code refactoringstyle:- Code style changeschore:- Maintenance tasks
Examples:
git commit -m "feat: Add custom error message configuration"
git commit -m "fix: Handle None request in signal handler"
git commit -m "docs: Update installation guide"
Pull Request Process
Create a feature branch:
git checkout -b feature/my-new-feature
Make your changes and commit them
Push to your fork:
git push origin feature/my-new-feature
Open a Pull Request on GitHub
Ensure all checks pass:
Tests pass
Code coverage is maintained
Linting passes
Documentation is updated
Address review feedback if requested
Pull Request Checklist
[ ] Tests added/updated
[ ] Documentation updated
[ ] Type hints added
[ ] Code follows style guidelines
[ ] All tests pass
[ ] Coverage maintained
[ ] CHANGELOG updated (if applicable)
Reporting Issues
When reporting bugs, please include:
Django version
Python version
django-honeyguard version
Steps to reproduce
Expected behavior
Actual behavior
Error messages/tracebacks
Feature Requests
For feature requests:
Describe the use case
Explain why it would be useful
Provide examples if possible
License
By contributing, you agree that your contributions will be licensed under the same license as the project (see LICENSE file).
Questions?
Feel free to open an issue or discussion on GitHub for any questions.