Thank you for your interest in contributing to SocialPie! This document provides guidelines and instructions for contributing.
- Code of Conduct
- Getting Started
- Development Setup
- Making Changes
- Testing
- Code Style
- Submitting Changes
- Plugin Development
Be respectful, constructive, and professional in all interactions.
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/SocialPie.git cd SocialPie - Add upstream remote:
git remote add upstream https://github.com/EricsonWillians/SocialPie.git
# Create virtual environment
python3.10 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode with all extras
pip install -e ".[all,dev]"
# Install pre-commit hooks
pre-commit install# Run type checking
mypy src/socialpie
# Run linting
ruff check src/socialpie
# Run formatting check
black --check src/socialpie
# Run tests
pytestgit checkout -b feature/your-feature-name
# or
git checkout -b fix/your-bug-fix- Write clean, typed Python code
- Follow the existing code style
- Add tests for new functionality
- Update documentation as needed
# Hooks run automatically on commit, or run manually:
pre-commit run --all-files# Run all tests
pytest
# Run with coverage
pytest --cov=socialpie --cov-report=html
# Run specific test file
pytest tests/test_protocol.py
# Run specific test
pytest tests/test_protocol.py::TestMessage::test_create_message
# Run in verbose mode
pytest -v
# Run with output
pytest -s- Place tests in the
tests/directory - Name test files
test_*.py - Name test classes
Test* - Name test methods
test_* - Use pytest fixtures for setup
- Aim for 80%+ code coverage
Example test:
import pytest
from socialpie.core.protocol import Message, MessageType
class TestMessage:
def test_create_message(self) -> None:
"""Test creating a message."""
message = Message(
type=MessageType.CHAT,
user="Alice",
content="Hello!",
)
assert message.type == MessageType.CHAT
assert message.user == "Alice"
assert message.content == "Hello!"All code must have complete type hints:
from typing import Optional, List, Dict, Any
def process_message(
message: str,
user: str,
metadata: Optional[Dict[str, Any]] = None
) -> List[str]:
"""Process a message and return tokens."""
...- Line length: 100 characters
- Imports: Sorted with isort
- Code: Formatted with black
- Docstrings: Google style
Example:
"""Module docstring explaining what this module does."""
from typing import Optional
import structlog
from socialpie.core.protocol import Message
logger = structlog.get_logger(__name__)
class MyClass:
"""Class docstring.
Attributes:
name: The name attribute.
value: The value attribute.
"""
def __init__(self, name: str, value: int) -> None:
"""Initialize the class.
Args:
name: Name parameter.
value: Value parameter.
"""
self.name = name
self.value = value
def process(self, data: str) -> Optional[str]:
"""Process data and return result.
Args:
data: Input data to process.
Returns:
Processed result or None if processing failed.
Raises:
ValueError: If data is invalid.
"""
if not data:
raise ValueError("Data cannot be empty")
return data.upper()Code must pass:
- mypy strict mode (no type errors)
- ruff (no linting errors)
- black (properly formatted)
- isort (imports sorted)
# Add files
git add .
# Commit with descriptive message
git commit -m "Add feature: description of changes
- Detailed point 1
- Detailed point 2
Fixes #123"<type>: <subject>
<body>
<footer>
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringtest: Adding or updating testschore: Maintenance tasks
Example:
feat: Add dice roller plugin
- Implement dice notation parser (XdY+Z)
- Add /roll command
- Support multiple dice types
- Add validation for maximum dice/sides
Closes #42
git push origin feature/your-feature-name- Go to your fork on GitHub
- Click "Pull Request"
- Select your branch
- Fill in the template:
- Description: What changes does this PR make?
- Motivation: Why is this change needed?
- Testing: How has this been tested?
- Screenshots: If UI changes, include screenshots
- Address reviewer feedback
- Make requested changes
- Push updates to your branch (PR updates automatically)
See PLUGIN_DEVELOPMENT_GUIDE.md for detailed instructions.
Quick start:
# Create plugin directory
mkdir -p plugins/community/my-plugin
# Create plugin structure
cd plugins/community/my-plugin
touch __init__.py plugin.py plugin.yaml README.md-
Follow the plugin structure:
plugin.yaml- Manifest with metadataplugin.py- Main plugin code__init__.py- Package initREADME.md- Documentation
-
Use type hints: All plugin code must be fully typed
-
Handle errors: Use try/except and log errors appropriately
-
Document: Add docstrings and README
-
Test: Include tests in
tests/directory -
Configuration: Use config schema for validation
Official plugins go in plugins/official/:
- Must be high quality
- Must have comprehensive tests
- Must have good documentation
- Must follow all coding standards
Community plugins go in plugins/community/:
- More relaxed requirements
- Should have basic tests
- Should have README
- Must work correctly
# Watch tests
ptw # If you have pytest-watch
# Format all code
black src/socialpie tests
isort src/socialpie tests
# Type check
mypy src/socialpie
# Lint
ruff check src/socialpie --fix
# Run specific test with output
pytest -svv tests/test_protocol.py::TestMessage::test_create_message
# Generate coverage report
pytest --cov=socialpie --cov-report=html
open htmlcov/index.htmlUse structlog for logging:
import structlog
logger = structlog.get_logger(__name__)
# Log with context
logger.debug("processing_message", user=user, length=len(content))
logger.info("message_sent", message_id=msg.id)
logger.warning("rate_limit_exceeded", user=user, limit=limit)
logger.error("failed_to_send", error=str(e), exc_info=True)Install extensions:
- Python
- Pylance
- Black Formatter
- isort
- Mypy Type Checker
Settings (.vscode/settings.json):
{
"python.linting.enabled": true,
"python.linting.mypyEnabled": true,
"python.formatting.provider": "black",
"editor.formatOnSave": true,
"python.analysis.typeCheckingMode": "strict"
}- Enable type checking in settings
- Configure Black as external tool
- Set line length to 100
- Enable auto-import optimization
- GitHub Discussions: Ask questions
- Issues: Report bugs or request features
- Discord: Join the community (if available)
By contributing, you agree that your contributions will be licensed under the GPL-3.0-or-later license.
Thank you for contributing to SocialPie! 🎉