Contributing Guide
Thank you for considering contributing to Lambda Universal Router! This document provides guidelines and instructions for contributing.
Getting Started
- Fork the repository
- Clone your fork:
git clone https://github.com/your-username/lambda-universal-router.git cd lambda-universal-router
- Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
- Install development dependencies:
pip install -r requirements-dev.txt
Development Workflow
- Create a new branch:
git checkout -b feature/your-feature-name
- Make your changes
- Run tests:
python -m pytest
- Commit your changes:
git add . git commit -m "Add your meaningful commit message"
- Push to your fork:
git push origin feature/your-feature-name
- Create a Pull Request
Adding New Event Types
- Create a new file in
lambda_universal_router/events/
:from __future__ import annotations from typing import Any, Dict from dataclasses import dataclass from ..base import BaseEvent @dataclass class NewEventData: field1: str field2: int class NewEvent(BaseEvent): def _parse_event(self, event_dict: Dict[str, Any]) -> None: self.data = NewEventData( field1=event_dict.get('field1', ''), field2=event_dict.get('field2', 0) )
- Create a handler in
lambda_universal_router/handlers.py
:class NewEventHandler(EventHandler): def can_handle(self, event: Dict[str, Any]) -> bool: return 'specific_field' in event def parse_event(self, event: Dict[str, Any]) -> NewEvent: return NewEvent(event)
- Add to Router class in
router.py
:def new_event(self) -> Callable: def decorator(func: Callable) -> Callable: self._handlers.append( HandlerRegistration( func=func, handler=self._event_handlers['new_event'] ) ) return func return decorator
- Add tests in
tests/test_router.py
Code Style
- Follow PEP 8
- Use type hints
- Write docstrings for public methods
- Keep functions focused and small
- Add tests for new features
Running Tests
# Run all tests
python -m pytest
# Run with coverage
python -m pytest --cov=lambda_universal_router
# Run specific test file
python -m pytest tests/test_router.py
Documentation
- Update docstrings for any new code
- Add examples for new features
- Update README.md if needed
- Add changelog entries
Pull Request Process
- Update documentation
- Add tests for new features
- Update CHANGELOG.md
- Ensure all tests pass
- Request review from maintainers
Release Process
- Update version in
setup.py
- Update CHANGELOG.md
- Create a new release on GitHub
- Publish to PyPI
Questions?
Feel free to open an issue for:
- Bug reports
- Feature requests
- Questions about the codebase
- Documentation improvements