# Run basic usage exampleuv run python examples/basic_usage.py# Run async loading exampleuv run python examples/async_loading.py# Run any exampleuv run python examples/<example_name>.py
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")
<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 Testimport pytestfrom unittest.mock import Mock, patchimport tif1class 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
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