chore(release): 0.0.3
Squash-merge lib-standardisation: adopt repo standards across packaging, tooling, docs, and CI. - standardize pyproject.toml (canonical packaging, lint config, extras, GSDFC pydoclint) - add py.typed marker, modernize type hints and Google-style docstrings - nest generated docs under docs/lib and docs/mcp; add hand-written wiki - adopt standard Type A PyPI CI pipeline (tag==version guard + quality gate) - promote generated CHANGELOG.md; bump version to 0.0.3
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.
|
||||
|
||||
@@ -55,11 +55,11 @@ def _extract_from_part(part: Dict[str, Any]) -> Optional[str]:
|
||||
- `text/html` (converted to plain text)
|
||||
|
||||
Args:
|
||||
part (Dict[str, Any]):
|
||||
part (dict[str, Any]):
|
||||
MIME part dictionary from a provider payload.
|
||||
|
||||
Returns:
|
||||
Optional[str]:
|
||||
str | None:
|
||||
Extracted plain-text content, or `None` if unsupported or empty.
|
||||
"""
|
||||
mime_type = part.get("mimeType")
|
||||
@@ -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.
|
||||
|
||||
@@ -94,7 +94,7 @@ def extract_body(payload: Dict[str, Any]) -> str:
|
||||
4. Empty string (if nothing usable found)
|
||||
|
||||
Args:
|
||||
payload (Dict[str, Any]):
|
||||
payload (dict[str, Any]):
|
||||
Provider-native message payload dictionary.
|
||||
|
||||
Returns:
|
||||
|
||||
@@ -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,19 +10,17 @@ 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.
|
||||
|
||||
Args:
|
||||
raw_headers (List[Dict[str, str]]):
|
||||
raw_headers (list[dict[str, str]]):
|
||||
List of header dictionaries, each containing `name` and `value` keys.
|
||||
|
||||
Returns:
|
||||
Dict[str, str]:
|
||||
dict[str, str]:
|
||||
Dictionary mapping lowercase header names to stripped values.
|
||||
|
||||
Notes:
|
||||
@@ -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,16 +62,16 @@ 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.
|
||||
|
||||
Args:
|
||||
headers (Dict[str, str]):
|
||||
headers (dict[str, str]):
|
||||
Normalized header dictionary as returned by `parse_headers()`.
|
||||
|
||||
Returns:
|
||||
Tuple[str, Optional[str]]:
|
||||
tuple[str, str | None]:
|
||||
A tuple `(email, name)` where `email` is the sender email address
|
||||
and `name` is the display name, or `None` if unavailable.
|
||||
|
||||
|
||||
@@ -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