Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/TracingInsights/tif1/llms.txt

Use this file to discover all available pages before exploring further.

Welcome Contributors!

Thank you for your interest in contributing to tif1! This guide will help you get started with development and explain our contribution process.
tif1 is built with a focus on performance, reliability, and API compatibility. All contributions should align with these core principles.

Development Setup

Prerequisites

1

Python 3.10+

Ensure you have Python 3.10 or higher installed
2

uv package manager

Install uv for dependency management
curl -LsSf https://astral.sh/uv/install.sh | sh

Installation

git clone https://github.com/TracingInsights/tif1.git
cd tif1
The git hooks will run linting and type checking before every commit and push. This ensures code quality and catches issues early.

Development Workflow

Running Tests

uv run pytest tests/ -v
Default configuration runs tests in parallel for faster execution.
uv run pytest tests/unit/test_core.py -v
uv run pytest tests/ -v -k "test_name"
uv run pytest tests/unit/ -v
uv run pytest tests/integration/ -v
Integration tests run serially to avoid rate limits.
uv run pytest tests/property/ -v
uv run pytest -o addopts='' tests/test_benchmarks.py -v -m benchmark --benchmark-only --no-cov -n 0
uv run pytest tests/ -v --cov=src/tif1 --cov-report=html
Coverage report generated in htmlcov/index.html

Code Quality

# Check for linting issues
uv run ruff check src/ tests/

# Auto-fix issues
uv run ruff check --fix src/ tests/

Running Examples

# Run basic usage example
uv run python examples/basic_usage.py

# Run async loading example
uv run python examples/async_loading.py

# Run any example
uv run python examples/<example_name>.py

Code Style Guidelines

PEP 8 Compliance

Follow Python PEP 8 guidelines for all code

Type Hints

Use type hints for all function signatures

Docstrings

Write Google-style docstrings for public APIs

Line Length

Keep lines to 100 characters maximum

Code Style Details

Example Function
def get_fastest_lap(
    session: Session,
    driver: str,
    *,
    compound: str | None = None
) -> pd.DataFrame:
    """Get the fastest lap for a driver in a session.
    
    Args:
        session: The session object to query
        driver: Three-letter driver code (e.g., 'VER')
        compound: Optional tire compound filter
    
    Returns:
        DataFrame with single fastest lap
    
    Raises:
        DriverNotFoundError: If driver not in session
    
    Example:
        ```python
        session = tif1.get_session(2025, "Monaco GP", "Qualifying")
        fastest = get_fastest_lap(session, "VER", compound="SOFT")
"""

Implementation here

pass

<Warning>
  Always use meaningful variable names. Avoid single-letter variables except for common cases like `i`, `j` in loops or `e` for exceptions.
</Warning>

## Testing Guidelines

### Test Requirements

<Steps>
  <Step title="Write tests for all new features">
    Every new feature must include comprehensive tests
  </Step>
  
  <Step title="Maintain 80%+ code coverage">
    Coverage must not decrease with new changes (enforced by CI)
  </Step>
  
  <Step title="Use pytest fixtures">
    Leverage fixtures for common setup and teardown
  </Step>
  
  <Step title="Mock external dependencies">
    Use mocks for HTTP requests and file I/O in unit tests
  </Step>
  
  <Step title="Add integration tests">
    Include integration tests for features that interact with real data
  </Step>
</Steps>

### Test Structure

```python Example Test
import pytest
from unittest.mock import Mock, patch
import tif1

class TestSession:
    """Tests for Session class."""
    
    @pytest.fixture
    def mock_session(self):
        """Create a mock session for testing."""
        return tif1.get_session(2025, "Test GP", "Race")
    
    def test_get_driver_valid(self, mock_session):
        """Test getting a valid driver."""
        with patch('tif1.core.Session.drivers_df') as mock_drivers:
            mock_drivers.return_value = pd.DataFrame({
                'Driver': ['VER', 'HAM'],
                'Team': ['Red Bull', 'Mercedes']
            })
            
            driver = mock_session.get_driver('VER')
            assert driver.code == 'VER'
    
    def test_get_driver_invalid(self, mock_session):
        """Test getting an invalid driver raises error."""
        with pytest.raises(tif1.DriverNotFoundError):
            mock_session.get_driver('XXX')
    
    @pytest.mark.benchmark
    def test_laps_loading_performance(self, benchmark):
        """Benchmark laps loading performance."""
        session = tif1.get_session(2025, "Test GP", "Race")
        result = benchmark(lambda: session.laps)
        assert len(result) > 0

Pull Request Process

Before Submitting

PR Requirements

CI will run the full test suite. All tests must pass before merge.
Coverage should not decrease. Aim for 80%+ on new code.
Code must pass ruff linting and ty type checking.
Update docstrings and documentation for new features.
Add an entry to CHANGELOG.md describing your changes.

Submitting the PR

1

Push to your fork

git push origin feature/your-feature
2

Open a Pull Request

Go to the tif1 repository and open a PR from your branch
3

Fill out PR template

Describe your changes, link related issues, and explain testing
4

Wait for review

Maintainers will review your PR and provide feedback
5

Address feedback

Make requested changes and push updates
6

Merge

Once approved, your PR will be merged!

Commit Message Format

Use clear, descriptive commit messages following conventional commits:
feat: Add support for weather data integration

- Implement weather data fetching from CDN
- Add weather DataFrame processing
- Include tests for weather data

Documentation

When to Update Docs

New Features

Add examples and API documentation for new functionality

API Changes

Update API reference for changed function signatures

Breaking Changes

Document migration guide and update compatibility matrix

Bug Fixes

Update examples if behavior changes

Documentation Structure

  • README.md: Quick start and overview
  • docs/: Full documentation (Mintlify)
  • Docstrings: Google-style in code
  • examples/: Practical usage examples

Performance Considerations

Performance is critical to tif1. The entire existence of this library focuses on optimization, speed, and performance.

Performance Checklist

Benchmarking

# Run benchmarks
uv run pytest -o addopts='' tests/test_benchmarks.py -v -m benchmark --benchmark-only --no-cov -n 0

# Compare with baseline
uv run pytest tests/test_benchmarks.py --benchmark-compare

Architecture Constraints

Never use https://raw.githubusercontent.com as a CDN source due to rate limits. Only use jsDelivr CDN.

Key Patterns

  1. Data Flow: CDN URL → async HTTP → JSON parse → DataFrame → cache
  2. Error Handling: Use custom exceptions from exceptions.py, never swallow errors
  3. JSON Parsing: Always use orjson, not stdlib json
  4. Backend Support: Gate polars behind _ensure_polars_available()
  5. Type Hints: Use everywhere; Python >=3.10 syntax
  6. Imports: Keep sorted (ruff), avoid unused imports

Need Help?

GitHub Issues

Report bugs or request features

GitHub Discussions

Ask questions and discuss ideas

Architecture Guide

Learn about system design

Examples

See practical usage patterns

Code of Conduct

We are committed to providing a welcoming and inclusive environment. Please be respectful, constructive, and professional in all interactions.

Expected Behavior

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

Unacceptable Behavior

  • Harassment or discrimination
  • Trolling or insulting comments
  • Personal or political attacks
  • Publishing others’ private information

License

By contributing, you agree that your contributions will be licensed under the MIT License.

Start small! Look for issues labeled good first issue or help wanted on GitHub.

Build docs developers (and LLMs) love