ó
    Ñ]j  ã                   ó�   • S r SSKrSSKrSSKrSSKJr  SqS r " S S5      r\" 5       r	 " S S5      r
S	 rS
 rS rS\S\4S jrg)aÁ  
Async helper function that are invalid syntax on Python 3.5 and below.

This code is best effort, and may have edge cases not behaving as expected. In
particular it contain a number of heuristics to detect whether code is
effectively async and need to run in an event loop or not.

Some constructs (like top-level `return`, or `yield`) are taken care of
explicitly to actually raise a SyntaxError and stay as close as possible to
Python semantics.
é    N)Úwrapsc                  óÄ   •  [         R                  " 5       $ ! [         a     Of = f[        b  [        R	                  5       (       a  [         R
                  " 5       q[        $ )a:  asyncio has deprecated get_event_loop

Replicate it here, with our desired semantics:

- always returns a valid, not-closed loop
- not thread-local like asyncio's,
  because we only want one loop for IPython
- if called from inside a coroutine (e.g. in ipykernel),
  return the running loop

.. versionadded:: 8.0
)ÚasyncioÚget_running_loopÚRuntimeErrorÚ_asyncio_event_loopÚ	is_closedÚnew_event_loop© ó    ÚW/home/mande/repo/quber/.venv/lib/python3.13/site-packages/IPython/core/async_helpers.pyÚget_asyncio_loopr      sV   € ðÜ×'Ò'Ó)Ð)øÜó ñ 	ðúô Ñ"Ô&9×&CÑ&C×&EÑ&EÜ%×4Ò4Ó6ÐÜÐs   ‚ —
$£$c                   ó    • \ rS rSrS rS rSrg)Ú_AsyncIORunneré2   c                 ó4   • [        5       R                  U5      $ )z
Handler for asyncio autoawait
)r   Úrun_until_complete)ÚselfÚcoros     r   Ú__call__Ú_AsyncIORunner.__call__3   s   € ô  Ó!×4Ñ4°TÓ:Ð:r   c                 ó   • g)Nr   r   ©r   s    r   Ú__str__Ú_AsyncIORunner.__str__9   s   € Ør   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   r   Ú__static_attributes__r   r   r   r   r   2   s   † ò;õr   r   c                   ó0   • \ rS rSrSrS rS rS rS rSr	g)	Ú_AsyncIOProxyé@   zVProxy-object for an asyncio

Any coroutine methods will be wrapped in event_loop.run_
c                 ó   • Xl         X l        g ©N)Ú_objÚ_event_loop)r   ÚobjÚ
event_loops      r   Ú__init__Ú_AsyncIOProxy.__init__F   s   € ØŒ	Ø%Õr   c                 ó$   • SU R                   < S3$ )Nz<_AsyncIOProxy(z)>)r&   r   s    r   Ú__repr__Ú_AsyncIOProxy.__repr__J   s   € Ø  §¡¡¨RÐ0Ð0r   c                 óš   ^ ^• [        T R                  U5      m[        R                  " T5      (       a  [	        T5      UU 4S j5       nU$ T$ )Nc                  ó~   >• [         R                  " T" U 0 UD6TR                  5      n[         R                  " U5      $ r%   )r   Úrun_coroutine_threadsafer'   Úwrap_future)ÚargsÚkwargsÚconcurrent_futureÚattrr   s      €€r   Ú_wrappedÚ+_AsyncIOProxy.__getattr__.<locals>._wrappedR   s=   ø€ ä$+×$DÒ$DÙ˜$Ð) &Ñ)¨4×+;Ñ+;ó%Ð!ô ×*Ò*Ð+<Ó=Ð=r   )Úgetattrr&   ÚinspectÚiscoroutinefunctionr   )r   Úkeyr7   r6   s   `  @r   Ú__getattr__Ú_AsyncIOProxy.__getattr__M   sH   ù€ Ü�t—y‘y #Ó&ˆÜ×&Ò& t×,Ñ,ô �4‹[õ>ó ð>ð ˆOàˆKr   c                 ó,   • [        U R                  5      $ r%   )Údirr&   r   s    r   Ú__dir__Ú_AsyncIOProxy.__dir__]   s   € Ü�4—9‘9‹~Ðr   )r'   r&   N)
r   r   r   r   Ú__doc__r*   r-   r=   rA   r    r   r   r   r"   r"   @   s   † ñò
&ò1òõ r   r"   c                 ó,   • SSK nUR                  U 5      $ )z
handler for curio autoawait
r   N)ÚcurioÚrun)Ú	coroutinerE   s     r   Ú_curio_runnerrH   a   s   € ó à�9‰9�YÓÐr   c                 ó2   • SS K nS nUR                  X 5      $ )Nr   c              “   ó"   #   • U I Sh  v•N $  N7f)zv
We need the dummy no-op async def to protect from
trio's internal. See https://github.com/python-trio/trio/issues/89
Nr   )r   s    r   ÚlocÚ_trio_runner.<locals>.locm   s   é € ð
 �zÐ‰zùs   ‚ˆ‰)ÚtriorF   )Úasync_fnrM   rK   s      r   Ú_trio_runnerrO   j   s   € Ûòð �8‰8�CÓ"Ð"r   c                 ó°   •  U R                  S5        [        SR                  U R                  S95      e! [         a  nUR
                  s SnA$ SnAff = f)z´
A runner that does not really allow async execution, and just advance the coroutine.

See discussion in https://github.com/python-trio/trio/issues/608,

Credit to Nathaniel Smith
Nz%{coro_name!r} needs a real async loop)Ú	coro_name)Úsendr   Úformatr   ÚStopIterationÚvalue)r   Úexcs     r   Ú_pseudo_sync_runnerrW   w   sR   € ð
Ø�	‰	�$Œô
 Ø3×:Ñ:ÀTÇ]Á]Ð:ÐSó
ð 	
øô	 ó Ø�y‰yÕûðús   ‚5 µ
A¿AÁ
AÁAÚcellÚreturnc           
      óÌ   •  [        U SS[        [        SS5      S9n[        R                  UR
                  -  [        R                  :H  $ ! [        [        [        4 a     gf = f)z§Detect if a block of code needs to be wrapped in an `async def`

If the code block has a top-level return statement or is otherwise
invalid, `False` will be returned.
z<>ÚexecÚPyCF_ALLOW_TOP_LEVEL_AWAITr   )ÚflagsF)	Úcompiler9   Úastr:   ÚCO_COROUTINEÚco_flagsÚSyntaxErrorÚ
ValueErrorÚMemoryError)rX   Úcodes     r   Ú_should_be_asyncrf   Š   s`   € ðÜØ�$˜¤g¬cÐ3OÐQTÓ&Uñ
ˆô ×#Ñ# d§m¡mÑ3´w×7KÑ7KÑKÐKøÜœ¤[Ð1ó Ùðús   ‚AA ÁA#Á"A#)rC   r_   r   r:   Ú	functoolsr   r   r   r   Ú_asyncio_runnerr"   rH   rO   rW   ÚstrÚboolrf   r   r   r   Ú<module>rk      sd   ðñ
ó Û Û Ý àÐ ò÷:ñ ñ !Ó"€÷ñ òB ò
#ò
ð&˜3ð  4õ r   