j7i ddlmZddlmZddlmZddlmZddlmZddgZedZed Z Gd deeZ Gd dZ y ) ) annotations)Any)cast)Generic)TypeVarStashStashKeyTDceZdZdZdZy)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. .. versionadded:: 7.0 N)__name__ __module__ __qualname____doc__ __slots__r V/mnt/ssd/data/python-lab/ChefSystem/venv/lib/python3.12/site-packages/_pytest/stash.pyr r sIrcTeZdZdZdZd dZd dZddZddZddZ ddZ dd Z dd Z y )raJ``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] .. versionadded:: 7.0 _storageci|_y)Nrselfs r__init__zStash.__init__Hs 57 rc"||j|<y)zSet a value for key.Nr)rkeyvalues r __setitem__zStash.__setitem__Ks" crc<tt|j|S)zZGet the value for key. Raises ``KeyError`` if the key wasn't set before. )rr rrrs r __getitem__zStash.__getitem__Os At}}S)**rc0 ||S#t$r|cYSwxYw)zNGet the value for key, or return default if the key wasn't set before.KeyErrorrrdefaults rgetz Stash.getVs% 9  N s  c: ||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.setdefault^s. 9  DIN s c|j|=y)z]Delete the value for key. Raises ``KeyError`` if the key wasn't set before. Nrr!s r __delitem__zStash.__delitem__gs MM# rc||jvS)zReturn whether key was set.rr!s r __contains__zStash.__contains__nsdmm##rc,t|jS)z)Return how many items exist in the stash.)lenrrs r__len__z Stash.__len__rs4==!!rN)returnNone)r StashKey[T]rr r2r3)rr4r2r )rr4r'r r2zT | D)rr4r'r r2r )rr4r2r3)rr4r2bool)r2int) rrrrrrrr"r(r*r,r.r1r rrrrs7&PI8#+$"rN) __future__rtypingrrrr__all__r r r rr rrr:sP" J  CL CL wqz W"W"r