
    X-Ph@                       U d 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mZ ddlZddlmZ dd	lmZ dd
l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m Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z; ddlm<Z< ddl=m>Z>m?Z?m@Z@mAZAmBZBmCZC ddlDmEZE ddlFmGZG ddlHmIZImJZJmKZKmLZL ddlMmNZNmOZOmPZPmQZQmRZRmSZSmTZTmUZUmVZVmWZWmXZXmYZYmZZZm[Z[m\Z\m]Z]m^Z^ ddl_m`Z` ddlambZb h dZcdedd<   dhZededd<   ddhZfdedd<   h dZgdedd <   h d!Zhdedd"<   d#d$hZidedd%<   d&Zjdedd'<   d(Zkdedd)<   d*Zldedd+<   d,Zmdedd-<    G d. d/          Zn G d0 d1          Zodd6Zp	 ddd;Zqdd=Zr	 	 	 dddBZsddCZtddDZuddHZvddKZwddLZxddPZyddTZzddYZ{dd\Z|dd`Z}ddcZ~ddfZddiZddkZddnZddqZddrZddsZddtZ G du dh          ZddyZdd~ZddZddZddZddZdS )z>Plugin for supporting the attrs library (http://www.attrs.org)    )annotations)defaultdict)IterableMapping)reduce)FinalLiteralcastN)apply_generic_arguments)LITERAL_REQ)expand_typeexpand_type_by_instance)TypeTranslationErrorexpr_to_unanalyzed_type)
meet_types)format_type_bare)	ARG_NAMEDARG_NAMED_OPTARG_OPTARG_POSMDEFArgumentAssignmentStmtCallExprContext	Decorator
ExpressionFuncDef	IndexExprJsonDict
LambdaExprListExpr
MemberExprNameExprOverloadedFuncDefPlaceholderNodeRefExprSymbolTableNodeTempNode	TupleExprTypeApplicationTypeInfoTypeVarExprVaris_class_var)SemanticAnalyzerPluginInterface)_get_argument_get_bool_argument_get_decorator_bool_argumentadd_attribute_to_classadd_method_to_classdeserialize_and_fixup_type)make_wildcard_trigger)state)get_type_varsmake_simplified_unionmap_type_from_supertypetype_object_type)AnyTypeCallableTypeFunctionLikeInstanceLiteralTypeNoneType
Overloaded
ProperType	TupleTypeType	TypeOfAnyTypeType	TypeVarIdTypeVarTypeUninhabitedType	UnionTypeget_proper_type)fill_typevars)unmangle>   attr.s
attr.attrsattr.attributesr   attr_class_makerszattr.dataclassattr_dataclass_makerszattr.frozenzattrs.frozenattr_frozen_makers>   attr.defineattr.mutableattrs.defineattrs.mutableattr_define_makers>   attr.ib	attr.attr
attr.fieldattr.attribattrs.fieldattr_attrib_makerszattr.converters.optionalzattrs.converters.optionalattr_optional_converters_ATSELF_TVAR_NAME__attrs_attrs__MAGIC_ATTR_NAMEz__{}_AttrsAttributes__MAGIC_ATTR_CLS_NAME_TEMPLATE__attrs_init__ATTRS_INIT_NAMEc                      e Zd ZdZd	d
dZdS )	Converterz/Holds information about a `converter=` argumentN	init_typeType | Noneret_typereturnNonec                "    || _         || _        d S N)rk   rm   )selfrk   rm   s      R/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/mypy/plugins/attrs.py__init__zConverter.__init__h   s    "     NN)rk   rl   rm   rl   rn   ro   )__name__
__module____qualname____doc__rt    ru   rs   rj   rj   e   s3        99! ! ! ! ! ! !ru   rj   c                  J    e Zd ZdZd"dZd#dZd$dZed%d            Zd&d Z	d!S )'	AttributezThe value of an attr.ib() call.namestralias
str | Noneinfor,   has_defaultboolinitkw_only	converterConverter | Nonecontextr   rk   rl   rn   ro   c
                    || _         || _        || _        || _        || _        || _        || _        || _        |	| _        d S rq   )	r~   r   r   r   r   r   r   r   rk   )
rr   r~   r   r   r   r   r   r   r   rk   s
             rs   rt   zAttribute.__init__p   sH     	
	&	""ru   ctxmypy.plugin.ClassDefContextr   c                f   | j         sJ d}| j        r| j        j        r| j        j        }|r| j        r| j        j        ryt	          | j        j                  }t	          | j                  }|rJt          |          t          |          k    r*d t          ||          D             }t          ||          }nX|j        	                    d| j
                   t          t          j                  }n| j        p| j        | j                 j        }d}|d}t          t          j                  }n;t%          |          }t'          |t                    r|j        t          j        k    rd}|rQ|j        j        j        r@| j        | j                 j        }|J |j        j                            || j
                   | j        r| j        rt8          nt:          }	n| j        rt<          nt>          }	| j         p| j        !                    d          }
tE          tG          |
|          |d|	          S )z1Return this attribute as an argument to __init__.Nc                $    i | ]\  }}|j         |S r{   id).0binderargs      rs   
<dictcomp>z&Attribute.argument.<locals>.<dictcomp>   s-     % % %/:vsFIs% % %ru   z-Cannot determine __init__ type from converterFT_)$r   r   rk   rm   r9   lenzipr   apifailr   r=   rG   
from_errorr   r~   typeunannotatedrM   
isinstancetype_of_anyoptionsdisallow_untyped_defsnodemsgneed_annotation_for_varr   r   r   r   r   r   r   lstripr   r.   )rr   r   rk   converter_vars	init_vars	variablesr   proper_typer   arg_kindr~   s              rs   argumentzAttribute.argument   s.   y!%	> 	D~' : N4	 	F 	FDN4K 	F &34>3J%K%KN -dn = =I% F#n*=*=Y*O*O% %>A.R[>\>\% % %	 %0	9$E$E	Ldl[[[#I$899		C$)DI*>*CIK	 566II))44K+w// '*i.CCC"&K 	D37?@ 	D
 9TY',D###GK//dlCCC< 	@(,(8G}}iHH"&"2?wwH z2TY--c22D),,ixHHHru   r    c                &   | j         | j        | j        | j        | j        | j        du| j        r*| j        j        r| j        j                                        nd| j        j	        | j        j
        | j        r| j                                        ndd
S )z6Serialize this object so it can be saved and restored.N)
r~   r   r   r   r   has_converterconverter_init_typecontext_linecontext_columnrk   )r~   r   r   r   r   r   rk   	serializer   linecolumn)rr   s    rs   r   zAttribute.serialize   s     IZ+I|!^47 >&*n&>(22444 L-"l17;~O113334
 
 	
ru   datar   r0   c                @   |d         }|rt          ||          nd}|d         }|rt          ||          nd}t          |d         |d         ||d         |d         |d         |d	         rt          |          ndt          |d
         |d                   |	  	        S )z)Return the Attribute that was serialized.rk   Nr   r~   r   r   r   r   r   r   r   )r   r   )r6   r}   rj   r   )clsr   r   r   raw_init_typerk   raw_converter_init_typer   s           rs   deserializezAttribute.deserialize   s    
 [)FS].}cBBBY]	"&'<"= '&'>DDD 	 LMLO.2?.CMI)***n-d;K6LMMM

 

 
	
ru   sub_typec                f    | j         r"t          | j         || j                  | _         dS d| _         dS )zoExpands type vars in the context of a subtype when an attribute is inherited
        from a generic super type.N)rk   r;   r   )rr   r   s     rs   expand_typevar_from_subtypez%Attribute.expand_typevar_from_subtype   s4     > 	"4T^XtyYYDNNN!DNNNru   N)r~   r   r   r   r   r,   r   r   r   r   r   r   r   r   r   r   rk   rl   rn   ro   )r   r   rn   r   )rn   r    )r   r,   r   r    r   r0   rn   r}   )r   r,   rn   ro   )
rw   rx   ry   rz   rt   r   r   classmethodr   r   r{   ru   rs   r}   r}   m   s        ))# # # #,2I 2I 2I 2Ih
 
 
 
& 
 
 
 [
2" " " " " "ru   r}   r   r   rn   r   c                <   t          | d          }t          | d          }t          | d          }|5t          |du|duf          r | j                            d| j                   ||S |d}||}|du r$|du r | j                            d| j                   |S )	zh
    Validate the combination of *cmp*, *eq*, and *order*. Derive the effective
    value of order.
    cmpeqorderNz%Don't mix "cmp" with "eq" and "order"TFz eq must be True if order is True)%_get_decorator_optional_bool_argumentanyr   r   reason)r   r   r   r   s       rs   _determine_eq_orderr      s    
 0U
;
;C	.sD	9	9B1#w??E
3$T0ABCC=szJJJ 
 
z}	U{{u}}7DDDLru   r~   r   defaultbool | Nonec                >   t          | j        t                    rt          | j        |          }|rit          |t                    r'|j        dk    rdS |j        dk    rdS |j        dk    rdS | j                            d| d| j        t          	           |S |S |S )
zqReturn the Optional[bool] argument for the decorator.

    This handles both @decorator(...) and @decorator.
    zbuiltins.TrueTzbuiltins.FalseFzbuiltins.NoneN"z1" argument must be a True, False, or None literalcode)	r   r   r   r1   r$   fullnamer   r   r   )r   r~   r   
attr_values       rs   r   r     s     #*h'' "3:t44
 	*h//  &/994&*::: 5&/994GLLKDKKK
     
 Nru   ro   c                .    i | j         j        j        d<   dS )zRecord that we have an attrs class in the main semantic analysis pass.

    The later pass implemented by attr_class_maker_callback will use this
    to detect attrs classes in base classes.
    	attrs_tagN)r   r   metadatar   s    rs   attr_tag_callbackr   )  s     *,CGL+&&&ru   Fauto_attribs_defaultfrozen_defaultslots_defaultc                    t          j        | j        j        j                  5  t          | |||          cddd           S # 1 swxY w Y   dS )a  Add necessary dunder methods to classes decorated with attr.s.

    attrs is a package that lets you define classes without writing dull boilerplate code.

    At a quick glance, the decorator searches the class body for assignments of `attr.ib`s (or
    annotated variables if auto_attribs=True), then depending on how the decorator is called,
    it will add an __init__ or all the compare methods.
    For frozen=True it will turn the attrs into properties.

    Hashability will be set according to https://www.attrs.org/en/stable/hashing.html.

    See https://www.attrs.org/en/stable/how-does-it-work.html for information on how attrs works.

    If this returns False, some required metadata was not ready yet, and we need another
    pass.
    N)r8   strict_optional_setr   r   strict_optionalattr_class_maker_callback_impl)r   r   r   r   s       rs   attr_class_maker_callbackr   3  s    , 
	"37?#B	C	C 
 
 .%~}
 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
s   AA
Ac                   | j         j        t          | dd          }t          | |          }t	          |           }t          | d|          }t          | d|          }t          | dd          }	t          | dd          }
| j         j        j        dd	         D ]}d
|j        v rd|j        vr dS t          | ||	          }|D ]0}	                    |j
                  }|t                      dS 1t          | fd|D                        |rt          | |           |
r-| j        j        j        d d         dk    rt#          | |           d |D             |d| j         j        j        d<   t%          |           }t'          | |||rdnt(                     |rt+          | |           |r3t-          | |           t          | dd          ot          | dd          }n"t          | d          }|t          | d          }t          | d          }d| j         j        j        v }|s||du rnF|r5| j         j        j        d	         j        d         | j         j        j        d<   nt1          |            dS )Nr   Tslotsauto_attribsr   F
match_args   r   attrsc                B    g | ]}|j         |j                  j        fS r{   )r~   r   )r   attrr   s     rs   
<listcomp>z2attr_class_maker_callback_impl.<locals>.<listcomp>r  s)    $^$^$^4didi1E%F$^$^$^ru      )   
   c                6    g | ]}|                                 S r{   )r   r   r   s     rs   r   z2attr_class_maker_callback_impl.<locals>.<listcomp>|  s"    ???Dt~~''???ru   
attributesfrozenrt   hashunsafe_hashr   __hash__)r   r   r3   _get_frozenr   r   mror   _analyze_classgetr~   _add_empty_metadata_add_attrs_magic_attribute
_add_slotsr   r   python_version_add_match_argsMethodAdder	_add_initrh   
_add_order_make_frozennames_remove_hashability)r   r   r   r   r   r   r   r   r   r   r   
super_infor   r   r   adderhashabler   has_own_hashr   s                      @rs   r   r   Q  s    7<D'VT::Dn--F$$E(g}EEE8nNbccL*3	5AAG-c<FFJgl&qt,  
*---'AT2T2T55\7;;J   xx	""<  %%%44	  s$^$^$^$^S]$^$^$^___ $3
### )cgo4RaR8GCC 	Z((( @?J???& &CGL'"
 Ec:uD&MjjoNNN 3 	JS*%%% <!
 !
 !E*3tDD 	 9mLL<S&IIH	.sD	9	9B!33L !(R5[[	 !),)9")=)CJ)O:&&C   4ru   c                    t          | d|          rdS | j        j        j        dd         D ]!}d|j        v r|j        d         d         r dS "dS )z$Return whether this class is frozen.r   Tr   r   r   F)r3   r   r   r   r   )r   r   r   s      rs   r   r     sg    #C>BB tgl&qt,  
j)))j.A'.J8.T)445ru   r   r   list[Attribute]c                L   i }|t          |           }| j        j        j        D ]o}t	          |t
                    r3t          | |||          D ]}|s|j        |v r||j        = |||j        <    Jt	          |t                    rt          ||           p|
                                D ]o}|j        | j        j        j        v rU| j        j        j        |j                 j        }t	          |t                    rQt	          |t                    sJ d|_        pt#          |          }g }	| j        j        j        dd         D ]}
d|
j        v r| j                            t-          |
j                             |
j        d         d         D ]{}|d         |vrot0                              |
|| j                  }|                    | j        j                   |	                    |           |                    |j                   ||	t;          |
                                          z   }d}t=          |          D ]d\  }}|j        s|j         r|tC          |	          k    r|j"        n| j        }|j#        s|r| j        $                    d|           ||j#        z  }e|S )	aI  Analyze the class body of an attr maker, its parents, and return the Attributes found.

    auto_attribs=True means we'll generate attributes from type annotations also.
    auto_attribs=None means we'll detect which mode to use.
    kw_only=True means that all attributes created here will be keyword only args in __init__.
    NFr   r   r   r   r~   z<Non-default attributes not allowed after default attributes.)%_detect_auto_attribsr   defsbodyr   r   _attributes_from_assignmentr~   r   _cleanup_decoratorvaluesr   r   r   r&   r.   is_initialized_in_classsetr   r   r   add_plugin_dependencyr7   r   r}   r   r   appendaddlist	enumerater   r   r   r   r   r   )r   r   r   	own_attrsstmtr   	attributer   taken_attr_namessuper_attrsr   r   ar   last_defaultir   s                    rs   r   r     s    ')I+C00 ! 0 0dN++ 
	03C|WUU , ,
 $ -	Y(>(>!$),'+	$)$$, i(( 	0tY///%%'' 	1 	1	 >SW\///7<%in5:D$00 dC(((((+0D( 9~~Kgl&qt, 1 1
j)))G))*?
@S*T*TUUU"+G4\B 1 1 <'777!--j$HHA11#',???&&q)))$((000tI$4$4$6$6777J L!*-- . .9~ 	 	 ()C,<,<'<'<)###'$ 	b 	bGLLWY`aaa	--ru   r   r,   c                     g dd| j         d<   dS )zEAdd empty metadata to mark that we've finished processing this class.Fr   r   N)r   )r   s    rs   r   r     s    ,.%@@DM'ru   c                   | j         j        j        D ]}t          |t                    r|j        D ]}t          ||          \  }}t          |          t          |          k    r6t          ||          D ]S\  }}t          |t                    r9t          |j
        t                    r|j
        j        t          v r|j        s   dS TdS )zyReturn whether auto_attribs should be enabled or disabled.

    It's disabled if there are any unannotated attribs()
    FT)r   r  r  r   r   lvalues_parse_assignmentsr   r   r   calleer'   r   r`   
new_syntax)r   r  lvaluer  rvalueslhsrvalues          rs   r  r    s    
 ! % %dN++ 	%, % %#5fd#C#C w<<3w<<// #&w#8#8 
% 
%KC #6844%&v}g>>% #M26HHH $ I
  %uuuu
% 4ru   r  r   Iterable[Attribute]c           
   #    K   |j         D ]}t          ||          \  }}t          |          t          |          k    r6t          ||          D ]\  }}t	          |t
                    rHt	          |j        t                    r.|j        j        t          v rt          | |||||          }	|	r|	V  b|r2|j        r+|j        r$t          |          st          | ||||          V  dS )a@  Return Attribute objects that are created by this assignment.

    The assignments can look like this:
        x = attr.ib()
        x = y = attr.ib()
        x, y = attr.ib(), attr.ib()
    or if auto_attribs is enabled also like this:
        x: type
        x: type = default_value
        x: type = attr.ib(...)
    N)r  r  r   r   r   r   r  r'   r   r`   _attribute_from_attrib_makerr   r  r/   _attribute_from_auto_attrib)
r   r  r   r   r   r  r!  r"  r#  r   s
             rs   r  r    s0      , S S-fd;;w<<3w<<'' w00 	S 	SKC 68,,	Sv}g66	S M*.@@@3CwPSU[]abb JJJ S$) S SUXHYHY S1#wVTRRRRR	SS Sru   r   attr_mapdict[str, Attribute]c                V   g }| j         D ]}t          |t                    rht          |j        t                    rN|j        j        |v r@|j        dk    rd||j        j                 _        |j        dv r|                    |           |D ]}| j                             |           dS )zHandle decorators in class bodies.

    `x.default` will set a default value on x
    `x.validator` and `x.default` will get removed to avoid throwing a type error.
    r   T)r   	validatorN)	
decoratorsr   r#   exprr$   r~   r   r  remove)r  r(  	remove_mefunc_decoratordecs        rs   r	  r	  ?  s     I/ 1 1~z22	1>.99	1 #(H44"i//AE,12>"&>>>   000 $ $s####$ $ru   r"  r$   r#  r   c                    t          |j                  }t          |t                     }| j        j        j                            |          }|r|j        nd}t          |d| j        j        |d|d||	  	        S )z.Return an Attribute for a new type assignment.NT)
rO   r~   r   r)   r   r   r   r   r   r}   )	r   r   r"  r#  r  r~   has_rhssymrk   s	            rs   r'  r'  ]  sr     CHDVX...G
',

 
 
&
&C)TIT4wgtTS\]]]ru   r   Attribute | Nonec                X   |r7|j         s0|j        J | j        j                            |j        |           dS t          |j                  dk    r| j                            d|           dS |j        }t          | |dd          }|t          | |dd          z  }t          t          |d                    }t          t          |d	                    }	|r|	r| j                            d
|           n|	rd}t          |d          }
|
r|s	 t          |
| j        j        | j        j                  }| j                            |          }|r9t!          |j        t"                    r|j        j        s||j        _        d|_        n+# t&          $ r | j                            d|
           Y nw xY wt          |d          }t          |d          }|r|r| j                            d|           n|r| j                            d|           |}t)          | |          }d}t          |d          }|r>| j                            |          }|"| j                            d|t,                     t/          |j                  }t3          ||| j        j        ||||||	  	        S )zFReturn an Attribute from the assignment or None if you can't make one.Nr   z Too many names for one attributer   Tr   Fr   factoryz(Can't pass both "default" and "factory".r   zInvalid argument to typer   convertz*Can't pass both "convert" and "converter".z$convert is deprecated, use converterr   z8"alias" argument to attrs field must be a string literalr   )r  r   r   r   r   r   r  r   r   r2   r   r1   r   r   is_stub_file	anal_typer   r.   is_inferred_defr   _parse_converterparse_str_literalr   rO   r~   r}   r   r   )r   r   r   r"  r#  r  rk   r   attr_has_defaultattr_has_factorytype_argun_typer   r8  converter_infor   
alias_exprr~   s                     rs   r&  r&  m  s     DO x###++CHd;;;t
4<17>>>t 	I c66488D !#vy%@@@G M&)<<==M&)<<==  ,  @&IIII	   VV,,H 
,	 
,		,-hI]^^G ))'22I ,Z#66 ,sx} , )&+# $ 	? 	? 	?GLL3X>>>>>	? fk22IFI..G 9 BFKKKK	 ;VDDD	%c955N Evw//J ))*55=GLLJ     
 CHDeSW\#3T7NTXZc  s   %F %F32F3converter_exprExpression | Noner   c                   |sdS t                      }t          |t                    rQt          |j        t                    r7|j        j        t          v r$|j        r|j        d         r|j        d         }d}nd}d}t          |t                    r|j        rt          |j        t                    rY|j        j
        r-t          |j        j
        t                    r|j        j
        }net          t          j                  |_        |S t          |j        t                     r"t#          |j                  r|j        j
        }n	t          |j        t$                    rt'          |j        | j        j                  }nt          |t,                    rt          |j        t0                    rt          |j        t                    rt          |j        j        t$                    rgt'          |j        j        | j        j                  }t          |t4                    r,t7          ||j        j        | j        j        j        |          }nd}t          |t>                    r t          t          j                  |_        |S |s;| j                             d|           t          t          j!                  |_        |S tE          |          }t          |t4                    r(|j#        r!|j#        d         |_        |s|j$        |_$        nt          |tJ                    rg }|j&        D ]f}tO          |j#                  }|s|dk    r'tQ          d |j)        dd         D                       rF|*                    |j#        d                    g|rtW          |          |_        |r3|j        r,tY          j-        |j        t]                      g          |_        |S )z/Return the Converter object from an Expression.Nr   TFzVUnsupported converter, only named functions, types and lambdas are currently supportedr   c              3  ,   K   | ]}|t           k    V  d S rq   )r   )r   kinds     rs   	<genexpr>z#_parse_converter.<locals>.<genexpr>  s&      (X(XT(X(X(X(X(X(Xru   )/rj   r   r   r  r'   r   ra   argsr   r   r   r?   r=   rG   r   rk   r%   is_valid_overloaded_converterr,   r<   r   
named_typer   analyzedr+   baser>   r   typesr   incompatible_typevar_valuer!   r   r   rM   	arg_typesrm   rC   itemsr   r   	arg_kindsr  r:   rL   
make_unionrB   )r   rD  rB  is_attr_converters_optionalconverter_typerO  itemnum_arg_typess           rs   r<  r<    s   
  t[[N>8,,,~,g66, !*.FFF G" G (,Q/&*##&+#"&N.'** "~/B "n)733 	W"' &J~7J7OQ],^,^ &!/!4!9+293H+I+I(%%+->?? 	WDaE
 E
 	W ,05NN+X66 	W-n.A37CUVVN>9--"~.@@" ~*G44" ~*/::	" *.*=*BCGDVWWnl33 	"4'-6	 NN "N.*-- #*9+@#A#A  	
 	
 	

 $+9+?#@#@ $^44N.,// DN4L D#1#;A#> * 	>&4&=N#	NJ	/	/ D"( 	, 	,D//M  q  S(X(XT^TUTVTVEW(X(X(X%X%X LL*++++ 	D'<U'C'CN$" `~'? ` $-#79QS[S]S]8^#_#_ ru   defnr%   c                >    t          d | j        D                       S )Nc              3     K   | ]9}t          |t                     pt          |j        j        t                    V  :d S rq   )r   r   funcr   r?   r   rW  s     rs   rI  z0is_valid_overloaded_converter.<locals>.<genexpr>  sV         i((	(	TJty~|,T,T     ru   )allrR  )rY  s    rs   rK  rK    s2      J     ru   r   'tuple[list[NameExpr], list[Expression]]c                l   g }g }t          | t          t          f          rqt          d | j        D                       r%t          t          t                   | j                  }t          |j        t          t          f          r|j        j        }n t          | t                    r| g}|j        g}||fS )zSConvert a possibly complex assignment expression into lists of lvalues and rvalues.c              3  @   K   | ]}t          |t                    V  d S rq   )r   r$   r]  s     rs   rI  z%_parse_assignments.<locals>.<genexpr>)  s,      CCdz$))CCCCCCru   )	r   r*   r"   r^  rR  r
   r  r$   r#  )r   r  r  r!  s       rs   r  r  "  s     !G "G&9h/00  CCflCCCCC 	94>6<88GdkIx#899 	(k'G	FH	%	%  (;-Gru   r   r   c           
        | j                             d          }| j                             d          }| j        j        j         dt
           }t          t
          |t          dd          g |t          t          j
                            }t          t
          |g |t          t          j
                            }t          t          |          | j        j        j        t
          <   dD ]}| j        j        j         d| }|                    t          |j        j        |          	          }t%          t'          d
|          |dt(                    g}	|                    ||	|||           dS )z1Generate all the ordering methods for this class.zbuiltins.boolzbuiltins.object.r    )	namespace)r   r
  upper_boundr   )__lt____le____gt____ge__r   otherN)	self_typetvd)r   rL  r   r   r   rc   rJ   rI   r=   rG   from_omitted_genericsr-   r(   r   r   copy_modifiedr   raw_idr   r.   r   
add_method)
r   r   	bool_typeobject_typer   rm  self_tvar_exprmethodre  rJ  s
             rs   r   r   3  sk   ""?33I'$$%677K
 ','::.::H
R2&&&	788  C !"k79;Z3[3[ N *9~)N)NCGL~&: J Jw|,77v77	9SV]i#P#P#PQQWc**Cw??@yCSIIII	J Jru   r   c                   |D ]}|j         | j        j        j        v r?| j        j        j        |j                  j        }t          |t                    sQd|_        Yt          |j         |j                  }| j        j        |_        | j        j        j	         d|j          |_
        t          t          |          | j        j        j        |j         <   d|_        dS )zCTurn all the attributes into properties to simulate frozen classes.Trc  N)r~   r   r   r   r   r   r.   is_propertyrk   r   	_fullnamer(   r   )r   r   r  r   vars        rs   r   r   Q  s     # #	>SW\///7<%in5:DdC((  #D ini&9::Cw|CH"w|4AAsxAACM+:4+E+ECGLsx("COO## #ru   method_name%Literal['__init__', '__attrs_init__']c                   g }g }| j         j        j        }|D ]}|j        s
|j        r)|                    |                    |                      n(|                    |                    |                      |j        s>|j        |v r5||j                 j	        }t          |t                    r|j        rd|_        ||z   }	t          d |	D                       rF|	D ]C}
t          t           j                  |
j        _        t          t           j                  |
_        D|                    ||	t-                                 dS )zGGenerate an __init__ method for the attributes and add it to the class.Tc              3  h   K   | ]-}t          |j        j        d d          t          j        k    V  .dS )r   N)getattrvariabler   rG   r   )r   r   s     rs   rI  z_add_init.<locals>.<genexpr>  sQ        
  	!=$779;PP	     ru   N)r   r   r   r   r   r  r   r   r~   r   r   r.   is_finalfinal_set_in_initr^  r=   rG   implementation_artifactr  r   type_annotationrq  rB   )r   r   r   rz  pos_argskw_only_args	sym_tabler  sym_noderJ  r  s              rs   r   r   g  sm    HL"I 2 2	~ 	 	5	 2 23 7 78888OOI..s33444 $ 	29)D)D 05H(C(( 2X-> 2-1*l"D
  
      K  	K 	KA%i&GHHAJO '	(I J JA	[$

33333ru   r   list[tuple[str, Type | None]]c           	         t          t          j                   fd|D             } j                            d j                            dg          pg          }t                               j        j	        
                    dd                    } j                            ||d          }t          ||          D ]u\  \  }}}t          ||          }	||	_        d|	_        t!          |          }
t#          |
t$                    r|
j        |	_        t+          t,          |	d          |j        |<   vt%          |g           }t+          t,          |d           j        j        j        |<   t1           j         j        t2          t5          ||	           j        j	         dt2           dd
           d S )Nc                V    g | ]%\  }}j                             d |pg          p&S )attr.Attribute)r   named_type_or_none)r   r   	attr_typeany_typer   s      rs   r   z._add_attrs_magic_attribute.<locals>.<listcomp>  sN     $ $ $Ay 	""#3i6K85LMMYQY$ $ $ru   builtins.tupler  rc  r   r   T)plugin_generatedfallback)r   override_allow_incompatibleis_classvar)r=   rG   explicitr   rL  r  rf   formatr   r   replacebasic_new_typeinfor   r.   rx  rw  rM   r   r@   r   r   r(   r   r   r4   re   rE   )r   r   attributes_typesfallback_type	attr_nametir~   r   r  ry  r   attributes_typer  s   `           @rs   r   r     s    y)**H$ $ $ $ $!$ $ $ G&&37556F
SS_W_` M -33CG4D4L4LSRU4V4VWWI		#	#I}a	@	@B #E+; < < K K	q9$	""%i00k8,, 	("'CH(sTJJJr2&&O %4D"t$T$T$TCGLy!"_===G$8888$(     ru   c                F    t          d  j        j        j        dd         D                       rd S d |D              j        j        _        t           fd|D              j                            d                    }t           j         j        d|	           d S )
Nc              3  (   K   | ]}|j         d u V  d S rq   )r   )r   ps     rs   rI  z_add_slots.<locals>.<genexpr>  s(      
;
;q17d?
;
;
;
;
;
;ru   r   r   c                    h | ]	}|j         
S r{   )r~   r   s     rs   	<setcomp>z_add_slots.<locals>.<setcomp>  s    ;;;$);;;ru   c                D    g | ]}j                             d           S )builtins.str)r   rL  )r   r   r   s     rs   r   z_add_slots.<locals>.<listcomp>  s)    @@@		N	+	+@@@ru   r  r  	__slots__r   r   r~   typ)	r   r   r   r   r   rE   r   rL  r4   )r   r   
slots_types   `  rs   r   r     s    

;
;CGL$4QrT$:
;
;
;;;  	 <;
;;;CGL @@@@Z@@@##$455  J swCG+:VVVVVVru   c                B   d| j         j        j        vs| j         j        j        d         j        rn| j                            d          t          fd|D             | j                            d                    }t          | j        | j         d|           d S d S )N__match_args__r  c                    g | ]:}|j         	|j                            t          |j                             ;S )r  )last_known_value)r   r   ro  rA   r~   )r   r   str_types     rs   r   z#_add_match_args.<locals>.<listcomp>  s^       | )-	&&DIX`8a8a8a&bb  ru   r  r  r  )r   r   r   r  r   rL  rE   r4   )r   r   r   r  s      @rs   r   r     s     2227<./@ 	3 7%%n55   &  
 W''(899
 
 

 	37>NT^______ 	32ru   c                \    t          | j        | j        dt                      dd           dS )z Remove hashability from a class.r   T)r  overwrite_existingN)r4   r   r   rB   r   s    rs   r   r     s9    *hjjdW[     ru   c                  (    e Zd ZdZddZ	 	 dddZdS )r   znHelper to add methods to a TypeInfo.

    ctx: The ClassDefCtx we are using on which we will add methods.
    r   r   rn   ro   c                P    || _         t          |j        j                  | _        d S rq   )r   rN   r   r   rl  )rr   r   s     rs   rt   zMethodAdder.__init__  s     &sw|44ru   Nrz  r   rJ  list[Argument]rm   rF   rl  rl   rm  TypeVarType | Nonec           	     n    ||n| j         }t          | j        j        | j        j        |||||           dS )zAdd a method: def <method_name>(self, <args>) -> <ret_type>): ... to info.

        self_type: The type to use for the self argument or None to use the inferred self type.
        tvd: If the method is generic these should be the type variables.
        N)rl  r5   r   r   r   )rr   rz  rJ  rm   rl  rm  s         rs   rq  zMethodAdder.add_method  sH     "+!6IIDN	HL$(,T8YPS	
 	
 	
 	
 	
ru   r   r   rn   ro   rv   )rz  r   rJ  r  rm   rF   rl  rl   rm  r  rn   ro   )rw   rx   ry   rz   rt   rq  r{   ru   rs   r   r     sS         5 5 5 5 "&"&
 
 
 
 
 
 
ru   r  r@   CallableType | Nonec                8   | j                             t                    }||j        sdS | j                             d          p| j                             t
                    }t          |t                    rt          |j         t                    sdS |j         S )zT
    If `typ` refers to an attrs class, get the type of its initializer method.
    Nrt   )	r   r   re   r  
get_methodrh   r   r   r>   )r  
magic_attrinit_methods      rs   _get_attrs_init_typer    s     o..J!<t(%%j11YSX5H5H5Y5YKk7++ :k>NP\3]3] tru   mypy.plugin.FunctionSigContexttrF   parent_tc                H   t          || j        j                  }||u r"t          |t                    rd| dnd| d}nAt          || j        j                  }t          |t                    r	d| d| dnd| d| d}| j                            || j                   d S )	Nz,Argument 1 to "evolve" has a variable type "z" not bound to an attrs classz.Argument 1 to "evolve" has incompatible type "z"; expected an attrs classz!Argument 1 to "evolve" has type "z" whose item "z " is not bound to an attrs classz" is not an attrs class)r   r   r   r   rJ   r   r   )r   r  r  t_namer   pt_names         rs   _fail_not_attrs_classr    s    a11F1}} ![))e`6````d&ddd 	 #8SW_== ![))yooovoooox'xxY_xxx 	 GLLck"""""ru   rD   display_typ
parent_typlist[Mapping[str, Type]] | Nonec                   t          |t                    rdS t          |t                    rHg }|                                D ]/}t	          |          }t          | |||          }||||z  }-d}0|S t          |t                    r$t          | t	          |j                  ||          S t          |t                    rt          |          }|t          | ||           dS t          ||          }t          t          t                   |j        dd                   }|j        dd         }	t#          t%          ||	                    gS t          | ||           dS )a  
    For a given type, determine what attrs classes it can be: for each class, return the field types.
    For generic classes, the field types are expanded.
    If the type contains Any or a non-attrs type, returns None; in the latter case, also reports an error.
    Nr   )r   r=   rL   relevant_itemsrM   _get_expanded_attr_typesrJ   rf  r@   r  r  r   r
   r  r   	arg_namesrQ  dictr   )
r   r  r  r  retrW  
item_types	init_funcfield_namesfield_typess
             rs   r  r  !  su    #w t	C	#	# /1&&(( 	 	D"4((D1#tT:NNJ:#9z!
	C	%	% '11;

 
 	
 
C	"	" (--	!#{J???4+Is;;	49i&9!""&=>>)!""-Sk223344c;
;;;tru   rO  list[Mapping[str, Type]]Mapping[str, Type]c                     t          t                    } D ]7}|                                D ] \  }}||                             |           !8 fd|                                D             S )zr
    "Meet" the fields of a list of attrs classes, i.e. for each field, its new type will be the lower bound.
    c           	         i | ]V\  }}|t          |          t                    k    r"t          t          t          |                    nt	                      WS r{   )r   rM   r   r   rK   )r   r~   f_typesrO  s      rs   r   z _meet_fields.<locals>.<dictcomp>T  si        D' 	7||s5zz)) F:w77888 ""	  ru   )r   r  rR  r  )rO  field_to_typesfieldsr~   r  s   `    rs   _meet_fieldsr  K  s     !&&N - - 	- 	-ID#4 '',,,,	-    ,1133   ru   r>   c           
        t          | j                  dk    r5| j                            d| j        j         d| j                   | j        S t          | j        d                   dk    r| j        S | j        d         d         }t          | j                            |                    }t          || j        j
                  }t          | |||          }|| j        S t          |          }t          dg|                                t          gt           gt          |          z  z   |g|                                || j        j        | j        j         d| 	          S )
z
    Generate a signature for the 'attr.evolve' function that's specific to the call site
    and dependent on the type of the first argument.
    r   r   z " has unexpected type annotationr   r   Ninstz of )r  rS  rQ  rm   r  r~   )r   rJ  r   r   default_signaturer~   r   rM   get_expression_typer   r   r  r  r>   keysr   r   r
  r  )r   inst_arg	inst_typeinst_type_str
attr_typesr  s         rs   evolve_function_sig_callbackr  ^  sS   
 38}}U.3UUUWZWbccc$$
38A;1$$x{1~H ; ;H E EFFI$Y@@M)#y)YOOJ$$*%%F*FKKMM*)}oF;;/v}}/&/%*????   ru   c                   t          | j                  dk    st          | j        d                   dk    r| j        S t          | j                            | j        d         d                             }t          |t                    s/t          |t                    r!t          |j	        t                    r| j        S d}| j        j
        }t          |t                    r4t          |j                  }t          |t                    r
|g}|j        }n)t          |t                    r|                                }|Et"          |j        v r7|j        t"                   j        }|J | j                            ||          S | j        S )z)Provide the signature for `attrs.fields`.r   r   N)rQ  rm   )r   rJ  r  rM   r   r  r   r=   rH   rW  rQ  rJ   rf  r@   r   r>   type_objectre   r   ro  )r   r   r   rQ  innerrm   s         rs   fields_function_sig_callbackr  ~  sm   
38}}S!--22$$!#'"="=chqk!n"M"MNNK 	;((%k8,,% {'11%
 $$
C%/I+{++ ( 788eX&& 	$I*C	K	.	. (%%''
?ci779_-2###$22YQY2ZZZ  ru   )r   r   rn   r   rq   )r   r   r~   r   r   r   rn   r   r  )FFF)
r   r   r   r   r   r   r   r   rn   r   )r   r   r   r   rn   r   )r   r   r   r   r   r   rn   r  )r   r,   rn   ro   )
r   r   r  r   r   r   r   r   rn   r$  )r  r   r(  r)  rn   ro   )r   r   r   r   r"  r$   r#  r   r  r   rn   r}   )r   r   r   r   r   r   r"  r$   r#  r   r  r   rn   r5  )r   r   rD  rE  rn   r   )rY  r%   rn   r   )r   r   r  r   rn   r_  )r   r   r   r   rn   ro   )r   r   r   r  rn   ro   )
r   r   r   r  r   r   rz  r{  rn   ro   )r   r   r   r  rn   ro   )r  r@   rn   r  )r   r  r  rF   r  rF   rn   ro   )
r   r  r  rD   r  rD   r  rD   rn   r  )rO  r  rn   r  )r   r  rn   r>   )rz   
__future__r   collectionsr   collections.abcr   r   	functoolsr   typingr   r	   r
   mypy.pluginmypymypy.applytyper   mypy.errorcodesr   mypy.expandtyper   r   mypy.exprtotyper   r   	mypy.meetr   mypy.messagesr   
mypy.nodesr   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/   r0   mypy.plugins.commonr1   r2   r3   r4   r5   r6   mypy.server.triggerr7   
mypy.stater8   mypy.typeopsr9   r:   r;   r<   
mypy.typesr=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   mypy.typevarsrN   	mypy.utilrO   rS   __annotations__rT   rU   rZ   r`   ra   rc   re   rf   rh   rj   r}   r   r   r   r   r   r   r   r   r  r  r	  r'  r&  r<  rK  r  r   r   r   r   r   r   r   r   r  r  r  r  r  r  r{   ru   rs   <module>r     s   D D D " " " " " " # # # # # # - - - - - - - -       ' ' ' ' ' ' ' ' ' '     2 2 2 2 2 2 ' ' ' ' ' ' @ @ @ @ @ @ @ @ I I I I I I I I             * * * * * *                                                             > 8 7 7 7 7 7                6 5 5 5 5 5                                                      & ( ' ' ' ' '       GFF  F F F F 01  1 1 1 1*N;  ; ; ; ;\\\  \ \ \ \```  ` ` ` `#=?Z"[  [ [ [ [    * * * * *&>  > > > >) ) ) ) )! ! ! ! ! ! ! !@" @" @" @" @" @" @" @"F   < IM    8, , , , ). 	
 
 
 
 
<K K K K\   L L L L^A A A A
   :!S !S !S !SH$ $ $ $<^ ^ ^ ^ K K K K\] ] ] ]@      "J J J J<# # # #,(4 (4 (4 (4V$ $ $ $NW W W W"` ` ` `"   
 
 
 
 
 
 
 
>
 
 
 
# # # #&' ' ' 'T   &   @!! !! !! !! !! !!ru   