Contributing to fastapi_otel_common
Table of contents
- Overview
- Development Setup
- Code Style
- Testing
- Coding Guidelines
- Commit Messages
- Pull Request Process
- Project Structure
- Questions?
Overview
Thank you for your interest in contributing! This document provides guidelines for contributing to this project.
Development Setup
- Clone the repository
git clone https://github.com/devdenvino/fastapi_otel_common.git cd fastapi_otel_common - Create a virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate - Install development dependencies
pip install -e ".[dev]"
Code Style
This project follows Python best practices and uses automated tools for code quality:
- Black for code formatting (line length: 100)
- Ruff for linting and import sorting
- MyPy for type checking
Run formatting and linting:
# Format code
black .
# Lint code
ruff check .
# Type check
mypy fastapi_otel_common
Testing
All code changes should include tests. We use pytest for testing.
# Run all tests
pytest
# Run with coverage
pytest --cov=fastapi_otel_common --cov-report=term-missing
# Run specific test file
pytest test_middleware.py -v
Coding Guidelines
- Type Hints: All functions must have proper type hints
def my_function(param: str) -> dict: return {"result": param} - Docstrings: Use Google-style docstrings
def my_function(param: str) -> dict: """Short description. Args: param: Description of parameter Returns: dict: Description of return value """ return {"result": param} - Imports: Keep imports organized (standard lib, third-party, local)
import os from typing import Optional from fastapi import FastAPI from pydantic import BaseModel from .config import APP_TITLE - Error Handling: Use proper exception handling with logging
try: result = risky_operation() except SpecificError as e: logger.error(f"Operation failed: {e}") raise
Commit Messages
Follow conventional commits format:
feat: add new middlewarefix: resolve rate limiting issuedocs: update READMEtest: add tests for middlewarerefactor: improve error handlingchore: update dependencies
Pull Request Process
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes with tests
- Ensure all tests pass and code is formatted
- Update documentation if needed
- Push and create a pull request
- Wait for review and address feedback
Project Structure
fastapi_otel_common/
├── core/ # Core configuration and middleware
├── database/ # Database session management
├── logging/ # Logging configuration
├── routes/ # Common routes (health checks)
├── security/ # Authentication and authorization
└── telemetry/ # OpenTelemetry tracing
Questions?
Feel free to open an issue for questions or discussions.