٭CddlmZddlmZddlmZddlmZddlmZddlmZddgZed Zed Z Gd deeZ Gd dZ d S))Any)cast)Dict)Generic)TypeVar)UnionStashStashKeyTDceZdZdZdZdS)r z``StashKey`` is an object used as a key to a :class:`Stash`. A ``StashKey`` is associated with the type ``T`` of the value of the key. A ``StashKey`` is unique and cannot conflict with another key. N)__name__ __module__ __qualname____doc__ __slots__r/srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/_pytest/stash.pyr r sIIIrceZdZdZdZddZdeededdfdZdeedefd Z deed e de ee ffd Z deed edefd Z deeddfd ZdeedefdZdefdZdS)r a/``Stash`` is a type-safe heterogeneous mutable mapping that allows keys and value types to be defined separately from where it (the ``Stash``) is created. Usually you will be given an object which has a ``Stash``, for example :class:`~pytest.Config` or a :class:`~_pytest.nodes.Node`: .. code-block:: python stash: Stash = some_object.stash If a module or plugin wants to store data in this ``Stash``, it creates :class:`StashKey`\s for its keys (at the module level): .. code-block:: python # At the top-level of the module some_str_key = StashKey[str]() some_bool_key = StashKey[bool]() To store information: .. code-block:: python # Value type must match the key. stash[some_str_key] = "value" stash[some_bool_key] = True To retrieve the information: .. code-block:: python # The static type of some_str is str. some_str = stash[some_str_key] # The static type of some_bool is bool. some_bool = stash[some_bool_key] _storagereturnNci|_dS)Nrselfs r__init__zStash.__init__Ds 57 rkeyvaluec||j|<dS)zSet a value for key.Nr)rrrs r __setitem__zStash.__setitem__Gs" crcBtt|j|S)zZGet the value for key. Raises ``KeyError`` if the key wasn't set before. )rr rrrs r __getitem__zStash.__getitem__Ks At}S)***rdefaultc8 ||S#t$r|cYSwxYw)zNGet the value for key, or return default if the key wasn't set before.KeyErrorrrr%s rgetz Stash.getRs5 9    NNN s  cB ||S#t$r |||<|cYSwxYw)zmReturn the value of key if already set, otherwise set the value of key to default and return default.r'r)s r setdefaultzStash.setdefaultZs> 9    DINNN s  c|j|=dS)z]Delete the value for key. Raises ``KeyError`` if the key wasn't set before. Nrr#s r __delitem__zStash.__delitem__cs M#   rc||jvS)zReturn whether key was set.rr#s r __contains__zStash.__contains__jsdm##rc*t|jS)z)Return how many items exist in the stash.)lenrrs r__len__z Stash.__len__ns4=!!!r)rN)rrrrrrr r r!r$r rr*r,r.boolr0intr3rrrr r sV$$LI8888#x{#1#####+x{+q++++x{Q5A;hqkA!x{t$ $$$$$"""""""rN) typingrrrrrr__all__r r r r rrrr8s J  GCLL GCLLwqzU"U"U"U"U"U"U"U"U"U"r