- Formatting: All code must pass
blackformatting - Imports: Must be organized with
isort - Linting: Must pass
ruffchecks - Type Hints: All functions must have type hints (enforced by
mypy) - Security: Must pass
banditsecurity scan - Test Coverage: Minimum 80% coverage required
Pre-commit hooks are configured and must pass before commits:
# Install pre-commit hooks
pre-commit install
# Run manually
pre-commit run --all-files# Clone with submodules
git clone --recursive https://github.com/Ladvien/entity.git
cd entity
# Install Poetry
curl -sSL https://install.python-poetry.org | python3 -
# Install dependencies
poetry install
# Activate virtual environment
poetry shell# Create feature branch
git checkout -b feature/your-feature
# Make changes
# ...
# Run quality checks
poetry run black src/ tests/
poetry run isort src/ tests/
poetry run ruff check src/ tests/
poetry run mypy src/
poetry run bandit -r src/
# Run tests
poetry run pytest tests/ --cov=src/entityFollow conventional commits:
feat:New featurefix:Bug fixdocs:Documentation changesstyle:Code style changesrefactor:Code refactoringtest:Test changeschore:Maintenance tasks
For significant milestones:
# Create checkpoint branch
git checkout -b checkpoint-XX
# Commit and push
git add -A
git commit -m "checkpoint-XX: Description"
git push origin checkpoint-XX
# Merge to main (no-delete)
git checkout main
git merge checkpoint-XX
git push origin main- All plugins must inherit from
Pluginbase class - Implement required methods:
execute,validate - Use type hints for all parameters and return values
- Include comprehensive docstrings
Example:
from entity.plugins.base import Plugin
from entity.plugins.context import PluginContext
class MyPlugin(Plugin):
"""Brief description of plugin."""
supported_stages = ["INPUT", "OUTPUT"]
async def execute(self, context: PluginContext) -> PluginContext:
"""Execute plugin logic."""
# Implementation
return context
async def validate(self, context: PluginContext) -> bool:
"""Validate plugin can execute."""
return True- Use context managers for resources
- Implement proper cleanup in
__aexit__ - Handle exceptions gracefully
- Log all errors appropriately
- Write tests for all new features
- Use pytest fixtures for setup
- Mock external dependencies
- Test both success and failure cases
import pytest
from unittest.mock import Mock, patch
@pytest.fixture
def setup_data():
"""Fixture for test data."""
return {"key": "value"}
async def test_feature(setup_data):
"""Test feature description."""
result = await function_under_test(setup_data)
assert result.success is True- Correctness > Performance
- Readability > Cleverness
- Maintainability > Micro-optimizations
- Clear collections when done:
list.clear(),dict.clear() - Use generators for large datasets
- Implement
__slots__for frequently instantiated classes - Profile memory usage for critical paths
- Use
async/awaitfor I/O operations - Batch operations when possible
- Implement proper cancellation handling
- Use
asyncio.gather()for concurrent operations
- API keys, tokens, or secrets
- Personal information
- Internal URLs or endpoints
- Debug output with sensitive data
- User input sanitization
- SQL injection prevention
- Path traversal protection
- Command injection prevention
def function(param1: str, param2: int) -> dict:
"""Brief description.
Longer description if needed.
Args:
param1: Description of param1.
param2: Description of param2.
Returns:
Description of return value.
Raises:
ValueError: When param1 is invalid.
"""Update README.md when:
- Adding new features
- Changing API
- Modifying installation steps
- Adding dependencies
Daily:
- Check CI/CD pipeline status
- Review error logs
Weekly:
- Run full test suite locally
- Check dependency updates
- Review open issues
Monthly:
- Performance profiling
- Security audit
- Documentation review
Run periodically (stored in memory as "Cleanup Checklist"):
- Remove dead code (vulture)
- Find duplicates (pylint)
- Fix imports (autoflake, isort)
- Format code (black)
- Type checking (mypy)
- Security scan (bandit)
- Test coverage check
- Documentation updates
Follow semantic versioning:
- MAJOR: Breaking changes
- MINOR: New features
- PATCH: Bug fixes
- Update version in
pyproject.toml - Update CHANGELOG.md
- Run full test suite
- Create git tag:
git tag v1.2.3 - Push tag:
git push origin v1.2.3 - GitHub Actions will handle PyPI release
- Issues: https://github.com/Ladvien/entity/issues
- Discussions: https://github.com/Ladvien/entity/discussions
- Documentation: See
/docsdirectory
- Fork the repository
- Create feature branch
- Make changes with tests
- Ensure all checks pass
- Submit pull request
This project is licensed under the MIT License. See LICENSE file for details.