First off, thank you for considering contributing to the OpenF1 Python Client! 🏎️
- Code of Conduct
- Getting Started
- Development Setup
- Making Changes
- Code Style
- Testing
- Submitting Changes
- Reporting Bugs
- Suggesting Features
This project and everyone participating in it is governed by our commitment to providing a welcoming and inclusive environment. Please be respectful and constructive in all interactions.
-
Fork the repository on GitHub
-
Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/openf1-python.git cd openf1-python -
Add the upstream repository as a remote:
git remote add upstream https://github.com/openf1-client/openf1-python.git
-
Ensure you have Python 3.10 or higher installed:
python --version
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install the package in development mode with all dependencies:
pip install -e ".[dev]" -
Verify the installation:
pytest --version mypy --version black --version ruff --version
-
Create a new branch for your changes:
git checkout -b feature/your-feature-name # or git checkout -b fix/your-bug-fix -
Make your changes following the Code Style guidelines
-
Add or update tests as needed
-
Run the test suite to ensure everything passes:
pytest
-
Commit your changes with a clear, descriptive message:
git commit -m "Add feature: description of what you added" # or git commit -m "Fix: description of what you fixed"
This project follows strict code style guidelines:
- Black for code formatting (line length: 88)
- Ruff for linting
Run formatters before committing:
black src tests
ruff check src tests --fix-
All public functions and methods must have type hints
-
Use
from __future__ import annotationsfor modern annotation syntax -
Run type checking with:
mypy src/openf1_client
-
Use Google-style docstrings
-
All public classes, methods, and functions must have docstrings
-
Example:
def get_laps(self, session_key: int, driver_number: int) -> list[Lap]: """ Fetch lap data for a specific driver. Args: session_key: The session identifier. driver_number: The driver's car number. Returns: A list of Lap objects for the specified driver. Raises: OpenF1APIError: If the API returns an error response. """
- Classes:
PascalCase - Functions and variables:
snake_case - Constants:
UPPER_SNAKE_CASE - Private attributes:
_leading_underscore
# Run all tests
pytest
# Run with coverage report
pytest --cov=openf1_client --cov-report=term-missing
# Run specific test file
pytest tests/test_client.py
# Run specific test
pytest tests/test_client.py::TestClientInitialization::test_default_initialization
# Run with verbose output
pytest -v- Place tests in the
tests/directory - Name test files
test_*.py - Name test functions
test_* - Use
pytestfixtures for setup/teardown - Mock external HTTP calls using the
responseslibrary
Example test:
import pytest
import responses
from openf1_client import OpenF1Client
@responses.activate
def test_fetch_drivers():
"""Test fetching driver data."""
responses.add(
responses.GET,
"https://api.openf1.org/v1/drivers",
json=[{"driver_number": 1, "full_name": "Max Verstappen"}],
status=200,
)
with OpenF1Client() as client:
drivers = client.drivers.list(session_key=9158)
assert len(drivers) == 1
assert drivers[0].full_name == "Max Verstappen"-
Push your branch to your fork:
git push origin feature/your-feature-name
-
Create a Pull Request on GitHub
-
In your PR description, include:
- A clear description of the changes
- The motivation for the changes
- Any breaking changes
- Screenshots or examples if applicable
-
Wait for review and address any feedback
Before submitting, ensure:
- All tests pass (
pytest) - Code is formatted (
black src tests) - Linting passes (
ruff check src tests) - Type checking passes (
mypy src/openf1_client) - New features have tests
- Documentation is updated if needed
When reporting bugs, please include:
- Python version: Output of
python --version - Package version: Output of
pip show openf1-client - Operating system: e.g., macOS 14.0, Ubuntu 22.04, Windows 11
- Steps to reproduce: Minimal code example that demonstrates the issue
- Expected behavior: What you expected to happen
- Actual behavior: What actually happened
- Error messages: Full traceback if applicable
Use this template:
**Environment:**
- Python: 3.12.0
- openf1-client: 1.0.0
- OS: macOS 14.0
**Steps to reproduce:**
```python
from openf1_client import OpenF1Client
# Your code hereExpected behavior: Description of what should happen.
Actual behavior: Description of what actually happened.
Error message:
Traceback (most recent call last):
...
## Suggesting Features
Feature suggestions are welcome! When suggesting a feature:
1. Check existing issues to avoid duplicates
2. Clearly describe the use case
3. Explain how the feature would benefit users
4. If possible, suggest an API design
---
Thank you for contributing! 🏁