o
    tBh܅                  
   @  s  U 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	Z	ddl
Z
ddlZddlmZmZ ddlmZ ddlmZmZmZmZmZ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#m$Z$ ddl%m&Z& ddl'm(Z( ddl)m*Z*m+Z+ ddl,m-Z- z
ddl.m/Z/ dZ0W n e1y   dZ0Y nw e2e+j3dfe+j4dfe+j5dfe+j6dfe+j7dfe+j8dfe+j9dfgZ:de;d< ee<eede<gdf e=f f Z>de;d< i Z?d e;d!< G d"d dZ@G d#d ded$ZA	dfdgd-d.ZBdhd1d2ZCdid4d5ZDdjd7d8ZEG d9d: d:e(ZFG d;d< d<eAZGeBd=eG G d>d? d?eAZHeBd@eH G dAdB dBe(ZIG dCdD dDeAZJeBdEeJ G dFdG dGZKG dHdI dIeAZLeBdJeLddK dkdOdPZMG dQdR dRZNG dSdT dTeAZOeBdUeOddK G dVdW dWeAZPG dXdY dYePZQeBdZeQddK G d[d\ d\ePZReBd]eRddK G d^d_ d_ePZSeBd`eSddK eCd]da eCd`db G dcdd ddeAZTeBdeeT eUe?eUe ksJ dS )lz5Classes for producing HTML reports about imprecision.    )annotationsN)ABCMetaabstractmethod)
attrgetter)AnyCallableDictIteratorTuplecast)Final	TypeAlias)pathname2url)stats)REPORTER_NAMES)
ExpressionFuncDefMypyFile)Options)TraverserVisitor)Type	TypeOfAny)__version__)etreeTFUnannotatedExplicit
UnimportedzOmitted GenericsErrorzSpecial FormzImplementation Artifactz(Final[collections.OrderedDict[int, str]]type_of_any_name_mapReportsAbstractReporter
_TypeAliasReporterClasseszFinal[ReporterClasses]reporter_classesc                   @  s4   e Zd ZdddZdddZdddZdddZdS )r   data_dirstrreport_dirsdict[str, str]returnNonec                 C  s8   || _ g | _i | _t| D ]
\}}| || qd S N)r$   	reportersnamed_reporterssorteditems
add_report)selfr$   r&   report_type
report_dir r3   b/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/mypy/report.py__init__7   s   zReports.__init__r1   r2   r    c                 C  sp   z| j | W S  ty   Y nw t| \}}|r&ts&td|tjd t|| |}| j	
| || j |< |S )NzYou must install the lxml package before you can run mypy with `--{}-report`.
You can do this with `python3 -m pip install lxml`.)file)r,   KeyErrorr#   LXML_INSTALLEDprintformatsysstderrImportErrorr+   append)r0   r1   r2   reporter_cls
needs_lxmlreporterr3   r3   r4   r/   ?   s"   

zReports.add_reporttreer   modulesdict[str, MypyFile]type_mapdict[Expression, Type]optionsr   c                 C  s    | j D ]
}||||| qd S r*   )r+   on_file)r0   rB   rC   rE   rG   rA   r3   r3   r4   r6   T   s   
zReports.filec                 C  s   | j D ]}|  qd S r*   )r+   	on_finish)r0   rA   r3   r3   r4   finish^   s   

zReports.finishN)r$   r%   r&   r'   r(   r)   )r1   r%   r2   r%   r(   r    
rB   r   rC   rD   rE   rF   rG   r   r(   r)   r(   r)   )__name__
__module____qualname__r5   r/   r6   rJ   r3   r3   r3   r4   r   6   s
    



c                   @  s2   e Zd ZdddZedddZedddZdS )r    reportsr   
output_dirr%   r(   r)   c                 C  s    || _ |dkrt| d S d S )N<memory>)rQ   r   ensure_dir_existsr0   rP   rQ   r3   r3   r4   r5   d   s   zAbstractReporter.__init__rB   r   rC   rD   rE   rF   rG   r   c                 C     d S r*   r3   r0   rB   rC   rE   rG   r3   r3   r4   rH   i   s   zAbstractReporter.on_filec                 C  rU   r*   r3   r0   r3   r3   r4   rI   s   s   zAbstractReporter.on_finishNrP   r   rQ   r%   r(   r)   rK   rL   )rM   rN   rO   r5   r   rH   rI   r3   r3   r3   r4   r    c   s    
	)	metaclassreport_namer%   rA   *Callable[[Reports, str], AbstractReporter]r@   boolr(   r)   c                 C  s   ||ft | < d S r*   r#   )rZ   rA   r@   r3   r3   r4   register_reporterx   s   r^   source_reportertarget_reporterc                 C  s   t |  t |< d S r*   r]   )r_   r`   r3   r3   r4   alias_reporter   s   ra   pathc                 C  sB   t | rdS | drdS d| dv sd| tjv rdS dS )NT..stubs/F)r   is_special_module
startswithsplitossep)rb   r3   r3   r4   should_skip_path   s   

rk   Iterator[tuple[int, str]]c                 c  sB    t | }t|dE dH  W d   dS 1 sw   Y  dS )zDReturn an iterator over (line number, line text) from a Python file.   N)tokenizeopen	enumerate)rb   
input_filer3   r3   r4   iterate_python_lines   s   "rr   c                      s(   e Zd Zd	 fddZd
ddZ  ZS )FuncCounterVisitorr(   r)   c                   s   t    ddg| _d S Nr   superr5   countsrW   	__class__r3   r4   r5      s   
zFuncCounterVisitor.__init__defnr   c                 C  s   | j |jd u  d7  < d S Nrm   )rw   type)r0   rz   r3   r3   r4   visit_func_def      z!FuncCounterVisitor.visit_func_defrL   rz   r   r(   r)   )rM   rN   rO   r5   r}   __classcell__r3   r3   rx   r4   rs      s    rs   c                      s2   e Zd Zd fddZdddZdddZ  ZS )LineCountReporterrP   r   rQ   r%   r(   r)   c                      t  || i | _d S r*   ru   rT   rx   r3   r4   r5         
zLineCountReporter.__init__rB   r   rC   rD   rE   rF   rG   r   c                 C  s   t |jd}t| }W d    n1 sw   Y  t }|| |j\}}	|	| }
|jr2d}	|
r:||	 |
 n|}|||	|
f| j|j< d S )Nrbr   )	ro   rb   len	readlinesrs   acceptrw   ignore_errors	_fullname)r0   rB   rC   rE   rG   fphysical_linesfunc_counterunannotated_funcsannotated_funcstotal_funcsimputed_annotated_linesr3   r3   r4   rH      s    	

zLineCountReporter.on_filec                   s   t dd | j D dd t fddtdD }ttj| j	dd8}|
d	j|   D ]$\}}|
|d
 dd|d dd|d dd|d dd| d
 q1W d    d S 1 saw   Y  d S )Nc                 s  s    | ]	\}}||fV  qd S r*   r3   ).0pcr3   r3   r4   	<genexpr>       z.LineCountReporter.on_finish.<locals>.<genexpr>T)reversec                 3  s&    | ] t  fd dD V  qdS )c                 3  s    | ]	\}}|  V  qd S r*   r3   )r   r   r   ir3   r4   r      r   z8LineCountReporter.on_finish.<locals>.<genexpr>.<genexpr>N)sum)r   rw   r   r4   r      s   $    zlinecount.txtwz{:7} {:7} {:6} {:6} total
r   7 rm      6   
)r-   rw   r.   tuplerangero   ri   rb   joinrQ   writer:   )r0   total_countsr   r   r   r3   r   r4   rI      s   B"zLineCountReporter.on_finishrX   rK   rL   )rM   rN   rO   r5   rH   rI   r   r3   r3   rx   r4   r      s    
 r   	linecountc                      sT   e Zd ZdZd" fdd	Zd#ddZd$ddZd%ddZd$ddZd$d d!Z	  Z
S )&AnyExpressionsReporterz3Report frequencies of different kinds of Any types.rP   r   rQ   r%   r(   r)   c                   s   t  || i | _i | _d S r*   )rv   r5   rw   any_types_counterrT   rx   r3   r4   r5      s   
zAnyExpressionsReporter.__init__rB   r   rC   rD   rE   rF   rG   r   c           	      C  s   t jd|j||ddd}|| |j| j|j< t|j 	t j
}|j| }|j|j | }|dkr>||f| j|j< d S d S )NTF)inferredfilenamerC   typemap	all_nodesvisit_untyped_defsr   )r   StatisticsVisitorfullnamer   type_of_any_counterr   listline_mapvaluescountTYPE_UNANALYZEDnum_any_exprsnum_imprecise_exprsnum_precise_exprsrw   )	r0   rB   rC   rE   rG   visitornum_unanalyzed_linesnum_any	num_totalr3   r3   r4   rH      s    

zAnyExpressionsReporter.on_filec                 C  s   |    |   d S r*   )_report_any_exprs_report_types_of_anysrW   r3   r3   r4   rI      s   z AnyExpressionsReporter.on_finishr   header	list[str]rowslist[list[str]]footerc                   s  t | t fdd|||g D sJ d}dg  }|||g D ]}t|D ]\}}	t|| t |	||< q(q"t|D ]\}}
|dkrK|
| ||< q=ttj| j|dd}dt | j	t
jt||  }dt | }||d	  ||d	  |D ]}dt | j	t
jt||  }||d	  q}||d	  dt | j	t
jt||  }||d	  W d    d S 1 sw   Y  d S )
Nc                 3  s    | ]	}t | kV  qd S r*   r   )r   rowrow_lenr3   r4   r      r   z;AnyExpressionsReporter._write_out_report.<locals>.<genexpr>r   r   r   z{:>{}}-r   )r   allrp   maxro   ri   rb   r   rQ   r:   	itertoolschainzipr   )r0   r   r   r   r   min_column_distancewidthsr   r   valuer   r   
header_str	separator
row_valuesr
footer_strr3   r   r4   _write_out_report   s0   "
"z(AnyExpressionsReporter._write_out_reportc                 C  s   t dd | j D }t dd | j D }d}|dkr*t|| t| d }g d}g }t| jD ](}| j| \}}t|| t| d }	|	dd	}
||t|t||
g q5|jd
d d dt|t||dd	g}| d||| d S )Nc                 s  s    | ]\}}|V  qd S r*   r3   )r   r   _r3   r3   r4   r         z;AnyExpressionsReporter._report_any_exprs.<locals>.<genexpr>c                 s  s    | ]\}}|V  qd S r*   r3   )r   r   totalr3   r3   r4   r     r   g      Y@r   d   )NameAnysExprsCoveragez.2f%c                 S     | d S rt   r3   xr3   r3   r4   <lambda>      z:AnyExpressionsReporter._report_any_exprs.<locals>.<lambda>keyTotalzany-exprs.txt)	r   rw   r   floatr-   r>   r%   sortr   )r0   	total_any
total_exprtotal_coveragecolumn_namesr   r   r   r   coveragecoverage_str	total_rowr3   r3   r4   r     s   z(AnyExpressionsReporter._report_any_exprsc           	        s   t  | j D ]   D ]\}}|  |7  < qq	d}d}|gtt  }g }| j D ]\} ||g fddtD   q1|jdd d |gfddtD  }| 	d	||| d S )
Nr   r   c                      g | ]}t  | qS r3   r%   r   typ)counterr3   r4   
<listcomp>*      z@AnyExpressionsReporter._report_types_of_anys.<locals>.<listcomp>c                 S  r   rt   r3   r   r3   r3   r4   r   +  r   z>AnyExpressionsReporter._report_types_of_anys.<locals>.<lambda>r   c                   r   r3   r   r   )total_counterr3   r4   r   ,  r   ztypes-of-anys.txt)
collectionsCounterr   r   r.   r   r   r>   r   r   )	r0   any_typer   file_column_nametotal_row_namer   r   r   r   r3   )r   r   r4   r      s    z,AnyExpressionsReporter._report_types_of_anysrX   rK   rL   )
r   r%   r   r   r   r   r   r   r(   r)   )rM   rN   rO   __doc__r5   rH   rI   r   r   r   r   r3   r3   rx   r4   r      s    



r   z	any-exprsc                      s2   e Zd ZdddZdd
dZd fddZ  ZS )LineCoverageVisitorsourcer   r(   r)   c                 C  s   || _ dd |D | _d S )Nc                 S  s   g | ]}d qS ))r   Tr3   )r   lr3   r3   r4   r   <  s    z0LineCoverageVisitor.__init__.<locals>.<listcomp>)r  lines_covered)r0   r  r3   r3   r4   r5   4  s   zLineCoverageVisitor.__init__line_numberint
int | Nonec                 C  sn   | j | }d}t|D ])}|dkr|d7 }q|dkr#d|d d  }q|dkr* dS |dkr1 dS |  S dS )	zReturn the indentation of a line of the source (specified by
        zero-indexed line number). Returns None for blank lines or comments.r   r   rm   	   #Nr   )r  r   )r0   r  lineindentcharr3   r3   r4   indentation_levelH  s   

z%LineCoverageVisitor.indentation_levelrz   r   c                   s  |  d }d }|t| jk r$| |}|d urn|d7 }|t| jk s|d u r*d S |d }|}|t| jk r\| |}|d u rE|d7 }n|d urT||krT|d7 }|}nn|t| jk s7|jd u}t||D ]}| j| \}	}
|	|krz||f| j|< qft | d S r{   )	get_liner   r  r  r|   r   r  rv   r}   )r0   rz   
start_linestart_indentcur_lineend_line
cur_indentis_typedr  
old_indentr   rx   r3   r4   r}   `  s8   



z"LineCoverageVisitor.visit_func_def)r  r   r(   r)   )r  r  r(   r  r   )rM   rN   rO   r5   r  r}   r   r3   r3   rx   r4   r  3  s    

r  c                      6   e Zd ZdZd fdd	ZdddZdddZ  ZS )LineCoverageReportera[  Exact line coverage reporter.

    This reporter writes a JSON dictionary with one field 'lines' to
    the file 'coverage.json' in the specified report directory. The
    value of that field is a dictionary which associates to each
    source file's absolute pathname the list of line numbers that
    belong to typed functions in that file.
    rP   r   rQ   r%   r(   r)   c                   r   r*   )rv   r5   r  rT   rx   r3   r4   r5     r   zLineCoverageReporter.__init__rB   r   rC   rD   rE   rF   rG   r   c                 C  s   t |j}| }W d    n1 sw   Y  t|}|| g }t|jD ]\}	\}
}|r8||	d  q)|| jtj	|j< d S r{   )
ro   rb   r   r  r   rp   r  r>   ri   abspath)r0   rB   rC   rE   rG   r   tree_sourcecoverage_visitorcovered_linesr  r   typedr3   r3   r4   rH     s   

zLineCoverageReporter.on_filec                 C  sN   t tj| jdd}td| ji| W d    d S 1 s w   Y  d S )Nzcoverage.jsonr   lines)ro   ri   rb   r   rQ   jsondumpr  )r0   r   r3   r3   r4   rI     s   "zLineCoverageReporter.on_finishrX   rK   rL   rM   rN   rO   r  r5   rH   rI   r   r3   r3   rx   r4   r    s
    	
r  linecoveragec                   @  s*   e Zd ZdddZdd	d
ZdddZdS )FileInfonamer%   moduler(   r)   c                 C  s"   || _ || _dgttj | _d S rt   )r%  r&  r   r   precision_namesrw   )r0   r%  r&  r3   r3   r4   r5     s   zFileInfo.__init__r  c                 C  s
   t | jS r*   )r   rw   rW   r3   r3   r4   r     s   
zFileInfo.totalr'   c                 C  s   dd t ttj| jD S )Nc                 S  s   i | ]	\}}|t |qS r3   r   )r   r%  valr3   r3   r4   
<dictcomp>  s    z#FileInfo.attrib.<locals>.<dictcomp>)r-   r   r   r'  rw   rW   r3   r3   r4   attrib  r~   zFileInfo.attribN)r%  r%   r&  r%   r(   r)   )r(   r  )r(   r'   )rM   rN   rO   r5   r   r*  r3   r3   r3   r4   r$    s    

r$  c                      sn   e Zd ZU dZd# fdd	Zed
dd edD dZ	de
d< d$ddZed%dd Zd&d!d"Z  ZS )'MemoryXmlReporterz}Internal reporter that generates XML in memory.

    This is used by all other XML-based reporters to avoid duplication.
    rP   r   rQ   r%   r(   r)   c                   s~   t  || tj|jdd| _tj|jdd| _tj|jdd| _tj|jdd}t	
t	|| _d | _g | _d S )Nxmlmypy-html.xsltzmypy-txt.xsltmypy-html.csszmypy.xsd)rv   r5   ri   rb   r   r$   xslt_html_pathxslt_txt_pathcss_html_pathr   	XMLSchemaparseschemalast_xmlfiles)r0   rP   rQ   xsd_pathrx   r3   r4   r5     s   
zMemoryXmlReporter.__init__ c                 c  s     | ]}|d krt |V  qdS )	   N)chr)r   r   r3   r3   r4   r     s    zMemoryXmlReporter.<genexpr>    z???????????????????????????????r   control_fixerrB   r   rC   rD   rE   rF   rG   r   c              	   C  sJ  d | _ z	tj|j}W n
 ty   Y d S w t|s!tj|r#d S tjd|j	||dd}|
| tjd||jd}t|}t||j}	t|D ]0\}
}|j|
tj}|	j|  d7  < tj|d| ||
|d| jt|
tj| d qKtjd	|}td
dt| d}|| | j | || _ | j!"|	 d S )NTr   r   rC   r   r   zmypy-report-file)r%  r&  rm   r  r   )any_infocontentnumber	precisionr-  xml-stylesheettype="text/xsl" href="")#r5  ri   rb   relpath
ValueErrorrk   isdirr   r   r   r   r   Elementr   ElementTreer$  rr   r   get
TYPE_EMPTYrw   
SubElement_get_any_info_for_linerstrip	translater<  r%   r'  ProcessingInstructionr   addpreviousr4  assertValidr6  r>   )r0   rB   rC   rE   rG   rb   r   rootdoc	file_infolineno	line_textstatus	xslt_pathtransform_pir3   r3   r4   rH     sL   


	
zMemoryXmlReporter.on_filer   stats.StatisticsVisitorrV  r  c                 C  sl   || j v r4d}t }| j | D ]}||j  d7  < q| D ]\}}|dt|  d| d7 }q |S dS )NzAny Types on this line: rm   r   z (x)zNo Anys on this line!)any_line_mapr   r   type_of_anyr.   r   )r   rV  resultr   r   r   occurrencesr3   r3   r4   rM    s   
z(MemoryXmlReporter._get_any_info_for_linec              
   C  s   d | _ t| jdd d}tjddd}t|}|D ]}tj|d| |jt	|j
t| d qtjd	d
}tddt	| d}|| | j| || _ d S )Nc                 S     | j S r*   r&  r   r3   r3   r4   r         z-MemoryXmlReporter.on_finish.<locals>.<lambda>r   zmypy-report-indexindex)r%  r6   )r&  r%  r   r-  .rB  rC  rD  )r5  r-   r6  r   rH  rI  rL  r*  r&  r   r%  r%   r   ri   rb   rE  rP  rQ  r4  rR  )r0   output_filesrS  rT  rU  rY  rZ  r3   r3   r4   rI     s(   



zMemoryXmlReporter.on_finishrX   rK   )r   r[  rV  r  r(   r%   rL   )rM   rN   rO   r  r5   r%   	maketransr   r   r<  __annotations__rH   staticmethodrM  rI   r   r3   r3   rx   r4   r+    s   
 (
4r+  
memory-xml)r@   r  r  total_linesc                 C  s   |dkrt dS | | dS )Nr   g      ?z.4fr   )r  rk  r3   r3   r4   get_line_rate:  s   rl  c                   @  s.   e Zd ZdZdddZdd	d
ZdddZdS )CoberturaPackagezMContainer for XML and statistics mapping python modules to Cobertura package.r%  r%   r(   r)   c                 C  s"   || _ i | _i | _d| _d| _d S rt   )r%  classespackagesrk  r  )r0   r%  r3   r3   r4   r5   D  s
   
zCoberturaPackage.__init__r   c                 C  sj   t jdd| jd}d|jd< t| j| j|jd< t |d}t| j	D ]
}|
| j	|  q#| | |S )Npackage1.0)
complexityr%  0branch-rate	line-ratern  )r   rH  r%  r*  rl  r  rk  rL  r-   rn  r>   add_packages)r0   package_elementclasses_element
class_namer3   r3   r4   as_xmlK  s   

zCoberturaPackage.as_xmlparent_elementc                 C  sD   | j rt|d}t| j  tddD ]}||  qd S d S )Nro  r%  r   )ro  r   rL  r-   r   r   r>   rz  )r0   r{  packages_elementrp  r3   r3   r4   rv  U  s   zCoberturaPackage.add_packagesN)r%  r%   r(   r)   )r(   r   )r{  r   r(   r)   )rM   rN   rO   r  r5   rz  rv  r3   r3   r3   r4   rm  A  s
    


rm  c                      r  )CoberturaXmlReporterz0Reporter for generating Cobertura compliant XML.rP   r   rQ   r%   r(   r)   c                   sH   t  || tjdttt td| _t	| j| _
td| _d S )Nr   )	timestampversionre  )rv   r5   r   rH  r%   r  timer   rS  rI  rT  rm  root_packagerT   rx   r3   r4   r5   _  s   zCoberturaXmlReporter.__init__rB   r   rC   rD   rE   rF   rG   r   c              
   C  s  t j|j}tjd|j||dd}|| t j|}t||j	}t
jdd||d}	t
|	d t
|	d}
t|}d}d}t|d	D ]R\}}|j|tj}d}d
}|tjkr]qG|d	7 }|tjkrl|d	7 }d	}|tjkrsd}|j|  d	7  < t
j|
dt| t|t|tj| d}|rd|jd< qGd|	jd< t|||	jd< |jdd	d }|jdr|j}|| jj vrt!|| jj |< | jj | }| j|g}|D ]}| j"|7  _"| j#|7  _#q|	|j$|< W d    d S 1 sw   Y  d S )NTr=  classrq  )rr  r   r%  methodsr  r   rm   Fr  )branchhitsr@  rA  z	50% (1/2)zcondition-coveragers  rt  ru  re  z__init__.py)%ri   rb   rE  r   r   r   r   basenamer$  r   r   rH  rL  rn   ro   rp   r   rJ  rK  TYPE_ANYTYPE_IMPRECISErw   r%   lowerr'  r*  rl  r&  rsplitr%  endswithr  ro  rm  rk  r  rn  )r0   rB   rC   rE   rG   rb   r   ry  rU  class_elementlines_elementrq   class_lines_coveredclass_total_linesrV  r   rX  r  r  line_elementparent_modulecurrent_packagepackages_to_updaterp  r3   r3   r4   rH   f  sr   








"zCoberturaXmlReporter.on_filec                 C  s   t | jj| jj| jjd< d| jjd< t| jd}t|d}t	 |_
| j| j tj| jd}| jj|ddd	 td
tj| d S )Nru  rs  rt  sourcesr  zcobertura.xmlutf-8T)encodingpretty_printzGenerated Cobertura report:)rl  r  r  rk  rS  r*  r   rL  ri   getcwdtextrv  rb   r   rQ   rT  r   r9   r  )r0   r  source_elementout_pathr3   r3   r4   rI     s   
zCoberturaXmlReporter.on_finishrX   rK   rL   r"  r3   r3   rx   r4   r}  \  s
    
Er}  zcobertura-xmlc                      s"   e Zd ZdZd
 fdd	Z  ZS )AbstractXmlReporterz8Internal abstract class for reporters that work via XML.rP   r   rQ   r%   r(   r)   c                   s*   t  || |dd}tt|| _d S )Nrj  rR   )rv   r5   r/   r   r+  
memory_xml)r0   rP   rQ   memory_reporterrx   r3   r4   r5     s   zAbstractXmlReporter.__init__rX   )rM   rN   rO   r  r5   r   r3   r3   rx   r4   r    s    r  c                   @  s$   e Zd ZdZdddZdddZdS )XmlReporteraC  Public reporter that exports XML.

    The produced XML files contain a reference to the absolute path
    of the html transform, so they will be locally viewable in a browser.

    However, there is a bug in Chrome and all other WebKit-based browsers
    that makes it fail from file:// URLs but work on http:// URLs.
    rB   r   rC   rD   rE   rF   rG   r   r(   r)   c                 C  sj   | j j}|d u r
d S tj|j}|drd S tj| jd|d }t	tj
| |j|dd d S )Nrc   r,  z.xmlr  r  )r  r5  ri   rb   rE  rg   r   rQ   r   rS   dirnamer   )r0   rB   rC   rE   rG   r5  rb   r  r3   r3   r4   rH     s   
zXmlReporter.on_filec                 C  s   | j j}|d us
J tj| jd}tj| jd}tj| jd}|j|dd t| j j	| t| j j
| tdtj| d S )Nz	index.xmlr-  r.  r  r  zGenerated XML report:)r  r5  ri   rb   r   rQ   r   shutilcopyfiler/  r1  r9   r  )r0   r5  r  out_xsltout_cssr3   r3   r4   rI     s   zXmlReporter.on_finishNrK   rL   )rM   rN   rO   r  rH   rI   r3   r3   r3   r4   r    s    
	r  r,  c                      r  )XsltHtmlReporterzPublic reporter that exports HTML via XSLT.

    This is slightly different than running `xsltproc` on the .xml files,
    because it passes a parameter to rewrite the links.
    rP   r   rQ   r%   r(   r)   c                   s6   t  || tt| jj| _tjd| _	d S )Nhtml)
rv   r5   r   XSLTr3  r  r/  	xslt_htmlstrparam
param_htmlrT   rx   r3   r4   r5     s   zXsltHtmlReporter.__init__rB   r   rC   rD   rE   rF   rG   r   c           
      C  s   | j j}|d u r
d S tj|j}|drd S tj| jd|d }t	tj
| t| j|| jd}t|d}	|	| W d    d S 1 sLw   Y  d S )Nrc   r  z.htmlextwb)r  r5  ri   rb   rE  rg   r   rQ   r   rS   r  bytesr  r  ro   r   )
r0   rB   rC   rE   rG   r5  rb   r  transformed_htmlout_filer3   r3   r4   rH     s   
"zXsltHtmlReporter.on_filec                 C  s   | j j}|d us
J tj| jd}tj| jd}t| j|| jd}t	|d}|
| W d    n1 s9w   Y  t| j j| tdtj| d S )Nz
index.htmlr.  r  r  z!Generated HTML report (via XSLT):)r  r5  ri   rb   r   rQ   r  r  r  ro   r   r  r  r1  r9   r  )r0   r5  r  r  r  r  r3   r3   r4   rI     s   zXsltHtmlReporter.on_finishrX   rK   rL   r"  r3   r3   rx   r4   r    s
    
r  z	xslt-htmlc                      r  )XsltTxtReporterzvPublic reporter that exports TXT via XSLT.

    Currently this only does the summary, not the individual reports.
    rP   r   rQ   r%   r(   r)   c                   s(   t  || tt| jj| _d S r*   )rv   r5   r   r  r3  r  r0  xslt_txtrT   rx   r3   r4   r5   &  s   zXsltTxtReporter.__init__rB   r   rC   rD   rE   rF   rG   r   c                 C  rU   r*   r3   rV   r3   r3   r4   rH   +  s   zXsltTxtReporter.on_filec                 C  s|   | j j}|d us
J tj| jd}t| |}t|d}|	| W d    n1 s.w   Y  t
dtj| d S )Nz	index.txtr  z Generated TXT report (via XSLT):)r  r5  ri   rb   r   rQ   r  r  ro   r   r9   r  )r0   r5  r  transformed_txtr  r3   r3   r4   rI   4  s   zXsltTxtReporter.on_finishrX   rK   rL   r"  r3   r3   rx   r4   r     s
    
	r  zxslt-txtr  txtc                      r  )LinePrecisionReportera  Report per-module line counts for typing precision.

    Each line is classified into one of these categories:

    * precise (fully type checked)
    * imprecise (Any types in a type component, such as List[Any])
    * any (something with an Any type, implicit or explicit)
    * empty (empty line, comment or docstring)
    * unanalyzed (mypy considers line unreachable)

    The meaning of these categories varies slightly depending on
    context.
    rP   r   rQ   r%   r(   r)   c                   s   t  || g | _d S r*   )rv   r5   r6  rT   rx   r3   r4   r5   S  r   zLinePrecisionReporter.__init__rB   r   rC   rD   rE   rF   rG   r   c                 C  s   z	t j|j}W n
 ty   Y d S w t|rd S tjd|j||dd}|| t	||j
}t|D ]\}}	|j|tj}
|j|
  d7  < q4| j| d S )NTr=  rm   )ri   rb   rE  rF  rk   r   r   r   r   r$  r   rr   r   rJ  rK  rw   r6  r>   )r0   rB   rC   rE   rG   rb   r   rU  rV  r   rX  r3   r3   r4   rH   W  s(   
zLinePrecisionReporter.on_filec           
      C  s  | j sd S t| j dd d}tj| jd}tdtdd |D }d}|ftd	d |D  }d
| }t|dK}|	|j
dg|R   |	d|d  d  |D ](}|j}	|	|
|j|| |	tj |	tj |	tj |	tj |	tj  qSW d    d S 1 sw   Y  d S )Nc                 S  ra  r*   rb  r   r3   r3   r4   r   {  rc  z1LinePrecisionReporter.on_finish.<locals>.<lambda>r   zlineprecision.txtr   c                 s  s    | ]}t |jV  qd S r*   )r   r&  )r   infor3   r3   r4   r   }  s    z2LinePrecisionReporter.on_finish.<locals>.<genexpr>)LinesPrecise	Impreciser   Empty
Unanalyzedc                 s  s    | ]}t |V  qd S r*   r   )r   tr3   r3   r4   r     r   z0{:%d}  {:%d}  {:%d}  {:%d}  {:%d}  {:%d}  {:%d}
r   r   r   3   r   )r6  r-   ri   rb   r   rQ   r   r   ro   r   r:   rw   r&  ljustr   r   TYPE_PRECISEr  r  rK  r   )
r0   rf  report_filewidthtitlesr   fmtr   rU  rw   r3   r3   r4   rI   w  s4   
"zLinePrecisionReporter.on_finishrX   rK   rL   r"  r3   r3   rx   r4   r  D  s
    
 r  lineprecision)F)rZ   r%   rA   r[   r@   r\   r(   r)   )r_   r%   r`   r%   r(   r)   )rb   r%   r(   r\   )rb   r%   r(   rl   )r  r  rk  r  r(   r%   )Vr  
__future__r   r   r   r   ri   r  r;   r  rn   typingabcr   r   operatorr   r   r   r   r	   r
   r   typing_extensionsr   r   r!   urllib.requestr   mypyr   mypy.defaultsr   
mypy.nodesr   r   r   mypy.optionsr   mypy.traverserr   
mypy.typesr   r   mypy.versionr   lxmlr   r8   r=   OrderedDictunannotatedexplicitfrom_unimported_typefrom_omitted_generics
from_errorspecial_formimplementation_artifactr   rh  r%   r\   r"   r#   r   r    r^   ra   rk   rr   rs   r   r   r  r  r$  r+  rl  rm  r}  r  r  r  r  r  setr3   r3   r3   r4   <module>   s     -



	
0
`[
'r
]',


O