standardize packaging, tooling, docs, CI, and licensing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from .body import extract_body
|
||||
from .headers import parse_headers, extract_sender
|
||||
from .headers import extract_sender, parse_headers
|
||||
from .subject import normalize_subject
|
||||
|
||||
__all__ = ["extract_body", "parse_headers", "extract_sender", "normalize_subject"]
|
||||
|
||||
@@ -11,7 +11,7 @@ prefers human-readable text over fidelity to original formatting.
|
||||
"""
|
||||
|
||||
import base64
|
||||
from typing import Dict, Any, Optional
|
||||
from typing import Any
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
@@ -45,7 +45,7 @@ def _decode_base64(data: str) -> str:
|
||||
raise MailIntakeParsingError("Failed to decode message body") from exc
|
||||
|
||||
|
||||
def _extract_from_part(part: Dict[str, Any]) -> Optional[str]:
|
||||
def _extract_from_part(part: dict[str, Any]) -> str | None:
|
||||
"""
|
||||
Extract text content from a single MIME part.
|
||||
|
||||
@@ -82,7 +82,7 @@ def _extract_from_part(part: Dict[str, Any]) -> Optional[str]:
|
||||
return None
|
||||
|
||||
|
||||
def extract_body(payload: Dict[str, Any]) -> str:
|
||||
def extract_body(payload: dict[str, Any]) -> str:
|
||||
"""
|
||||
Extract the best-effort message body from a Gmail payload.
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
from typing import Dict, Any
|
||||
from typing import Any
|
||||
|
||||
def extract_body(payload: Dict[str, Any]) -> str: ...
|
||||
def extract_body(payload: dict[str, Any]) -> str: ...
|
||||
|
||||
@@ -10,10 +10,8 @@ The functions here are intentionally simple and tolerant of malformed
|
||||
or incomplete header data.
|
||||
"""
|
||||
|
||||
from typing import Dict, List, Tuple, Optional
|
||||
|
||||
|
||||
def parse_headers(raw_headers: List[Dict[str, str]]) -> Dict[str, str]:
|
||||
def parse_headers(raw_headers: list[dict[str, str]]) -> dict[str, str]:
|
||||
"""
|
||||
Convert a list of Gmail-style headers into a normalized dict.
|
||||
|
||||
@@ -50,7 +48,7 @@ def parse_headers(raw_headers: List[Dict[str, str]]) -> Dict[str, str]:
|
||||
}
|
||||
```
|
||||
"""
|
||||
headers: Dict[str, str] = {}
|
||||
headers: dict[str, str] = {}
|
||||
|
||||
for header in raw_headers or []:
|
||||
name = header.get("name")
|
||||
@@ -64,7 +62,7 @@ def parse_headers(raw_headers: List[Dict[str, str]]) -> Dict[str, str]:
|
||||
return headers
|
||||
|
||||
|
||||
def extract_sender(headers: Dict[str, str]) -> Tuple[str, Optional[str]]:
|
||||
def extract_sender(headers: dict[str, str]) -> tuple[str, str | None]:
|
||||
"""
|
||||
Extract sender email and optional display name from headers.
|
||||
|
||||
|
||||
@@ -1,4 +1,2 @@
|
||||
from typing import Dict, List, Tuple, Optional
|
||||
|
||||
def parse_headers(raw_headers: List[Dict[str, str]]) -> Dict[str, str]: ...
|
||||
def extract_sender(headers: Dict[str, str]) -> Tuple[str, Optional[str]]: ...
|
||||
def parse_headers(raw_headers: list[dict[str, str]]) -> dict[str, str]: ...
|
||||
def extract_sender(headers: dict[str, str]) -> tuple[str, str | None]: ...
|
||||
|
||||
@@ -12,7 +12,6 @@ meaning while removing common reply and forward prefixes.
|
||||
|
||||
import re
|
||||
|
||||
|
||||
_PREFIX_RE = re.compile(r"^(re|fw|fwd)\s*:\s*", re.IGNORECASE)
|
||||
"""
|
||||
Regular expression matching common reply/forward subject prefixes.
|
||||
|
||||
Reference in New Issue
Block a user