a
    lc                     @   sf   d Z ddlZddlmZ e Zdd Zdd Zdd	 Zd
d Z	dd Z
dd Zdd ZefddZdS )z
A static version of getattr.
This is a backport of the Python 3 code with a little bit of additional
information returned to enable Jedi to make decisions.
    N)debugc                 C   s6   i }zt | d}W n ty&   Y n0 t||tS N__dict__)object__getattribute__AttributeErrordictget	_sentinel)objattrinstance_dict r   b/var/www/html/django/DPS/env/lib/python3.9/site-packages/jedi/inference/compiled/getattr_static.py_check_instance   s    r   c              	   C   sF   t | D ]8}tt|tu rz|j| W   S  ty>   Y q0 qtS N)_static_getmro_shadowed_dicttyper
   r   KeyError)klassr   entryr   r   r   _check_class   s    r   c                 C   s&   zt |  W n ty    Y dS 0 dS )NFT)r   	TypeErrorr   r   r   r   _is_type!   s
    r   c              	   C   sl   t jd }t| D ]T}z||d }W n ty:   Y q0 t |tju r^|jdkr^|j|u s|  S qt	S r   )
r   r   r   __get__r   typesGetSetDescriptorType__name____objclass__r
   )r   	dict_attrr   
class_dictr   r   r   r   )   s    

r   c                 C   s8   t jd | }t|ttfs4td| |f  dS |S )N__mro__z(mro of %s returned %s, should be a tupler   )r   r   r   
isinstancetuplelistr   warning)r   mror   r   r   r   8   s
    r   c                 C   s   t t| |tuS r   )r   r   r
   )r   namer   r   r   _safe_hasattrC   s    r*   c                 C   s   t | dpt | dS )N__set__
__delete__)r*   r   r   r   r   _safe_is_data_descriptorG   s    r-   c              	   C   s  t }t| s>t| }t|}|t u s2t|tju rBt| |}n| }t||}|t urv|t urvt|drvt	|rv|dfS |t ur|dfS |t ur|t|dfS | |u rt
t|D ]<}tt|t u rz|j| dfW   S  ty   Y q0 q|t ur |dfS t|dS )a  Retrieve attributes without triggering dynamic lookup via the
       descriptor protocol,  __getattr__ or __getattribute__.

       Note: this function may not be able to retrieve all attributes
       that getattr can fetch (like dynamically created attributes)
       and may find attributes that getattr can't (like descriptors
       that raise AttributeError). It can also return descriptor objects
       instead of instance members in some cases. See the
       documentation for details.

       Returns a tuple `(attr, is_get_descriptor)`. is_get_descripter means that
       the attribute is a descriptor that has a `__get__` attribute.
    r   TFN)r
   r   r   r   r   MemberDescriptorTyper   r   r*   r-   r   r   r   r   )r   r   defaultinstance_resultr   r!   klass_resultr   r   r   r   getattr_staticK   s6    


r2   )__doc__r   Zjedir   r   r
   r   r   r   r   r   r*   r-   r2   r   r   r   r   <module>   s   	
