
    *e                        U d Z ddlmZ ddlmZmZ ddlZddlm	Z	m
Z
mZ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hZd	ed
<   h dZd	ed<    G d de          Z	 dddZddZddZdS )z<Plugin for supporting the functools standard library module.    )annotations)Final
NamedTupleN)ARG_POS	ARG_STAR2ArgumentFuncItemVar)add_method_to_class)AnyTypeCallableTypeType	TypeOfAnyUnboundTypeget_proper_typezfunctools.total_orderingr   functools_total_ordering_makers>   __ge____gt____le____lt___ORDERING_METHODSc                  $    e Zd ZU ded<   ded<   dS )_MethodInfobool	is_staticr   typeN)__name__
__module____qualname____annotations__     6lib/python3.11/site-packages/mypy/plugins/functools.pyr   r      s'         OOOr"   r   Fctxmypy.plugin.ClassDefContextauto_attribs_defaultr   returnc                  
 t          |           

s"| j                            d| j                   dS t	          

fd          }
|         }|sdS t          |          }| j                            d          }|}|j        j        | j                            d          k    rkt          |j        j                  }t          |t                    r$|j                            d          d         dk    st          t          j                  }t"          D ]Z}
                    |          sCt'          t)          d	|          |d
t*                    g}	t-          | j        | j        ||	|           [dS )zFAdd dunder methods to classes decorated with functools.total_ordering.zNNo ordering operation defined when using "functools.total_ordering": < > <= >=Tc                    |          d u | fS )Nr!   )kcomparison_methodss    r#   <lambda>z9functools_total_ordering_maker_callback.<locals>.<lambda>"   s    2DQ2G42OQR1S r"   )keyzbuiltins.bool.r   otherN)_analyze_classapifailreasonmax_find_other_type
named_typer   ret_typer   
isinstancer   namesplitr   r   implementation_artifactr   getr   r
   r   r   cls)r$   r&   rootroot_method
other_type	bool_typer8   proper_ret_typeadditional_opargsr+   s             @r#   'functools_total_ordering_maker_callbackrF      s    (,, \J	
 	
 	
 t !'S'S'S'STTTD$T*K t!+..J""?33IH CG$6$6$G$GGG)+*:*CDD44	B$**3//3v==y@AAH* Q Q "%%m44 	QS*55z4QQRD-xPPP4r"   methodr   c                   | j         rdnd}d}d}t          | j        j        | j        j                  D ]8\  }}|                                r||k    r|} n|dz  })|t          k    r|} n9|t          t          j	                  S |S )z?Find the type of the ``other`` argument in a comparison method.r      N)
r   zipr   	arg_kinds	arg_typesis_positionalr   r   r   r<   )rG   first_arg_poscur_pos_arg	other_argarg_kindarg_types         r#   r6   r6   <   s    )0AAqMKI!&+"79NOO 	 	(!!## 	m++$	1KK"" IE # y8999r"   dict[str, _MethodInfo | None]c                   i }| j         j        j        dd         D ]}t          D ]}||j        v r||vr|j        |         j        }t          |t                    r8t          |j        t                    rt          |j        |j                  ||<   nt          |t                    rBt          |j                  }t          |t                    rt          |j        |          ||<   d||<   ˌ|S )zMAnalyze the class body, its parents, and return the comparison methods found.Nr/   )r>   infomror   namesnoder9   r	   r   r   r   r   r
   r   is_staticmethod)r$   r+   r>   r:   rX   proper_types         r#   r1   r1   R   s    9;w|$ 0 0% 	0 	0Dsy  T1C%C%Cy+dH-- *TY2U2U /:4>49/U/U&t,dC(( !"1$)"<"<K!+|<< !3>t?SU`3a3a*40 +/"4(	0 r"   )F)r$   r%   r&   r   r'   r   )rG   r   r'   r   )r$   r%   r'   rS   )__doc__
__future__r   typingr   r   mypy.pluginmypy
mypy.nodesr   r   r   r	   r
   mypy.plugins.commonr   
mypy.typesr   r   r   r   r   r   r   r    r   r   rF   r6   r1   r!   r"   r#   <module>rc      sZ   B B B " " " " " " $ $ $ $ $ $ $ $     B B B B B B B B B B B B B B 3 3 3 3 3 3 [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [*D)E  E E E ECCC  C C C C    *    DI$ $ $ $ $N   ,     r"   