Repository navigation
docs: update copilot instructions with API integration details - #2
Conversation
There was a problem hiding this comment.
Pull Request Overview
Updates the Copilot instructions to reflect the new community API integration, expanded data coverage, and testing/mocking patterns.
- Switches API source to community Helldivers 2 API with required headers and rate limits
- Expands documented scraper/database scope and lifecycle/config details
- Documents unit testing approach using unittest.mock.patch and updated dependency notes
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| import httpx | ||
|
|
||
| @retry(wait=wait_exponential(multiplier=1, min=2, max=10), stop=stop_after_attempt(5), retry=retry_if_exception_type(httpx.HTTPStatusError)) | ||
| async def fetch_with_rate_limit(url, headers): | ||
| async with httpx.AsyncClient() as client: | ||
| response = await client.get(url, headers=headers) | ||
| if response.status_code == 429: | ||
| raise httpx.HTTPStatusError("Rate limit exceeded", request=response.request, response=response) | ||
| response.raise_for_status() | ||
| return response.json() |
There was a problem hiding this comment.
The pseudocode uses httpx.AsyncClient, but the Dependencies section specifies Requests and the testing guidance patches requests (requests.Session.request). To avoid confusion, either (a) rewrite the example to use requests (sync) or (b) add httpx (and tenacity if mandated) to the Dependencies section and adjust testing examples accordingly (e.g., patching the httpx import path used in scraper.py).
| # Throttle requests in collector/scraper: | ||
| semaphore = asyncio.Semaphore(5) | ||
| async def throttled_fetch(*args, **kwargs): | ||
| async with semaphore: | ||
| return await fetch_with_rate_limit(*args, **kwargs) |
There was a problem hiding this comment.
Using asyncio.Semaphore(5) limits concurrent requests, not the documented rate of 5 requests per 10 seconds. Replace with a time-window rate limiter (e.g., token bucket) such as aiolimiter: from aiolimiter import AsyncLimiter; limiter = AsyncLimiter(5, 10); async with limiter: ... to enforce the actual time-based rate, and list the chosen limiter in Dependencies if you expect contributors to use it.
Description
Updates
.github/copilot-instructions.mdwith latest API integration details, test mocking approach, and implementation patterns.Changes
Related
Completes documentation updates from merged PR #1 (feature/hell-divers-api-integration)
Checklist