
    e	                        d Z ddlmZ ddlZddlmZ ddlZddlmZ erddlm	Z	 ddl
mZ ddZ	 d	 	 	 	 	 	 	 dd	Z	 d	 	 	 	 	 	 	 dd
ZddZy)a  Contains logic for retrieving special methods.

This implementation does not rely on the dot attribute access
logic, found in ``.getattr()``. The difference between these two
is that the dunder methods are looked with the type slots
(you can find more about these here
http://lucumr.pocoo.org/2014/8/16/the-python-i-would-like-to-see/)
As such, the lookup for the special methods is actually simpler than
the dot attribute access.
    )annotationsN)TYPE_CHECKING)AttributeInferenceError)nodes)InferenceContextc                   | j                   j                  g       }t        j                  j	                  fd| j                  d      D              }t        t        j                  ||            }|st        |       |S )Nc              3  V   K   | ]   }|j                   j                  g        " y wN)localsget).0ancestornames     C/usr/lib/python3/dist-packages/astroid/interpreter/dunder_lookup.py	<genexpr>z!_lookup_in_mro.<locals>.<genexpr>   s'      **2D"%*s   &)T)recurs	attributetarget)r   r   	itertoolschainfrom_iterable	ancestorslistr   )noder   attrsr   valuess    `   r   _lookup_in_mror      so    KKOOD"%EOO)) *6:nnDn6Q* E )//%/0F%TBBM    c                ~   t        | t        j                  t        j                  t        j                  t        j
                  t        j                  f      rt        | |      S t        | t        j                        rt        | |      S t        | t        j                        rt        | ||      S t        ||       )zLookup the given special method name in the given *node*.

    If the special method was found, then a list of attributes
    will be returned. Otherwise, `astroid.AttributeInferenceError`
    is going to be raised.
    contextr   )
isinstanceastroidListTupleConstDictSet_builtin_lookupInstancer   ClassDef_class_lookupr   )r   r   r"   s      r   lookupr.   )   s     w||W]]GMM7<<U tT**$(()dD))$(()T499
!D
>>r   c                \    | j                  |      }|t        ||       t        ||      S )Nr!   r   )	metaclassr   r   )r   r   r"   r0   s       r   r-   r-   >   s4     w/I%TBB)T**r   c                \    | j                   j                  |g       }|st        ||       |S )Nr   )r   r   r   )r   r   r   s      r   r*   r*   H   s+    [[__T2&F%TBBMr   )returnr   r
   )r   znodes.NodeNGr   strr"   InferenceContext | Noner2   r   )r   znodes.ClassDefr   r3   r"   r4   r2   r   )__doc__
__future__r   r   typingr   r$   astroid.exceptionsr   r   astroid.contextr   r   r.   r-   r*    r   r   <module>r;      s   
	 #     60
 GK?
?!?,C?	?, IM+
+ #+.E+	+r   