Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib/python3.7/site-packages/pylint/checkers/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/pylint/checkers/__pycache__/utils.cpython-37.pyc

B

A!p\>��	@sdZddlZddlmZmZddlZddlZddlZddlZddl	Z	ddl
mZmZm
Z
mZmZmZmZmZmZddlZddlZddlmZddlmZddlmZejZejejejej fZ!ej"ddkZ#e#s�d	Z$nd
Z$ddd
dhZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.ddddddd�Z/dd �e/�0�D�Z1e2e1�Z3Gd!d"�d"e4�Z5d#d$�Z6ej7j8e9d%�d&d'�Z:ej7j8eej7j8d%�d(d)�Z;ej7j8e
e9e
e<e<ffd%�d*d+�Z=ej7j8e9d%�d,d-�Z>ej7j8e9d%�d.d/�Z?ej@�A�Zd0ZBej7j8e9d%�d1d2�ZCe<e9d3�d4d5�ZDej7j8e<ej7j8e9d6�d7d8�ZEej7j8e9d9�d:d;�ZFej7j8e9d%�d<d=�ZGej7j8e9d%�d>d?�ZHej7j8ej7j8e9d@�dAdB�ZIej7j8ej7j8d%�dCdD�ZJej7j8e<e9dE�dFdG�ZKe<edH�dIdJ�ZLGdKdL�dLe4�ZMGdMdN�dNe4�ZNe<e
ee<eOee<e<fee<fdO�dPdQ�ZPe
e<ee
e9e<ffdR�dSdT�ZQeee<dR�dUdV�ZRe<e
ee
e<ee
e9e<ffeOeOfdO�dWdX�ZSe<e9dY�dZd[�ZTej7j8eej7j8d%�d\d]�ZUe<eee<dY�d^d_�ZVd�ejWeOe<ejXd`�dadb�ZYej7j8e9d%�dcdd�ZZej[e9de�dfdg�Z\ej]e9d%�dhdi�Z^ejXe9dj�dkdl�Z_ej]ee<e9dm�dndo�Z`edpdq�d�ej7j8ej]ee<ej7j8fdr�dsdt��Zaej7j8eej[ejbfd%�dudv�Zcej7j8e9d%�dwdx�Zdej[e9dy�dzd{�Zee4fej7j8eej[d%�d|d}�Zfejge9d%�d~d�Zhe4fej7j8e9d%�d�d��Ziejje9d%�d�d��Zkej7j8e<e9d��d�d��Zlej7j8e9d%�d�d��Zmej7j8e9d��d�d��Znej7j8e9d��d�d��Zoej7j8e9d��d�d��Zpej7j8e9d��d�d��Zqej7j8e9d��d�d��Zrej7j8e9d��d�d��Zsej7j8e9d��d�d��Zte<e9d3�d�d��Zuej7j8e9d%�d�d��Zvej7j8ej]e9d��d�d��Zwd�ej7j8e9e9d��d�d��Zxej7j8e9d��d�d��Zyej7j8e9d��d�d��Zzej7j8e9d��d�d��Z{ej7j8e9d��d�d��Z|ej7j8e9d��d�d��Z}edpdq�d�ej7j8eej7j8d%�d�d���Z~d�ejje9d��d�d��Zej7j8e9d%�d�d��Z�ej7j8ee�d%�d�d��Z�ej]e9d%�d�d��Z�ej7j8eOd%�d�d��Z�ej7j8e9d%�d�d��Z�ejjejje9d��d�d��Z�dS)�z7some functions that may be useful for various checkers
�N)�	lru_cache�partial)	�Optional�Iterable�Tuple�Callable�Set�Union�Match�Dict�List)�_NonDeducibleTypeHierarchy)�bases)�scoped_nodes��
exceptions�builtinszabc.abstractpropertyzabc.abstractmethodzabc.abstractclassmethodzabc.abstractstaticmethod�__iter__�	__aiter__�__next__�__getitem__�__class_getitem__�__setitem__�__delitem__�__contains__�keys)�__new__�__init__�__call__)&�__del__�__repr__�__str__�	__bytes__�__hash__�__bool__�__dir__�__len__�__length_hint__r�__reversed__�__neg__�__pos__�__abs__�
__invert__�__complex__�__int__�	__float__r)r*r+r-r.r/�	__index__�	__enter__�
__aenter__�__getnewargs_ex__�__getnewargs__�__getstate__�
__reduce__�__copy__�__unicode__�__nonzero__�	__await__r�	__anext__�
__fspath__)<�
__format__�__lt__�__le__�__eq__�__ne__�__gt__�__ge__�__getattr__�__getattribute__�__delattr__�
__delete__�__instancecheck__�__subclasscheck__r�__missing__rr�__add__�__sub__�__mul__�__truediv__�__floordiv__�__mod__�
__divmod__�
__lshift__�
__rshift__�__and__�__xor__�__or__�__radd__�__rsub__�__rmul__�__rtruediv__�__rmod__�__rdivmod__�__rpow__�__rlshift__�__rrshift__�__rand__�__rxor__�__ror__�__iadd__�__isub__�__imul__�__itruediv__�
__ifloordiv__�__imod__�__ilshift__�__irshift__�__iand__�__ixor__�__ior__�__ipow__�__setstate__�
__reduce_ex__�__deepcopy__Z__cmp__�
__matmul__�__rmatmul__Z__div__)�__setattr__�__get__�__set__r�__set_name__)�__exit__�	__aexit__)�	__round__)Nr��r)rr{cCs i|]\}}|D]
}||�qqS�r})�.0�params�methods�namer}r}�F/opt/alt/python37/lib/python3.7/site-packages/pylint/checkers/utils.py�
<dictcomp>�sr�c@seZdZdS)�NoSuchArgumentErrorN)�__name__�
__module__�__qualname__r}r}r}r�r��sr�cCs2|}x|r t|jtj�s |j}qW|o0||jjkS)z=Returns true if node is inside the name of an except handler.)�
isinstance�parent�astroid�
ExceptHandlerr�)�node�currentr}r}r��is_inside_except�s
r�)r��returncCs.|j}x"|dk	r(t|tj�r dS|j}qWdS)z*Return true if given node is inside lambdaNTF)r�r�r��Lambda)r�r�r}r}r��is_inside_lambda�s

r�ccsFt|tjtjf�r<x.|jD]}xt|�D]
}|Vq(WqWn|VdS)z9Recursively returns all atoms in nested lists and tuples.N)r�r�rrZelts�get_all_elements)r��child�er}r}r�r��s
r�cCs�t|tj�r&d|jd|j��fffSt|tj�r�|j}t|�rLd|dffS|�	|�d}|r�t|d�
�tjtjtj
f�s�d|d|djffSdS)z�Checks if an assignment node in an except handler clobbers an existing
    variable.

    Returns (True, args for W0623) if assignment clobbers an existing variable,
    (False, None) otherwise.
    Tz	object %rrr{rzouter scope (line %s))FN)r�r�Z
AssignAttr�attrname�expr�	as_string�
AssignNamer��
is_builtin�lookupZassign_type�AssignZ	AugAssignr��
fromlineno)r�r�Zstmtsr}r}r��clobber_in_except�s	
r�cCs&t|dd�dkr"|��jtkr"dSdS)zHreturn True if the node is referencing the "super" builtin function
    r�N�superTF)�getattr�rootr��
BUILTINS_NAME)r�r}r}r��is_supersr�cCs&x |��D]}t|tj�r
dSq
WdS)zAreturn true if the function does nothing but raising an exceptionTF)Zget_childrenr�r��Raise)r�Z
child_noder}r}r��is_errorsr�)�__builtins__cCs|o|��jtkS)zHReturns True if the given node is an object from the __builtin__ module.)r�r�r�)r�r}r}r��is_builtin_objectsr�)r�r�cCs|tkp|tkS)zMreturn true if <name> could be considered as a builtin defined by python
    )r�SPECIAL_BUILTINS)r�r}r}r�r�!sr�)�var_node�varname�scoper�cs�t|tj�r^xL|jD]B}t|tj�r<t�fdd�|jD��sRt|tj�r�|jkrdSqW�n@t|t	tj
f�r�x"|�tj�D]}|j
�kr|dSq|W�nt|tj�r�x�|jD]2\}}|�|�r�P|r�t|tj�r�|j
�kr�dSq�Wn�t|tjtjf��rj|j����rR|j�|��rNy"|j���|j}t|�|�Wntjk
�rLYnXdSt|dd��k�r�dSn4t|tj��r�t|j
tj��r�|j
}|j
�k�r�dSdS)Nc3s$|]}t|tj�o|j�kVqdS)N)r�r�r�r�)r~�target)r�r}r��	<genexpr>1sz&is_defined_in_scope.<locals>.<genexpr>Tr�F)r�r�ZIf�bodyr��any�targetsZNonlocal�names�COMP_NODE_TYPESZFor�nodes_of_classr�r�ZWith�itemsZ	parent_ofr��FunctionDef�argsZis_argumentZ
default_valuer��is_defined_in_scopeZ	NoDefaultr�r�)r�r�r�r�Zass_noder�Zidsr})r�r�r�'sH



r�)r�r�cCs�|j}|j}x|r*t|||�r"dS|j}qW|��}|��}|j}xr|r�|j|kr�x"|�tj�D]}|j|kr`dSq`Wx2|�tj	tj
f�D]}|dd�|jD�kr�dSq�W|��}qDWdS)z�return True if the variable node is defined by a parent node (list,
    set, dict, or generator comprehension, lambda) or in a previous sibling
    node on the same line (statement_defining ; statement_using)
    TcSsg|]}|dp|d�qS)r{rr})r~r�r}r}r��
<listcomp>ksz%is_defined_before.<locals>.<listcomp>F)r�r�r�Z	statementZprevious_siblingr�r�r�r��
ImportFrom�Importr�)r�r��_node�stmt�linenoZassign_nodeZimp_noder}r}r��is_defined_beforeWs$

r�cCsR|��}t|tjtjf�rNx2|jjD]&}x |�tj�D]}||kr6dSq6Wq$WdS)zbreturn true if the given Name node is used in function or lambda
    default argument's value
    TF)	r�r�r�r�r�r��defaultsr��Name)r�r��default_nodeZdefault_name_noder}r}r��is_default_argumentqsr�cCsL|j}x@|dk	rFt|tj�r dS|js<t|tjtjtjf�r>P|j}qWdS)z5return true if the name is used in function decoratorNTF)	r�r�r�Z
DecoratorsZis_statementr�rZComprehensionScope�ListComp)r�r�r}r}r��is_func_decorator~s

r�)�framer�r�cCsFy
|j}Wntk
rdSXx |D]}||�tj�kr&dSq&WdS)zjreturn True if `frame` is an astroid.Class node with `node` in the
    subtree of its bases attribute
    FT)r�AttributeErrorr�r�r�)r�r�r�baser}r}r��is_ancestor_name�s

r�cCs*x$|r$t|tjtjtjf�r$|j}qW|S)zLreturn the higher parent which is not an AssignName, Tuple or List node
    )r�r�r�rrr�)r�r}r}r��
assign_parent�s
r�)�
class_noder�r�cCs2x,|��D] }||kr
t||tj�r
dSq
WdS)z=return True if <name> is a method overridden from an ancestorTF)�	ancestorsr�r�r�)r�r��ancestorr}r}r��overrides_a_method�sr�)�messagesr�cs�fdd�}|S)z@decorator to store messages that are handled by a checker methodcs
�|_|S)N)Zchecks_msgs)�func)r�r}r��store_messages�sz&check_messages.<locals>.store_messagesr})r�r�r})r�r��check_messages�sr�c@seZdZdZdS)�IncompleteFormatStringz:A format string ended in the middle of a format specifier.N)r�r�r��__doc__r}r}r}r�r��sr�c@seZdZdZdd�ZdS)�UnsupportedFormatCharacterzXA format character in a format string is not one of the supported
    format characters.cCst�||�||_dS)N)�	Exceptionr�index)�selfr�r}r}r�r�sz#UnsupportedFormatCharacter.__init__N)r�r�r�r�rr}r}r}r�r��sr�)�
format_stringr�c
s�t�}t�}g}d}�fdd�}d}�x�|t��k�r�|}|dk�r�||�\}}d}|dkr�d}	||�\}}|}
x:|	dkr�|dkr�|	d7}	n|dkr�|	d8}	||�\}}qvW|d}�|
|�}x|d	kr�||�\}}q�W|d
kr�|d7}||�\}}nx|tjk�r||�\}}q�W|dk�rp||�\}}|d
k�rP|d7}||�\}}n x|tjk�rn||�\}}�qRW|dk�r�||�\}}t�r�d
}nd}||k�r�t|��|�r�|�|�|||<n|dk�r�|d7}|�|�|d7}q(W||||fS)a'Parses a format string, returning a tuple of (keys, num_args), where keys
    is the set of mapping keys in the format string, and num_args is the number
    of arguments required by the format string.  Raises
    IncompleteFormatString or UnsupportedFormatCharacter if a
    parse error occurs.rcs$|d7}|t��krt�|�|fS)Nr{)�lenr�)�i)r�r}r��	next_char�sz&parse_format_string.<locals>.next_char�%N�(r{�)z#0- +�*�.ZhlLzdiouxXeEfFgGcrs%azdiouxXeEfFgGcrs%)	�set�dictr��string�digits�PY3Kr��add�append)
r�rZ	key_typesZ	pos_types�num_argsr�r��char�key�depthZ	key_startZkey_end�flagsr})r�r��parse_format_string�sh











r�)r�cCs*y
t�|�Stk
r$t��YnXdS)N)�_string�formatter_field_name_split�
ValueErrorr�)r�r}r}r��split_format_field_namess
r�c
cs�t��}yj|�|�}xZ|D]R}tdd�|dd�D��r:q|d}|d}|V|rxt|�D]
}|Vq^WqWWnJtk
r�}z,|jd�d�r�dVd	VdSt|��Wdd}~XYnXdS)
zy Given a format string, return an iterator
    of all the valid format fields. It handles nested fields
    as well.
    css|]}|dkVqdS)Nr})r~�itemr}r}r�r�"sz(collect_string_fields.<locals>.<genexpr>r{Nr|rzcannot switch from manual��1)	r��	Formatter�parse�all�collect_string_fieldsr�r��
startswithr�)r��	formatterZ
parseiterator�resultr��nested�field�excr}r}r�r�s$

r�c	Cs�g}d}t�}x�t|�D]�}|r<t|���r<|�t|��q|r�t|�\}}t|tj�rn|�t|��t	|�}y|�
|t|�f�Wq�tk
r�t
��Yq�Xq|d7}qW||t|�fS)aq
    Parses a PEP 3101 format string, returning a tuple of
    (keyword_arguments, implicit_pos_args_cnt, explicit_pos_args),
    where keyword_arguments is the set of mapping keys in the format string, implicit_pos_args_cnt
    is the number of arguments required by the format string and
    explicit_pos_args is the number of arguments passed with the position.
    rr{)r�r��str�isdigitr�r�r��numbers�Number�intr��listr�r�r�)r�Zkeyword_argumentsZimplicit_pos_args_cntZexplicit_pos_argsr�ZkeynameZ
fielditeratorr}r}r��parse_format_method_string:s"
r)r�r�cCs*|ddko(|dko(|�d�o&|�d�S)zkreturn True if attribute name is protected (start with _ and some other
    details), False otherwise.
    r�_�__)r��endswith)r�r}r}r��is_attr_protectedZsrcCs@|��}x2|dk	r:t|tj�s:|jdkr.d}q
|j��}q
W|S)zhreturn klass node for a method node (or a staticmethod or a
    classmethod), return null otherwise
    N)r�r�r��ClassDefr�)r��klassr}r}r��node_frame_classes
rcCst�d�}|�|�S)zqCheck that attribute name is private (at least two leading underscores,
    at most one trailing underscore)
    z^_{2,}.*[^_]+_?$)�re�compile�match)r��regexr}r}r��is_attr_privatevs
r)�	call_node�position�keywordr�cCsr|dkr|dkrtd��|dk	r@y
|j|Stk
r>YnX|rj|jrjx|jD]}|j|krR|jSqRWt�dS)a
Returns the specified argument from a function call.

    :param astroid.Call call_node: Node representing a function call to check.
    :param int position: position of the argument.
    :param str keyword: the keyword of the argument.

    :returns: The node representing the argument, None if the argument is not found.
    :rtype: astroid.Name
    :raises ValueError: if both position and keyword are None.
    :raises NoSuchArgumentError: if no argument at the provided position or with
    the provided keyword.
    Nz2Must specify at least one of: position or keyword.)r�r��
IndexError�keywords�arg�valuer�)rrrrr}r}r��get_argument_from_call~s



rcCsD|jdkr|��jtkrdSt|d�s*dStdd�|jdd�D��S)zV
    Return true if the given class node is subclass of
    exceptions.Exception.
    )r��
BaseExceptionTr�Fcss|]}t|�VqdS)N)�inherit_from_std_ex)r~r�r}r}r�r��sz&inherit_from_std_ex.<locals>.<genexpr>)Zrecurs)r�r��EXCEPTIONS_MODULE�hasattrr�r�)r�r}r}r�r�s

r)�handlerr�cs>dd��t|t�s|f}�fdd�|D�}|js4dS|�|�S)ar
    Check if the given exception handler catches
    the given error_type.

    The *handler* parameter is a node, representing an ExceptHandler node.
    The *error_type* can be an exception, such as AttributeError,
    the name of an exception, or it can be a tuple of errors.
    The function will return True if the handler catches any of the
    given errors.
    cSst|t�s|jS|S)N)r�r�r�)�errorr}r}r��stringify_error�s
z&error_of_type.<locals>.stringify_errorcsh|]}�|��qSr}r})r~r)rr}r��	<setcomp>�sz error_of_type.<locals>.<setcomp>T)r��tuple�typeZcatch)r�
error_typeZexpected_errorsr})rr��
error_of_type�s
r$c	CsV|js
dSxF|jjD]:}t|tj�s&qyt|�r4dSWqtjk
rLYqXqWdS)zA Detect if the given function node is decorated with a property. FT)�
decorators�nodesr�r�r��_is_property_decorator�InferenceError)r��	decoratorr}r}r��decorated_with_property�s
r*)r)r�cCslxf|��D]Z}t|tj�r
|��jtkr6|jdkr6dSx,|��D] }|jdkr@|��jtkr@dSq@Wq
WdS)N�propertyTF)�inferr�r�r	r�r�r�r�)r)�inferedr�r}r}r�r'�s
r')r��qnamesr�c	s`|jr|jjng}xH|D]@}y"t�fdd�|��D��r<dSWqtjk
rVwYqXqWdS)zMDetermine if the `func` node has a decorator with the qualified name `qname`.c3s"|]}|dk	o|���kVqdS)N)Zqname)r~r�)r.r}r�r��sz!decorated_with.<locals>.<genexpr>TF)r%r&r�r,r�r()r�r.r%Zdecorator_noder})r.r��decorated_with�s
r/i)�maxsize)r��is_abstract_cbr�cCs�|dkrtttd�}i}yt|���}Wn(tk
r<iStjk
rPiSXx�|D]�}x�|��D]�}|}t	|tj
�r�t|�}|s�|j|krf||j=qft	|tj
�s�|j|kr�||j=t	|tj
�rf||�}|r�|||j<qf|sf|j|krf||j=qfWqXW|S)a�
    Get the unimplemented abstract methods for the given *node*.

    A method can be considered abstract if the callback *is_abstract_cb*
    returns a ``True`` value. The check defaults to verifying that
    a method is decorated with abstract methods.
    The function will work only for new-style classes. For old-style
    classes, it will simply return an empty dictionary.
    For the rest of them, it will return a dictionary of abstract method
    names and their inferred objects.
    N)r.)rr/�ABC_METHODS�reversed�mro�NotImplementedErrorr�ZResolveError�valuesr�r��
safe_inferr�r�)r�r1�visitedr4r��objr-�abstractr}r}r��unimplemented_abstract_methods�s8


	r;cCsF|}tjtjf}x|r*t|j|�s*|j}qW|rBt|j|�rB|jSdS)zDReturn the ExceptHandler or the TryExcept node in which the node is.N)r�r��	TryExceptr�r�)r�r�Zignoresr}r}r��find_try_except_wrapper_node+s
r=cCspt|�}|sdSt|tj�r.|jj}|jj}ntj�	dd�|jD��}|j}t
dd�|D��}t|t�}|pn|S)z8Check if the given node is from a fallback import block.Fcss|]}|jVqdS)N)r�)r~rr}r}r�r�Dsz)is_from_fallback_block.<locals>.<genexpr>css |]}t|tjtjf�VqdS)N)r�r�r�r�)r~Zimport_noder}r}r�r�Is)
r=r�r�r�r�r��handlers�	itertools�chain�
from_iterabler��"_except_handlers_ignores_exception�ImportError)r��contextZ
other_bodyr>Zhas_fallback_importsZignores_import_errorr}r}r��is_from_fallback_block9s


rE)r>r�cCstt|fd�}tt||��S)N)r#)rr$r��map)r>�	exceptionr�r}r}r�rBPsrBcs,t|�}t|tj�r(�fdd�|jD�SdS)a]Return the collections of handlers handling the exception in arguments.

    Args:
        node (astroid.NodeNG): A node that is potentially wrapped in a try except.
        exception (builtin.Exception or str): exception or name of the exception.

    Returns:
        list: the collection of handlers that are handling the exception or None.

    csg|]}t|��r|�qSr})r$)r~r)rGr}r�r�gsz*get_exception_handlers.<locals>.<listcomp>N)r=r�r�r<r>)r�rGrDr})rGr��get_exception_handlersWs
rHcCst|�}t|tj�S)aCheck if the node is directly under a Try/Except statement.
    (but not under an ExceptHandler!)

    Args:
        node (astroid.Raise): the node raising the exception.

    Returns:
        bool: True if the node is inside a try/except statement, False otherwise.
    )r=r�r�r<)r�rDr}r}r��is_node_inside_try_exceptls
rIcCst||�}|sdSt|�S)z�Check if the node is in a TryExcept which handles the given exception.

    If the exception is not given, the function is going to look for bare
    excepts.
    F)rHr�)r�rGZmanaging_handlersr}r}r��node_ignores_exceptionzs
rJcCs4x.|��D]"}|j��|kr
|jdd�r
dSq
WdS)zVreturn true if the given class node should be considered as an abstract
    class
    F)Zpass_is_abstractT)r�r�r��is_abstract)r��methodr}r}r��class_is_abstract�s
rM)r�attrr�cCsRy|�|�}Wntjk
r$dSX|d}t|tj�rNt|jjtj�rNdSdS)NFrT)r�r�Z
NotFoundErrorr�r�r�r�Const)rrNZ
attributes�firstr}r}r��_supports_protocol_method�srQcCstjtjtjtjf}t||�S)N)r�r��SetComp�DictComp�GeneratorExpr�)r�Zcomprehensionsr}r}r��is_comprehension�s
rU)rr�cCst|t�ot|t�S)N)rQ�GETITEM_METHOD�KEYS_METHOD)rr}r}r��_supports_mapping_protocol�srXcCs
t|t�S)N)rQ�CONTAINS_METHOD)rr}r}r��"_supports_membership_test_protocol�srZcCst|t�pt|t�S)N)rQ�ITER_METHODrV)rr}r}r��_supports_iteration_protocol�sr\cCs
t|t�S)N)rQ�AITER_METHOD)rr}r}r��"_supports_async_iteration_protocol�sr^cCs
t|t�S)N)rQrV)rr}r}r��_supports_getitem_protocol�sr_cCs
t|t�S)N)rQ�SETITEM_METHOD)rr}r}r��_supports_setitem_protocol�sracCs
t|t�S)N)rQ�DELITEM_METHOD)rr}r}r��_supports_delitem_protocol�srccCs<|��}|�d�}|�d�}|�d�p.|�d�}|p:|p:|S)NZmixinr:r�)�lowerrr�)r��lnameZis_mixinrKZis_baser}r}r��_is_abstract_class_name�s


rfcCsPxJ|dk	rJt|tj�rBt|�r"dSt|dd�}|dk	rBt|�rBdS|j}qWdS)NTr�F)r�r�r	rMr�rfr�)r�r�r}r}r��is_inside_abstract_class�s

rg)r�protocol_callbackr�cCs�t|tj�r4t|�sdS|��}|dk	r4||�r4dSt|tj�rdt|�sLdS|��rXdS||�rddSt|tj�r�t|j	tj�r�t|j	�r�|j	}||�SdS)NTF)
r�r�r	�has_known_bases�	metaclassZBaseInstanceZhas_dynamic_getattr�_basesZProxyZ_proxied)rrh�metar}r}r��_supports_protocol�s(
rmF)r�check_asyncr�cCs|r
t}nt}t||�S)N)r^r\rm)rrnZprotocol_checkr}r}r��is_iterable�srocCs
t|t�S)N)rmrX)rr}r}r��
is_mappingsrpcCst|t�}|pt|�S)N)rmrZro)r�	supportedr}r}r��supports_membership_test
s
rrcCs$t|tj�rt|t�rdSt|t�S)NT)r�r�r	rQ�CLASS_GETITEM_METHODrmr_)rr}r}r��supports_getitems
rtcCs
t|t�S)N)rmra)rr}r}r��supports_setitemsrucCs
t|t�S)N)rmrc)rr}r}r��supports_delitemsrvcCsjy|j|d�}t|�}Wntjk
r.dSXyt|�dStjk
rRdStk
rd|SXdS)z�Return the inferred value for the given node.

    Return None if inference failed or if there is some ambiguity (more than
    one node has been inferred).
    )rDN)r,�nextr�r(�
StopIteration)r�rDZinferitrr}r}r�r7s	r7)r
r�cCsly|jStk
rYnXxD|jD]:}t||d�}t|tj�rT||ksTt||d�s$d|_dSq$Wd|_dS)z=Return true if all base classes of a class could be inferred.)rDFT)Z_all_bases_knownr�rr7r�r�r	ri)r
rDr�r�r}r}r�ri6sricCs4|dkp2t|tj�r|jdkp2t|tj�o2|jdkS)N�None)r�r�rOrr�r�)r�r}r}r��is_noneJsrzcCsrt�}yDx>|��D]2}|tjkst|�r*q|�|�t|�dkrdSqWWntjk
r`dSX|rn|��SdS)z�Return the inferred type for `node`

    If there is more than one possible type, or if inferred type is Uninferable or None,
    return None
    r{N)	r�r,r�ZUninferablerzr�r�r(�pop)r��typesZvar_typer}r}r��	node_typeRs
r}c	Cs�d}t|tj�sdS|jr"|jjng}xz|D]r}t|tj�s>q,|j}t|tj�r,|jdkr\q,yt	|j
���}Wntjk
r�w,YnXt|tj�r,t
||�Sq,WdS)z>Check if the given function node is a singledispatch function.)zfunctools.singledispatchzsingledispatch.singledispatchF�register)r�r�r�r%r&�Callr��	Attributer�rwr�r,r(r/)r�Zsingledispatch_qnamesr%r)r�Zfunc_defr}r}r��(is_registered_in_singledispatch_functiongs"
r�cCsnt|dd�rt|jd�St|dd�r4t|jd�St|dd�rNt|jd�St|dd�rht|jd�S|jS)z�
    Get the last lineno of the given node. For a simple statement this will just be node.lineno,
    but for a node that has child statements (e.g. a method) this will be the lineno of the last
    child statement recursively.
    �	finalbodyF����orelser>r�)r��get_node_last_linenor�r�r>r�r�)r�r}r}r�r��sr�cCs:d}|��}|j�|�}|o8t|dtj�o8|djdkS)z;Check if the postponed evaluation of annotations is enabled�annotationsr�
__future__)r��locals�getr�r�r��modname)r�r��moduler�r}r}r��is_postponed_evaluation_enabled�sr�)r�r�r�c	Cs^tdd�||fD��sdSx>|��D]2}ytj�||�r<dSWq$tk
rTw$Yq$Xq$WdS)z�
    Check if first node is a subclass of second node.
    :param child: Node to check for subclass.
    :param parent: Node to check for superclass.
    :returns: True if child is derived from parent. False otherwise.
    css|]}t|tj�VqdS)N)r�r�r	)r~r�r}r}r�r��sz!is_subclass_of.<locals>.<genexpr>FT)r�r�r�ZhelpersZ
is_subtyper
)r�r�r�r}r}r��is_subclass_of�sr�)NN)N)F)N)N)�r�r�	functoolsrrr?rr�sysr��typingrrrrrr	r
rrr�r�Zastroid.exceptionsr
rrkrr�r�r�rRrSrTr��version_infor�rr2r[r]ZNEXT_METHODrVrsr`rbrYrWZ_SPECIAL_METHODS_PARAMSr�ZSPECIAL_METHODS_PARAMSr�Z	PYMETHODSr�r�r�Znode_classesZNodeNG�boolr�r�r�r�r�r��__dict__�copyr�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�r�rrrrrr�rrr�r$r�r*r'r/r;r<r=rErBrHr�rIrJr	rMrQrUrXrZr\r^r_rarcrfrgrmrorprrrtrurvr7rirzr"r}r�r�r�r�r}r}r}r��<module>s,
(=	
,


*L""0	
:




!