Skip to content

# Pickle

## `` mail_intake.credentials.pickle

### Summary

Local filesystem–based credential persistence for Mail Intake.

This module provides a file-backed implementation of the `CredentialStore` abstraction using Python's `pickle` module.

The `pickle`-based credential store is intended for local development, single-node deployments, and controlled environments where credentials do not need to be shared across processes or machines.

Due to the security and portability risks associated with `pickle`-based serialization, this implementation is not suitable for distributed or untrusted environments.

### Classes

#### `` PickleCredentialStore

    1

    PickleCredentialStore(path: str)

Bases: `CredentialStore[T]`

Filesystem-backed credential store using pickle serialization.

This store persists credentials as a pickled object on the local filesystem. It is a simple implementation intended primarily for development, testing, and single-process execution contexts.

Notes

Guarantees:

    1
    2
    3

    - Stores credentials on the local filesystem.
    - Uses `pickle` for serialization and deserialization.
    - Does not provide encryption, locking, or concurrency guarantees.

Constraints:

    1
    2

    - Credential lifecycle management, validation, and refresh logic are
      explicitly out of scope for this class.

Initialize a pickle-backed credential store.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`path` | `str` | Filesystem path where credentials will be stored. The file will be created or overwritten as needed. | required

##### Functions

###### `` clear

    1

    clear() -> None

Remove persisted credentials from the local filesystem.

Notes

Lifecycle:

    1

    - This method deletes the credential file if it exists and should be treated as an idempotent operation

###### `` load

    1

    load() -> Optional[T]

Load credentials from the local filesystem.

Returns:

Type | Description
--- | ---
`Optional[T]` | Optional[T]: An instance of type `T` if credentials are present and successfully deserialized; otherwise `None`.

Notes

Guarantees:

    1
    2
    3
    4

    - If the credential file does not exist or cannot be successfully
      deserialized, this method returns `None`.
    - The store does not attempt to validate or interpret the
      returned credentials.

###### `` save

    1

    save(credentials: T) -> None

Persist credentials to the local filesystem.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`credentials` | `T` | The credential object to persist. | required

Notes

Responsibilities:

    1

    - Any previously stored credentials at the configured path are overwritten