Skip to content
v0.1.3

Context Module API Reference

This section documents the internals of the context module in Bijux CLI.

bijux_cli.contracts.context

Defines the contract for the request-scoped context service.

This module specifies the ContextProtocol, a formal interface for services that manage contextual data associated with a specific operation or request. This pattern allows for state to be carried implicitly through an application's call stack.

ContextProtocol

Bases: Protocol

Defines the contract for a request-scoped context object.

This interface specifies methods for a context that can store arbitrary key-value data and supports both synchronous (with) and asynchronous (async with) context management patterns.

clear

clear() -> None

Clears all data from the context.

Source code in src/bijux_cli/contracts/context.py
def clear(self) -> None:
    """Clears all data from the context."""
    ...

get

get(key: str) -> Any

Retrieves a value by key from the context.

Parameters:

  • key (str) –

    The key of the value to retrieve.

Returns:

  • Any ( Any ) –

    The value associated with the key.

Source code in src/bijux_cli/contracts/context.py
def get(self, key: str) -> Any:
    """Retrieves a value by key from the context.

    Args:
        key (str): The key of the value to retrieve.

    Returns:
        Any: The value associated with the key.
    """
    ...

set

set(key: str, value: Any) -> None

Sets a key-value pair in the context.

Parameters:

  • key (str) –

    The key to set.

  • value (Any) –

    The value to associate with the key.

Returns:

  • None ( None ) –
Source code in src/bijux_cli/contracts/context.py
def set(self, key: str, value: Any) -> None:
    """Sets a key-value pair in the context.

    Args:
        key (str): The key to set.
        value (Any): The value to associate with the key.

    Returns:
        None:
    """
    ...