
    ,h                       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 ej                  dej                        Z
ddddZ ej                  d	
       G d d             ZddZddZddZedk(  r eej$                  dd        yy)a  Translates Mypy's output into GitHub's error/warning annotation syntax.

See: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions

This first is run with Mypy's output piped in, to collect messages in
mypy_annotate.dat. After all platforms run, we run this again, which prints the
messages in GitHub's format but with cross-platform failures deduplicated.
    )annotationsNa)  
    ([^:]+):  # Filename (anything but ":")
    ([0-9]+):  # Line number (start)
    (?:([0-9]+):  # Optional column number
      (?:([0-9]+):([0-9]+):)?  # then also optionally, 2 more numbers for end columns
    )?
    \s*(error|warn|note):  # Kind, prefixed with space
    (.+)  # Message
    errorwarningnotice)r   warnnoteT)kw_onlyc                  d    e Zd ZU dZded<   ded<   ded<   ded<   dZd	ed
<   dZd	ed<   dZd	ed<   y)Resultz7Accumulated results, used as a dict key to deduplicate.strfilenameint
start_linekindmessageNz
int | None	start_colend_lineend_col)__name__
__module____qualname____doc____annotations__r   r   r        [/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/trio/_tools/mypy_annotate.pyr   r   (   s7    AMO
IL Iz HjGZr   r   c           	        t         j                  | j                               x}ra|j                         \  }}}}}}}t	        |t        |      |t        |      nd |t        |      nd |t        |      nd t        |   |      S y )N)r   r   r   r   r   r   r   )	report_re	fullmatchrstripgroupsr   r   mypy_to_github)	linematchr   st_linest_colr   r   r   r   s	            r   process_liner'   5   s    ##DKKM22u2FKllnC'68WdG7|%+%7c&kT&.&:S]$+$7CLT%
 	
 r   c                   | j                         D ]X  \  }}t        d|j                   d|j                   d|j                   dd       |j
                  t        d|j
                   dd       |j                  x|j                  lt        d	|j                   d
|j                   dd       d|j                   d|j
                   d|j                   d|j                   d|j                   
}nEd|j                   d|j
                   d|j                   }n|j                   d|j                   }t        ddj                  |       d|j                   d|        [ y)zDisplay the collected results.z::z file=z,line=, )endNzcol=zendLine=z,endColumn=(:z - z):ztitle=Mypy-+)
itemsprintr   r   r   r   r   r   r   join)resultsres	platformsr   s       r   exportr5   E   sF   !--/ MY388*F3<<.s~~6FaHbQ==$Dq)r2{{&3<<+Ck#++aHbQcnn-Qs}}oSaPSP[P[}\^_b_j_j^klcnn-Qs}}oR}M(#++7GCHHY/03<<.'KLMr   c                   t        j                  t              }|j                  ddd       |j                  ddd	       |j	                  |       }	 t        |j                  d
      5 }t        j                  |      }ddd       |j                  t               y|j                  }t        j                  D ]C  }t        |      }|	 |   j!                  |       t        j$                  j'                  |       E t        |j                  d      5 }t        j(                  |       ddd       y# 1 sw Y   xY w# t        t        j                  f$ r i }Y w xY w# t"        $ r	 |g|<   Y w xY w# 1 sw Y   yxY w)z0Look for error messages, and convert the format.)descriptionz
--dumpfilez"File to write pickled messages to.T)helprequiredz
--platformz.OS name, if set Mypy should be piped to stdin.N)r8   defaultrbwb)argparseArgumentParserr   add_argument
parse_argsopendumpfilepickleloadFileNotFoundErrorUnpicklingErrorplatformr5   sysstdinr'   appendKeyErrorstdoutwritedump)argvparsercmd_linefr2   rG   r#   parseds           r   mainrT   U   sz   $$9F
1  
 =  
   &H(##T* 	%akk!nG	%  w ))II 	#D!$'F!1FO**84 JJT"	# (##T* 	$aKK#	$ 	$'	% 	%v556    1'/jGFO1	$ 	$sH   E +D9E E&E;9E>E E#"E#&E87E8;F__main__   )r#   r   returnzResult | None)r2   zdict[Result, list[str]]rW   None)rO   z	list[str]rW   rX   )r   
__future__r   r=   rC   rerH   attrscompileVERBOSEr   r"   frozenr   r'   r5   rT   r   rO   r   r   r   <module>r_      s    #   	 
  BJJ JJ	  d	 	 	 M %$P z!" r   