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

@@ -1,5 +1,5 @@
from .store import CredentialStore
from .pickle import PickleCredentialStore
from .redis import RedisCredentialStore
from .store import CredentialStore
__all__ = ["CredentialStore", "PickleCredentialStore", "RedisCredentialStore"]

View File

@@ -16,7 +16,7 @@ untrusted environments.
"""
import pickle
from typing import Optional, TypeVar
from typing import TypeVar
from mail_intake.credentials.store import CredentialStore
@@ -55,7 +55,7 @@ class PickleCredentialStore(CredentialStore[T]):
"""
self.path = path
def load(self) -> Optional[T]:
def load(self) -> T | None:
"""
Load credentials from the local filesystem.

View File

@@ -1,4 +1,5 @@
from typing import Optional, TypeVar
from typing import TypeVar
from .store import CredentialStore
T = TypeVar("T")
@@ -6,6 +7,6 @@ T = TypeVar("T")
class PickleCredentialStore(CredentialStore[T]):
path: str
def __init__(self, path: str) -> None: ...
def load(self) -> Optional[T]: ...
def load(self) -> T | None: ...
def save(self, credentials: T) -> None: ...
def clear(self) -> None: ...

View File

@@ -24,8 +24,8 @@ Credential validation, refresh, rotation, and acquisition remain the
responsibility of authentication provider implementations.
"""
from typing import Optional, TypeVar, Callable
from collections.abc import Callable
from typing import TypeVar
from mail_intake.credentials.store import CredentialStore
@@ -61,7 +61,7 @@ class RedisCredentialStore(CredentialStore[T]):
key: str,
serialize: Callable[[T], bytes],
deserialize: Callable[[bytes], T],
ttl_seconds: Optional[int] = None,
ttl_seconds: int | None = None,
):
"""
Initialize a Redis-backed credential store.
@@ -88,7 +88,7 @@ class RedisCredentialStore(CredentialStore[T]):
self.deserialize = deserialize
self.ttl_seconds = ttl_seconds
def load(self) -> Optional[T]:
def load(self) -> T | None:
"""
Load credentials from Redis.

View File

@@ -1,4 +1,6 @@
from typing import Optional, TypeVar, Callable, Any
from collections.abc import Callable
from typing import Any, TypeVar
from .store import CredentialStore
T = TypeVar("T")
@@ -8,8 +10,15 @@ class RedisCredentialStore(CredentialStore[T]):
key: str
serialize: Callable[[T], bytes]
deserialize: Callable[[bytes], T]
ttl_seconds: Optional[int]
def __init__(self, redis_client: Any, key: str, serialize: Callable[[T], bytes], deserialize: Callable[[bytes], T], ttl_seconds: Optional[int] = ...) -> None: ...
def load(self) -> Optional[T]: ...
ttl_seconds: int | None
def __init__(
self,
redis_client: Any,
key: str,
serialize: Callable[[T], bytes],
deserialize: Callable[[bytes], T],
ttl_seconds: int | None = ...,
) -> None: ...
def load(self) -> T | None: ...
def save(self, credentials: T) -> None: ...
def clear(self) -> None: ...

View File

@@ -19,9 +19,8 @@ or secrets managers—without coupling authentication logic to any
specific storage mechanism.
"""
from abc import ABC, abstractmethod
from typing import Generic, Optional, TypeVar
from typing import Generic, TypeVar
T = TypeVar("T")
@@ -48,7 +47,7 @@ class CredentialStore(ABC, Generic[T]):
"""
@abstractmethod
def load(self) -> Optional[T]:
def load(self) -> T | None:
"""
Load previously persisted credentials.

View File

@@ -1,11 +1,11 @@
from abc import ABC, abstractmethod
from typing import Generic, Optional, TypeVar
from typing import Generic, TypeVar
T = TypeVar("T")
class CredentialStore(ABC, Generic[T]):
@abstractmethod
def load(self) -> Optional[T]: ...
def load(self) -> T | None: ...
@abstractmethod
def save(self, credentials: T) -> None: ...
@abstractmethod