pynenc.arguments¶
Module Contents¶
Classes¶
Represents a distinctive set of arguments used in a task call. |
API¶
- class pynenc.arguments.Arguments(kwargs: Optional[pynenc.types.Args] = None, *, app: Optional[pynenc.Pynenc] = None)[source]¶
Represents a distinctive set of arguments used in a task call.
This class facilitates the handling of arguments by providing functionalities such as generating a unique identifier for a set of arguments, and supporting hashability and equality checks.
- Parameters:
kwargs (Optional[Args]) – Keyword arguments to initialize the Arguments object. Defaults to an empty dictionary if None is provided.
Initialization
- classmethod from_call(func: pynenc.types.Func, *args: Any, **kwargs: Any) pynenc.arguments.Arguments[source]¶
Creates an Arguments object from a function call.
It uses inspect.signature to determine the function’s signature and binds the provided arguments to it.
- Parameters:
func (Func) – The function whose arguments are to be processed.
args (Any) – Positional arguments of the function call.
kwargs (Any) – Keyword arguments of the function call.
- Returns:
An instance of Arguments representing the arguments of the call.
- args_id() str¶
Generates a unique identifier for the set of arguments.
The identifier is a SHA-256 hash of the sorted argument names and values, ensuring uniqueness.
- Returns:
A string representing the unique identifier of the arguments.
- to_json(app: pynenc.Pynenc) dict[str, Any][source]¶
Serializes the Arguments object to a JSON-compatible dictionary.
- Parameters:
app – Pynenc application instance for serializing complex arguments.
- Returns:
A dictionary with serialized argument data.
- classmethod from_json(app: pynenc.Pynenc, data: dict[str, Any]) pynenc.arguments.Arguments[source]¶
Deserializes a JSON-compatible dictionary to an Arguments object.
- Parameters:
app – Pynenc application instance for deserializing complex arguments.
data – Dictionary with serialized argument data.
- Returns:
An Arguments object with deserialized arguments.
- _format_value(conf: pynenc.conf.config_pynenc.ConfigPynenc, value: Any) str[source]¶
Format a single argument value based on configuration.