Ë
    ¾lÔh®  ã                  óX  — d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	m
Z
 ddlmZmZmZ ddlmZ ddlmZ ddlmZmZ dd	lmZ dd
lmZmZ ddlmZ ddlmZ ddlm Z  ddl!m"Z"m#Z# dd„Z$dd„Z%dd„Z& ed¬«      	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„«       Z'	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Z(y)z§
Formatting many files at once via multiprocessing. Contains entrypoint and utilities.

NOTE: this module is only imported if we need to format several files at once.
é    )ÚannotationsN)ÚIterable)ÚExecutorÚProcessPoolExecutorÚThreadPoolExecutor)ÚManager)ÚPath)ÚAnyÚOptional)Ú
mypyc_attr)Ú	WriteBackÚformat_file_in_place)ÚCache)ÚMode)Úerr)ÚChangedÚReportc                 óL   — 	 ddl } | j                  «        y# t        $ r Y yw xY w)z¿If our environment has uvloop installed we use it.

    This is called only from command-line entry points to avoid
    interfering with the parent process if Black is used as a library.
    r   N)ÚuvloopÚinstallÚImportError)r   s    úf/home/josh/.local/share/pipx/venvs/python-lsp-server/lib/python3.12/site-packages/black/concurrency.pyÚmaybe_install_uvloopr      s&   € ðÛà�‰ÕøÜò Ùðús   ‚ —	#¢#c                óH   — t        d«       | D ]  }|j                  «        Œ y)zFasyncio signal handler that cancels all `tasks` and reports to stderr.zAborted!N)r   Úcancel)ÚtasksÚtasks     r   r   r   ,   s!   € äˆ
„OØò ˆØ�‰�ñó    c                ó–  — 	 t        j                  | «      D �cg c]  }|j                  «       rŒ|‘Œ }}|sF	 t        j                  d«      }|j                  t        j                  «       | j                  «        y|D ]  }|j                  «        Œ | j                  t        j                  |ddiŽ«       t        j                  d«      }|j                  t        j                  «       | j                  «        yc c}w # t        j                  d«      }|j                  t        j                  «       | j                  «        w xY w)zFCancel all pending tasks on `loop`, wait for them, and close the loop.zconcurrent.futuresNÚreturn_exceptionsT)ÚasyncioÚ	all_tasksÚdoneÚloggingÚ	getLoggerÚsetLevelÚCRITICALÚcloser   Úrun_until_completeÚgather)Úloopr   Ú	to_cancelÚ	cf_loggers       r   Úshutdownr.   3   s  € ðä&-×&7Ñ&7¸Ó&=ÖQ˜dÀTÇYÁYÅ[’TÐQˆ	ÐQÙØô ×%Ñ%Ð&:Ó;ˆ	Ø×Ñœ7×+Ñ+Ô,Ø�
‰
�ð ò 	ˆDØ�K‰K�Mð	à×Ñ¤§¡°	Ð RÈTÑ RÔSô
 ×%Ñ%Ð&:Ó;ˆ	Ø×Ñœ7×+Ñ+Ô,Ø�
‰
�ùò Røô ×%Ñ%Ð&:Ó;ˆ	Ø×Ñœ7×+Ñ+Ô,Ø�
‰
�ús'   ‚D ™C=¯C=³D Á=;D Ã=D ÄAET)Ú	patchablec                ó6  — t        «        |€Et        t        j                  j	                  dd«      «      }|xs t        j
                  «       xs d}t        j                  dk(  rt        |d«      }d}|dkD  r	 t        |¬«      }|€t        d¬«      }t        j                  «       }t        j                   |«       	 |j#                  t%        | ||||||¬«      «       	 t'        |«       t        j                   d«       |�|j'                  «        yy# t        t        t        f$ r Y Œ¤w xY w# t        j                   d«       w xY w# 	 t'        |«       t        j                   d«       n# t        j                   d«       w xY w|�|j'                  «        w w xY w)	z4Reformat multiple files using a ProcessPoolExecutor.NÚBLACK_NUM_WORKERSr   é   Úwin32é<   )Úmax_workers)ÚsourcesÚfastÚ
write_backÚmodeÚreportr+   Úexecutor)r   ÚintÚosÚenvironÚgetÚ	cpu_countÚsysÚplatformÚminr   r   ÚNotImplementedErrorÚOSErrorr   r!   Únew_event_loopÚset_event_loopr)   Úschedule_formattingr.   )r6   r7   r8   r9   r:   Úworkersr;   r+   s           r   Úreformat_manyrJ   I   sp  € ô Ôà€Ü”b—j‘j—n‘nÐ%8¸!Ó<Ó=ˆØÒ0œRŸ\™\›^Ò0¨qˆÜ
‡|�|�wÒä�g˜rÓ"ˆà $€HØ�‚{ð	Ü*°wÔ?ˆHð ÐÜ%°!Ô4ˆä×!Ñ!Ó#€DÜ×Ñ˜4Ô ð Ø×ÑÜØØØ%ØØØØ!ôô
	
ð	)Ü�TŒNä×"Ñ" 4Ô(ØÐØ×ÑÕð  øô; Ô0´'Ð:ò 	ñ
 ð	ûô8 ×"Ñ" 4Õ(ûð	)Ü�TŒNä×"Ñ" 4Õ(øŒG×"Ñ" 4Õ(úØÐØ×ÑÕð  úsB   Á9D Â=!E ÃD- ÄD*Ä)D*Ä-EÅFÅ	E*ÅFÅ*FÆFc              ƒ  ó&  K  — t        j                  |«      }|t        j                  t        j                  fvrD|j                  | «      \  } }t        |«      D ]"  }	|j                  |	t        j                  «       Œ$ | syg }
g }d}|t        j                  t        j                  fv rt        «       }|j                  «       }t        | «      D �	ci c]1  }	t        j                  |j                  |t        |	||||«      «      |	“Œ3 }}	|j!                  «       }	 |j#                  t$        j&                  t(        |«       |j#                  t$        j*                  t(        |«       |�r]t        j.                  |t        j0                  ¬«      ƒ d{  –—† \  }}|D �]#  }|j3                  |«      }	|j5                  «       r|
j7                  |«       Œ7|j9                  «       x}rR|j:                  r*t=        j>                  tA        |«      ||jB                  «       |jE                  |	tG        |«      «       Œ›|jI                  «       rt        jJ                  nt        jL                  }|t        jJ                  u s$|t        jN                  u r#|t        jL                  u r|j7                  |	«       |j                  |	|«       �Œ& |r�Œ]|
rt        jP                  |
ddiŽƒ d{  –—†  |r|jS                  |«       yyc c}	w # t,        $ r Y �Œ¥w xY w7 �Œ~7 Œ1­w)záRun formatting of `sources` in parallel using the provided `executor`.

    (Use ProcessPoolExecutors for actual parallelism.)

    `write_back`, `fast`, and `mode` options are passed to
    :func:`format_file_in_place`.
    N)Úreturn_whenr    T)*r   Úreadr   ÚDIFFÚ
COLOR_DIFFÚfiltered_cachedÚsortedr#   r   ÚCACHEDr   ÚLockr!   Úensure_futureÚrun_in_executorr   ÚkeysÚadd_signal_handlerÚsignalÚSIGINTr   ÚSIGTERMrD   ÚwaitÚFIRST_COMPLETEDÚpopÚ	cancelledÚappendÚ	exceptionÚverboseÚ	tracebackÚprint_exceptionÚtypeÚ__traceback__ÚfailedÚstrÚresultÚYESÚNOÚCHECKr*   Úwrite)r6   r7   r8   r9   r:   r+   r;   ÚcacheÚcachedÚsrcr^   Úsources_to_cacheÚlockÚmanagerr   Úpendingr#   Ú_r   ÚexcÚchangeds                        r   rH   rH   �   s�  è ø€ ô  �J‰J�tÓ€EØœ)Ÿ.™.¬)×*>Ñ*>Ð?Ñ?Ø×/Ñ/°Ó8‰ˆ�Ü˜&“>ò 	-ˆCØ�K‰K˜œWŸ^™^Õ,ð	-áØà€IØÐØ€DØ”i—n‘n¤i×&:Ñ&:Ð;Ñ;ô “)ˆØ�|‰|‹~ˆô ˜'“?öð ô 	×ÑØ× Ñ ØÔ.°°T¸4ÀÈTóó	
ð ñ		ð€Eð ð �j‰j‹l€GðØ×Ñ¤§¡¬v°wÔ?Ø×Ñ¤§¡´¸Ô@ò ÜŸ™ W¼'×:QÑ:QÔR×R‰ˆˆaØó 	*ˆDØ—)‘)˜D“/ˆCØ�~‰~ÔØ× Ñ  Õ&ØŸ™Ó(Ð(�Ð(Ø—>’>Ü×-Ñ-¬d°3«i¸¸c×>OÑ>OÔPØ—‘˜c¤3 s£8Õ,à)-¯©¬œ'Ÿ+š+¼G¿J¹J�ð ¤§¡Ñ.Ø¤)§/¡/Ñ1°gÄÇÁÑ6Kà$×+Ñ+¨CÔ0Ø—‘˜C Ö)ð!	*ó ñ& Ü�n‰n˜iÐ@¸4Ñ@×@Ð@ÙØ�‰Ð$Õ%ð ùòIøô ò âðúð Sùð& 	Aús\   ‚CLÃ6K7ÄLÄA
K< Å#+LÆLÆD2LËLËLËLË<	L	ÌLÌL	Ì	LÌL)ÚreturnÚNone)r   zIterable['asyncio.Future[Any]']rw   rx   )r+   úasyncio.AbstractEventLooprw   rx   )r6   ú	set[Path]r7   Úboolr8   r   r9   r   r:   r   rI   zOptional[int]rw   rx   )r6   rz   r7   r{   r8   r   r9   r   r:   z'Report'r+   ry   r;   z
'Executor'rw   rx   ))Ú__doc__Ú
__future__r   r!   r$   r=   rX   rA   rb   Úcollections.abcr   Úconcurrent.futuresr   r   r   Úmultiprocessingr   Úpathlibr	   Útypingr
   r   Úmypy_extensionsr   Úblackr   r   Úblack.cacher   Ú
black.moder   Úblack.outputr   Úblack.reportr   r   r   r   r.   rJ   rH   © r   r   ú<module>rŠ      s
  ðñõ #ã Û Û 	Û Û 
Û Ý $ß PÑ PÝ #Ý ß  å &ç 1Ý Ý Ý ß (óóóñ, �dÔð4 Øð4 à
ð4 ð ð4 ð ð	4 ð
 ð4 ð ð4 ð 
ò4 ó ð4 ðnE&ØðE&à
ðE&ð ðE&ð ð	E&ð
 ðE&ð $ðE&ð ðE&ð 
ôE&r   