o
    ÕtBh„X  ã                   @  s   d Z ddlmZ ddlZddlZddlmZmZmZ ddl	Z
ddlmZmZ ddlmZ er2ddlZ
G dd„ dee ƒZddd„Zddd„ZdS )z*Conversion of parse tree nodes to strings.é    )ÚannotationsN)ÚTYPE_CHECKINGÚAnyÚSequence)ÚIdMapperÚ
short_type)ÚNodeVisitorc                   @  sN  e Zd ZdZdddd„Zddd„Zddd„Zddd„Zddd„Zddd„Z	ddd „Z
d d"d#„Zd!d%d&„Zd"d(d)„Zd#d+d,„Zd$d.d/„Zd%d1d2„Zd&d4d5„Zd'd7d8„Zd(d:d;„Zd)d=d>„Zd*d@dA„Zd+dCdD„Zd,dFdG„Zd-dIdJ„Zd.dLdM„Zd/dOdP„Zd0dRdS„Zd1dUdV„Zd2dXdY„Zd3d[d\„Zd4d^d_„Zd5dadb„Z d6ddde„Z!d7dgdh„Z"d8djdk„Z#d9dmdn„Z$d:dpdq„Z%d;dsdt„Z&d<dvdw„Z'd=dydz„Z(d>d|d}„Z)d?dd€„Z*d@d‚dƒ„Z+dAd…d†„Z,dBdˆd‰„Z-dCd‹dŒ„Z.	dDdEd•d–„Z/dFd˜d™„Z0dGd›dœ„Z1dHdždŸ„Z2dId¡d¢„Z3dJd¤d¥„Z4dKd§d¨„Z5dLdªd«„Z6dMd­d®„Z7dNd°d±„Z8dOd³d´„Z9dPd¶d·„Z:dQd¹dº„Z;dRd¼d½„Z<dSd¿dÀ„Z=dTdÂdÃ„Z>dUdÅdÆ„Z?dVdÈdÉ„Z@dWdËdÌ„ZAdXdÎdÏ„ZBdYdÑdÒ„ZCdZdÔdÕ„ZDd[d×dØ„ZEd\dÚdÛ„ZFd]dÝdÞ„ZGd^dàdá„ZHd_dãdä„ZId`dædç„ZJdadédê„ZKdbdìdí„ZLdcdïdð„ZMdddòdó„ZNdedõdö„ZOdfdødù„ZPdgdûdü„ZQdhdþdÿ„ZRdidd„ZSdjdd„ZTdkdd„ZUdld
d„ZVdmdd„ZWdndd„ZXdodd„ZYdpdd„ZZdS (q  ÚStrConvzîVisitor for converting a node to a human-readable string.

    For example, an MypyFile node from program '1' is converted into
    something like this:

      MypyFile:1(
        fnam
        ExpressionStmt:1(
          IntExpr(1)))
    FÚshow_idsÚboolÚreturnÚNonec                 C  s    || _ d | _|rtƒ | _d S d S ©N)r
   Ú	id_mapperr   )Úselfr
   © r   úc/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/mypy/strconv.pyÚ__init__   s
   ÿzStrConv.__init__ÚoÚobjectú
int | Nonec                 C  s   | j r	| j  |¡S d S r   )r   Úid©r   r   r   r   r   Úget_id#   s   zStrConv.get_idÚstrc                 C  s   | j rd|  |¡› dS dS )Nú<ú>Ú )r   r   r   r   r   r   Ú	format_id(   s   zStrConv.format_idÚnodesúSequence[object]Úobjúmypy.nodes.Contextc                 C  sN   t |ƒd t| ¡ ƒ }| jr!| jdusJ ‚|d|  |¡› d7 }t||| ƒS )zåConvert a list of items to a multiline pretty-printed string.

        The tag is produced from the type name of obj and its line
        number. See mypy.util.dump_tagged for a description of the nodes
        argument.
        ú:Nr   r   )r   r   Úget_liner
   r   r   Údump_tagged)r   r   r!   Útagr   r   r   Údump.   s
   zStrConv.dumpúmypy.nodes.FuncItemúlist[object]c                 C  sî   g }g }|j D ]F}|j}| ¡ r| |j¡ q| ¡ r.|jdus"J ‚| d|j|jgf¡ q|tjj	kr>| d|jgf¡ q|tjj
krM| d|jgf¡ qg }|rY| d|f¡ |jrb| |j¡ |jrj| d¡ | |¡ | |j¡ |S )zþReturn a list in a format suitable for dump() that represents the
        arguments and the body of a function. The caller can then decorate the
        array with information specific to methods, global functions or
        anonymous functions.
        NÚdefaultÚVarArgÚ
DictVarArgÚArgsÚ	Generator)Ú	argumentsÚkindÚis_requiredÚappendÚvariableÚis_optionalÚinitializerÚmypyr   ÚARG_STARÚ	ARG_STAR2ÚtypeÚis_generatorÚextendÚbody)r   r   ÚargsÚextraÚargr0   Úar   r   r   Úfunc_helper;   s0   
€

zStrConv.func_helperúmypy.nodes.MypyFilec                 C  sr   |j g}|jr| dd¡ |jdkr| d|j tjd¡¡ |jr3| dd 	dd„ t
|jƒD ƒ¡ ¡ |  ||¡S )	Nr   ÚBOMÚmainú/zIgnoredLines(%s)ú, c                 s  s    | ]}t |ƒV  qd S r   )r   )Ú.0Úliner   r   r   Ú	<genexpr>h   s   € z*StrConv.visit_mypy_file.<locals>.<genexpr>)ÚdefsÚis_bomÚinsertÚpathÚreplaceÚosÚsepÚignored_linesr2   ÚjoinÚsortedr'   ©r   r   r@   r   r   r   Úvisit_mypy_file[   s   
$zStrConv.visit_mypy_fileúmypy.nodes.Importc                 C  sV   g }|j D ]\}}|d ur| |› d|› ¡ q| |¡ qd|j› dd |¡› dS )Nú : zImport:ú(rF   ú))Úidsr2   rH   rR   )r   r   r@   r   Úas_idr   r   r   Úvisit_importk   s   zStrConv.visit_importúmypy.nodes.ImportFromc                 C  sh   g }|j D ]\}}|d ur| |› d|› ¡ q| |¡ qd|j› dd|j |j › dd |¡› dS )NrW   zImportFrom:rX   Ú.z, [rF   z]))Únamesr2   rH   Úrelativer   rR   )r   r   r@   ÚnameÚas_namer   r   r   Úvisit_import_fromt   s   ,zStrConv.visit_import_fromúmypy.nodes.ImportAllc                 C  s    d|j › dd|j |j › dS )Nz
ImportAll:rX   r^   rY   )rH   r`   r   r   r   r   r   Úvisit_import_all}   ó    zStrConv.visit_import_allúmypy.nodes.FuncDefc                 C  s¾   |   |¡}| d|j¡ dd„ |jD ƒ}t|tjjtjjh@ ƒdkr-| dd|j	› d¡ |j
tjjtjjfv r>| dd¡ |jrG| dd	¡ |jrP| dd
¡ |jrY| dd¡ |  ||¡S )Nr   c                 S  s   h | ]}|j ’qS r   )r0   )rG   r?   r   r   r   Ú	<setcomp>…   ó    z)StrConv.visit_func_def.<locals>.<setcomp>é   zMaxPos(rY   éÿÿÿÿÚAbstractÚStaticÚClassÚProperty)rA   rL   ra   r/   Úlenr6   r   Ú	ARG_NAMEDÚARG_NAMED_OPTÚmax_posÚabstract_statusÚIS_ABSTRACTÚIMPLICITLY_ABSTRACTÚ	is_staticÚis_classÚis_propertyr'   )r   r   r@   Ú	arg_kindsr   r   r   Úvisit_func_def‚   s   
zStrConv.visit_func_defúmypy.nodes.OverloadedFuncDefc                 C  sf   |j d d … }|jr| d|j¡ |jr| d|j¡ |jr$| dd¡ |jr-| dd¡ |  ||¡S )Nr   rk   rm   rn   )Úitemsr9   rL   Úimplrw   rx   r'   rT   r   r   r   Úvisit_overloaded_func_def’   s   z!StrConv.visit_overloaded_func_defúmypy.nodes.ClassDefc                 C  s*  |j |jjg}|jr7|jr.|jjr.t|jjƒdks#|jjd jjdkr-| 	dd|jjf¡ n	| 	dd|jf¡ |j
rC| 	dd|j
f¡ |jrQ| 	dd|j› d¡ |jr]| 	dd	|jf¡ |jrp|jjrp| 	dd
|jj› d¡ |jr‚|jjr‚| 	dd|jjgf¡ |jr|jjr| 	dd¡ |  ||¡S )Nrj   r   úbuiltins.objectÚBaseTypeÚBaseTypeExprÚTypeVarsz
Metaclass(rY   Ú
DecoratorszPromote(Ú	TupleTypeÚFallbackToAny)ra   rJ   r<   Úbase_type_exprsÚinfoÚbasesrp   r9   ÚfullnamerL   Ú	type_varsÚ	metaclassÚ
decoratorsÚ_promoteÚ
tuple_typeÚfallback_to_anyr'   rT   r   r   r   Úvisit_class_defž   s(   $€zStrConv.visit_class_defúmypy.nodes.Varc                 C  s(   d}|j dk r	d}d| d |j d S )Nr   r   z:nilÚVarrX   rY   )rH   ra   )r   r   Úlstr   r   r   Ú	visit_var¶   s   
zStrConv.visit_varúmypy.nodes.GlobalDeclc                 C  ó   |   |jg|¡S r   ©r'   r_   r   r   r   r   Úvisit_global_decl¾   ó   zStrConv.visit_global_declúmypy.nodes.NonlocalDeclc                 C  r˜   r   r™   r   r   r   r   Úvisit_nonlocal_declÁ   r›   zStrConv.visit_nonlocal_declúmypy.nodes.Decoratorc                 C  ó   |   |j|j|jg|¡S r   )r'   ÚvarrŽ   Úfuncr   r   r   r   Úvisit_decoratorÄ   ó   zStrConv.visit_decoratorúmypy.nodes.Blockc                 C  ó   |   |j|¡S r   )r'   r<   r   r   r   r   Úvisit_blockÉ   ó   zStrConv.visit_blockúmypy.nodes.ExpressionStmtc                 C  r˜   r   ©r'   Úexprr   r   r   r   Úvisit_expression_stmtÌ   r›   zStrConv.visit_expression_stmtúmypy.nodes.AssignmentStmtc                 C  sV   g }t |jƒdkrd|jfg}n|jd g}| |j¡ |jr%| |j¡ |  ||¡S )Nrj   ÚLvaluesr   )rp   Úlvaluesr2   Úrvaluer9   r'   rT   r   r   r   Úvisit_assignment_stmtÏ   s   zStrConv.visit_assignment_stmtú!mypy.nodes.OperatorAssignmentStmtc                 C  rŸ   r   )r'   ÚopÚlvaluer¯   r   r   r   r   Úvisit_operator_assignment_stmtÚ   r£   z&StrConv.visit_operator_assignment_stmtúmypy.nodes.WhileStmtc                 C  s0   |j |jg}|jr| d|jjf¡ |  ||¡S )NÚElse)rª   r<   Ú	else_bodyr2   r'   rT   r   r   r   Úvisit_while_stmtÝ   s   zStrConv.visit_while_stmtúmypy.nodes.ForStmtc                 C  sh   g }|j r
| d¡ | |j¡ |jr| |j¡ | |j|jg¡ |jr.| d|jjf¡ |  ||¡S )N©ÚAsyncr   r¶   )	Úis_asyncr2   ÚindexÚ
index_typer;   rª   r<   r·   r'   rT   r   r   r   Úvisit_for_stmtã   s   
zStrConv.visit_for_stmtúmypy.nodes.ReturnStmtc                 C  r˜   r   r©   r   r   r   r   Úvisit_return_stmtï   r›   zStrConv.visit_return_stmtúmypy.nodes.IfStmtc                 C  sn   g }t t|jƒƒD ]}| d|j| gf¡ | d|j| jf¡ q	|js+|  ||¡S |  |d|jjfg|¡S )NÚIfÚThenr¶   )Úrangerp   rª   r2   r<   r·   r'   ©r   r   r@   Úir   r   r   Úvisit_if_stmtò   s   zStrConv.visit_if_stmtúmypy.nodes.BreakStmtc                 C  ó   |   g |¡S r   ©r'   r   r   r   r   Úvisit_break_stmtý   ó   zStrConv.visit_break_stmtúmypy.nodes.ContinueStmtc                 C  rÊ   r   rË   r   r   r   r   Úvisit_continue_stmt   rÍ   zStrConv.visit_continue_stmtúmypy.nodes.PassStmtc                 C  rÊ   r   rË   r   r   r   r   Úvisit_pass_stmt  rÍ   zStrConv.visit_pass_stmtúmypy.nodes.RaiseStmtc                 C  ó   |   |j|jg|¡S r   )r'   rª   Ú	from_exprr   r   r   r   Úvisit_raise_stmt  ó   zStrConv.visit_raise_stmtúmypy.nodes.AssertStmtc                 C  s.   |j d ur|  |j|j g|¡S |  |jg|¡S r   )Úmsgr'   rª   r   r   r   r   Úvisit_assert_stmt	  s   
zStrConv.visit_assert_stmtúmypy.nodes.AwaitExprc                 C  r˜   r   r©   r   r   r   r   Úvisit_await_expr  r›   zStrConv.visit_await_exprúmypy.nodes.DelStmtc                 C  r˜   r   r©   r   r   r   r   Úvisit_del_stmt  r›   zStrConv.visit_del_stmtúmypy.nodes.TryStmtc                 C  s’   |j g}tt|jƒƒD ]}| |j| ¡ |j| r"| |j| ¡ | |j| ¡ q|jr7| d|jj f¡ |jrC| d|jj f¡ |  	||¡S )Nr¶   ÚFinally)
r<   rÅ   rp   Úvarsr2   ÚtypesÚhandlersr·   Úfinally_bodyr'   rÆ   r   r   r   Úvisit_try_stmt  s   
zStrConv.visit_try_stmtúmypy.nodes.WithStmtc                 C  s„   g }|j r
| d¡ tt|jƒƒD ]}| d|j| gf¡ |j| r.| d|j| gf¡ q|jr8| |j¡ |  ||jg |¡S )Nrº   ÚExprÚTarget)	r¼   r2   rÅ   rp   rª   ÚtargetÚunanalyzed_typer'   r<   rÆ   r   r   r   Úvisit_with_stmt%  s   

€zStrConv.visit_with_stmtúmypy.nodes.MatchStmtc                 C  sx   |j g}tt|jƒƒD ]*}| d|j| gf¡ |j| d ur*| d|j| gf¡ | d|j| jf¡ q|  ||¡S )NÚPatternÚGuardÚBody)	ÚsubjectrÅ   rp   Úpatternsr2   ÚguardsÚbodiesr<   r'   rÆ   r   r   r   Úvisit_match_stmt1  s   zStrConv.visit_match_stmtúmypy.nodes.IntExprc                 C  ó   d|j › dS )NzIntExpr(rY   ©Úvaluer   r   r   r   Úvisit_int_expr>  r§   zStrConv.visit_int_exprúmypy.nodes.StrExprc                 C  ó   d|   |j¡› dS )NzStrExpr(rY   ©Ústr_reprr÷   r   r   r   r   Úvisit_str_exprA  rÖ   zStrConv.visit_str_exprúmypy.nodes.BytesExprc                 C  rú   )Nz
BytesExpr(rY   rû   r   r   r   r   Úvisit_bytes_exprD  rÖ   zStrConv.visit_bytes_exprÚsc                 C  s$   t  ddd„ |¡}t  ddd„ |¡S )Nz\\u[0-9a-fA-F]{4}c                 S  s   d|   d¡ S )Nú\r   )Úgroup©Úmr   r   r   Ú<lambda>H  s    z"StrConv.str_repr.<locals>.<lambda>z[^\x20-\x7e]c                 S  s   dt |  d¡ƒ S )Nz\u%.4xr   )Úordr  r  r   r   r   r  I  ri   )ÚreÚsub)r   r   r   r   r   rü   G  s   zStrConv.str_reprúmypy.nodes.FloatExprc                 C  rõ   )Nz
FloatExpr(rY   rö   r   r   r   r   Úvisit_float_exprK  r§   zStrConv.visit_float_exprúmypy.nodes.ComplexExprc                 C  rõ   )NzComplexExpr(rY   rö   r   r   r   r   Úvisit_complex_exprN  r§   zStrConv.visit_complex_exprúmypy.nodes.EllipsisExprc                 C  s   dS )NÚEllipsisr   r   r   r   r   Úvisit_ellipsisQ  s   zStrConv.visit_ellipsisúmypy.nodes.StarExprc                 C  r˜   r   r©   r   r   r   r   Úvisit_star_exprT  r›   zStrConv.visit_star_exprúmypy.nodes.NameExprc                 C  s`   |   |j|j|j|jp|j|j¡}t|jtj	j
ƒr&|jjr&|d|jj› 7 }t|ƒd | d S )Nz = rX   rY   )Úpretty_namera   r0   r‹   Úis_inferred_defÚis_special_formÚnodeÚ
isinstancer6   r   r”   Úis_finalÚfinal_valuer   ©r   r   Úprettyr   r   r   Úvisit_name_exprW  s   ÿzStrConv.visit_name_exprNra   r0   r‹   ú
str | Noner  Útarget_nodeúmypy.nodes.Node | Nonec                 C  sÆ   |}|r|d7 }|r|   |¡}nd}t|tjjƒr#||kr#||7 }|S |tjjks1||kr=|d ur=|d|› |› d7 }|S |tjjkrM|d|› d7 }|S |tjjkr]|d|› d7 }|S ||7 }|S )NÚ*r   z [ú]z [lz [m)r   r  r6   r   ÚMypyFileÚGDEFÚLDEFÚMDEF)r   ra   r0   r‹   r  r  Únr   r   r   r   r  _  s(   õ	øûÿzStrConv.pretty_nameúmypy.nodes.MemberExprc                 C  s.   |   |j|j|j|j|j¡}|  |j|g|¡S r   )r  ra   r0   r‹   r  r  r'   rª   r  r   r   r   Úvisit_member_expr}  s   zStrConv.visit_member_exprúmypy.nodes.YieldExprc                 C  r˜   r   r©   r   r   r   r   Úvisit_yield_expr  r›   zStrConv.visit_yield_exprúmypy.nodes.YieldFromExprc                 C  s(   |j r|  |j  | ¡g|¡S |  g |¡S r   )rª   r'   Úacceptr   r   r   r   Úvisit_yield_from_expr„  s   zStrConv.visit_yield_from_exprúmypy.nodes.CallExprc                 C  sä   |j r	|j  | ¡S g }g }t|jƒD ]P\}}|tjjtjjfv r4| |j	| ¡ |tjjkr3| d¡ q|tjj
krJ| d|j| |j	| gf¡ q|tjjkr\| d|j	| gf¡ qtd|› ƒ‚|jd|fg}|  || |¡S )Nr+   ÚKwArgsr,   zunknown kind r-   )Úanalyzedr,  Ú	enumeraterz   r6   r   ÚARG_POSr7   r2   r=   rq   Ú	arg_namesr8   ÚRuntimeErrorÚcalleer'   )r   r   r=   r>   rÇ   r0   r@   r   r   r   Úvisit_call_exprŠ  s"   
€ zStrConv.visit_call_exprúmypy.nodes.OpExprc                 C  rŸ   r   )r'   r²   ÚleftÚrightr   r   r   r   Úvisit_op_expr  r£   zStrConv.visit_op_exprúmypy.nodes.ComparisonExprc                 C  rÓ   r   )r'   Ú	operatorsÚoperandsr   r   r   r   Úvisit_comparison_expr   rÖ   zStrConv.visit_comparison_exprúmypy.nodes.CastExprc                 C  rÓ   r   ©r'   rª   r9   r   r   r   r   Úvisit_cast_expr£  rÖ   zStrConv.visit_cast_exprúmypy.nodes.AssertTypeExprc                 C  rÓ   r   r@  r   r   r   r   Úvisit_assert_type_expr¦  rÖ   zStrConv.visit_assert_type_exprúmypy.nodes.RevealExprc                 C  s.   |j tjjkr|  |jg|¡S |  |jg|¡S r   )r0   r6   r   ÚREVEAL_TYPEr'   rª   Úlocal_nodesr   r   r   r   Úvisit_reveal_expr©  s   zStrConv.visit_reveal_exprúmypy.nodes.AssignmentExprc                 C  rÓ   r   )r'   rè   r÷   r   r   r   r   Úvisit_assignment_expr°  rÖ   zStrConv.visit_assignment_exprúmypy.nodes.UnaryExprc                 C  rÓ   r   )r'   r²   rª   r   r   r   r   Úvisit_unary_expr³  rÖ   zStrConv.visit_unary_exprúmypy.nodes.ListExprc                 C  r¥   r   ©r'   r}   r   r   r   r   Úvisit_list_expr¶  r§   zStrConv.visit_list_exprúmypy.nodes.DictExprc                 C  s   |   dd„ |jD ƒ|¡S )Nc                 S  s   g | ]\}}||g‘qS r   r   )rG   ÚkÚvr   r   r   Ú
<listcomp>º  s    z+StrConv.visit_dict_expr.<locals>.<listcomp>rM  r   r   r   r   Úvisit_dict_expr¹  r£   zStrConv.visit_dict_exprúmypy.nodes.SetExprc                 C  r¥   r   rM  r   r   r   r   Úvisit_set_expr¼  r§   zStrConv.visit_set_exprúmypy.nodes.TupleExprc                 C  r¥   r   rM  r   r   r   r   Úvisit_tuple_expr¿  r§   zStrConv.visit_tuple_exprúmypy.nodes.IndexExprc                 C  s&   |j r	|j  | ¡S |  |j|jg|¡S r   )r0  r,  r'   Úbaser½   r   r   r   r   Úvisit_index_exprÂ  s   zStrConv.visit_index_exprúmypy.nodes.SuperExprc                 C  rÓ   r   )r'   ra   Úcallr   r   r   r   Úvisit_super_exprÇ  rÖ   zStrConv.visit_super_exprúmypy.nodes.TypeApplicationc                 C  s   |   |jd|jfg|¡S )NÚTypes)r'   rª   rá   r   r   r   r   Úvisit_type_applicationÊ  r£   zStrConv.visit_type_applicationúmypy.nodes.TypeVarExprc                 C  s‚   dd l }g }|j|jjkr|dg7 }|j|jjkr|dg7 }|jr)|d|jfg7 }|j |jd¡s;|d|j› dg7 }|  	||¡S )Nr   úVariance(COVARIANT)úVariance(CONTRAVARIANT)ÚValuesr   úUpperBound(rY   )
Ú
mypy.typesÚvariancer   Ú	COVARIANTÚCONTRAVARIANTÚvaluesrá   Úis_named_instanceÚupper_boundr'   ©r   r   r6   r@   r   r   r   Úvisit_type_var_exprÍ  s   

zStrConv.visit_type_var_exprúmypy.nodes.ParamSpecExprc                 C  ól   dd l }g }|j|jjkr|dg7 }|j|jjkr|dg7 }|j |jd¡s0|d|j› dg7 }|  ||¡S ©Nr   rb  rc  r   re  rY   ©	rf  rg  r   rh  ri  rá   rk  rl  r'   rm  r   r   r   Úvisit_paramspec_exprÛ  ó   

zStrConv.visit_paramspec_exprúmypy.nodes.TypeVarTupleExprc                 C  rp  rq  rr  rm  r   r   r   Úvisit_type_var_tuple_exprç  rt  z!StrConv.visit_type_var_tuple_exprúmypy.nodes.TypeAliasExprc                 C  rõ   )NzTypeAliasExpr(rY   )r9   r   r   r   r   Úvisit_type_alias_expró  r§   zStrConv.visit_type_alias_exprúmypy.nodes.NamedTupleExprc                 C  s"   d|j › d|jj› d|jj› dS )NzNamedTupleExpr:rX   rF   rY   )rH   r‰   ra   r   r   r   r   r   Úvisit_namedtuple_exprö  s   "zStrConv.visit_namedtuple_exprúmypy.nodes.EnumCallExprc                 C  s    d|j › d|jj› d|j› dS )NzEnumCallExpr:rX   rF   rY   )rH   r‰   ra   r}   r   r   r   r   Úvisit_enum_call_exprù  rf   zStrConv.visit_enum_call_exprúmypy.nodes.TypedDictExprc                 C  s   d|j › d|jj› dS )NzTypedDictExpr:rX   rY   )rH   r‰   ra   r   r   r   r   Úvisit_typeddict_exprü  r£   zStrConv.visit_typeddict_exprúmypy.nodes.PromoteExprc                 C  s   d|j › d|j› dS )NzPromoteExpr:rX   rY   )rH   r9   r   r   r   r   Úvisit__promote_exprÿ  s   zStrConv.visit__promote_exprúmypy.nodes.NewTypeExprc              	   C  s(   d|j › d|j› d|  |jg|¡› dS )NzNewTypeExpr:rX   rF   rY   )rH   ra   r'   Úold_typer   r   r   r   Úvisit_newtype_expr  s   (zStrConv.visit_newtype_exprúmypy.nodes.LambdaExprc                 C  s   |   |¡}|  ||¡S r   )rA   r'   rT   r   r   r   Úvisit_lambda_expr  s   
zStrConv.visit_lambda_exprúmypy.nodes.GeneratorExprc                 C  s.   t |jƒr|jnd }|  |j|j|j|g|¡S r   )ÚanyÚ	condlistsr'   Ú	left_exprÚindicesÚ	sequences©r   r   rˆ  r   r   r   Úvisit_generator_expr	  s   zStrConv.visit_generator_exprúmypy.nodes.ListComprehensionc                 C  r˜   r   ©r'   Ú	generatorr   r   r   r   Úvisit_list_comprehension  r›   z StrConv.visit_list_comprehensionúmypy.nodes.SetComprehensionc                 C  r˜   r   r  r   r   r   r   Úvisit_set_comprehension  r›   zStrConv.visit_set_comprehensionú"mypy.nodes.DictionaryComprehensionc                 C  s2   t |jƒr|jnd }|  |j|j|j|j|g|¡S r   )r‡  rˆ  r'   Úkeyr÷   rŠ  r‹  rŒ  r   r   r   Úvisit_dictionary_comprehension  s   z&StrConv.visit_dictionary_comprehensionúmypy.nodes.ConditionalExprc                 C  s   |   d|jgf|j|jg|¡S )NÚ	Condition)r'   ÚcondÚif_exprÚ	else_exprr   r   r   r   Úvisit_conditional_expr  s   zStrConv.visit_conditional_exprúmypy.nodes.SliceExprc                 C  s<   |j |j|jg}|d sd|d< |d sd|d< |  ||¡S )Nr   z<empty>rj   )Úbegin_indexÚ	end_indexÚstrider'   rT   r   r   r   Úvisit_slice_expr  s   zStrConv.visit_slice_exprúmypy.nodes.TempNodec                 C  r˜   r   )r'   r9   r   r   r   r   Úvisit_temp_node"  r›   zStrConv.visit_temp_nodeúmypy.patterns.AsPatternc                 C  rÓ   r   )r'   Úpatternra   r   r   r   r   Úvisit_as_pattern%  rÖ   zStrConv.visit_as_patternúmypy.patterns.OrPatternc                 C  r¥   r   ©r'   rð   r   r   r   r   Úvisit_or_pattern(  r§   zStrConv.visit_or_patternúmypy.patterns.ValuePatternc                 C  r˜   r   r©   r   r   r   r   Úvisit_value_pattern+  r›   zStrConv.visit_value_patternúmypy.patterns.SingletonPatternc                 C  r˜   r   )r'   r÷   r   r   r   r   Úvisit_singleton_pattern.  r›   zStrConv.visit_singleton_patternúmypy.patterns.SequencePatternc                 C  r¥   r   r¨  r   r   r   r   Úvisit_sequence_pattern1  r§   zStrConv.visit_sequence_patternúmypy.patterns.StarredPatternc                 C  r˜   r   )r'   Úcapturer   r   r   r   Úvisit_starred_pattern4  r›   zStrConv.visit_starred_patternúmypy.patterns.MappingPatternc                 C  sl   g }t t|jƒƒD ]}| d|j| gf¡ | d|j| gf¡ q	|jd ur0| d|jgf¡ |  ||¡S )NÚKeyÚValueÚRest)rÅ   rp   Úkeysr2   rj  Úrestr'   rÆ   r   r   r   Úvisit_mapping_pattern7  s   
zStrConv.visit_mapping_patternúmypy.patterns.ClassPatternc                 C  sd   |j g}t|jƒdkr| d|jf¡ tt|jƒƒD ]}| d|j| |j| gf¡ q|  ||¡S )Nr   ÚPositionalsÚKeyword)Ú	class_refrp   Úpositionalsr2   rÅ   Úkeyword_keysÚkeyword_valuesr'   rÆ   r   r   r   Úvisit_class_pattern@  s    zStrConv.visit_class_pattern)F)r
   r   r   r   )r   r   r   r   )r   r   r   r   )r   r    r!   r"   r   r   )r   r(   r   r)   )r   rB   r   r   )r   rV   r   r   )r   r]   r   r   )r   rd   r   r   )r   rg   r   r   )r   r|   r   r   )r   r€   r   r   )r   r“   r   r   )r   r—   r   r   )r   rœ   r   r   )r   rž   r   r   )r   r¤   r   r   )r   r¨   r   r   )r   r¬   r   r   )r   r±   r   r   )r   rµ   r   r   )r   r¹   r   r   )r   rÀ   r   r   )r   rÂ   r   r   )r   rÉ   r   r   )r   rÎ   r   r   )r   rÐ   r   r   )r   rÒ   r   r   )r   r×   r   r   )r   rÚ   r   r   )r   rÜ   r   r   )r   rÞ   r   r   )r   rå   r   r   )r   rë   r   r   )r   rô   r   r   )r   rù   r   r   )r   rþ   r   r   )r   r   r   r   )r   r	  r   r   )r   r  r   r   )r   r  r   r   )r   r  r   r   )r   r  r   r   r   )ra   r   r0   r   r‹   r  r  r   r  r  r   r   )r   r'  r   r   )r   r)  r   r   )r   r+  r   r   )r   r.  r   r   )r   r7  r   r   )r   r;  r   r   )r   r?  r   r   )r   rB  r   r   )r   rD  r   r   )r   rH  r   r   )r   rJ  r   r   )r   rL  r   r   )r   rO  r   r   )r   rT  r   r   )r   rV  r   r   )r   rX  r   r   )r   r[  r   r   )r   r^  r   r   )r   ra  r   r   )r   ro  r   r   )r   ru  r   r   )r   rw  r   r   )r   ry  r   r   )r   r{  r   r   )r   r}  r   r   )r   r  r   r   )r   r  r   r   )r   r„  r   r   )r   r†  r   r   )r   rŽ  r   r   )r   r’  r   r   )r   r”  r   r   )r   r—  r   r   )r   r  r   r   )r   r¢  r   r   )r   r¤  r   r   )r   r§  r   r   )r   rª  r   r   )r   r¬  r   r   )r   r®  r   r   )r   r°  r   r   )r   r³  r   r   )r   rº  r   r   )[Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r'   rA   rU   r\   rc   re   r{   r   r’   r–   rš   r   r¢   r¦   r«   r°   r´   r¸   r¿   rÁ   rÈ   rÌ   rÏ   rÑ   rÕ   rÙ   rÛ   rÝ   rä   rê   ró   rø   rý   rÿ   rü   r
  r  r  r  r  r  r(  r*  r-  r6  r:  r>  rA  rC  rG  rI  rK  rN  rS  rU  rW  rZ  r]  r`  rn  rs  rv  rx  rz  r|  r~  r€  rƒ  r…  r  r‘  r“  r–  rœ  r¡  r£  r¦  r©  r«  r­  r¯  r²  r¹  rÁ  r   r   r   r   r	      s´     		ú	r	   r   r    r&   r  Ústr_convr   r   c                 C  s
  ddl m}m} g }|r| |d ¡ | D ]`}t|tƒr(|r'| t|d|ƒ¡ qt|tƒr@t|d |d |ƒ}| t|dƒ¡ qt|t	j
jƒrS| t| |¡dƒ¡ qt||ƒrg| t| ||jƒ¡dƒ¡ q|duru| tt|ƒdƒ¡ q|r€|d  d7  < d	 |¡S )
aX  Convert an array into a pretty-printed multiline string representation.

    The format is
      tag(
        item1..
        itemN)
    Individual items are formatted like this:
     - arrays are flattened
     - pairs (str, array) are converted recursively, so that str is the tag
     - other items are converted to strings and indented
    r   )ÚTypeÚTypeStrVisitorrX   Nrj   é   rk   rY   Ú
)rf  rÇ  rÈ  r2   r  Úlistr%   ÚtupleÚindentr6   r   ÚNoder,  r   r   rR   )r   r&   rÆ  rÇ  rÈ  r@   r&  r   r   r   r   r%   J  s,   
€

€
r%   r   r&  Úintc                 C  s$   d| |  } |   ddd|  ¡} | S )z>Indent all the lines in s (separated by newlines) by n spaces.ú rÊ  )rN   )r   r&  r   r   r   rÍ  m  s   rÍ  )r   r    r&   r  rÆ  r	   r   r   )r   r   r&  rÏ  r   r   )rÅ  Ú
__future__r   rO   r  Útypingr   r   r   Ú
mypy.nodesr6   Ú	mypy.utilr   r   Úmypy.visitorr   Úmypy.patternsr   r	   r%   rÍ  r   r   r   r   Ú<module>   s"        
=#