standardize packaging, tooling, docs, CI, and licensing

This commit is contained in:
2026-09-10 18:49:08 +05:30
parent c541577788
commit 3bc45ff9fa
36 changed files with 308 additions and 115 deletions

View File

@@ -15,14 +15,15 @@ It is the only place in the codebase where:
All Gmail-specific behavior must be strictly contained within this module.
"""
from typing import Iterator, Dict, Any
from collections.abc import Iterator
from typing import Any
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
from mail_intake.adapters.base import MailIntakeAdapter
from mail_intake.exceptions import MailIntakeAdapterError
from mail_intake.auth.base import MailIntakeAuthProvider
from mail_intake.exceptions import MailIntakeAdapterError
class MailIntakeGmailAdapter(MailIntakeAdapter):
@@ -89,7 +90,7 @@ class MailIntakeGmailAdapter(MailIntakeAdapter):
) from exc
return self._service
def iter_message_refs(self, query: str) -> Iterator[Dict[str, str]]:
def iter_message_refs(self, query: str) -> Iterator[dict[str, str]]:
"""
Iterate over message references matching the query.
@@ -107,9 +108,7 @@ class MailIntakeGmailAdapter(MailIntakeAdapter):
"""
try:
request = (
self.service.users()
.messages()
.list(userId=self._user_id, q=query)
self.service.users().messages().list(userId=self._user_id, q=query)
)
while request is not None:
@@ -121,18 +120,14 @@ class MailIntakeGmailAdapter(MailIntakeAdapter):
"thread_id": msg["threadId"],
}
request = (
self.service.users()
.messages()
.list_next(request, response)
)
request = self.service.users().messages().list_next(request, response)
except HttpError as exc:
raise MailIntakeAdapterError(
"Gmail API error while listing messages"
) from exc
def fetch_message(self, message_id: str) -> Dict[str, Any]:
def fetch_message(self, message_id: str) -> dict[str, Any]:
"""
Fetch a full Gmail message by message ID.
@@ -160,7 +155,7 @@ class MailIntakeGmailAdapter(MailIntakeAdapter):
f"Gmail API error while fetching message {message_id}"
) from exc
def fetch_thread(self, thread_id: str) -> Dict[str, Any]:
def fetch_thread(self, thread_id: str) -> dict[str, Any]:
"""
Fetch a full Gmail thread by thread ID.