ó
    Ñ]jl  ã                  óH   • S r SSKJr  SSKrSSKJr  SSKJr   " S S5      rg)zMiscellaneous context managers.é    )ÚannotationsN)ÚTracebackType)ÚAnyc                  óF   • \ rS rSrSrSS jrS	S jr        S
S jrSrg)Úpreserve_keysé   a½  Preserve a set of keys in a dictionary.

Upon entering the context manager the current values of the keys
will be saved. Upon exiting, the dictionary will be updated to
restore the original value of the preserved keys. Preserved keys
which did not exist when entering the context manager will be
deleted.

Examples
--------

>>> d = {'a': 1, 'b': 2, 'c': 3}
>>> with preserve_keys(d, 'b', 'c', 'd'):
...     del d['a']
...     del d['b']      # will be reset to 2
...     d['c'] = None   # will be reset to 3
...     d['d'] = 4      # will be deleted
...     d['e'] = 5
...     print(sorted(d.items()))
...
[('c', None), ('d', 4), ('e', 5)]
>>> print(sorted(d.items()))
[('b', 2), ('c', 3), ('e', 5)]
c                ó   • Xl         X l        g ©N)Ú
dictionaryÚkeys)Úselfr   r   s      ÚS/home/mande/repo/quber/.venv/lib/python3.13/site-packages/IPython/utils/contexts.pyÚ__init__Úpreserve_keys.__init__(   s   € Ø$ŒØ�	ó    c                óž   • / n0 nU R                   nU R                   H!  nXC;   a  X4   X$'   M  UR                  U5        M#     Xl        X l        g r
   )r   r   ÚappendÚ	to_deleteÚ	to_update)r   r   r   ÚdÚks        r   Ú	__enter__Úpreserve_keys.__enter__,   sK   € à!ˆ	Ø$&ˆ	à�O‰OˆØ—”ˆAØ‹vØ ™t�	“à× Ñ  Ö#ñ	 ð #ŒØ"�r   c                óœ   • U R                   nU R                   H  nUR                  US 5        M     UR                  U R                  5        g r
   )r   r   ÚpopÚupdater   )r   Úexc_typeÚexc_valÚexc_tbr   r   s         r   Ú__exit__Úpreserve_keys.__exit__;   s8   € ð �O‰Oˆà—”ˆAØ�E‰E�!�TŽNñ  à	�‰�—‘Õ r   )r   r   r   r   N)r   zdict[Any, Any]r   r   ÚreturnÚNone)r"   r#   )r   ztype[BaseException] | Noner   zBaseException | Noner   zTracebackType | Noner"   r#   )	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r    Ú__static_attributes__© r   r   r   r      s<   † ñô2ô#ð
!à,ð
!ð &ð
!ð %ð	
!ð
 
÷
!r   r   )	r(   Ú
__future__r   ÚwarningsÚtypesr   Útypingr   r   r*   r   r   Ú<module>r/      s   ðá %å "ã Ý Ý ÷7!ò 7!r   