fix(mypy): resolve type issues in MongoDB, batches, and auth providers

Resolves typing issues across provider utilities:

**MongoDB (6 errors fixed):**
- Fix AsyncMongoClient parameter dict unpacking by building typed dict with None filtering
- Fix AsyncCursor synchronous iteration - use async for loop

**Batches (1 error fixed):**
- Handle memoryview|bytes union type for file content decoding

**Auth Providers (4 errors fixed):**
- Add missing Any import
- Ensure JWKS URI is not None with validation
- Only pass lifespan parameter when configured (let library use its default)
- Conditionally build httpx post kwargs to avoid passing None for auth

Fixes 11 mypy type errors in provider utility layer.
This commit is contained in:
Ashwin Bharambe 2025-10-27 21:21:52 -07:00
parent 41a65b87e6
commit f34b6288cc
3 changed files with 52 additions and 29 deletions

View file

@ -358,7 +358,11 @@ class ReferenceBatchesImpl(Batches):
# TODO(SECURITY): do something about large files
file_content_response = await self.files_api.openai_retrieve_file_content(batch.input_file_id)
file_content = file_content_response.body.decode("utf-8")
# Handle both bytes and memoryview types
body = file_content_response.body
if isinstance(body, memoryview):
body = bytes(body)
file_content = body.decode("utf-8")
for line_num, line in enumerate(file_content.strip().split("\n"), 1):
if line.strip(): # skip empty lines
try: