Skip to content

Contributing

Thank you for your interest in contributing to FastAPI Environment Banner! This document provides guidelines and instructions for contributing.

Getting Started

Prerequisites

  • Python 3.12 or higher
  • pip or uv for package management
  • Git

Development Setup

  1. Fork and clone the repository
git clone https://github.com/YOUR_USERNAME/fastapi-env-banner.git
cd fastapi-env-banner
  1. Install development dependencies
pip install -e ".[dev]"

Or with uv:

uv pip install -e ".[dev]"
  1. Verify installation
pytest

Running Tests

Run all tests

pytest

Run with coverage

pytest --cov=fastapi_env_banner --cov-report=html

Run specific test file

pytest tests/test_config.py

Run specific test

pytest tests/test_config.py::TestEnvironmentEnum::test_environment_values

Code Style

  • Follow PEP 8 guidelines
  • Use type hints for all function parameters and return values
  • Write docstrings for all public functions and classes
  • Keep functions focused and single-purpose
  • Maximum line length: 100 characters

Example

def get_banner_color(self) -> str:
    """Get the banner background color based on environment.

    Returns:
        str: Hexadecimal color code
    """
    if self.custom_color:
        return self.custom_color

    return self.color_map.get(self.environment, "#4CAF50")

Testing Guidelines

  • Write tests for all new features
  • Ensure tests cover both happy path and edge cases
  • Aim for >90% code coverage
  • Use descriptive test names
  • Group related tests in classes

Test Structure

class TestFeatureName:
    """Tests for feature description."""

    def test_happy_path(self):
        """Test the expected behavior."""
        # Arrange
        config = EnvBannerConfig()

        # Act
        result = config.get_banner_color()

        # Assert
        assert result == "#4CAF50"

    def test_edge_case(self):
        """Test edge case behavior."""
        # Test implementation

Pull Request Process

  1. Create a feature branch
git checkout -b feature/your-feature-name
  1. Make your changes
  2. Write code
  3. Add tests
  4. Update documentation

  5. Run tests and ensure they pass

pytest
  1. Commit your changes
git add .
git commit -m "Add feature: description of your changes"
  1. Push to your fork
git push origin feature/your-feature-name
  1. Open a Pull Request
  2. Go to the original repository
  3. Click "New Pull Request"
  4. Select your branch
  5. Fill in the PR template
  6. Submit the PR

Pull Request Checklist

  • [ ] Tests pass locally
  • [ ] Code follows project style guidelines
  • [ ] Documentation is updated
  • [ ] Commit messages are clear and descriptive
  • [ ] No unnecessary files are included
  • [ ] Branch is up to date with main

Bug Reports

When reporting bugs, please include:

  1. Description: Clear description of the bug
  2. Steps to Reproduce: Minimal steps to reproduce the issue
  3. Expected Behavior: What you expected to happen
  4. Actual Behavior: What actually happened
  5. Environment: Python version, OS, library version
  6. Code Sample: Minimal code that reproduces the issue

Feature Requests

When requesting features, please include:

  1. Use Case: Why is this feature needed?
  2. Proposed Solution: How should it work?
  3. Alternatives: Other solutions you've considered
  4. Additional Context: Any other relevant information

Documentation

  • Update README.md for user-facing changes
  • Add docstrings to all new functions and classes
  • Update examples if behavior changes
  • Keep documentation clear and concise

Release Process

Releases are managed by maintainers. The process includes:

  1. Update version in pyproject.toml
  2. Update CHANGELOG.md
  3. Create a git tag
  4. Build and publish to PyPI

Questions?

If you have questions, feel free to:

  • Open an issue for discussion
  • Check existing issues and PRs
  • Review the documentation

Code of Conduct

  • Be respectful and inclusive
  • Provide constructive feedback
  • Focus on what is best for the community
  • Show empathy towards others

Thank you for contributing! 🎉