
    yIf                   p   d Z ddlmZ ddlZddlZddlZddlZddlmZm	Z	m
Z
mZ ddlmZmZ ddlmZmZmZmZmZmZ ddlmZmZmZ ddlmZmZmZmZ dd	lm Z m!Z!m"Z"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. ddl/m0Z0 ddl1m2Z2m3Z3m4Z4 ddl5m6Z6 ddl7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z> ddl?m@Z@mAZA ddlBmCZC ddlDmEZE ddlFmGZGmHZHmIZImJZJ erddlmKZKmLZL ddlMmNZN dZO ePddh          ZQ ePh d          ZR ed          ZSd ZTd<dZUd=d$ZVd% ZW G d& d'eA          ZX G d( d)e@          ZY G d* d+e@          ZZ G d, d-e@          Z[ G d. d/e@          Z\d0 Z] G d1 d2e<j^        eA          Z_ G d3 d4e<j`        e<j^        e<ja        eA          Zb G d5 d6eb          Zcd>d?d8Zdd>d@d9Zed: Zf G d; d!e<j^        eAe<ja                  ZgdS )Az
This module contains the classes for "scoped" node, i.e. which are opening a
new local scope in the language definition : Module, ClassDef, FunctionDef (and
Lambda, GeneratorExp, DictComp and SetComp to some extent).
    )annotationsN)	GeneratorIterableIteratorSequence)cached_property	lru_cache)TYPE_CHECKINGAnyClassVarLiteralNoReturnTypeVar)bases	protocolsutil)IS_PYPYPY38	PY39_PLUSPYPY_7_3_11_PLUS)CallContextInferenceContextbind_context_to_nodecopy_context)
AstroidBuildingErrorAstroidTypeErrorAttributeInferenceErrorDuplicateBasesErrorInconsistentMroErrorInferenceErrorMroErrorParentMissingErrorStatementMissingTooManyLevelsError)lookup)
ClassModelFunctionModelModuleModel)AstroidManager)	ArgumentsConstNodeNGUnknown_base_nodesconst_factorynode_classes)ComprehensionScopeLocalsDictNodeNG)builtin_lookup)Position)InferBinaryOpInferenceErrorInfoInferenceResultSuccessfulInferenceResult)nodesobjects)LookupMixIn)__iter____getitem__	ExceptionBaseException>   classmethodstaticmethodbuiltins.classmethodbuiltins.staticmethod_Tc                    g }	 d | D             } | s|S | D ]!}|d         }| D ]}||dd         v rd} n n"|st          d| ||          |                    |           | D ]}|d         |k    r|d= s)zMerges MROs in *sequences* to a single MRO using the C3 algorithm.

    Adapted from http://www.python.org/download/releases/2.3/mro/.

    Tc                    g | ]}||S  rG   ).0ss     [/var/www/piapp/venv/lib/python3.11/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py
<listcomp>z_c3_merge.<locals>.<listcomp>U   s    ///1Q/Q///    r      NzTCannot create a consistent method resolution order for MROs {mros} of class {cls!r}.messagemrosclscontext)r   append)	sequencesrQ   rR   results1	candidates2seqs           rJ   	_c3_mergerZ   M   s     F//	///	 	M 	 	B1I  122&& $IE '    		 '4    	i    	 	C1v""F7rL   rT   list[list[ClassDef]]returnNonec                V   | dd         }| d         }t          |          D ]!\  }}|                                dk    r|} n"dS t          |          D ]'\  }}||k    rt          d |D                       r n(dS |                    |           |                    |           dS )a  A class can inherit from typing.Generic directly, as base,
    and as base of bases. The merged MRO must however only contain the last entry.
    To prepare for _c3_merge, remove some typing.Generic entries from
    sequences if multiple are present.

    This method will check if Generic is in inferred_bases and also
    part of bases_mro. If true, remove it from inferred_bases
    as well as its entry the bases_mro.

    Format sequences: [[self]] + bases_mro + [inferred_bases]
    rM   typing.GenericNc              3  F   K   | ]}|                                 d k    V  dS )r`   NqnamerH   bases     rJ   	<genexpr>z+clean_typing_generic_mro.<locals>.<genexpr>   s0      @@Dtzz||//@@@@@@rL   )	enumeraterc   anypop)rT   	bases_mroinferred_basesire   position_in_inferred_basesrY   s          rJ   clean_typing_generic_mrorn   s   s     !B$Ir]N^,,  4::<<+++)*&E , 	 I&&  3***@@C@@@@@ 	E	 	 1222MM,-----rL   rQ   ClassDefrR   InferenceContext | Nonec                    | D ]\}t                      }|D ]I}|j        |                                f}||v rt          d| ||          |                    |           J]| S )Nz,Duplicates found in MROs {mros} for {cls!r}.rN   )setlinenorc   r   add)rT   rQ   rR   sequenceseennodelineno_and_qnames          rJ   clean_duplicates_mrory      s    
  ' 'uu 		' 		'D $TZZ\\:4'')J"#	    HH%&&&&		' rL   c                    t          | t                    rL| j        dk    rt          j        | |          S | j        dk    r| S | j        dk    rt          j        |           S | S )Nr@   propertyrA   )
isinstanceFunctionDeftyper   BoundMethodUnboundMethod)nklasss     rJ   function_to_methodr      si    ![!! *6]""$Q...6ZH6^##&q)))HrL   c                  d    e Zd ZU dZdZded<   	 dZded<   	 dZded	<   	  e            Z		 h d
Z
ded<   	 dZdZ	 	 	 	 dOdP fdZdddQdZd  Zd! ZdRd%Z	 dSdTd+ZdUd-ZdVd.Z	 dWdXd1Z	 dYdZd3Zd[d4Zdd5d\d9Zd: Zd; ZdZd[d<Z	 	 	 d]d^dBZd_dCZdD ZdE Z dYd`dFZ!dG Z"dd5dadJZ#	 dYdbdNZ$ xZ%S )cModulezClass representing an :class:`ast.Module` node.

    >>> import astroid
    >>> node = astroid.extract_node('import astroid')
    >>> node
    <Import l.1 at 0x7f23b2e4e5c0>
    >>> node.parent
    <Module l.0 at 0x7f23b2e4eda0>
    )doc_nodebodyConst | Noner   Nzstr | bytes | None
file_bytes
str | Nonefile_encoding>   __doc____file____name____path____package__zClassVar[set[str]]scope_attrs)namefilepathpackagepure_pythonfuture_imports)localsglobalsFTr   strr   r   Sequence[str] | Noner   boolr   r\   r]   c                    || _         	 || _        	 || _        || _        	 || _        	 |  	 i x| _        | _        	 g | _        	 t                      | _	        	 t                                          dd dd d            d S )Nr   )rs   parent
col_offset
end_linenoend_col_offset)r   r   r   r   r   r   r   r   rr   r   super__init__)selfr   r   r   r   r   	__class__s         rJ   r   zModule.__init__   s     	%		 	@&46U%''dlS/1	)(+.TaDQU 	 	
 	
 	
 	
 	
rL   )r   r   list[node_classes.NodeNG]c               "    || _         || _        d S N)r   r   )r   r   r   s      rJ   postinitzModule.postinit  s     	 rL   c                    | j         t          j        | j                   S | j        t	          | j        d          }|S d S )Nrb)r   ioBytesIOr   open)r   streams     rJ   _get_streamzModule._get_stream  s?    ?&:do...9 $)T**FMtrL   c                *    |                                  S )zaGet a stream to the underlying file or bytes.

        :type: file or io.BytesIO or None
        )r   r   s    rJ   r   zModule.stream$  s    
 !!!rL   rs   inttuple[int, int]c                    | j         | j        fS )zGet a range from where this node starts to where this node ends.

        :param lineno: Unused.

        :returns: The range of line numbers that this node belongs to.
        
fromlinenotolinenor   rs   s     rJ   block_rangezModule.block_range+       --rL   r   rw   r;   offset2tuple[LocalsDictNodeNG, list[node_classes.NodeNG]]c                    || j         v r5|| j        vr,	 | |                     |          fS # t          $ r | g fcY S w xY w|                     |||          S )a  Lookup where the given variable is assigned.

        :param node: The node to look for assignments up to.
            Any assignments after the given node are ignored.

        :param name: The name of the variable to find assignments for.

        :param offset: The line offset to filter statements up to.

        :returns: This scope node and the list of assignments associated to the
            given name according to the scope where it has been found (locals,
            globals or builtin).
        )r   r   getattrr   _scope_lookup)r   rw   r   r   s       rJ   scope_lookupzModule.scope_lookup4  sz      4###DK(?(? T\\$////*      Rx !!$f555s   + <<Literal['builtins.module']c                    dS )eGet the name of the type that this node represents.

        :returns: The name of the type.
        zbuiltins.modulerG   r   s    rJ   pytypezModule.pytypeK  s
    
 ! rL   c                    dS )jA human readable type of this node.

        :returns: The type of this node.
        :rtype: str
        r   rG   r   s    rJ   display_typezModule.display_typeR  s	     xrL   rR   rp   c                   |st          | ||          g }|| j        v }|| j        v rH|sF|sD| j                            |          g}|dk    r"|                    t          d                     n_|s|r| j        |         }nM| j        rF	 |                     |d          g}n,# t          t          f$ r}t          | ||          |d }~ww xY wd |D             }|r|S t          | ||          )Ntarget	attributerR   r   __main__T)relative_onlyc                F    g | ]}t          |t          j                  |S rG   )r|   r0   DelNamerH   r   s     rJ   rK   z"Module.getattr.<locals>.<listcomp>p  *    OOO:a9M+N+NO!OOOrL   )
r   r   special_attributesr%   rS   r/   r   import_moduler   SyntaxError)r   r   rR   ignore_localsrU   name_in_localsexcs          rJ   r   zModule.getattrZ  sP     	X)wWWWW,4***=**-44T::;Fz!!mJ77888 	> 	[&FF\ 	,,T,FFG(+6   -4   POVOOO 	M%TT7SSSSs   B$ $C5CCIterator[InferenceResult]c                    t          |          }||_        	 t          j        |                     ||          ||           S # t
          $ r&}t          t          |          | ||          |d}~ww xY w)Infer the possible values of the given variable.

        :param name: The name of the variable to infer.

        :returns: The inferred possible values.
        framer   N)r   
lookupnamer   _infer_stmtsr   r   r    r   r   r   rR   errors       rJ   igetattrzModule.igetattru  s     w''!	%dll4&A&A7RVWWWW& 	 	 	 E

44  	s   *A 
A3!A..A3c                H    | j         duo| j                             d          S )zCheck if this module has been build from a .py file.

        If so, the module contains a complete representation,
        including the code.

        :returns: Whether the module has been built from a .py file.
        Nz.py)r   endswithr   s    rJ   fully_definedzModule.fully_defined  s&     y$B););E)B)BBrL   futurer   Literal[None, True]r   c               ^    |t          j        dt          d           t          |           )zThe first parent node, including self, marked as statement node.

        When called on a :class:`Module` this raises a StatementMissing.
        Nz.The future arg will be removed in astroid 4.0.   )
stacklevelr   )warningswarnDeprecationWarningr#   r   r   s     rJ   	statementzModule.statement  s?    
 M@"   
 d++++rL   c                    dS )zThe previous sibling statement.

        :returns: The previous sibling statement node.
        :rtype: NodeNG or None
        NrG   r   s    rJ   previous_siblingzModule.previous_sibling        rL   c                    dS )z|The next sibling statement node.

        :returns: The next sibling statement node.
        :rtype: NodeNG or None
        NrG   r   s    rJ   next_siblingzModule.next_sibling  r   rL   c                    | j         S )zWhether :pep:`328` absolute import behaviour has been enabled.

        :returns: Whether :pep:`328` has been enabled.
        )_absolute_import_activatedr   s    rJ   absolute_import_activatedz Module.absolute_import_activated  s    
 ..rL   modnamer   level
int | None	use_cachec                    |r|d}|                      ||          }	 t                                          ||          S # t          $ r |r ||k    r Y nw xY wt                                          ||          S )ax  Get the ast for a given module as if imported from this module.

        :param modname: The name of the module to "import".

        :param relative_only: Whether to only consider relative imports.

        :param level: The level of relative import.

        :param use_cache: Whether to use the astroid_cache of modules.

        :returns: The imported module ast.
        Nr   )r   )relative_to_absolute_namer)   ast_from_module_namer   )r   r   r   r   r   
absmodnames         rJ   r   zModule.import_module  s    &  	U]E33GUCC
	!##88i 9    $ 	 	 	   *$$ %$	 44W	4RRRs   "A AAc                @   |                                  r||S |rE| j        r'|dz
  }| j                            d|          d         }n| j        rt
          j                            t
          j                            | j        d                   dz             snt
          j                            t
          j                            | j        d                   dz   |                    d          d         z             r|dz
  }d}n!| j                            d|          d         }|r4| j        	                    d          |k     rt          || j                  n0| j        r| j        }n!| j                            dd          d         }|r|s|S | d| S |S )	a  Get the absolute module name for a relative import.

        The relative import can be implicit or explicit.

        :param modname: The module name to convert.

        :param level: The level of relative import.

        :returns: The absolute module name.

        :raises TooManyLevelsError: When the relative import refers to a
            module too far above this one.
        NrM   .r   z/__init__.py/ )r   r   )r   r   r   rsplitr   osexistsdirnamesplitcountr$   )r   r   r   package_names       rJ   r   z Module.relative_to_absolute_name  s   " ))++ 	N 	7| ?	#y//U;;A>	
?rwty|'D'D~'UVV
? GNNGOODIaL11C7'--:L:LQ:OO 
? 	!#y//U;;A> F--55(u49EEEE\ 	79LL9++C33A6L 	/ $##"..W...rL   c                   d |                                  D             }	 | d         }n# t          $ r |cY S w xY w	 t          |                                          }n&# t          t
          f$ r |cY S t          $ r |cY S w xY wg }	 t          |                                          }n# t          t
          f$ r |cY S w xY wt          |t          j
        t          j        f          s|S dd}|j        D ]} ||          r|                    |j                   (	 t          |                                          }n# t          t
          f$ r Y ^w xY w ||          r|                    |j                   |S )a  The list of imported names when this module is 'wildcard imported'.

        It doesn't include the '__builtins__' name which is added by the
        current CPython implementation of wildcard imports.

        :returns: The list of imported names.
        :rtype: list(str)
        c                <    g | ]}|                     d           |S _
startswithrH   r   s     rJ   rK   z0Module.wildcard_import_names.<locals>.<listcomp>  s)    LLLDts7K7KL4LLLrL   __all__r\   r   c                j    t          | t          j                  ot          | j        t                    S r   )r|   r0   r+   valuer   )rw   s    rJ   	str_constz/Module.wildcard_import_names.<locals>.str_const0  s'    dL$677WJtzSV<W<WWrL   r\   r   )keysKeyErrornextassigned_stmtsr    StopIterationAttributeErrorinferr|   r0   TupleListeltsrS   r  )r   default
all_valuesexplicitinferredr  rw   inferred_nodes           rJ   wildcard_import_nameszModule.wildcard_import_names  s    MLDIIKKLLL	iJJ 	 	 	NNN		J557788HH. 	 	 	NNN 	 	 	 NNN	 	HNN,,--HH. 	 	 	NNN	(\%79J$KLL 	N	X 	X 	X 	X M 		9 		9Dy 9
++++$($6$6MM&6   H9]++ 9OOM$7888sG   ) 88!A B3B B!B) )B?>B?!E  EEc                >    d |                                  D             S )zThe list of the names that are publicly available in this module.

        :returns: The list of public names.
        :rtype: list(str)
        c                <    g | ]}|                     d           |S r  r  r  s     rJ   rK   z'Module.public_names.<locals>.<listcomp>E  s)    IIIDOOC4H4HIIIIrL   )r  r   s    rJ   public_nameszModule.public_names?  s!     JIIIIIrL   c                    dS )zDetermine the boolean value of this node.

        :returns: The boolean value of this node.
            For a :class:`Module` this is always ``True``.
        TrG   r   rR   s     rJ   
bool_valuezModule.bool_valueG  	     trL   c              #  $   K   | j         E d {V  d S r   r   r   s    rJ   get_childrenzModule.get_childrenO  s&      9rL   r   rD   c                   | S zThe node's frame node.

        A frame node is a :class:`Module`, :class:`FunctionDef`,
        :class:`ClassDef` or :class:`Lambda`.

        :returns: The node itself.
        rG   r   s     rJ   r   zModule.frameR  	     rL   kwargsr   Generator[Module, None, None]c              +     K   | V  d S r   rG   r   rR   r6  s      rJ   _inferzModule._infer\         




rL   )NNFT)r   r   r   r   r   r   r   r   r   r   r\   r]   )r   r   r   r   rs   r   r\   r   r   )rw   r;   r   r   r   r   r\   r   )r\   r   r\   r   )NFrR   rp   r   r   r   rR   rp   r\   r   r  )r   r   r\   r   )FNT)
r   r   r   r   r   r   r   r   r\   r   )r   r   r   r   r\   r   rR   rp   r\   r   r   rD   r   r   r\   rD   )rR   rp   r6  r   r\   r7  )&r   
__module____qualname__r   _astroid_fields__annotations__r   r   r(   r   r   _other_fields_other_other_fieldsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r(  r+  r.  r2  r   r:  __classcell__r   s   @rJ   r   r      s
          +O1 &*J))))8 $M$$$$ %?' ' 'K     MM 0
  %) (
 (
 (
 (
 (
 (
 (
Z LP! ! ! ! ! !  " " ". . . . ;<6 6 6 6 6.! ! ! !    LQT T T T T8 =A    (C C C C :> , , , , , ,     "&/ / / / $ $S $S $S $S $SL. . . .`0 0 0dJ J J       :>       26        rL   r   c                  R     e Zd ZU dZdZdZded<   	 d fdZddZdddZ	d Z
 xZS )GeneratorExpzClass representing an :class:`ast.GeneratorExp` node.

    >>> import astroid
    >>> node = astroid.extract_node('(thing for thing in things if thing)')
    >>> node
    <GeneratorExp l.1 at 0x7f23b2e4e400>
    elt
generatorsr   r,   rN  rs   r   r   r   r   r   r   r\   r]   c               t    i | _         	 g | _        	 t                                          |||||           d S Nrs   r   r   r   r   r   rO  r   r   r   rs   r   r   r   r   r   s         rJ   r   zGeneratorExp.__init__p  S     S575!!) 	 	
 	
 	
 	
 	
rL   rO  list[nodes.Comprehension]c                "    || _         || _        d S r   rM  r   rN  rO  s      rJ   r   zGeneratorExp.postinit      $rL   NrR   rp   Literal[True]c                    dS )zDetermine the boolean value of this node.

        :returns: The boolean value of this node.
            For a :class:`GeneratorExp` this is always ``True``.
        TrG   r-  s     rJ   r.  zGeneratorExp.bool_value  r/  rL   c              #  6   K   | j         V  | j        E d {V  d S r   rM  r   s    rJ   r2  zGeneratorExp.get_children  1      h?"""""""""rL   rs   r   r   r   r   r,   r   r   r   r   r\   r]   rN  r,   rO  rW  r\   r]   r   rR   rp   r\   r[  r   rC  rD  r   rE  rH  rF  r   r   r.  r2  rI  rJ  s   @rJ   rL  rL  b  s           ,O%KKK>
 
 
 
 
 
.% % % %    # # # # # # #rL   rL  c                  ^     e Zd ZU dZdZdZded<   	 ded<   	 d fdZddZdddZ	d Z
 xZS )DictCompzClass representing an :class:`ast.DictComp` node.

    >>> import astroid
    >>> node = astroid.extract_node('{k:v for k, v in things if k > v}')
    >>> node
    <DictComp l.1 at 0x7f23b2e41d68>
    keyr  rO  rP  r,   rf  r  rs   r   r   r   r   r   r   r\   r]   c               d    i | _         	 t                                          |||||           d S rR  )r   r   r   rU  s         rJ   r   zDictComp.__init__  sI     S!!) 	 	
 	
 	
 	
 	
rL   rO  rW  c                0    || _         || _        || _        d S r   re  )r   rf  r  rO  s       rJ   r   zDictComp.postinit  s     
$rL   NrR   rp   c                    t           j        S )zDetermine the boolean value of this node.

        :returns: The boolean value of this node.
            For a :class:`DictComp` this is always :class:`Uninferable`.
        :rtype: Uninferable
        r   Uninferabler-  s     rJ   r.  zDictComp.bool_value       rL   c              #  H   K   | j         V  | j        V  | j        E d {V  d S r   re  r   s    rJ   r2  zDictComp.get_children  s?      hj?"""""""""rL   r_  )rf  r,   r  r,   rO  rW  r\   r]   r   r?  rb  rJ  s   @rJ   rd  rd    s           5O%KKK!MMM#
 
 
 
 
 
(% % % %         # # # # # # #rL   rd  c                  R     e Zd ZU dZdZdZded<   	 d fdZddZdddZ	d Z
 xZS )SetCompzClass representing an :class:`ast.SetComp` node.

    >>> import astroid
    >>> node = astroid.extract_node('{thing for thing in things if thing}')
    >>> node
    <SetComp l.1 at 0x7f23b2e41898>
    rM  rP  r,   rN  rs   r   r   r   r   r   r   r\   r]   c               t    i | _         	 g | _        	 t                                          |||||           d S rR  rT  rU  s         rJ   r   zSetComp.__init__  rV  rL   rO  rW  c                "    || _         || _        d S r   rM  rY  s      rJ   r   zSetComp.postinit  rZ  rL   NrR   rp   c                    t           j        S )zDetermine the boolean value of this node.

        :returns: The boolean value of this node.
            For a :class:`SetComp` this is always :class:`Uninferable`.
        :rtype: Uninferable
        rj  r-  s     rJ   r.  zSetComp.bool_value  rl  rL   c              #  6   K   | j         V  | j        E d {V  d S r   rM  r   s    rJ   r2  zSetComp.get_children  r^  rL   r_  r`  r   r?  rb  rJ  s   @rJ   ro  ro    s           ,O%KKK>
 
 
 
 
 
.% % % %         # # # # # # #rL   ro  c                  R     e Zd ZU dZdZdZded<   	 d fdZddZdddZ	d Z
 xZS )ListCompzClass representing an :class:`ast.ListComp` node.

    >>> import astroid
    >>> node = astroid.extract_node('[thing for thing in things if thing]')
    >>> node
    <ListComp l.1 at 0x7f23b2e418d0>
    rM  rP  r,   rN  rs   r   r   r   r   r   r   r\   r]   c               t    i | _         	 g | _        	 t                                          |||||           d S rR  rT  rU  s         rJ   r   zListComp.__init__  sS     L575!!) 	 	
 	
 	
 	
 	
rL   rO  rW  c                "    || _         || _        d S r   rM  rY  s      rJ   r   zListComp.postinit3  rZ  rL   NrR   rp   c                    t           j        S )zDetermine the boolean value of this node.

        :returns: The boolean value of this node.
            For a :class:`ListComp` this is always :class:`Uninferable`.
        :rtype: Uninferable
        rj  r-  s     rJ   r.  zListComp.bool_value7  rl  rL   c              #  6   K   | j         V  | j        E d {V  d S r   rM  r   s    rJ   r2  zListComp.get_children@  r^  rL   r_  )rN  r,   rO  rW  r   r?  rb  rJ  s   @rJ   ru  ru    s           ,O%KKK>
 
 
 
 
 
.% % % %         # # # # # # #rL   ru  c                    t          | t                    sdS | j        sdS 	 t          |                     | j                  d          }n# t
          $ r Y dS w xY wt          |t          j                  r|j        }t          |t                    r.|
                    d          rdS |
                    d          rdS t          |t                    r|j        sdS |j        j        D ]}t          |t          j                  r|j        t           v r	|j        c S t          |t          j                  rFt          |j        t          j                  r'|j        j        dk    r|j        t           v r	|j        c S dS )z_Detect decorator call chaining and see if the end result is a
    static or a classmethod.
    NrB   r@   rC   rA   builtins)r|   r}   r   r  infer_call_resultr    r   Instance_proxiedro   is_subtype_of
decoratorsr9   r0   Namer   BUILTIN_DESCRIPTORS	Attributeexprattrname)rw   rU   	decorators      rJ   _infer_decorator_callchainr  F  s    dK(( t; td,,T[994@@   tt&%.)) !&(## " 677 	! = 788 	"!>&+&& *  	4*0 
	* 
	*I)\%677 *>%888$>)))9l&<==*y~|/@AA* N':55&*=== ))))4s   (A 
AAc                      e Zd ZU dZdZded<   dZded<   dZdZ e	            Z
	 d	ed
<   	 ded<   	 dAdZedBd            ZdC fdZdDdZdEdZdFdZdGd!ZdHd#Z	 dIdJd*Z	 dKdLd1ZdIdMd2Zd3 Zd$d4dNd9Z	 dIdOd;Z	 dIdPd?Zd@ Z xZS )QLambdazClass representing an :class:`ast.Lambda` node.

    >>> import astroid
    >>> node = astroid.extract_node('lambda arg: arg + 1')
    >>> node
    <Lambda.<lambda> l.1 at 0x7f23b2e41518>
    argsr   zClassVar[tuple[str, ...]]rE  rP  rH  z<lambda>Tr*   r  r,   r   r\   
Literal[0]c                    dS )Nr   rG   r   s    rJ   implicit_parameterszLambda.implicit_parameters      qrL   Literal['method', 'function']c                    | j         j        rP| j         j        d         j        dk    r5| j        r.t	          | j                                        t                    rdS dS )zuWhether this is a method or function.

        :returns: 'method' if this is a method, 'function' otherwise.
        r   r   methodfunction)r  	argumentsr   r   r|   scopero   r   s    rJ   r~   zLambda.type  s[     9 	 49#6q#9#>&#H#H{  z$+*;*;*=*=xHH  xzrL   rs   r   r   r   r   r   r   c               r    i | _         	 i | _        t                                          |||||           d S rR  )r   instance_attrsr   r   rU  s         rJ   r   zLambda.__init__  sQ     L79!!) 	 	
 	
 	
 	
 	
rL   r]   c                "    || _         || _        d S r   r  )r   r  r   s      rJ   r   zLambda.postinit  s    				rL   7Literal['builtins.instancemethod', 'builtins.function']c                    d| j         v rdS dS r   r  zbuiltins.instancemethodzbuiltins.functionr~   r   s    rJ   r   zLambda.pytype      
 ty  ,,""rL   r   c                    d| j         v rdS dS r   r  MethodFunctionr  r   s    rJ   r   zLambda.display_type       ty  8zrL   r[  c                    dS )zWhether this node defines something that is callable.

        :returns: Whether this defines something that is callable
            For a :class:`Lambda` this is always ``True``.
        TrG   r   s    rJ   callablezLambda.callable  r/  rL   	list[str]c                P    | j         j        rd | j         j        D             }ng }|S )  Get the names of each of the arguments, including that
        of the collections of variable-length arguments ("args", "kwargs",
        etc.), as well as positional-only and keyword-only arguments.

        :returns: The names of the arguments.
        :rtype: list(str)
        c                    g | ]	}|j         
S rG   r   rH   rN  s     rJ   rK   z#Lambda.argnames.<locals>.<listcomp>      ===#SX===rL   r  r  r   namess     rJ   argnameszLambda.argnames  5     9 	==)<===EEErL   Ncaller SuccessfulInferenceResult | NonerR   rp   r   c                6    | j                             |          S ),Infer what the function returns when called.)r   r  )r   r  rR   s      rJ   r|  zLambda.infer_call_result  s     yw'''rL   r   rw   r;   r   r   %tuple[LocalsDictNodeNG, list[NodeNG]]c                   | j         j        r|| j         j        v s| j         j        rA|| j         j        v r3| j        st	          |           | j                                        }d}n| }|                    |||          S )a  Lookup where the given names is assigned.

        :param node: The node to look for assignments up to.
            Any assignments after the given node are ignored.

        :param name: The name to find assignments for.

        :param offset: The line offset to filter statements up to.

        :returns: This scope node and the list of assignments associated to the
            given name according to the scope where it has been found (locals,
            globals or builtin).
        r   r_   )r  defaultskw_defaultsr   r"   r   r   r   rw   r   r   r   s        rJ   r   zLambda.scope_lookup  s      I 	449+=#=#=I! $>&*di.C&C&C; 6(5555K%%''E FF E""4v666rL   c                    dS )zDetermine the boolean value of this node.

        :returns: The boolean value of this node.
            For a :class:`Lambda` this is always ``True``.
        TrG   r-  s     rJ   r.  zLambda.bool_value  r/  rL   c              #  .   K   | j         V  | j        V  d S r   r  r   s    rJ   r2  zLambda.get_children  s       iirL   r   r   rD   r   r   c                   | S r4  rG   r   s     rJ   r   zLambda.frame  r5  rL   list[NodeNG]c                    |st          | ||          g }|| j        v r| j        |         }|| j        v r-|                    | j                            |                     |r|S t          | |          Nr   )r   r   r   r  r   rS   r%   r   r   rR   found_attrss       rJ   r   zLambda.getattr        	X)wWWWW4&&&-d3K4***t6==dCCDDD 	%TTBBBBrL   r6  r   Generator[Lambda, None, None]c              +     K   | V  d S r   rG   r9  s      rJ   r:  zLambda._infer  r;  rL   c              #  H   K   | j                                         E d{V  dS )z3A Lambda node can contain a Yield node in the body.N)r   _get_yield_nodes_skip_functionsr   s    rJ   r  z&Lambda._get_yield_nodes_skip_functions#  s2      9<<>>>>>>>>>>>rL   )r\   r  )r\   r  )
rs   r   r   r   r   r,   r   r   r   r   )r  r*   r   r,   r\   r]   r\   r  r>  r\   r[  r\   r  r   r  r  rR   rp   r\   r   r=  )rw   r;   r   r   r   r   r\   r  ra  rB  r   r   rR   rp   r\   r  )rR   rp   r6  r   r\   r  )r   rC  rD  r   rE  rF  rH  r   	is_lambdar'   r   r  r{   r~   r   r   r   r   r  r  r|  r   r.  r2  r   r   r:  r  rI  rJ  s   @rJ   r  r  k  s          2BOAAAA5@@@@@DI&AOOO0LLL,       X
 
 
 
 
 
,   # # # #         $ ,0( ( ( ( ( ;<7 7 7 7 7<       :>       =AC C C C C  26    
? ? ? ? ? ? ?rL   r  c                      e Zd ZU dZdZdZdZded<   	 ded<   	 d	ed
<   	 dZ	 dZ		 dZ
	 dZ	 dZdZdZdZ e            Z	 dW fdZ	 	 	 	 dXdddddYd#ZedZd%            Zd[d'Zd\d(Zd]d*Zd^d,Z	 d_d`d/Zed\d0            Zedad1            Zed2             Zdbd4Zdcd6Z	 d_ddd8Z ded:Z!d_dfd<Z"ded=Z#dgded?Z$ded@Z%	 d_dhdDZ&d_didEZ'	 d_djdHZ(d_dkdIZ)dJ Z*	 dldmdPZ+ddQdndVZ, xZ-S )or}   zClass representing an :class:`ast.FunctionDef`.

    >>> import astroid
    >>> node = astroid.extract_node('''
    ... def my_func(arg):
    ...     return arg + 1
    ... ''')
    >>> node
    <FunctionDef.my_func l.2 at 0x7f23b2e71e10>
    )r  r  returnstype_paramsr   r   r1  Nnode_classes.Decorators | Noner  r   r   r*   r  T)r   position)r   _typetype_comment_returnstype_comment_argsz<functiondef>r   r   rs   r   r   r   r,   r   r   r   r\   r]   c               ,   || _         	 i | _        	 g | _        	 g | _        	 i | _        t                                          |||||           |rAt          |t                    s.|	                                }|
                    ||            d S d S d S rR  )r   r   r   r  r  r   r   r|   r-   r   	set_local)	r   r   rs   r   r   r   r   r   r   s	           rJ   r   zFunctionDef.__init__o  s     	'L"$	0  	 	\79!!) 	 	
 	
 	
  	(*VW55 	(LLNNEOOD$'''''	( 	( 	( 	(rL   r  r   r  r   r  r  Position | Noner  Alist[nodes.TypeVar | nodes.ParamSpec | nodes.TypeVarTuple] | Nonec                   || _         || _        || _        || _        || _        || _        || _        || _        |	pg | _        dS )a  Do some setup after initialisation.

        :param args: The arguments that the function takes.

        :param body: The contents of the function body.

        :param decorators: The decorators that are applied to this
            method or function.
        :params type_comment_returns:
            The return type annotation passed via a type comment.
        :params type_comment_args:
            The args type annotation passed via a type comment.
        :params position:
            Position of function keyword(s) and name.
        :param doc_node:
            The doc node associated with this node.
        :param type_params:
            The type_params associated with this node.
        N)	r  r   r  r  r  r  r  r   r  )
r   r  r   r  r  r  r  r  r   r  s
             rJ   r   zFunctionDef.postinit  sR    D 		$$8!!2  &,"rL   list[node_classes.Call]c                H   | j         r.t          | j                                         x}t                    sg S g }|j        D ]}t          |j        t          j                  rt          |j        j        t          j	                  r|j
        D ]}t          |t          j                  s|j        | j        k    r.	 || j                 }t          |t                    r2|                                |k    r|                    |j                   # t          $ r Y w xY w|S )a  The extra decorators that this function can have.

        Additional decorators are considered when they are used as
        assignments, as in ``method = staticmethod(method)``.
        The property will return all the callables that are used for
        decoration.
        )r   r|   r   ro   _assign_nodes_in_scoper  r0   Callfuncr  targets
AssignNamer   r}   rS   r  )r   r   r  assignassign_nodemeths         rJ   extra_decoratorszFunctionDef.extra_decorators  sC    { 	*dk6G6G6I6I-IU8"T"T 	I.0
2 	< 	<F&,(9:: <z!<#4@ @ < $*> < <K%k<3JKK ! "'4944 !<$TY/ 't[99< + 1 1 3 3u < <&--fl;;; $ ! ! ! ! s   <D
DDr  c                    d| j         v rdS dS r  r  r   s    rJ   r   zFunctionDef.pytype  r  rL   c                    d| j         v rdS dS r  r  r   s    rJ   r   zFunctionDef.display_type  r  rL   r[  c                    dS NTrG   r   s    rJ   r  zFunctionDef.callable  s    trL   r  c                P    | j         j        rd | j         j        D             }ng }|S )r  c                    g | ]	}|j         
S rG   r  r  s     rJ   rK   z(FunctionDef.argnames.<locals>.<listcomp>  r  rL   r  r  s     rJ   r  zFunctionDef.argnames  r  rL   rR   rp   c                    |st          | ||          g }|| j        v r| j        |         }|| j        v r-|                    | j                            |                     |r|S t          | |          r  r  r  s       rJ   r   zFunctionDef.getattr  r  rL   c                   | j         D ]#}|j        j        t          v r|j        j        c S $| j        st          |           | j                                        }d}t          |t                    r)| j        dk    rdS | j        dk    rdS | j        dk    rdS d}| j	        s|S | j	        j
        D ]}t          |t          j                  r|j        t          v r	|j        c S t          |t          j                  rFt          |j        t          j                  r'|j        j        dk    r|j        t          v r	|j        c S t          |t          j                  rT	 t#          |j                                                  }n# t&          t(          f$ r Y w xY wt+          |          }||c S 	 |                                D ]}t+          |          }||c c S t          |t                    s/|                                D ]L}t          |t                    s|                    d
          r   dS |                    d          r   dS M# t&          $ r Y w xY w|S )ztThe function type for this node.

        Possible values are: method, function, staticmethod, classmethod.
        r   r  __new__r@   __init_subclass____class_getitem__r  r{  NrB   rC   rA   )r  r  r   r  r   r"   r   r|   ro   r  r9   r0   r  r  r  r  r  r  r  r    r  r  	ancestorsr  )	r   r  r   	type_namerw   currentr  r&  ancestors	            rJ   r~   zFunctionDef.type  s    . 	+ 	+I~"&999 ~**** : { 	2$D1111!!##	eX&& 	!yI%%$}y///$}y///$} I 	O) *	 *	D$ 122 %9 3339$$$4!788%ty,*;<<% INj00M%888}$$$$ 122 !
"49??#4#455GG&6   H27;;$ LLL $

 2 2H6x@@E($%h99 ! $,$6$6$8$8 2 2)(H== %$#112HII 1#0====#112IJJ 2#1>>>>222 "   s7    &FFF4*I!AI=II
I)(I)c                v    | j         pd}| j        &|t          d | j        j        D                       z  }|pdS )The first line that this node appears on in the source code.

        Can also return 0 if the line can not be determined.
        r   Nc              3  >   K   | ]}|j         |j        pd z
  dz   V  dS r   rM   Nr   rs   rH   rw   s     rJ   rf   z)FunctionDef.fromlineno.<locals>.<genexpr>o  sF        ;?!12Q6     rL   )rs   r  sumr9   r   s     rJ   r   zFunctionDef.fromlinenoe  s[     !?&c  CG?CX     F {rL   c                    | j         j        S )PThe line on which the beginning of this block ends.

        :type: int
        )r  r   r   s    rJ   blockstart_tolinenozFunctionDef.blockstart_tolinenou  s     y!!rL   Literal[0, 1]c                2    |                                  rdndS )NrM   r   )is_boundr   s    rJ   r  zFunctionDef.implicit_parameters}  s    MMOO*qq*rL   r   c                    | j         | j        fS zGet a range from the given line number to where this node ends.

        :param lineno: Unused.

        :returns: The range of line numbers that this node belongs to,
        r   r   s     rJ   r   zFunctionDef.block_range  r   rL   r   c                    	 t          j        |                     ||          ||           S # t          $ r&}t	          t          |          | ||          |d}~ww xY w)zCInferred getattr, which returns an iterator of inferred statements.r   r   N)r   r   r   r   r    r   r   s       rJ   r   zFunctionDef.igetattr  sv    	%dll4&A&A7RVWWWW& 	 	 	 E

44  	s   *- 
A!AAr   c                    | j         dk    o4| j        duo+t          | j                                        t                    S )zfCheck if this function node represents a method.

        :returns: Whether this is a method.
        r  N)r~   r   r|   r   ro   r   s    rJ   	is_methodzFunctionDef.is_method  sB     I# :4':4;,,..99	
rL   set[str]c                   t                      }g }| j        || j        j        z  }|| j        z  }|D ]S}	 |                    |          D ])}|                    |                                           *D# t          $ r Y Pw xY w|S )zGet the qualified names of each of the decorators on this function.

        :param context:
            An inference context that can be passed to inference functions
        :returns: The names of the decorators.
        NrR   )rr   r  r9   r  r  rt   rc   r    )r   rR   rU   decoratornodesdecnodeinfnodes         rJ   decoratornameszFunctionDef.decoratornames  s     ?&do33N$//% 	 	G&}}W}== 0 0GJJw}}////0!   s   A A77
BBc                    | j         dv S )zCheck if the function is bound to an instance or class.

        :returns: Whether the function is bound to an instance or class.
        >   r  r@   r  r   s    rJ   r  zFunctionDef.is_bound  s    
 y555rL   Fc                   | j         rd| j         j        D ]W}	 t          |                                          }n# t          t
          f$ r Y 8w xY w|r|                                dv r dS X| j        D ]U}t          |t          j
                  r|r dS |                                r dS |ot          |t          j                  c S |rdS dS )a  Check if the method is abstract.

        A method is considered abstract if any of the following is true:
        * The only statement is 'raise NotImplementedError'
        * The only statement is 'raise <SomeException>' and any_raise_is_abstract is True
        * The only statement is 'pass' and pass_is_abstract is True
        * The method is annotated with abc.astractproperty/abc.abstractmethod

        :returns: Whether the method is abstract.
        >   abc.abstractmethodabc.abstractpropertyTF)r  r9   r  r  r    r  rc   r   r|   r0   Raiseraises_not_implementedPass)r   pass_is_abstractany_raise_is_abstractrw   r&  
child_nodes         rJ   is_abstractzFunctionDef.is_abstract  s    ? 
	 - 	  	 #DJJLL11HH&6   H   0 0 5 ! !  44) 	R 	RJ*l&899  (  444466  44#Q
:|?P(Q(QQQQ 	4us   !9AAc                    t          |                                           }t          |                                           }t          ||z            S )zhCheck if this is a generator function.

        :returns: Whether this is a generator function.
        )rr   _get_yield_nodes_skip_lambdasr  r   )r   yields_without_lambdasyields_without_functionss      rJ   is_generatorzFunctionDef.is_generator  sM    
 "%T%G%G%I%I!J!J#&t'K'K'M'M#N#N *-EEFFFrL   r6  r   CGenerator[objects.Property | FunctionDef, None, InferenceErrorInfo]c              +    K   ddl m | j        rt          j        |           s| V  t          | |          S | j        st          |           | j                                        }| j	        |j
        v o*t          fd|j
        | j	                 D                       }t          | j        t          j        t          j        f          rd} j        | | j	        | j        |s| j        nd | j                  }|r| j        |_        |                    g | j        | j                   |V  t          | |          S )	Nr   r:   rw   rR   r   c              3  B   K   | ]}t          |j                  V  d S r   )r|   Property)rH   valr:   s     rJ   rf   z%FunctionDef._infer.<locals>.<genexpr>  sI       U
 U
25JsG,--U
 U
 U
 U
 U
 U
rL   T)r  r   rs   r   r   )r   r  r   )astroidr:   r  r   _is_propertyr6   r   r"   r   r   r   rh   r|   r0   TryIfr$  rs   r   r   r  r   )r   rR   r6  parent_frame!property_already_in_parent_locals	prop_funcr:   s         @rJ   r:  zFunctionDef._infer  s      	$##### 	Be&8&>&> 	BJJJ%4AAAA { 	2$D1111{((**,0I9L,L -
QT U
 U
 U
 U
9E9LTY9WU
 U
 U
 R
 R
) K|/
 
 	5 15-$G$;&GQ4;;T
 
 
	 - 	+#{IT]KKK!tW====rL   c              #  &  K   |                      t          j                  D ]n}|j        ,t          j        d          }||_        |j        |_        |V  5|                                | k    r!|j                            |          E d{V  odS )zInfer what the function yields when called

        :returns: What the function yields
        :rtype: iterable(NodeNG or Uninferable) or None
        Nr
  )	nodes_of_classr0   Yieldr  r+   r   rs   r  r  )r   rR   yield_consts       rJ   infer_yield_resultzFunctionDef.infer_yield_result  s       )),*<== 	? 	?F|#$*400%%}4''!<--g->>>>>>>>>	? 	?rL   r  r  c              #    K   |                                  rAt          | t                    rt          j        }nt          j        } ||           }|V  dS | j        dk    r|| j        j        rt          | j        j                  dk    r~| j        j	        qt          |j        t                    rB|j        j        J t          |j        j        d                                       d          }nmt          |j        t                    r/t          |j        d                                       d          }n$t          dt          |j                             t          |t                     r	 fd|j        dd         D             }n1# t"          $ r$}t%          |j        dd                   |d}~ww xY wt!          d	dddd| 
          }d|_        |                    d |D             g d|           |V  dS |                                 }	t          |	d          }
|
sT| j        r>|                     dd          rt0          j        V  nt5          j        d          V  dS t%          d          t9          j        |
f|	          D ]_}|j        t5          j        d          V   	 |j                                      E d{V  B# t$          $ r t0          j        V  Y \w xY wdS )r  )generator_initial_contextNwith_metaclassrM   r   z0caller.args was neither Arguments nor list; got c           	         g | ]E}t          d  |                    r                                n          D                       FS )c              3  R   K   | ]"}t          |t                    r|j        |V  #d S r   r|   r+   r  rH   bs     rJ   rf   z;FunctionDef.infer_call_result.<locals>.<listcomp>.<genexpr>K  sK         ! %/q%$8$8
 >?W_	  >M___ rL   r
  )r  r  clone)rH   argrR   s     rJ   rK   z1FunctionDef.infer_call_result.<locals>.<listcomp>I  sx     
# 
# 
#     %(YY;B(O &/ & &    
# 
# 
#rL   r"  temporary_class)r   rs   r   r   r   r   Tc                F    g | ]}t          |t          j                  |S rG   r|   r   UninferableBaserd   s     rJ   rK   z1FunctionDef.infer_call_result.<locals>.<listcomp>`  s;        )$0DEE  rL   )r   r   r  	metaclass)r  r  z0The function does not have any return statements)r  r|   AsyncFunctionDefr   AsyncGeneratorr   r   r  lenvarargr*   r  r  list	TypeErrorr~   ro   r  r    hider    _get_return_nodes_skip_functionsr   r  r   rk  r0   r+   	itertoolschainr  )r   r  rR   generator_clsrU   rA  class_basese	new_classr  first_return
returnnodes     `         rJ   r|  zFunctionDef.infer_call_result#  s       	$ 011 07<7K %"]47KKKFLLLF I)))"	 #DIN##q((	 ,&+y11 {'333 !1!!4!:!:7!C!CTJJ		FK..  Q!5!5g!>!>EE		ZtFKGXGXZZ   )X.. #W
# 
# 
# 
# $*;qrr?
# 
# 
#KK % W W W(fk!""owOOOUVVW$*  #$  	 "&	"" $/  
 #' # 	 	 	  7799GT** 	Uy ##TQU#VV 3*****&,T22222 !STTT#/</7CC 	+ 	+J'"(......+)/55g>>>>>>>>>>% + + +******+	+ 	+s*   ?F 
G	%GG	 K##K>=K>c                    dS )zDetermine the boolean value of this node.

        :returns: The boolean value of this node.
            For a :class:`FunctionDef` this is always ``True``.
        TrG   r-  s     rJ   r.  zFunctionDef.bool_value  r/  rL   c              #     K   | j         	| j         V  | j        V  | j        	| j        V  | j        E d {V  | j        E d {V  d S r   )r  r  r  r  r   r   s    rJ   r2  zFunctionDef.get_children  sx      ?&/!!!i<#,########9rL   r   rw   r;   r   +tuple[LocalsDictNodeNG, list[nodes.NodeNG]]c                   |dk    r:| j         r3t          | j                                         x}t                    r| |gfS | j        j        r|| j        j        v s| j        j        rA|| j        j        v r3| j         st          |           | j                                         }d}n| }|                    |||          S )z(Lookup where the given name is assigned.r   r   r_   )	r   r|   r   ro   r  r  r  r"   r   r  s        rJ   r   zFunctionDef.scope_lookup  s     ;
 { %z4;3D3D3F3F*F%QQ %eW}$I 	449+=#=#=I! $>&*di.C&C&C; 6(5555K%%''E FF E""4v666rL   r   r   rD   r   r   c                   | S r4  rG   r   s     rJ   r   zFunctionDef.frame  r5  rL   r   r   rs   r   r   r   r   r,   r   r   r   r   r\   r]   )NNNN)r  r*   r   r  r  r  r  r  r   r   r  r  )r\   r  r  r>  r  r  r   r  r\   r   )r\   r   r<  r@  r  )rR   rp   r\   r  )TF)rR   rp   r6  r   r\   r  r?  r  rA  r=  rw   r;   r   r   r   r   r\   rT  rB  ).r   rC  rD  r   rE  _multi_line_block_fieldsr  rF  is_functiontype_annotationr  r  rG  rH  r  r   r'   r   r   r   r   r  r   r   r  r  r   r~   r   r  r  r   r   r  r  r  r  r  r:  r2  r|  r.  r2  r   r   rI  rJ  s   @rJ   r}   r}   (  s        	 	O  )G....E1OOO0K O   \(M ED&A#( #( #( #( #( #(R 6:!*- %)!% *- *- *- *- *- *-X % % % _%N# # # #           =AC C C C C F F F _FP    _ " " _"+ + + +. . . . =A	 	 	 	 	
 
 
 
    (6 6 6 6" " " " "HG G G G 26&> &> &> &> &>P? ? ? ? ?( ,0\+ \+ \+ \+ \+|    
 
 
 ;<7 7 7 7 74 :>          rL   r}   c                      e Zd ZdZdS )rB  a  Class representing an :class:`ast.FunctionDef` node.

    A :class:`AsyncFunctionDef` is an asynchronous function
    created with the `async` keyword.

    >>> import astroid
    >>> node = astroid.extract_node('''
    async def func(things):
        async for thing in things:
            print(thing)
    ''')
    >>> node
    <AsyncFunctionDef.func l.2 at 0x7f23b2e416d8>
    >>> node.body[0]
    <AsyncFor l.3 at 0x7f23b2e417b8>
    N)r   rC  rD  r   rG   rL   rJ   rB  rB    s           rL   rB  r   c                   | j         dk    rdS |t                      }| j        D ]}	 |                    |          D ]}|                                }||v r|                    |           t          |t          j                  r  dS || u rSt          |t                    si|j	        dk    r  dS t          |||          r  dS # t          $ r Y w xY wdS )z>Return if the given class can be
    used as a metaclass.
    r~   TNr
  FrA  )r   rr   r   r  rc   rt   r|   r}  ro   r  _is_metaclassr    )r   rv   rR   re   baseobjbaseobj_names         rJ   r_  r_    s+    zVt|uu  	::g:66    &}}4''&&&gu~66 ! 555e##!'844 =K//444 $@@@  444  "  	 	 	H	5s$   A!C'C6CC
CCc                   | j         | j         S t          | |          rd| _         n| j                            d          rd| _         n|t	                      }|                                 }||v r	d| _         dS |                    |           |                     d          D ]<}t          ||          }|dk    r$|dk    rt          |           s.|j	        | _          n=| j         d| _         | j         S )	z]return a ClassDef node type to differ metaclass and exception
    from 'regular' classes
    Nr
  rA  r>   	exceptionclassF)recurs)
r  r_  r   r   rr   rc   rt   r  _class_typer~   )r   r  rR   
klass_namere   r   s         rJ   rf  rf    s   
 {{UG,,, !			[	)	) !I[[]]
""!EK7j!!!OO5O11 	 	DtY//Dw;&&}U/C/C& "i  {;rL   c                    |                                  }|Ot          |t                    s:|j        d}n|j                                         }|t          |t                    :|S )zGet the class that wraps the given node.

    We consider that a class wraps a node if the class
    is a parent for the said node.

    :returns: The class that wraps the given node
    :rtype: ClassDef or None
    N)r   r|   ro   r   )rw   r   s     rJ   get_wrapping_classri    sf     JJLLE

Juh$?$?
<EEL&&((E	 
Juh$?$?

 LrL   c                      e Zd ZU dZdZdZ	  e            Z	 dZdZ	de
d<   dZdZ eed          Zd	Zd
ZdZde
d<   d~ fdZej        Zde
d<   ddZd Z	 	 	 ddddddd0Zddd3ZdZ eed4          Zed fd5            Zed6             Zdd8Zdd:Z dd;Z!dd=Z"ddd>Z#d? Z$	 dddCZ%	 dddIZ&edJ             Z'	 dddNZ(dddOZ)dddPZ*ddQZ+dddRZ,dddSZ-ddUZ.	 	 dddXZ/ e0dYZ          d[             Z1d\ Z2	 	 ddd]Z3ddd^Z4ddd_Z5d` Z6da Z7db Z8	 dddcZ9	 dddfZ:	 dddgZ;dh Z<di Z=dj Z>edk             Z?dl Z@dddmZAdddnZBdddpZCdddrZDds ZEedt             ZFdduddzZG	 ddd}ZH xZIS )ro   a  Class representing an :class:`ast.ClassDef` node.

    >>> import astroid
    >>> node = astroid.extract_node('''
    class Thing:
        def my_meth(self, arg):
            return arg + self.offset
    ''')
    >>> node
    <ClassDef.Thing l.2 at 0x7f23b2e9e748>
    )r  r   keywordsr   r   r  NNodeNG | None
_metaclassFz\The class type for this node.

Possible values are: class, metaclass, exception.

:type: str)doc)r   is_dataclassr  )r   	_newstylebool | Nonerp  r   r   rs   r   r   r   r,   r   r   r   r\   r]   c                  i | _         i | _        	 g | _        	 g | _        	 g | _        	 || _        	 d | _        	 d | _        	 d| _        	 g | _	        	 t                                          |||||           |r=t          |t                    s(|                                                    ||            |                                 D ]\  }}|                     ||           d S )NFrS  )r  r   rk  r   r   r   r  r   ro  r  r   r   r|   r-   r   r  implicit_localsadd_local_node)
r   r   rs   r   r   r   r   
local_namerw   r   s
            rJ   r   zClassDef.__init__Y  s!    24L46	
 79
+"$	-	$<&*5"'0  	 	M!!) 	 	
 	
 	
  	1*VW55 	1LLNN$$T4000 $ 4 4 6 6 	2 	2Jj1111	2 	2rL   z!ClassVar[InferBinaryOp[ClassDef]]infer_binary_op
Literal[1]c                    dS )NrM   rG   r   s    rJ   r  zClassDef.implicit_parameters  r  rL   c                H    d| j         j        ff}|d| j         j        ffz  }|S )zGet implicitly defined class definition locals.

        :returns: the the name and Const pair for each local
        :rtype: tuple(tuple(str, node_classes.Const), ...)
        rC  rD  )r   attr___module__attr___qualname__)r   locals_s     rJ   rs  zClassDef.implicit_locals  s4     !$"9"IJL^T%<%NOQQrL   r  r   list[SuccessfulInferenceResult]r   r  r  r  newstylerA  rk  !list[node_classes.Keyword] | Noner  r  r   r   r  r  c                   ||| _         || _        || _        || _        || _        || _        || _        || _        |	pg | _        d S r   )	rk  r   r   r  rp  rm  r  r   r  )
r   r   r   r  r~  rA  rk  r  r   r  s
             rJ   r   zClassDef.postinit  sU     $DM
	$!#  &,"rL   rR   rp   c                b   |t                      }| j        | j        S |                     d|          D ] }|                    |          r	d| _         n!|                                 }|/t          |t                    r|                    |          | _        | j        d| _        | j        S )NFre  rR   T)r   rp  r  _newstyle_impldeclared_metaclassr|   ro   )r   rR   re   r   s       rJ   r  zClassDef._newstyle_impl  s    ?&((G>%>!NN%NAA 	 	D""7++ !% '')) E8!<!<"11'::DN>!"DN~rL   z=Whether this is a new style class or not

:type: bool or Nonec                    t           rHt          rAt          s:| j        pd}| j        &|t          d | j        j        D                       z  }|pdS t                      j        S )r  r   Nc              3  >   K   | ]}|j         |j        pd z
  dz   V  dS r  r  r  s     rJ   rf   z&ClassDef.fromlineno.<locals>.<genexpr>  sI         MT[%5A6:     rL   )	r   r   r   rs   r  r  r9   r   r   )r   rs   r   s     rJ   r   zClassDef.fromlineno  s      	t 	$4 	 [%AF*#   $ 5     
 ;Qww!!rL   c                B    | j         r| j         d         j        S | j        S )r  r_   )r   r   r   r   s    rJ   r  zClassDef.blockstart_tolineno  s%     : 	+:b>**rL   r   c                    | j         | j        fS r  r   r   s     rJ   r   zClassDef.block_range  r   rL   -Literal['builtins.type', 'builtins.classobj']c                    | j         rdS dS )r   builtins.typezbuiltins.classobj)r~  r   s    rJ   r   zClassDef.pytype  s    
 = 	#"?""rL   c                    dS )r   ClassrG   r   s    rJ   r   zClassDef.display_type  s	     wrL   r   c                    dS )zWhether this node defines something that is callable.

        :returns: Whether this defines something that is callable.
            For a :class:`ClassDef` this is always ``True``.
        TrG   r   s    rJ   r  zClassDef.callable  r/  rL   c                    |                                  k    rdS t          fd|                     |          D                       S )zWhether this class is a subtype of the given type.

        :param type_name: The name of the type of check against.
        :type type_name: str

        :returns: Whether this class is a subtype of the given type.
        Tc              3  H   K   | ]}|                                 k    V  d S r   rb   )rH   ancr  s     rJ   rf   z)ClassDef.is_subtype_of.<locals>.<genexpr>"  s0      WW399;;)+WWWWWWrL   r
  )rc   rh   r  )r   r  rR   s    ` rJ   r  zClassDef.is_subtype_of  sN     ::<<9$$4WWWWt~~g~7V7VWWWWWWrL   c           	        	 t          |j        d                             |                    }n/# t          $ r"}t	          |j        d         |          |d }~ww xY wt          |t          j                  r"t          |j        t                    r|j        }nt          j        S t          |ddddt                                }	 t          |j        d                             |                    }n/# t          $ r"}t	          |j        d         |          |d }~ww xY wt          |t          j        t          j        f          rkg }|                                D ]L}	t          |	                    |          d           }
|
r$ |j        t          j        |	|
                     M||_        nt          j        S 	 t          |j        d                             |                    }n# t          t          f$ r d }Y nw xY w|rkt          |t          j                  rQ|j        D ]I\  }}t          |t          j                  r*t          |j        t                    r|g|j        |j        <   J|j        |_        |S )Nr   r"  rS  rM   r
  )originalr  r   )r  r  r  r  r    r|   r0   r+   r  r   r   rk  ro   r-   r   r!  iteredrS   EvaluatedObjectr   Dictitemsr   r   )r   r  rR   	name_noderN  r   rU   rM  r   re   r&  membersattrr  s                 rJ   _infer_type_callzClassDef._infer_type_call$  s   	NV[^11'::;;II 	N 	N 	N fk!ngFFFAM	Ni!344 	$OS:
 :
 	$ ?DD##99
 
 
	Nv{1~33G<<==KK 	N 	N 	N fk!ngFFFAM	NkL$68I#JKK 	$E#**,,  

7
 ; ;TBB  EL$4d(SSS   !FLL
 ##	6;q>//8899GG. 	 	 	GGG	  	8z'<+<== 	8&} 8 8edL$677 8JtzSV<W<W 816FM$*-s>   -0 
AAA	-C7 7
D#DD#-G2 2HHr  r  r   c              #  0  K   |                      d|          r4t          |j                  dk    r|                     ||          }|V  dS d}	 |                     |          }|,d|j        v r#t          |                    d|                    }n# t          t          f$ r Y nw xY w|rR|
                                dk    r:t          ||           }||j        _        |                    ||          E d{V  dS |                                 V  dS )z+infer what a class is returning when calledr     Nr
  __call__zbuiltins.type.__call__)r  rD  r  r  rA  r   r  r   r   r  rc   r   callcontextcalleer|  instantiate_class)r   r  rR   rU   dunder_callrA  s         rJ   r|  zClassDef.infer_call_result[  sW      ow77 	C<L<LPQ<Q<Q**67;;FLLLF
	w77I$
 !111"&y'9'9*g'N'N"O"OK'7 	 	 	D	  	+;,,..2JJJ +7D99G)4G&"44VWEEEEEEEEEEE((*******s   AB B)(B)r   rw   r;   r   rT  c                H   t          j        t          j                  o|t	                      j        v }t          fd| j        D                       s|r3| j        st          |           | j        	                                }d}n| }|
                    ||          S )a  Lookup where the given name is assigned.

        :param node: The node to look for assignments up to.
            Any assignments after the given node are ignored.

        :param name: The name to find assignments for.

        :param offset: The line offset to filter statements up to.

        :returns: This scope node and the list of assignments associated to the
            given name according to the scope where it has been found (locals,
            globals or builtin).
        c              3  N   K   | ]}|k    p|                               V   d S r   )	parent_of)rH   re   rw   s     rJ   rf   z(ClassDef.scope_lookup.<locals>.<genexpr>  s8      LL4t 4 4LLLLLLrL   r   r_   )r|   r   r0   
Decoratorsr)   builtins_modulerh   r   r"   r   r   )r   rw   r   r   lookup_upper_framer   s    `    rJ   r   zClassDef.scope_lookup|  s    * t{L$;<< 9((88 	
 LLLLLLLLL	!	  ; 6(5555K%%''E FFE""4v666rL   c                $    d | j         D             S )zThe names of the parent classes

        Names are given in the order they appear in the class definition.

        :type: list(str)
        c                6    g | ]}|                                 S rG   )	as_string)rH   bnodes     rJ   rK   z&ClassDef.basenames.<locals>.<listcomp>  s"    :::e!!:::rL   r   r   s    rJ   	basenameszClassDef.basenames  s     ;:tz::::rL   Tre  Generator[ClassDef, None, None]c              #    K   | h}|t                      }| j        s7|                                 dk    rt          d          d         d         V  dS | j        D ]}|                                5  	 |                    |          D ]}t          |t                    s#t          |t          j                  r|j	        }n:|j
        s||v rF|                    |           |V  |sb|                    d|          D ]&}|| u r n||v r|                    |           |V  'n# t          $ r Y ddd           w xY w	 ddd           n# 1 swxY w Y   dS )zIterate over the base classes in prefixed depth first order.

        :param recurs: Whether to recurse or return direct ancestors only.

        :returns: The base classes
        Nbuiltins.objectobjectrM   r   Tr  )r   r   rc   r3   restore_pathr  r|   ro   r}  r~  rH  rt   r  r    )r   re  rR   yieldedstmtr`  grandpas          rJ   r  zClassDef.ancestors  s      &?&((Gz 	djjll.??? **1-a0000FJ 	 	D%%''  #'::g#6#6 * *)'8<< ))'5>BB )*1*: (&| *&'11 (#KK000")MMM% %$'.'8'8g'8'V'V * *G&$ %&'11 (#KK000")MMMM)** &   1      .+*              	 	s7   2E4B6D+*E+
E5EEEE	E	c              #     K   	 |                      |          dd         }n&# t          $ r |                     |          }Y nw xY w|D ]
}||v r|V  dS )zIterate over the parents that define the given name.

        :param name: The name to find definitions for.
        :type name: str

        :returns: The parents that define the given name.
        :rtype: iterable(NodeNG)
        rM   Nr
  )mror!   r  )r   r   rR   r  r&  s        rJ   local_attr_ancestorszClassDef.local_attr_ancestors  s      	8,0HHW,=,=abb,AII 	8 	8 	8 w77III	8 ! 	 	Gw	 	s   "  AAc              #  V   K   |                      |          D ]}||j        v r|V  dS )a  Iterate over the parents that define the given name as an attribute.

        :param name: The name to find definitions for.
        :type name: str

        :returns: The parents that define the given name as
            an instance attribute.
        :rtype: iterable(NodeNG)
        r
  N)r  r  )r   r   rR   r&  s       rJ   instance_attr_ancestorsz ClassDef.instance_attr_ancestors  sG       ~~g~66 	 	Gw---	 	rL   c                    || j         v S )zWhether this class directly inherits from the given node.

        :param node: The node to check for.
        :type node: NodeNG

        :returns: Whether this class directly inherits from the given node.
        r  )r   rw   s     rJ   has_basezClassDef.has_base		  s     tz!!rL   c                    g }|| j         v r| j         |         }n3t          |                     ||          d          }|r|j         |         }d |D             }|r|S t          | ||          )ah  Get the list of assign nodes associated to the given name.

        Assignments are looked for in both this class and in parents.

        :returns: The list of assignments to the given name.
        :rtype: list(NodeNG)

        :raises AttributeInferenceError: If no attribute with this name
            can be found in this class or parent classes.
        Nc                F    g | ]}t          |t          j                  |S rG   r|   r0   DelAttrr   s     rJ   rK   z'ClassDef.local_attr.<locals>.<listcomp>%	  r   rL   r   )r   r  r  r   )r   r   rR   rU   
class_nodes        rJ   
local_attrzClassDef.local_attr	  s     4;[&FFd77gFFMMJ 1#*40OOVOOO 	M%TT7SSSSrL   c                    t          | j                            |g                     }|                     ||          D ]}||j        |         z  }d |D             }|r|S t	          | ||          )ak  Get the list of nodes associated to the given attribute name.

        Assignments are looked for in both this class and in parents.

        :returns: The list of assignments to the given name.
        :rtype: list(NodeNG)

        :raises AttributeInferenceError: If no attribute with this name
            can be found in this class or parent classes.
        c                F    g | ]}t          |t          j                  |S rG   r  r   s     rJ   rK   z*ClassDef.instance_attr.<locals>.<listcomp>;	  r   rL   r   )rF  r  getr  r   )r   r   rR   valuesr  s        rJ   instance_attrzClassDef.instance_attr*	  s     d)--dB778866tWEE 	6 	6Jj/55FFOOVOOO 	M%TT7SSSSrL   bases.Instancec                    ddl m} 	 t          d |                                 D                       r |j        |           S n# t
          $ r Y nw xY wt          j        |           S )zGet an :class:`Instance` of the :class:`ClassDef` node.

        :returns: An :class:`Instance` of the :class:`ClassDef` node
        r   r!  c              3  2   K   | ]}|j         t          v V  d S r   )r   EXCEPTION_BASE_CLASSES)rH   rQ   s     rJ   rf   z-ClassDef.instantiate_class.<locals>.<genexpr>H	  s*      LL#3855LLLLLLrL   )r&  r:   rh   r  ExceptionInstancer!   r   r}  )r   r:   s     rJ   r  zClassDef.instantiate_class@	  s    
 	$#####	LLLLLLL 70w06667  	 	 	D	~d###s   :A 
AAclass_contextlist[InferenceResult]c                   |st          | ||          t          | j                            |g                     }|                     d|          D ] }||j                            |g           z  }!|| j        v r,|r*|s(| j                            |          g}|dk    r||z  }|S |r||                     ||          z  }|                                D ]y}t          |t          j                  r]|                                }t          |t          j                  r/|j        (|                    |                    |                     z|st          | ||          |S )a  Get an attribute from this class, using Python's attribute semantic.

        This method doesn't look in the :attr:`instance_attrs` dictionary
        since it is done by an :class:`Instance` proxy at inference time.
        It may return an :class:`Uninferable` object if
        the attribute has not been
        found, but a ``__getattr__`` or ``__getattribute__`` method is defined.
        If ``class_context`` is given, then it is considered that the
        attribute is accessed from a class context,
        e.g. ClassDef.attribute, otherwise it might have been accessed
        from an instance as well. If ``class_context`` is used in that
        case, then a lookup in the implicit metaclass and the explicit
        metaclass will be done.

        :param name: The attribute to look for.

        :param class_context: Whether the attribute can be accessed statically.

        :returns: The attribute.

        :raises AttributeInferenceError: If the attribute cannot be inferred.
        r   Tr  	__bases__)r   rF  r   r  r  r   r%   _metaclass_lookup_attributecopyr|   r0   r  r   	AnnAssignr  ri   index)	r   r   rR   r  r  	classnoderU   r  r  s	            rJ   r   zClassDef.getattrO	  s   8  	X)wWWWW )-T[__T2-F-F(G(GtWEE 	5 	5Ii&**4444FF4***}*V*-44T::;F{"" & M 	Fd66tWEEEF [[]] 	4 	4E%!899 4((dL$:;; 4
@RJJv||E22333 	X)wWWWWrL   i   )maxsizec                N   t                      }|                                 }t          |          }|                     |          }||fD ]X}|rT|| k    rNt	          |t
                    r9|                     |||          }|                    t          |                     Y|S )zASearch the given name in the implicit and the explicit metaclass.r
  )rr   implicit_metaclassr   rA  r|   ro   _get_attribute_from_metaclassupdate)r   r   rR   attrsimplicit_metarA  rQ   cls_attributess           rJ   r  z$ClassDef._metaclass_lookup_attribute	  s     //11w''NN7N33	!9- 	2 	2C 2sd{{z#x'@'@{!%!C!CCw!W!WS00111rL   c              #    K   ddl m} 	 |                    ||d          }n# t          $ r Y d S w xY wt	          j        |||          D ]}t          |t                    s|V  t          ||j                  r|V  6|j	        dk    r)t          |          p| }t	          j        ||          V  j|j	        dk    r|V  zt	          j        ||           V  d S )Nr   r!  T)rR   r  r   r@   rA   )r&  r:   r   r   r   r   r|   r}   r$  r~   ri  r   )r   rQ   r   rR   r:   r  r  r   s           rJ   r  z&ClassDef._get_attribute_from_metaclass	  s5     ######	KKgTKJJEE& 	 	 	FF	 &ugSAAA 	4 	4DdK00 


$ 011 


yM)) +4008D'e444444n,,



'd333333'	4 	4s   # 
11c              #  V  K   ddl m} t          |          }||_        |                     |          }	 |                     |||          }t          |          dk    r8|d         |dd         }}|                                |gfd|D             z   }t          j	        |||           D ]}t          |t          j                  sYt          |t          j                  r?	 |j                            d	|           t          j        V  b# t"          $ r |V  Y rw xY wt          ||j                  rg|j        }	|s|	                    | |
          E d{V  |r9|	j                                        |u r|	                    | |
          E d{V  |V  t-          ||           V  dS # t"          $ re}
|                    d          s$|                     |          rt          j        V  n!t3          t5          |
          | ||          |
Y d}
~
dS d}
~
ww xY w)r   r   r!  r
  )r  rM   Nc                \    g | ](}|j         r|j                                         k    &|)S rG   )r   r  )rH   r  first_scopes     rJ   rK   z%ClassDef.igetattr.<locals>.<listcomp>	  sH     - - -{- (,{'8'8':':k'I'I 'I'I'IrL   r   __get__)r  rR   __r   )r&  r:   r   r   rA  r   rD  r  r   r   r|   r0   r+   r}  r~  r   rk  r   r$  r  r|  r   r   r  has_dynamic_getattrr    r   )r   r   rR   r  r:   rA  
attributes
first_attrr&  r  r   r  s              @rJ   r   zClassDef.igetattr	  s      	$##### w''!NN7N33	6	dG=QQJ :"")3A
122J
(..00(\ - - - - *- - - 
 ".z7$OOO  =  =!(L,>?? =JenE E =/ )11)WEEE #..... 3 ' ' '&'  '*:;; ='0H( '#+#=#=#' $> $ $         # 'x'<'<'>'>)'K'K $,#=#=#' $> $ $         ',Xt<<<<<<A =  =B ' 	 	 	??4(( T-E-Eg-N-N &&&&&$JJttW   '&&&&&	s>   B1F9 )DF9 D$!F9 #D$$BF9 9
H(AH##H(c                    d }	  ||                      d|          d                   S # t          $ r= 	 |                      d|          d         } ||          cY S # t          $ r Y nw xY wY nw xY wdS )a0  Check if the class has a custom __getattr__ or __getattribute__.

        If any such method is found and it is not from
        builtins, nor from an extension module, then the function
        will return True.

        :returns: Whether the class has a custom __getattr__ or __getattribute__.
        c                b    |                                  }|j        dk    ot          |dd           S )Nr{  r   )rootr   r   )rw   r  s     rJ   _valid_getattrz4ClassDef.has_dynamic_getattr.<locals>._valid_getattr

  s-    99;;D9
*Qwt]D/Q/QQrL   __getattr__r   __getattribute__F)r   r   )r   rR   r  getattributes       rJ   r  zClassDef.has_dynamic_getattr 
  s    	R 	R 	R	!>$,,}g"F"Fq"IJJJ& 	 	 	#||,>HHK%~l33333*   	 us2   $* 
A1&AA1
A+(A1*A++A10A1c                   	 t          | d|          }nu# t          $ rh}t          | t                    r7	 |                     d          }n2# t          $ r t          | |          |w xY wt          | |          |Y d}~nd}~ww xY w|d         }t          ||           }t          |g|          |_        	 t          |
                    | |          t          j                  S # t          $ r? t          |t          j                  r#|                                 dk    rt"          r| cY S  t$          $ r t          j        cY S w xY w)	aA  Return the inference of a subscript.

        This is basically looking up the method in the metaclass and calling it.

        :returns: The inferred value of a subscript to this class.
        :rtype: NodeNG

        :raises AstroidTypeError: If this class does not define a
            ``__getitem__`` method.
        r=   r
  r  r"  Nr   )r  r  r  )r%   r   r|   ro   r   r   r   r   r  r  r|  r   rk  r  r0   	EmptyNoder   r   r    )r   r  rR   methodsr   r  new_contexts          rJ   getitemzClassDef.getitem
  s   	LT='BBBGG& 	L 	L 	L$)) L
P"ll+>??GG / P P P*gFFFCOP 'D'BBBK GGGG	L   +7D99"-E76"J"J"J	$00{CCTEUVVV 	 	 	 6<#9::KKMM_44 5  	$ 	$ 	$####	$sD    
BBA
BA((BB:-C( (AE/EEc              #     K   i }t          j        t          | f          |                                           D ]1}|                                D ]}|j        |v rd||j        <   |V  2dS )zIterate over all of the method defined in this class and its parents.

        :returns: The methods defined on the class.
        :rtype: iterable(FunctionDef)
        N)rJ  rK  iterr  	mymethodsr   )r   doner&  r  s       rJ   r  zClassDef.methodsN
  s        tTG}}dnn6F6FGG 	 	G))++  9$$"&TY



		 	rL   c              #  j   K   |                                  D ]}t          |t                    r|V  dS )zIterate over all of the method defined in this class only.

        :returns: The methods defined on the class.
        :rtype: iterable(FunctionDef)
        N)r  r|   r}   )r   members     rJ   r  zClassDef.mymethods\
  sE       kkmm 	 	F&+.. 	 	rL   c                J    | j         rt          d          d         d         S dS )a<  Get the implicit metaclass of the current class.

        For newstyle classes, this will return an instance of builtins.type.
        For oldstyle classes, it will simply return None, since there's
        no implicit metaclass there.

        :returns: The metaclass.
        :rtype: builtins.type or None
        r~   rM   r   N)r~  r3   r   s    rJ   r  zClassDef.implicit_metaclassf
  s+     = 	0!&))!,Q//trL   c                t   | j         D ]]}	 |                    |          D ]3}t          |t                    r|j        r|j        | _        d| _         n4N# t          $ r Y Zw xY w| j        rK	 t          d | j                            |          D                       S # t          t          f$ r Y dS w xY wdS )a  Return the explicit declared metaclass for the current class.

        An explicit declared metaclass is defined
        either by passing the ``metaclass`` keyword argument
        in the class definition line (Python 3) or (Python 2) by
        having a ``__metaclass__`` class attribute, or if there are
        no explicit bases but there is a global ``__metaclass__`` variable.

        :returns: The metaclass of this class,
            or None if one could not be found.
        r
  Tc              3  N   K   | ] }t          |t          j                  |V  !d S r   r?  r  s     rJ   rf   z.ClassDef.declared_metaclass.<locals>.<genexpr>
  sI        %dD,@AA     rL   N)
r   r  r|   ro   rH  rm  _metaclass_hackr    r  r  )r   rR   re   r`  s       rJ   r  zClassDef.declared_metaclasst
  s    J 	 	D#zz'z::  G!'844  *1*</3,!    ? 		   $ 5 5g 5 F F     
 #M2   tt ts$   A
A
A#"A#.1B   B54B5rv   set[ClassDef] | Nonec                    |t                      }|                    |            |                     |          }|6|                     |          D ]}||vr|                    |          }| n |S )Nr
  )rr   rt   r  r  _find_metaclass)r   rv   rR   r   r   s        rJ   r   zClassDef._find_metaclass
  s     <55D'''88=...99  %%"22488E(rL   c                .    |                      |          S )zGet the metaclass of this class.

        If this class does not define explicitly a metaclass,
        then the first defined metaclass in ancestors will be used
        instead.

        :returns: The metaclass of this class.
        r
  )r   r-  s     rJ   rA  zClassDef.metaclass
  s     ##G#444rL   c                    | j         S r   )r  r   s    rJ   has_metaclass_hackzClassDef.has_metaclass_hack
  s    ##rL   c              #    K   d| j         vrdS |                     d          D ];}t          D ])}	 |                    |            n# t          $ r Y &w xY w5t          |t          j                  r|j        r|V  [t          |d          slt          |t          j
                  rd |j        D             }n|                                }t          |t          j                  r|s|c S |D ]k}	 |                                D ]C}t          |t          j                  rt          |j        t                     s7|j        s?|V  D\# t"          $ r Y hw xY w=dS )z+Return an iterator with the inferred slots.	__slots__Nr  c                    g | ]
}|d          S r=  rG   )rH   items     rJ   rK   z$ClassDef._islots.<locals>.<listcomp>
  s    :::d$q':::rL   )r   r   ITER_METHODSr   r   r|   r0   r+   r  hasattrr  r  r  r   r@  r  r   r    )r   slotsr  r  rN  r&  s         rJ   _islotszClassDef._islots
  s     dk))4]];// +	 +	E$  MM$'''E.   H %!344  ;  KKK5(++ %!233 (::ek:::&$"677     
$'IIKK ' ')$l&8    %!+HNC!@!@% %'~ %$&' &   H ts$   A
AA5AE
EEc                   | j         st          d          |                                 }	 t          |          }n@# t          $ r3}|j        r!|j        d         dvr|j        d         cY d }~S Y d }~d S d }~ww xY w|g|S )N8The concept of slots is undefined for old-style classes.r   )r  N)r~  NotImplementedErrorr  r  r  r  )r   r
  firstr   s       rJ   _slotszClassDef._slots
  s    } 	%J   	KKEE 	 	 	x #CHQKz99x{""""""44444		
 s   < 
A9"A4(A94A9c                J   dd}| j         st          d          	 |                                 }n"# t          $ r}t          d          |d}~ww xY wt	           ||                    }t          d	 |D                       sdS t          t          |          d
           S )aY  Get all the slots for this node.

        :returns: The names of slots for this class.
            If the class doesn't define any slot, through the ``__slots__``
            variable, then this function will return a None.
            Also, it will return None in the case the slots were not inferred.
        :rtype: list(str) or None
        r  list[ClassDef]r\   $Iterator[node_classes.NodeNG | None]c              3     K   | D ]P}|                                 dk    r	 |                                }n# t          $ r Y =w xY w|	|E d {V  Ld V  Qd S )Nr  )rc   r  r  )r  rQ   	cls_slotss      rJ   grouped_slotsz*ClassDef._all_slots.<locals>.grouped_slots  s         99;;"333 #

II*   H((((((((((JJJJ s   6
AAr  z)Cannot get slots while parsing mro fails.Nc              3     K   | ]}|d uV  	d S r   rG   )rH   slots     rJ   rf   z&ClassDef._all_slots.<locals>.<genexpr>%  s'      664t#666666rL   c                    | j         S r   )r  )r  s    rJ   <lambda>z%ClassDef._all_slots.<locals>.<lambda>(  s    4: rL   )rf  )r  r  r\   r  )r~  r  r  r!   rF  allsortedrr   )r   r  r  rN  r
  s        rJ   
_all_slotszClassDef._all_slots
  s    	 	 	 	  } 	%J  	((**CC 	 	 	%; 	
 ]]3''((6666666 	4c%jj&=&=>>>>s   1 
AAAc                    | j         S r   )r  r   s    rJ   r
  zClassDef.slots*  s
    rL   c              #  
  K   |t                      }| j        s7|                                 dk    rt          d          d         d         V  d S | j        D ]}	 t	          d |                    |                                          D                       }n# t          t          f$ r Y Vw xY wt          |t          j
                  r|j        }t          |t                    s|j        s|V  |j        E d {V  d S )Nr  r  rM   r   c              3  R   K   | ]"}t          |t                    r|j        |V  #d S r   r8  r9  s     rJ   rf   z+ClassDef._inferred_bases.<locals>.<genexpr>D  sF        &q%00 67W_ 5D___ rL   r
  )r   r   rc   r3   r  r  r;  r    r  r|   r}  r~  ro   rH  )r   rR   r  r`  s       rJ   _inferred_baseszClassDef._inferred_bases-  sE      ?&((Gz 	djjll.??? **1-a0000FJ 	) 	)D  !ZZZ@@    
 #M2   '5>22 +!*gx00 < )"=((((((((#	) 	)s   ?BB/.B/c                   |                                  dk    r| gS t          |                     |                    }g }|D ]{}|| u r	 |                    |          }|                    |           4# t
          $ r; t          |                    |                    }|                    |           Y xw xY w| gg||}t          || |          }t          |           t          || |          S )Nr  r
  )
rc   rF  r!  _compute_mrorS   r  r  ry   rn   rZ   )r   rR   rk   rj   re   r  r  unmerged_mros           rJ   r#  zClassDef._compute_mroT  s&   ::<<,,,6Md2272CCDD	" 	, 	,Dt||
,'''88  %%%%& , , , !!@!@AA	  +++++, 04f-Qy-Q.-Q+L$HH ...tW555s   +A77AB<;B<r  c                .    |                      |          S )a*  Get the method resolution order, using C3 linearization.

        :returns: The list of ancestors, sorted by the mro.
        :rtype: list(NodeNG)
        :raises DuplicateBasesError: Duplicate bases in the same class base
        :raises InconsistentMroError: A class' MRO is inconsistent
        r
  )r#  r-  s     rJ   r  zClassDef.mroo  s        111rL   r[  c                    dS )zDetermine the boolean value of this node.

        :returns: The boolean value of this node.
            For a :class:`ClassDef` this is always ``True``.
        TrG   r-  s     rJ   r.  zClassDef.bool_valuey  r/  rL   c              #     K   | j         	| j         V  | j        E d {V  | j        | j        E d {V  | j        E d {V  | j        E d {V  d S r   )r  r   rk  r  r   r   s    rJ   r2  zClassDef.get_children  s      ?&/!!!:=$}$$$$$$$########9rL   c                |    d | j         D             }t          t          j                            |                    S )Nc              3  $   K   | ]}|j         V  d S r   )r  )rH   r  s     rJ   rf   z2ClassDef._assign_nodes_in_scope.<locals>.<genexpr>  s6       !
 !
2<J-!
 !
 !
 !
 !
 !
rL   )r   rF  rJ  rK  from_iterable)r   children_assign_nodess     rJ   r  zClassDef._assign_nodes_in_scope  sD    !
 !
@D	!
 !
 !
 IO112GHHIIIrL   r   r   rD   r   r   c                   | S r4  rG   r   s     rJ   r   zClassDef.frame  r5  rL   r6  r   c              +     K   | V  d S r   rG   r9  s      rJ   r:  zClassDef._infer  r;  rL   rW  )r\   rw  )NNN)r   r}  r   r  r  r  r~  rq  rA  rl  rk  r  r  r  r   r   r  r  r\   r]   r   r?  rX  r<  )r\   r  r>  r  rA  r  r=  rY  )TN)re  r   rR   rp   r\   r  )r\   r  r  )r   r   rR   rp   r  r   r\   r  )r   r   rR   rp   r  r   r\   r   )rR   rp   r\   r  NN)rv   r  rR   rp   r\   r  )rR   rp   r\   r  ra  rB  )rR   rp   r6  r   r\   r  )Jr   rC  rD  r   rE  r  r&   r   r  rm  rF  r  rH  r{   rf  r~   rG  rH  rp  r   r   instance_class_infer_binary_oprv  r  rs  r   r  r~  r   r   r  r   r   r   r  r  r  r|  r   r  r  r  r  r  r  r  r  r   r	   r  r  r   r  r  r  r  r  r  r   rA  r  r  r  r  r
  r!  r#  r  r.  r2  r  r   r:  rI  rJ  s   @rJ   ro   ro   "  s        
 
 O J $
 E $J$$$$OD8  D 9M1!I!!!!62 62 62 62 62 62r 	0        	 	 	" !%#'6:- %)!% - - - - - -4    $ IxQ  H
 " " " " " _"&   _. . . .# # # #      X X X X X5 5 5t ,0+ + + + +D ;<07 07 07 07 07d ; ; X; GK, , , , ,\    *    " " " "T T T T T.T T T T T,$ $ $ $$ ,0"	9 9 9 9 9v Yt
 
 
4 4 4@ ,0"	J J J J JX    23$ 3$ 3$ 3$ 3$j       26# # # # #L UY    " 265 5 5 5 5$ $ $1 1 1f  " *? *? _*?X  %) %) %) %) %)N6 6 6 6 662 2 2 2 2    	 	 	 J J _J :>       26        rL   )rT   r[   r\   r]   )rT   r[   rQ   ro   rR   rp   r\   r[   r.  rA  r?  )hr   
__future__r   r   rJ  r  r   collections.abcr   r   r   r   	functoolsr   r	   typingr
   r   r   r   r   r   r&  r   r   r   astroid.constr   r   r   r   astroid.contextr   r   r   r   astroid.exceptionsr   r   r   r   r   r    r!   r"   r#   r$   !astroid.interpreter.dunder_lookupr%   astroid.interpreter.objectmodelr&   r'   r(   astroid.managerr)   astroid.nodesr*   r+   r,   r-   r.   r/   r0    astroid.nodes.scoped_nodes.mixinr1   r2    astroid.nodes.scoped_nodes.utilsr3   astroid.nodes.utilsr4   astroid.typingr5   r6   r7   r8   r9   r:   astroid.nodes._base_nodesr;   r  	frozensetr  r  rD   rZ   rn   ry   r   r   rL  rd  ro  ru  r  FilterStmtsBaseNoder  MultiLineBlockNode	Statementr}   rB  r_  rf  ri  ro   rG   rL   rJ   <module>rD     s  
  # " " " " " 				     				  C C C C C C C C C C C C 0 0 0 0 0 0 0 0 K K K K K K K K K K K K K K K K * * * * * * * * * * D D D D D D D D D D D D                                   5 4 4 4 4 4 R R R R R R R R R R * * * * * *                  R Q Q Q Q Q Q Q ; ; ; ; ; ; ( ( ( ( ( (             6&&&&&&&&555555 +"K#ABB iTTT   WT]]# # #L!. !. !. !.H   (  i i i i i i i iX4# 4# 4# 4# 4#% 4# 4# 4#n9# 9# 9# 9# 9#! 9# 9# 9#x5# 5# 5# 5# 5#  5# 5# 5#p6# 6# 6# 6# 6#! 6# 6# 6#r" " "Jz? z? z? z? z?[,.> z? z? z?zO
 O
 O
 O
 O
"#	O
 O
 O
d    {   &    @    D  &~ ~ ~ ~ ~#%5{7L~ ~ ~ ~ ~rL   