o
    tBh                     @  s   U d 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
mZmZmZmZmZmZmZmZ ddlmZ ddlmZmZ dd	d
d
dZded< d%ddZd&ddZd'ddZd(d"d#Zd$S ))zfCalculate some properties of classes.

These happen after semantic analysis and before type checking.
    )annotations)Final)Errors)IMPLICITLY_ABSTRACTIS_ABSTRACTCallExpr	DecoratorFuncDefNodeOverloadedFuncDefPromoteExprSymbolTableTypeInfoVar)Options)InstanceTypefloatcomplexbytes)zbuiltins.intzbuiltins.floatzbuiltins.bytearrayzbuiltins.memoryviewr   TYPE_PROMOTIONStypr   is_stub_fileboolerrorsr   returnNonec                   s  j rdS t }g }g }jrg _dS jD ]s}|j D ]k\}}|j}	t|	t	r6|	jr3|	jd }
nd}
n|	}
t|
t
r@|
j}
t|
tre|
jttfv rd||vrdd_|||
jf |u rd|| nt|	tr|	jr||vrd_||tf |u r|| || qqt|_|r̈jrjjjdkrdS jrdS |r|sd fd
d}ddd t|D }|dj d| d |dd jr|rddd t|D } jjdj d|  dS dS dS )zCalculate abstract status of a class.

    Set is_abstract of the type to True if the type has an unimplemented
    abstract attribute.  Also compute a list of abstract attributes.
    Report error is required ABCMeta metaclass is missing.
    Nr   Tzabc.ABCMetamessagestrseverityr   r   c                       j jj| |d d S N)r   reportlinecolumnr   r   r   r    m/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/mypy/semanal_classprop.pyr#   h      z/calculate_class_abstract_status.<locals>.reportz, c                 s       | ]\}}d | d V  qdS "Nr(   .0attr_r(   r(   r)   	<genexpr>k       z2calculate_class_abstract_status.<locals>.<genexpr>zClass z has abstract attributes errorzIIf it is meant to be abstract, add 'abc.ABCMeta' as an explicit metaclassnotec                 s  r+   r,   r(   r.   r(   r(   r)   r2   q   r3   zFinal class r   r   r   r   r   r   )typeddict_typeset
is_newtypeabstract_attributesmronamesitemsnode
isinstancer   r   funcr	   abstract_statusr   r   is_abstractappendr   is_abstract_varaddsorteddeclared_metaclasstypefullnameis_protocoljoinis_finalr#   r$   r%   )r   r   r   concreteabstractabstract_in_this_classbasenamesymnoder>   r@   r#   attrsr(   r'   r)   calculate_class_abstract_status*   sj   







"
rT   infoc                   sH   j r jD ]}|jj s|jjdkrd fdd}|d	d
 qdS dS )z9Check that all classes in MRO of a protocol are protocolszbuiltins.objectr   r   r   r   r   c                   r    r!   r"   r&   r   rU   r(   r)   r#   }   r*   z%check_protocol_status.<locals>.reportz)All bases of a protocol must be protocolsr4   Nr6   )rJ   basesrH   rI   )rU   r   rH   r#   r(   rV   r)   check_protocol_statusw   s   

rX   c                 C  s|   | j  D ]6\}}|j}t|tr;|jr;|jr;|js;| jdd D ]}|j 	|}|dur:t|jtr:|jjr:d|_q!qdS )aH  Try to infer additional class variables.

    Subclass attribute assignments with no type annotation are assumed
    to be classvar if overriding a declared classvar from the base
    class.

    This must happen after the main semantic analysis pass, since
    this depends on base class bodies having been fully analyzed.
       NT)
r<   r=   r>   r?   r   rU   is_inferredis_classvarr;   get)rU   rQ   symr>   rP   memberr(   r(   r)   calculate_class_vars   s   
r_   module_namesr   optionsr   builtin_namesc                 C  s   | j }g }|jD ]}t|tr|j}t|tr||j q|sA|jt	v rA|
t	|j }|rA|j}	t|	ts9J |t|	g  |jdksK|jdkrg|d }
t|
jtsWJ |
jjt|jg  |
j|j_|rr|jj| dS dS )zSetup extra, ad-hoc subtyping relationships between classes (promotion).

    This includes things like 'int' being compatible with 'float'.
    zmypy_extensions.i64zmypy_extensions.i32intN)defn
decoratorsr?   r   analyzedr   rC   rH   rI   r   r\   r>   r   r   _promoterU   alt_promoteextend)rU   r`   ra   rb   rd   promote_targets	decoratorrf   
target_symtarget_infoint_symr(   r(   r)   add_type_promotion   s.   




ro   N)r   r   r   r   r   r   r   r   )rU   r   r   r   r   r   )rU   r   r   r   )
rU   r   r`   r   ra   r   rb   r   r   r   )__doc__
__future__r   typing_extensionsr   mypy.errorsr   
mypy.nodesr   r   r   r   r	   r
   r   r   r   r   r   mypy.optionsr   
mypy.typesr   r   r   __annotations__rT   rX   r_   ro   r(   r(   r(   r)   <module>   s     4


M
