
    cg                      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Zddlm	Z	m
Z
 ddlmZ ddlmZmZmZmZmZ ddlmZ ddlmZ dd	lmZ dd
lmZ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, ddl-m.Z. ddl/m0Z0m1Z1m2Z2 ddl3m4Z4 ddl5m6Z6m7Z7m8Z8m9Z9m:Z: ddl;m<Z<m=Z= ddl>m?Z? ddl@mAZA ddlBmCZCmDZDmEZE ejF        dk    rddlmGZG ddlmHZH nddlImHZH ddlJmKZG erddlmLZL dZM eNddh          ZO ejP        d          ZQ eNh d          ZR ed          ZSd  ZTdCd%ZUd& ZVd' ZW G d( d)e=          ZX G d* d+e<          ZY G d, d-e<          ZZ G d. d/e<          Z[ G d0 d1e<          Z\d2 Z] G d3 d4e9j^        e=          Z_ G d5 d6e9j`        e9ja        e_          Zb G d7 d8eb          ZcdDdEd<ZddDdFd>ZedDd?Zfd@ Zg G dA dBe9j^        e=e9ja                  ZhdS )Gz
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Iterator)	lru_cache)TYPE_CHECKINGClassVarNoReturnTypeVaroverloadbases)
decorators)util)IS_PYPYPY38	PY38_PLUS	PY39_PLUSPYPY_7_3_11_PLUS)CallContextInferenceContextbind_context_to_nodecopy_context)	AstroidBuildingErrorAstroidTypeErrorAttributeInferenceErrorDuplicateBasesErrorInconsistentMroErrorInferenceErrorMroErrorStatementMissingTooManyLevelsError)lookup)
ClassModelFunctionModelModuleModel)AstroidManager)	ArgumentsConstNodeNG_base_nodesnode_classes)ComprehensionScopeLocalsDictNodeNG)builtin_lookup)Position)InferBinaryOpInferenceResultSuccessfulInferenceResult)      )cached_property)Literal)cachedproperty)nodes)__iter____getitem__	ExceptionBaseExceptionobjects>   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  rE   ).0ss     Glib/python3.11/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py
<listcomp>z_c3_merge.<locals>.<listcomp>R   s    ///1Q/Q///    r      NzTCannot create a consistent method resolution order for MROs {mros} of class {cls!r}.messagemrosclscontext)r   append)	sequencesrO   rP   results1	candidates2seqs           rH   	_c3_mergerX   J   s     F//	///	 	M 	 	B1I  122&  $IE    		 '4    	i    	 	C1v" F7rJ   rR   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]
    rK   typing.GenericNc              3  F   K   | ]}|                                 d k    V  dS )r^   NqnamerF   bases     rH   	<genexpr>z+clean_typing_generic_mro.<locals>.<genexpr>   s0      @@Dtzz||//@@@@@@rJ   )	enumeratera   anypop)rR   	bases_mroinferred_basesirc   position_in_inferred_basesrW   s          rH   clean_typing_generic_mrorl   p   s     !B$Ir]N^,,  4::<<++ 	)*&E	 	 I&&  3** 	@@C@@@@@ 	E	 	 1222MM,-----rJ   c           	   #  @  K   | D ]}d |D             }t          t          t          t          |                              |r-|d         %|d                  dk    rt	          d| ||          fdt          t          ||                    D             V  d S )Nc                V    g | ]&}|j         r|j        |                                fnd 'S N)namelinenora   rF   nodes     rH   rI   z(clean_duplicates_mro.<locals>.<listcomp>   s@     
 
 
CG49>T[$**,,''$
 
 
rJ   r   z,Duplicates found in MROs {mros} for {cls!r}.rL   c                <    g | ]\  }\  }}||         |k    |S ro   rE   )rF   rj   rs   rp   
last_indexs       rH   rI   z(clean_duplicates_mro.<locals>.<listcomp>   sK     
 
 
<D$
  *$/14

 
 
rJ   )dictmapreversedre   r   zip)rR   rO   rP   sequencenamesru   s        @rH   clean_duplicates_mror|      s       
 

 
KS
 
 
 #h	%(8(899::
 	U1X 	jq.Ba.G 	%F	   
 
 
 
#,S5-A-A#B#B
 
 
 	
 	
 	
 	

 
rJ   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>   propertyr?   )
isinstanceFunctionDeftyper   BoundMethodUnboundMethod)nklasss     rH   function_to_methodr      so    ![!! *6]" 	/$Q...6Z 	H6^# 	*&q)))HrJ   c                  &    e Zd ZU dZdZdZded<   	 dZded<   	 dZded	<   	 dZ	d
ed<   	  e
            Z	 h dZ	 dZdZded<   ded<   ded<   ded<    ej        d          	 	 	 	 	 	 dRdS fd!            ZdTdd"dUd%ZedVd&            Zej        dWd(            Zd) Zd* Zd+ ZdXd,ZdYd.ZdZd/Z	 d[d\d3ZdTd\d4Zd]d6Zed7d8d^d:            Z ed_d=            Z dd8d`d@Z dA Z!dB Z"dZ#d]dCZ$	 	 	 dadbdIZ%dcdJZ&dK Z'dL Z(dTdddMZ)dN Z*dd8dedQZ+ xZ,S )f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bodyr   
Literal[0]
fromlinenorq   Nzstr | bytes | None
file_bytes
str | Nonefile_encoding>   __doc____file____name____path____package__)rp   docfilepathpackagepure_pythonfuture_imports)localsglobalsr[   
col_offset
end_linenoend_col_offsetparent'Use the postinit arg 'doc_node' insteadr   Trp   strr   r   r   list[str] | Noner   bool | Noner   rZ   c                   || _         	 || _        	 || _        	 || _        || _        	 || _        	 |  	 i x| _        | _        	 g | _        	 d| _	        	 t                      | _        	 t                                          d|           dS )a  
        :param name: The name of the module.

        :param doc: The module docstring.

        :param file: The path to the file that this ast has been extracted from.

        :param path:

        :param package: Whether the node represents a package or a module.

        :param parent: The parent node in the syntax tree.

        :param pure_python: Whether the ast was built from source.
        Nr   )rq   r   )rp   _docr   r   r   r   r   r   r   r   setr   super__init__)	selfrp   r   r   r   r   r   r   	__class__s	           rH   r   zModule.__init__   s    4 	%	#		 	@&4:U%''dlS68	)&*5(+.&11111rJ   )r   r   Const | Nonec               B    || _         || _        |r|j        | _        dS dS )zDo some setup after initialisation.

        :param body: The contents of the module.
        :type body: list(NodeNG) or None
        :param doc_node: The doc node associated with this node.
        N)r   r   valuer   )r   r   r   s      rH   postinitzModule.postinit+  s1     	  	' DIII	' 	'rJ   c                D    t          j        dt                     | j        S )zThe module docstring.zHThe 'Module.doc' attribute is deprecated, use 'Module.doc_node' instead.warningswarnDeprecationWarningr   r   s    rH   r   z
Module.doc7  s*     	-	
 	
 	

 yrJ   r   c                H    t          j        dt                     || _        d S )NzPSetting the 'Module.doc' attribute is deprecated, use 'Module.doc_node' instead.r   r   r   s     rH   r   z
Module.docA  s+    -	
 	
 	

 			rJ   c                    | j         t          j        | j                   S | j        t	          | j        d          }|S d S )Nrb)r   ioBytesIOr   open)r   streams     rH   _get_streamzModule._get_streamJ  sC    ? 	/:do...9 	$)T**FMtrJ   c                *    |                                  S )zaGet a stream to the underlying file or bytes.

        :type: file or io.BytesIO or None
        )r   r   s    rH   r   zModule.streamS  s    
 !!!rJ   c                    | j         | j        fS )zGet a range from where this node starts to where this node ends.

        :param lineno: Unused.
        :type lineno: int

        :returns: The range of line numbers that this node belongs to.
        :rtype: tuple(int, int)
        r   tolinenor   rq   s     rH   block_rangezModule.block_rangeZ       --rJ   c                    || j         v r5|| j        vr,	 | |                     |          fS # t          $ r | dfcY S w xY w|                     |||          S )at  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.
        :type node: NodeNG

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

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

        :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).
        :rtype: tuple(str, list(NodeNG))
        rE   )scope_attrsr   getattrr   _scope_lookup)r   rs   rp   offsets       rH   scope_lookupzModule.scope_lookupe  s~    $ 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.modulerE   r   s    rH   pytypezModule.pytype~  s
    
 ! rJ   c                    dS )jA human readable type of this node.

        :returns: The type of this node.
        :rtype: str
        r   rE   r   s    rH   display_typezModule.display_type  s	     xrJ   FrP   InferenceContext | Nonec                   |st          | ||          g }|| j        v }|| j        v r |s|s| j                            |          g}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	attributerP   T)relative_onlyc                F    g | ]}t          |t          j                  |S rE   )r   r+   DelNamerF   r   s     rH   rI   z"Module.getattr.<locals>.<listcomp>  *    OOO:a9M+N+NO!OOOrJ   )r   r   special_attributesr"   r   import_moduler   SyntaxError)r   rp   rP   ignore_localsrS   name_in_localsexcs          rH   r   zModule.getattr  s2     	X)wWWWW,4** 
	= 
	 
	-44T::;FF 	> 	[&FF\ 	,,T,FFG(+6   -4   POVOOO 	M%TT7SSSSs   #A< <B%B  B%c                    t          |          }||_        	 t          j        |                     ||          ||           S # t
          $ r&}t          t          |          | ||          |d}~ww xY w)zInfer the possible values of the given variable.

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

        :returns: The inferred possible values.
        :rtype: iterable(NodeNG) or None
        framer   N)r   
lookupnamer   _infer_stmtsr   r   r   r   r   rp   rP   errors       rH   igetattrzModule.igetattr  s     w''!	%dll4&A&A7RVWWWW& 	 	 	 E

44  	s   *A 
A3!A..A3boolc                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    rH   fully_definedzModule.fully_defined  s&     y$B););E)B)BBrJ   .futurer   c                   d S ro   rE   r   r   s     rH   	statementzModule.statement      rJ   Literal[True]r	   c                   d S ro   rE   r   s     rH   r   zModule.statement  r   rJ   Literal[None, True]Module | NoReturnc               ^    |rt          |           t          j        dt                     | S )aJ  The first parent node, including self, marked as statement node.

        When called on a :class:`Module` with the future parameter this raises an error.

        TODO: Deprecate the future parameter and only raise StatementMissing

        :raises StatementMissing: If no self has no parent attribute and future is True
        )r   zIn astroid 3.0.0 NodeNG.statement() will return either a nodes.Statement or raise a StatementMissing exception. nodes.Module will no longer be considered a statement. This behaviour can already be triggered by passing 'future=True' to a statement() call.)r    r   r   r   r   s     rH   r   zModule.statement  sB      	0"$////> 	
 	
 	
 rJ   c                    dS )zThe previous sibling statement.

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

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

        :returns: Whether :pep:`328` has been enabled.
        )_absolute_import_activatedr   s    rH   absolute_import_activatedz Module.absolute_import_activated  s    
 ..rJ   modnamer   level
int | None	use_cachec                    |r|d}|                      ||          }	 t                                          ||          S # t          $ r |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         rH   r   zModule.import_module  s    &  	U 	E33GUCC
	!##88i 9    $ 	 	 	   	
 44W===s   "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.
        NrK   .r   z/__init__.py/ )r  rp   )r  r   rp   rsplitr   osexistsdirnamesplitcountr!   )r   r  r  package_names       rH   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 F(u49EEEE\ 	79LL9++C33A6L 	/ $##"..W...rJ   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rF   rp   s     rH   rI   z0Module.wildcard_import_names.<locals>.<listcomp>V  s)    LLLDts7K7KL4LLLrJ   __all__rZ   r   c                j    t          | t          j                  ot          | j        t                    S ro   )r   r+   r(   r   r   )rs   s    rH   	str_constz/Module.wildcard_import_names.<locals>.str_constn  s'    dL$677WJtzSV<W<WWrJ   rZ   r   )keysKeyErrornextassigned_stmtsr   StopIterationAttributeErrorinferr   r+   TupleListeltsrQ   r   )r   default
all_valuesexplicitinferredr  rs   inferred_nodes           rH   wildcard_import_nameszModule.wildcard_import_namesK  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     rH   rI   z'Module.public_names.<locals>.<listcomp>  s)    IIIDOOC4H4HIIIIrJ   )r!  r   s    rH   public_nameszModule.public_names}  s!     JIIIIIrJ   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``.
        TrE   r   rP   s     rH   
bool_valuezModule.bool_value  	     trJ   c              #  $   K   | j         E d {V  d S ro   r   r   s    rH   get_childrenzModule.get_children  s&      9rJ   r   rB   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.
        rE   r   s     rH   r   zModule.frame  	     rJ   )NNNNNT)rp   r   r   r   r   r   r   r   r   r   r   r[   r   r   rZ   r[   ro   )r   r   rZ   r   r   r   rZ   r[   r   )rZ   r   rZ   r   )NFrP   r   r   )r   r[   rZ   r   )r   r   rZ   r	   )r   r   rZ   r   )FNT)
r  r   r   r   r  r  r  r   rZ   r   )r  r   r  r  rZ   r   rP   r   rZ   r   r   rB   r   r   rZ   rB   )-r   
__module____qualname__r   _astroid_fieldsr   __annotations__rq   r   r   r%   r   r   _other_fields_other_other_fieldsdecorators_moddeprecate_argumentsr   r   r~   r   setterr   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r   r  r0  r3  r6  r:  r   __classcell__r   s   @rH   r   r      s          +OJFF@ &*J))))8 $M$$$$ %? QPPKLM 0LLL'^',UVVV !%##'=2 =2 =2 =2 =2 =2 WV=2B
'd 
' 
' 
' 
' 
' 
'    X 	Z   Z  " " "	. 	. 	.6 6 6 62! ! ! !    LQT T T T T2    (C C C C *-      X    X :>      (     "&/ / / / $  >  >  >  >  >D0 0 0 0d0 0 0dJ J J       :>          rJ   r   c                  Z     e Zd ZdZdZdZdZ	 	 	 	 dddd fdZd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   Nr   r   c               d    i | _         	 t                                          |||||           dS a  
        :param lineno: The line that this node appears on in the source code.
        :type lineno: int or None

        :param col_offset: The column that this node appears on in the
            source code.
        :type col_offset: int or None

        :param parent: The parent node in the syntax tree.
        :type parent: NodeNG or None

        :param end_lineno: The last line this node appears on in the source code.
        :type end_lineno: Optional[int]

        :param end_col_offset: The end column this node appears on in the
            source code. Note: This is after the last symbol.
        :type end_col_offset: Optional[int]
        rq   r   r   r   r   Nr   r   r   r   rq   r   r   r   r   r   s         rH   r   zGeneratorExp.__init__  I    6 S!!) 	 	
 	
 	
 	
 	
rJ   rT   list[nodes.Comprehension] | Nonec                8    || _         |	g | _        dS || _        dS zDo some setup after initialisation.

        :param elt: The element that forms the output of the expression.
        :type elt: NodeNG or None

        :param generators: The generators that are looped through.
        NrR  r   rS  rT  s      rH   r   zGeneratorExp.postinit  )      	) DOOO(DOOOrJ   rP   r   rZ   r   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``.
        TrE   r5  s     rH   r6  zGeneratorExp.bool_value  r7  rJ   c              #  6   K   | j         V  | j        E d {V  d S ro   rR  r   s    rH   r:  zGeneratorExp.get_children  1      h?"""""""""rJ   NNNNNrT  r]  ro   rP   r   rZ   r   r   rE  rF  r   rG  rJ  rS  r   r   r6  r:  rN  rO  s   @rH   rQ  rQ    s          ,O%
C 	$
 $
 $
 $
 $
 $
 $
 $
L) ) ) ) )    # # # # # # #rJ   rQ  c                  f     e Zd ZdZdZdZdZ	 dZ	 	 	 	 dddd fdZ	 	 	 d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   rT  rU  NrV  c               d    i | _         	 t                                          |||||           dS rX  rZ  r[  s         rH   r   zDictComp.__init__  r\  rJ   rT  r]  c                F    || _         || _        |	g | _        dS || _        dS )a  Do some setup after initialisation.

        :param key: What produces the keys.
        :type key: NodeNG or None

        :param value: What produces the values.
        :type value: NodeNG or None

        :param generators: The generators that are looped through.
        Nrl  )r   rm  r   rT  s       rH   r   zDictComp.postinit*  s0      
 	) DOOO(DOOOrJ   rP   r   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   Uninferabler5  s     rH   r6  zDictComp.bool_valueA       rJ   c              #  H   K   | j         V  | j        V  | j        E d {V  d S ro   rl  r   s    rH   r:  zDictComp.get_childrenJ  s?      hj?"""""""""rJ   re  rg  ro   rB  )r   rE  rF  r   rG  rJ  rm  r   r   r   r6  r:  rN  rO  s   @rH   rk  rk    s          5O%
C E 	$
 $
 $
 $
 $
 $
 $
 $
P 7;	) ) ) ) ).         # # # # # # #rJ   rk  c                  Z     e Zd ZdZdZdZdZ	 	 	 	 dddd fdZd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>
    rR  rU  NrV  c               d    i | _         	 t                                          |||||           dS rX  rZ  r[  s         rH   r   zSetComp.__init__b  r\  rJ   rT  r]  c                8    || _         |	g | _        dS || _        dS r_  rR  r`  s      rH   r   zSetComp.postinit  ra  rJ   rP   r   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
        rq  r5  s     rH   r6  zSetComp.bool_value  rs  rJ   c              #  6   K   | j         V  | j        E d {V  d S ro   rR  r   s    rH   r:  zSetComp.get_children  rd  rJ   re  rf  rg  ro   rB  ri  rO  s   @rH   rv  rv  Q  s          ,O%
C 	$
 $
 $
 $
 $
 $
 $
 $
L) ) ) ) )         # # # # # # #rJ   rv  c                  Z     e Zd ZdZdZdZdZ	 	 	 	 dddd fdZd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>
    rR  rU  NrV  c               d    i | _         	 t                                          |||||           d S )NrY  rZ  r[  s         rH   r   zListComp.__init__  sI     L!!) 	 	
 	
 	
 	
 	
rJ   rT  r]  c                8    || _         |	g | _        dS || _        dS )a  Do some setup after initialisation.

        :param elt: The element that forms the output of the expression.
        :type elt: NodeNG or None

        :param generators: The generators that are looped through.
        :type generators: list(Comprehension) or None
        NrR  r`  s      rH   r   zListComp.postinit  s)      	) DOOO(DOOOrJ   rP   r   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
        rq  r5  s     rH   r6  zListComp.bool_value  rs  rJ   c              #  6   K   | j         V  | j        E d {V  d S ro   rR  r   s    rH   r:  zListComp.get_children  rd  rJ   re  rf  rg  ro   rB  ri  rO  s   @rH   r|  r|    s          ,O%
C 	
 
 
 
 
 
 
 
() ) ) ) )         # # # # # # #rJ   r|  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.
    Nr@   r>   rA   r?   builtins)r   r   r   r#  infer_call_resultr   r   Instance_proxiedClassDefis_subtype_ofr   r8   r+   Namerp   BUILTIN_DESCRIPTORS	Attributeexprattrname)rs   rS   	decorators      rH   _infer_decorator_callchainr    s    dK(( t; td,,T[994@@   tt&%.)) !&(## " 677 	! = 788 	"!>&+&& *  	4*0 
	* 
	*I)\%677 *>%88 *$>)))9l&<==*y~|/@AA* N':5* &*==	* !))))4s   (A 
AAc                       e Zd ZdZdZdZdZdZ e            Z		 d)dZ
ed*d
            Z	 	 	 d+ddd fdZd,dZd-dZd.dZd/dZd0dZd1d2dZd3dZd1d4dZd Zdd d5d%Z	 d1d6d(Z xZS )7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   rU  z<lambda>TrZ   r   c                    dS )Nr   rE   r   s    rH   implicit_parameterszLambda.implicit_parameters      qrJ   Literal['method', 'function']c                    | j         j        rI| j         j        d         j        dk    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  	argumentsrp   r   r   scoper  r   s    rH   r   zLambda.type!  sT     9 	 49#6q#9#>&#H 	 $+++--x88  xzrJ   NrV  c                   i | _         	 |  	 g | _        	 i | _        t                                          |||||           dS rX  )r   r   instance_attrsr   r   r[  s         rH   r   zLambda.__init__,  sh    6 L4		
 8:!!) 	 	
 	
 	
 	
 	
rJ   r  r'   c                "    || _         || _        dS )zDo some setup after initialisation.

        :param args: The arguments that the function takes.

        :param body: The contents of the function body.
        :type body: list(NodeNG)
        Nr  )r   r  r   s      rH   r   zLambda.postinit]  s     				rJ   6Literal['bultins.instancemethod', 'builtins.function']c                    d| j         v rdS dS )r   r  zbuiltins.instancemethodzbuiltins.functionr   r   s    rH   r   zLambda.pytypeh  s    
 ty  	-,,""rJ   r   c                    d| j         v rdS dS )r   r  MethodFunctionr  r   s    rH   r   zLambda.display_typeq  s     ty  	8zrJ   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``.
        TrE   r   s    rH   callablezLambda.callable{  r7  rJ   	list[str]c                4   | j         j        rt          | j         j                  }ng }| j         j        r|                    | j         j                   |d | j         j        D             z  }| j         j        r|                    | j         j                   |S )a  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 rE   rp   )rF   rS  s     rH   rI   z#Lambda.argnames.<locals>.<listcomp>  s    ;;;s#(;;;rJ   )r  r  _rec_get_namesvarargrQ   
kwonlyargskwarg)r   r{   s     rH   argnameszLambda.argnames  s     9 	"49#677EEE9 	+LL)***;;di&:;;;;9? 	*LL)))rJ   rP   r   c                6    | j                             |          S )zqInfer what the function returns when called.

        :param caller: Unused
        :type caller: object
        )r   r'  )r   callerrP   s      rH   r  zLambda.infer_call_result  s     yw'''rJ   r   c                    || j         j        v s|| j         j        v r| j                            d          }d}n| }|                    |||          S )aa  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.
        :type node: NodeNG

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

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

        :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).
        :rtype: tuple(str, list(NodeNG))
        Tr   r]   )r  defaultskw_defaultsr   r   r   )r   rs   rp   r   r   s        rH   r   zLambda.scope_lookup  sg    $ 49%% 	1F)F 	K%%T%22E FF E""4v666rJ   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``.
        TrE   r5  s     rH   r6  zLambda.bool_value  r7  rJ   c              #  .   K   | j         V  | j        V  d S ro   r  r   s    rH   r:  zLambda.get_children  s       iirJ   r   r   rB   r   r   c                   | S r<  rE   r   s     rH   r   zLambda.frame  r=  rJ   rp   list[NodeNG]c                    |st          | ||          g }|| j        v r| j        |         }|| j        v r-|                    | j                            |                     |r|S t          | |          )Nr   )r   r   )r   r  r   rQ   r"   )r   rp   rP   found_attrss       rH   r   zLambda.getattr  s      	X)wWWWW4&& 	4-d3K4** 	Et6==dCCDDD 	%TTBBBBrJ   )rZ   r   )rZ   r  re  )r  r'   )rZ   r  rA  )rZ   r   )rZ   r  ro   rB  r@  rh  rD  )rp   r   rP   r   rZ   r  )r   rE  rF  r   rG  rJ  rp   	is_lambdar$   r   r  r~   r   r   r   r   r   r  r  r  r   r6  r:  r   r   rN  rO  s   @rH   r  r    s         'O%DI&A       X 	/
 /
 /
 /
 /
 /
 /
 /
b	 	 	 	# # # #         &	( 	( 	( 	( 	(7 7 7 78       :>       =AC C C C C C C C CrJ   r  c                      e Zd ZU dZdZdZdZdZded<   	 dZ		 dZ
	 dZ	 dZ	 dZd	ZdZ ej        d
          	 	 	 	 	 d=dddd> fd            Z	 	 	 	 d?dddd@dZedAd            Zej        dBd            ZedCd            ZedDd             ZedEd"            Zed#             ZdFd%Zd& ZdGdHd)ZdId+Zej         dGdHd,            Z!dId-Z"dJdId/Z#dId0Z$dGdHd1Z%dKdHd2Z&dGdLd3Z'd4 Z(dM fd6	Z)dd7dNd<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  returnsr   r   r9  Nnode_classes.Decorators | Noner   T)rp   r   position)r   _typetype_comment_returnstype_comment_argsr   r   rV  r   r   c                   || _         	 || _        	 d| _        	 i | _        t	                                          |||||           |r.|                    d          }|                    ||            dS dS )a  
        :param name: The name of the function.
        :type name: str or None

        :param doc: The function docstring.

        :param lineno: The line that this node appears on in the source code.
        :type lineno: int or None

        :param col_offset: The column that this node appears on in the
            source code.
        :type col_offset: int or None

        :param parent: The parent node in the syntax tree.
        :type parent: NodeNG or None

        :param end_lineno: The last line this node appears on in the source code.
        :type end_lineno: Optional[int]

        :param end_col_offset: The end column this node appears on in the
            source code. Note: This is after the last symbol.
        :type end_col_offset: Optional[int]
        NrY  Tr   )rp   r   r   r  r   r   r   	set_local)
r   rp   r   rq   r   r   r   r   r   r   s
            rH   r   zFunctionDef.__init__  s    F 		
 	%&*5 !!) 	 	
 	
 	
  	(LLL--EOOD$'''''	( 	(rJ   r  r   r  r'   r  Position | Noner   r   c                   || _         || _        || _        || _        || _        || _        || _        || _        |r|j        | _	        dS dS )a  Do some setup after initialisation.

        :param args: The arguments that the function takes.

        :param body: The contents of the function body.
        :type body: list(NodeNG)

        :param decorators: The decorators that are applied to this
            method or function.
        :type decorators: Decorators or None
        :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.
        N)
r  r   r   r  r  r  r  r   r   r   )	r   r  r   r   r  r  r  r  r   s	            rH   r   zFunctionDef.postinitM  s]    > 		$$8!!2   	' DIII	' 	'rJ   rZ   c                D    t          j        dt                     | j        S )zThe function docstring.zRThe 'FunctionDef.doc' attribute is deprecated, use 'FunctionDef.doc_node' instead.r   r   s    rH   r   zFunctionDef.docw  s*     	2	
 	
 	

 yrJ   r   r[   c                H    t          j        dt                     || _        d S )NzZSetting the 'FunctionDef.doc' attribute is deprecated, use 'FunctionDef.doc_node' instead.r   r   s     rH   r   zFunctionDef.doc  s+    2	
 	
 	

 			rJ   list[node_classes.Call]c                \   | j                             d          }t          |t                    sg S g }|                                D ]}t          |j        t          j                  rt          |j        j        t          j	                  r|j
        D ]}t          |t          j                  s|j        | j        k    r.	 || j                 }t          |t                    r4|                    d          |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.
        Tr   )r   r   r   r  _get_assign_nodesr   r+   Callfuncr  targets
AssignNamerp   r   rQ   r"  )r   r   r   assignassign_nodemeths         rH   extra_decoratorszFunctionDef.extra_decorators  sS    !!!..%** 	I.0
--// 	< 	<F&,(9:: <z!<#4@ @ < $*> < <K%k<3JKK ! "'494 ! !<$TY/ 't[99< + 1 1 1 > >% G< '--fl;;; $ ! ! ! ! s   D
D('D(r   c                   | j         D ]#}|j        j        t          v r|j        j        c S $| j                            d          }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.
        Tr   r  __new__r>   __init_subclass____class_getitem__r  r  Nr@   rA   r?   )r  r  rp   r  r   r   r   r  r   r8   r+   r  r  r  r  r  r#  r'  r   r%  r  	ancestorsr  )	r   r  r   	type_namers   currentr  r.  ancestors	            rH   r   zFunctionDef.type  s    . 	+ 	+I~"&99 + ~****+ !!!..	eX&& 	!yI% %$}y// %$}y// %$} I 	O) *	 *	D$ 122 %9 33 %9$$$4!788%ty,*;<<% INj0% M%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   &E22FF*IAI(II
IIr  c                n    | j         }| j        &|t          d | j        j        D                       z  }|S )<The first line that this node appears on in the source code.Nc              3  :   K   | ]}|j         |j        z
  d z   V  dS rK   Nr   rq   rr   s     rH   rd   z)FunctionDef.fromlineno.<locals>.<genexpr>   sA        48+a/     rJ   )rq   r   sumr8   r   s     rH   r   zFunctionDef.fromlineno  sS    
 ? 	c  <@O<Q     F rJ   c                    | j         j        S )PThe line on which the beginning of this block ends.

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

        :param lineno: Unused.
        :type lineno: int

        :returns: The range of line numbers that this node belongs to,
        :rtype: tuple(int, int)
        r   r   s     rH   r   zFunctionDef.block_range  r   rJ   rP   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       rH   r   zFunctionDef.igetattr  sv    	%dll4&A&A7RVWWWW& 	 	 	 E

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

        :returns: Whether this is a method.
        r  Tr   )r   r   r   r   r  r   s    rH   	is_methodzFunctionDef.is_method%  s<     yJ& 
:KT**H,
 ,
 	
rJ   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.
        :rtype: set(str)
        NrP   )r   r   r8   r  r'  addra   r   )r   rP   rS   decoratornodesdecnodeinfnodes         rH   decoratornameszFunctionDef.decoratornames0  s     ? 	4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    rH   r  zFunctionDef.is_boundF  s    
 y555rJ   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   r8   r#  r'  r   r%  ra   r   r   r+   Raiseraises_not_implementedPass)r   pass_is_abstractany_raise_is_abstractrs   r.  
child_nodes         rH   is_abstractzFunctionDef.is_abstractM  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          |                                 d                    S )zhCheck if this is a generator function.

        :returns: Whether this is a generator function.
        F)r   r#  _get_yield_nodes_skip_lambdasr   s    rH   is_generatorzFunctionDef.is_generatorq  s(    
 D;;==uEEFFFrJ   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_classr+   Yieldr   r(   r   rq   r  r'  )r   rP   yield_consts       rH   infer_yield_resultzFunctionDef.infer_yield_resultx  s       )),*<== 	? 	?F| ?$*400%%}4' ?!<--g->>>>>>>>>	? 	?rJ   c              #    K   |                                  rAt          | t                    rt          j        }nt          j        } ||           }|V  dS | j        dk    rt          | j        j                  dk    r| j        j	        t          |j        d                                       d          }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             g g |           |V  dS |                                 }	t          |	d          }
|
sT| j        r>|                     d
d
          rt*          j        V  nt/          j        d          V  dS t          d          t3          j        |
f|	          D ]_}|j        t/          j        d          V   	 |j                                      E d{V  B# t          $ r t*          j        V  Y \w xY wdS )zInfer what the function returns when called.

        :returns: What the function returns.
        :rtype: iterable(NodeNG or Uninferable) or None
        )generator_initial_contextNwith_metaclassrK   r   c                T    g | ]$}t          |                                        %S rE   )r#  r'  )rF   argrP   s     rH   rI   z1FunctionDef.infer_call_result.<locals>.<listcomp>  s-    "W"W"W4		'(:(:#;#;"W"W"WrJ   rs   rP   temporary_classr  Tc                2    g | ]}|t           j        k    |S rE   rq  rb   s     rH   rI   z1FunctionDef.infer_call_result.<locals>.<listcomp>  s%    TTTD44CS;ST4TTTrJ   )r   r   r   	metaclass)r  r  z0The function does not have any return statements)r  r   AsyncFunctionDefr   AsyncGeneratorr   rp   lenr  r  r#  r'  r  r%  r   hider   r    _get_return_nodes_skip_functionsr   r  r   rr  r+   r(   	itertoolschainr   )r   r  rP   generator_clsrS   r  class_basese	new_classr  first_return
returnnodes     `         rH   r  zFunctionDef.infer_call_result  s       	$ 011 0 % 4 %"]47KKKFLLLF I))	DIN##q(	 	 	
 V[^11'::DAAI)X.. W"W"W"W"Wv{STSUSU"W"W"WKK$ W W W(fk!""owOOOUVVW$*;<<<	!%	#'	 ""TTKTTT!'	 #     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*   C. .
D8DD H88II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``.
        TrE   r5  s     rH   r6  zFunctionDef.bool_value  r7  rJ   c              #  v   K   | j         	| j         V  | j        V  | j        	| j        V  | j        E d {V  d S ro   )r   r  r  r   r   s    rH   r:  zFunctionDef.get_children  sa      ? 	"/!!!i< 	,9rJ   r   c                    |dk    r5| j                             d          }t          |t                    r| |gfS t	                                          |||          S )z(Lookup where the given name is assigned.r   Tr   )r   r   r   r  r   r   )r   rs   rp   r   r   r   s        rH   r   zFunctionDef.scope_lookup  sd    ; 	%
 K%%T%22E%** %eW}$ww##D$777rJ   r   r   rB   r   r   c                   | S r<  rE   r   s     rH   r   zFunctionDef.frame  r=  rJ   NNNNNr   r   )NNNN)r  r'   r   r  r  r  r   r   r>  r?  )rZ   r  rA  rZ   r  )rZ   r  ro   rB  r   )TFrf  rC  r@  rD  ),r   rE  rF  r   rG  _multi_line_block_fieldsr  r   rH  is_functiontype_annotationr  r  rI  rJ  r  rK  rL  r   r   r~   r   rM  r5   r  r   r   r  r  r   r   r  cachedr  r  r  r  r  r  r6  r:  r   r   rN  rO  s   @rH   r   r     sP        	 	 LO(G15J5555EK O   \/M E'^',UVVV 8( 8( 8( 8( 8( 8( 8( 8( WV8(| 6:!(' %)!%(' (' (' (' (' ('T    X 	Z   Z & & & _&P C C C _CJ 
 
 
 _
 " " _"+ + + +	. 	. 	.    	
 	
 	
 	
     *6 6 6 6" " " " "HG G G G? ? ? ? ?">+ >+ >+ >+ >+@    	 	 	
8 
8 
8 
8 
8 
8 :>          rJ   r   c                      e Zd ZdZdS )r  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   rE  rF  r   rE   rJ   rH   r  r    s           rJ   r  r{   r   r  c                    |g }| D ]L}t          |t          j                  rt          |j        |           2|                    |j                   M|S )z#return a list of all argument names)r   r+   r(  r  r*  rQ   rp   )r  r{   r  s      rH   r  r    sd      # #c<-.. 	#38U++++LL""""LrJ   r   c                   | j         dk    rdS |t                      }| j        D ]}	 |                                D ]}|                                }||v r|                    |           t          |t          j                  r  dS |t          j	        u r]|| u rbt          |t                    sx|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   TNFr  )rp   r   r   r'  ra   r  r   r  r   rr  r  r  _is_metaclassr   )r   seenrc   baseobjbaseobj_names        rH   r-  r-    s>    zV t uu  	::<<    &}}4' &&&gu~66 ! 555d.. e# !'844 =K/  444 $//  444 # &  	 	 	H	5s$   AC
6C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  r;   	exceptionclassF)recurs)
r  r-  rp   r   r   ra   r  r  _class_typer   )r   r  
klass_namerc   rp   s        rH   r5  r5  4  s    
 { {U !			[	)	) ! 	I[[]]
" 	!EK7j!!!OO5O11 	 	DtY//Dw ;& }U/C/C  "i { ;rJ   c                    |                      d          }|Qt          |t                    s<|j        d}n|j                             d          }|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
    Tr   N)r   r   r  r   )rs   r   s     rH   get_wrapping_classr8  V  s{     JJdJ##E
 4Juh$?$? 4< 	4EEL&&d&33E	  4Juh$?$? 4
 LrJ   c                  H    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 ej        d          	 	 	 	 	 dfddddg fd            Zde
d<   edhd            Zej        did            ZdjdZd Z	 	 	 dkddddld Zdmdnd#ZdZ eed$          Zedo fd&            Zed'             Zd( Z dpd*Z!dqd,Z"drd.Z#dmdsd/Z$d0 Z%dmdnd1Z&dtd3Z'ed4             Z(	 dudvd8Z)dmdnd9Z*dmdnd:Z+drd;Z,dmdnd<Z-dmdnd=Z.dwd?Z/	 	 dxdydCZ0 e1dDE          dF             Z2dG Z3	 	 dxdzdIZ4dmdsdJZ5dmdndKZ6dL Z7dM Z8dN Z9	 dmd{dOZ:	 d|d}dRZ;dmd{dSZ<dT Z=dU Z>dV Z?ej@        dW             ZAdmdndXZBdmdndYZCdmd~d[ZDdmdd]ZEd^ ZFej@        d_             ZGdd`ddeZH xZIS )r  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   NNodeNG | None
_metaclassFz\The class type for this node.

Possible values are: class, metaclass, exception.

:type: strr   )rp   r   is_dataclassr  )r   	_newstyler   rV  r   r   c                  i | _         i | _        	 g | _        	 g | _        	 g | _        	 || _        	 || _        	 d| _        	 d| _        	 t                      
                    |||||           |*|                    d                              ||            |                                 D ]\  }}	|                     |	|           dS )a  
        :param name: The name of the class.
        :type name: str or None

        :param doc: The class docstring.

        :param lineno: The line that this node appears on in the source code.
        :type lineno: int or None

        :param col_offset: The column that this node appears on in the
            source code.
        :type col_offset: int or None

        :param parent: The parent node in the syntax tree.
        :type parent: NodeNG or None

        :param end_lineno: The last line this node appears on in the source code.
        :type end_lineno: Optional[int]

        :param end_col_offset: The end column this node appears on in the
            source code. Note: This is after the last symbol.
        :type end_col_offset: Optional[int]
        NFrY  Tr   )r  r   r:  r   r   rp   r   r   r=  r   r   r   r  implicit_localsadd_local_node)r   rp   r   rq   r   r   r   r   
local_namers   r   s             rH   r   zClassDef.__init__  s   F !L	 $&
+		
 		
 	"&*5"'0!!) 	 	
 	
 	
  	<LLL%%//d;;; $ 4 4 6 6 	2 	2Jj1111	2 	2rJ   z!ClassVar[InferBinaryOp[ClassDef]]infer_binary_oprZ   c                D    t          j        dt                     | j        S )zThe class docstring.zLThe 'ClassDef.doc' attribute is deprecated, use 'ClassDef.doc_node' instead.r   r   s    rH   r   zClassDef.doc  s*     	/	
 	
 	

 yrJ   r   r[   c                H    t          j        dt                     || _        d S )NzZSetting the 'ClassDef.doc' attribute is deprecated, use 'ClassDef.doc_node.value' instead.r   r   s     rH   r   zClassDef.doc  s+    5	
 	
 	

 			rJ   
Literal[1]c                    dS )NrK   rE   r   s    rH   r  zClassDef.implicit_parameters  r  rJ   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), ...)
        rE  rF  )r   attr___module__attr___qualname__)r   locals_s     rH   r@  zClassDef.implicit_locals  s4     !$"9"IJL^T%<%NOQQrJ   r  r  r  r  r   r   c                   ||| _         || _        || _        || _        ||| _        ||| _        || _        || _        |r|j        | _	        dS dS )a  Do some setup after initialisation.

        :param bases: What the class inherits from.
        :type bases: list(NodeNG)

        :param body: The contents of the class body.
        :type body: list(NodeNG)

        :param decorators: The decorators that are applied to this class.
        :type decorators: Decorators or None

        :param newstyle: Whether this is a new style class or not.
        :type newstyle: bool or None

        :param metaclass: The metaclass of this class.

        :param keywords: The keywords given to the class definition.
        :type keywords: list(Keyword) or None

        :param position: Position of class keyword and name.

        :param doc_node: The doc node associated with this node.
        N)
r:  r   r   r   r>  r<  r  r   r   r   )	r   r   r   r   newstyler  r:  r  r   s	            rH   r   zClassDef.postinit  st    F  	%$DM
	$ 	&%DN 	('DO   	' DIII	' 	'rJ   rP   r   c                b   |t                      }| j        | j        S |                     d|          D ] }|                    |          r	d| _         n!|                                 }|/t          |t                    r|                    |          | _        | j        d| _        | j        S )NFr4  rP   T)r   r>  r  _newstyle_impldeclared_metaclassr   r  )r   rP   rc   r   s       rH   rP  zClassDef._newstyle_implC  s     	)&((G> 	">!NN%NAA 	 	D""7++ !% ''))  	;E8!<!< 	;"11'::DN> 	#"DN~rJ   z=Whether this is a new style class or not

:type: bool or Noner  c                    t           rt          rDt          r=t          s6| j        }| j        &|t          d | j        j        D                       z  }|S t                      j	        S )r  Nc              3  :   K   | ]}|j         |j        z
  d z   V  dS r  r  rr   s     rH   rd   z&ClassDef.fromlineno.<locals>.<genexpr>d  sA        8<DMDK/!3     rJ   )
r   r   r   r   rq   r   r  r8   r   r   )r   rq   r   s     rH   r   zClassDef.fromlineno[  s      
	G 
	 
	5E 
	 [F #  @D@U      Mww!!rJ   c                B    | j         r| j         d         j        S | j        S )r  r]   )r   r   r   r   s    rH   r  zClassDef.blockstart_tolinenok  s%     : 	+:b>**rJ   c                    | j         | j        fS r  r   r   s     rH   r   zClassDef.block_rangev  r   rJ   -Literal['builtins.type', 'builtins.classobj']c                    | j         rdS dS )r   builtins.typezbuiltins.classobj)rM  r   s    rH   r   zClassDef.pytype  s    
 = 	#"?""rJ   r   c                    dS )r   ClassrE   r   s    rH   r   zClassDef.display_type  s	     wrJ   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``.
        TrE   r   s    rH   r  zClassDef.callable  r7  rJ   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 ro   r`   )rF   ancr  s     rH   rd   z)ClassDef.is_subtype_of.<locals>.<genexpr>  s0      WW399;;)+WWWWWWrJ   r  )ra   rf   r  )r   r  rP   s    ` rH   r  zClassDef.is_subtype_of  sP     ::<<9$ 	4WWWWt~~g~7V7VWWWWWWrJ   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          |          }	 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  rK   r  )originalr      )r#  r  r'  r%  r   r   r+   r(   r   r   r   rr  r  r(  r)  iteredrQ   EvaluatedObjectr   Dictitemsr   r   )r   r  rP   	name_noder  rp   rS   r  r   rc   r.  membersattrr   s                 rH   _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##$	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7-C% %
D/DD2-G   G65G6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 calledrX  r3   Nr  __call__zbuiltins.type.__call__)r  r  r  ri  r  r   r#  r   r   r%  ra   r   callcontextcalleer  instantiate_class)r   r  rP   rS   dunder_callr  s         rH   r  zClassDef.infer_call_result  s_     ow77 	C<L<LPQ<Q 	**67;;FLLLF
	w77I P
 !11 P"&y'9'9*g'N'N"O"OK'7 	 	 	D	  	+;,,..2JJ 	+ +7D99G)4G&"44VWEEEEEEEEEEE((*******s   AB B)(B)r   c                   t          j        t          j                  o|t	                      j        v }t          fd| j        D                       s|r| j                            d          }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.
        :type node: NodeNG

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

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

        :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).
        :rtype: tuple(str, list(NodeNG))
        c              3  N   K   | ]}|k    p|                               V   d S ro   )	parent_of)rF   rc   rs   s     rH   rd   z(ClassDef.scope_lookup.<locals>.<genexpr>	  s8      LL4t 4 4LLLLLLrJ   Tr   r]   )
r   r   r+   
Decoratorsr&   builtins_modulerf   r   r   r   )r   rs   rp   r   lookup_upper_framer   s    `    rH   r   zClassDef.scope_lookup  s    . t{L$;<< 9((88 	
 LLLLLLLLL	!	" K%%T%22E FFE""4v666rJ   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 rE   )	as_string)rF   bnodes     rH   rI   z&ClassDef.basenames.<locals>.<listcomp>/	  s"    :::e!!:::rJ   r   r   s    rH   	basenameszClassDef.basenames'	  s     ;:tz::::rJ   Tr4  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objectrK   r   TrO  )r   r   ra   r.   restore_pathr'  r   r  r  r  r  r  r  r   )r   r4  rP   yieldedstmtr/  grandpas          rH   r  zClassDef.ancestors1	  s(      & 	)&((Gz 	djjll.?? 	 **1-a0000FJ 	 	D%%''  #'::g#6#6 * *)'8<< ))'5>BB )*1*: (&| *&'1 ) (#KK000")MMM% %$'.'8'8g'8'V'V * *G&$ & %&'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)
        rK   Nr  )mror   r  )r   rp   rP   r  astroids        rH   local_attr_ancestorszClassDef.local_attr_ancestors^	  s      	8))!""-II 	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   rp   rP   r  s       rH   instance_attr_ancestorsz ClassDef.instance_attr_ancestorss	  sI       ~~g~66 	 	Gw-- 	 	rJ   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   rs   s     rH   has_basezClassDef.has_base	  s     tz!!rJ   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 rE   r   r+   DelAttrr   s     rH   rI   z'ClassDef.local_attr.<locals>.<listcomp>	  r   rJ   r   )r   r#  r  r   )r   rp   rP   rS   
class_nodes        rH   
local_attrzClassDef.local_attr	  s     4; 	1[&FFd77gFFMMJ 1#*40OOVOOO 	M%TT7SSSSrJ   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 rE   r  r   s     rH   rI   z*ClassDef.instance_attr.<locals>.<listcomp>	  r   rJ   r   )listr  getr  r   )r   rp   rP   valuesr  s        rH   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SrJ   bases.Instancec                    	 t          d |                                 D                       rt                              |           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
        c              3  2   K   | ]}|j         t          v V  d S ro   )rp   EXCEPTION_BASE_CLASSES)rF   rO   s     rH   rd   z-ClassDef.instantiate_class.<locals>.<genexpr>	  s*      LL#3855LLLLLLrJ   )rf   r  r=   ExceptionInstancer   r   r  r   s    rH   rn  zClassDef.instantiate_class	  sy    
	LLLLLLL 7006667  	 	 	D	~d###s   AA 
AArp   class_contextlist[SuccessfulInferenceResult]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 ]{}t          |t          j                  r_|                    d          }t          |t          j                  r/|j        (|                    |                    |                     ||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   TrO  	__bases__r   )r   r  r   r  r  r   r"   _metaclass_lookup_attributecopyr   r+   r  r   	AnnAssignr   rg   index)	r   rp   rP   r  r  	classnoderS   r   r  s	            rH   r   zClassDef.getattr	  s   8  	X)wWWWW 37t{tR7P7P2Q2Q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d33dL$:;; 4
 4JJv||E22333 	X)wWWWWrJ   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  )r   implicit_metaclassr   r  r   r  _get_attribute_from_metaclassupdate)r   rp   rP   attrsimplicit_metar  rO   cls_attributess           rH   r  z$ClassDef._metaclass_lookup_attribute 
  s     //11w''NN7N33	!9- 	2 	2C 2sd{ 2z#x'@'@ 2!%!C!CCw!W!WS00111rJ   c              #    K   	 |                     ||d          }n# t          $ r Y d S w xY wt          j        |||          D ]}t	          |t
                    s|V  t	          |t          j                  r|V  ;|j        dk    r)t          |          p| }t          j
        ||          V  o|j        dk    r|V  t          j
        ||           V  d S )NT)rP   r  r   r>   r?   )r   r   r   r   r   r   r=   Propertyr   r8  r   )r   rO   rp   rP   r  rh  r   s          rH   r  z&ClassDef._get_attribute_from_metaclass
  s'     	KKgTKJJEE& 	 	 	FF	 &ugSAAA 	4 	4DdK00 


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


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



'd333333'	4 	4s    
++Iterator[InferenceResult]c              #  T  
K   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          |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!t1          t3          |	          | ||          |	Y d}	~	dS d}	~	ww xY w)zInfer the possible values of the given variable.

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

        :returns: The inferred possible values.
        r  )r  rK   r   Nc                \    g | ](}|j         	|j                                         k    &|)S rE   )r   r  )rF   rh  first_scopes     rH   rI   z%ClassDef.igetattr.<locals>.<listcomp>B
  sN     - - -{- (,{'8'8':':k'I-- - -rJ   r   __get__)r  rP   __r   )r   r   r  r   r  r  r   r   r   r+   r(   r  r  r   rr  r   r=   r  r  r  r   r   r  has_dynamic_getattrr   r   )r   rp   rP   r  r  
attributes
first_attrr.  r  r   r  s             @rH   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 ' $,#=#=#' $> $ $         ',Xt<<<<<<A =  =B ' 	 	 	??4(( T-E-Eg-N-N &&&&&$JJttW   '&&&&&	s>   B1F8 #D>F8 DF8 DBF8 8
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   )rootrp   r   )rs   r  s     rH   _valid_getattrz4ClassDef.has_dynamic_getattr.<locals>._valid_getattr|
  s-    99;;D9
*Qwt]D/Q/QQrJ   __getattr__r   __getattribute__F)r   r   )r   rP   r  getattributes       rH   r  zClassDef.has_dynamic_getattrr
  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  Nr   )r  rm  rX  )r"   r   r   r  r   r   r   r   rl  r#  r  r   rr  r&  r+   	EmptyNoder   r   r   )r   r  rP   methodsr   r  new_contexts          rH   getitemzClassDef.getitem
  s   	LT=11GG& 	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 
  	$ 	$ 	$####	$sD    
BB A	B 	A&&B  B8-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)r  r  iterr  	mymethodsrp   )r   doner  r  s       rH   r  zClassDef.methods
  s        tTG}}dnn6F6FGG 	 	G))++  9$ "&TY



		 	rJ   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     rH   r  zClassDef.mymethods
  sE       kkmm 	 	F&+.. 	 	rJ   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   rK   r   N)rM  r.   r   s    rH   r  zClassDef.implicit_metaclass
  s+     = 	0!&))!,Q//trJ   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  6   K   | ]}|t           j        u|V  d S ro   rq  rr   s     rH   rd   z.ClassDef.declared_metaclass.<locals>.<genexpr>  sD        4#33     rJ   N)
r   r'  r   r  r  r<  _metaclass_hackr   r#  r%  )r   rP   rc   r/  s       rH   rQ  zClassDef.declared_metaclass
  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r.  set[ClassDef] | Nonec                    |t                      }|                    |            |                     |          }|6|                     |          D ]}||vr|                    |          }| n |S Nr  )r   r  rQ  r  _find_metaclass)r   r.  rP   r   r   s        rH   r  zClassDef._find_metaclass  s      	55D'''88 	...99  % "22488E rJ   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  r5  s     rH   r  zClassDef.metaclass  s     ##G#444rJ   c                    | j         S ro   )r  r   s    rH   has_metaclass_hackzClassDef.has_metaclass_hack&  s    ##rJ   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          j        u r|s|c S |D ]z}	 |                                D ]R}|t          j        u rt          |t          j                  rt          |j        t                     sF|j        sN|V  Sk# t"          $ r Y ww xY w@dS )z+Return an iterator with the inferred slots.	__slots__Nrb  c                    g | ]
}|d          S r@  rE   )rF   items     rH   rI   z$ClassDef._islots.<locals>.<listcomp>C  s    :::d$q':::rJ   )r   r   ITER_METHODSr   r   r   r+   r(   r   hasattrrd  re  rb  r   rr  r'  r   r   )r   slotsr  r  rS  r.  s         rH   _islotszClassDef._islots)  s     dk) 	4]];// -	 -	E$  MM$'''E.   H %!344  ;  KKK5(++ %!233 (::ek:::))     $'IIKK 	' 	'#t'77 %$)$l&8    %!+HNC!@!@% %'~ %$&	' &   H ts$   A
AA)A'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t          |          z   S )N8The concept of slots is undefined for old-style classes.r   )r  N)rM  NotImplementedErrorr  r#  r%  r  r  )r   r  firstr   s       rH   _slotszClassDef._slots^  s    } 	%J   	KKEE 	 	 	x #CHQKz9 #x{""""""44444		
 we$$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]rZ   $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}  )ra   r  r  )r  rO   	cls_slotss      rH   grouped_slotsz%ClassDef.slots.<locals>.grouped_slotsz  s         99;;"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 ro   rE   )rF   slots     rH   rd   z!ClassDef.slots.<locals>.<genexpr>  s'      664t#666666rJ   c                    | j         S ro   )r   )r  s    rH   <lambda>z ClassDef.slots.<locals>.<lambda>  s    4: rJ   )rm  )r  r  rZ   r  )rM  r  r  r   r  allsortedr   )r   r  r  r  r  s        rH   r  zClassDef.slotso  s    	 	 	 	  } 	%J  	((**CC 	 	 	%; 	
 ]]3''((6666666 	4c%jj&=&=>>>>s   1 
AAA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~  rK   r   c              3  R   K   | ]"}t          |t                    r|j        |V  #d S ro   )r   r(   r   )rF   bs     rH   rd   z+ClassDef._inferred_bases.<locals>.<genexpr>  sR        &q%00 67W     rJ   r  )r   r   ra   r.   r#  r'  cloner   r%  r   r  r  r  r  )r   rP   r  r/  s       rH   _inferred_baseszClassDef._inferred_bases  sJ       	)&((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                   t          |                     |                    }g }|D ]{}|| u r	 |                    |          }|                    |           4# t          $ r; t          |                    |                    }|                    |           Y xw xY w| gg|z   |gz   }t          t          || |                    }t          |           t          || |          S r  )	r  r  _compute_mrorQ   r  r  r|   rl   rX   )r   rP   ri   rh   rc   r  r  unmerged_mros           rH   r  zClassDef._compute_mro  s   d2272CCDD	" 	, 	,Dt| 
,'''88  %%%%& , , , !!@!@AA	  +++++, x)+~.>>0tWMMNN ...tW555s   +AA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  r5  s     rH   r  zClassDef.mro  s        111rJ   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``.
        TrE   r5  s     rH   r6  zClassDef.bool_value  r7  rJ   c              #     K   | j         	| j         V  | j        E d {V  | j        | j        E d {V  | j        E d {V  d S ro   )r   r   r:  r   r   s    rH   r:  zClassDef.get_children  s|      ? 	"/!!!:= 	%}$$$$$$$9rJ   c                |    d | j         D             }t          t          j                            |                    S )Nc              3  >   K   | ]}|                                 V  d S ro   )r  )rF   r  s     rH   rd   z-ClassDef._get_assign_nodes.<locals>.<genexpr>  s?       !
 !
/9J((**!
 !
 !
 !
 !
 !
rJ   )r   r  r  r  from_iterable)r   children_assign_nodess     rH   r  zClassDef._get_assign_nodes  sD    !
 !
=AY!
 !
 !
 IO112GHHIIIrJ   r   r   rB   r   r   c                   | S r<  rE   r   s     rH   r   zClassDef.frame  r=  rJ   r#  r$  r>  r?  )rZ   rF  re  )r  r;  r  r  r   r   ro   rB  r%  )rZ   rV  rA  r   rC  r@  )TN)r4  r   rP   r   rZ   r{  )rZ   r  )NT)rp   r   rP   r   r  r   rZ   r  )rp   r   rP   r   r  r   rZ   r  )rP   r   rZ   r;  rf  )r.  r  rP   r   rZ   r;  )rP   r   rZ   r  rh  rD  )Jr   rE  rF  r   rG  r   r#   r   r  r<  rH  r  r  r~   r5  r   rI  rJ  r>  rK  rL  r   r   rM  r  r@  r   rP  rM  r5   r   r  r   r   r   r  r  ri  r  r   rz  r  r  r  r  r  r  rn  r   r   r  r  r   r  r  r  r  r  rQ  r  r  r  r  r  r)  r  r  r  r  r6  r:  r  r   rN  rO  s   @rH   r  r  j  s        
 
  NOJ $
 E $J$$$$OD8  D @M1I'^',UVVV Q2 Q2 Q2 Q2 Q2 Q2 Q2 Q2 WVQ2f 7666   X 	Z   Z   	 	 	" #'/' %)!%/' /' /' /' /' /'b    $ IxQ  H
 " " " " " _"   _	. 	. 	.# # # #      X X X X X. . .`+ + + + +:17 17 17 17f ; ; X; GK+ + + + +Z    *    " " " "T T T T T.T T T T T,$ $ $ $  ,0"	9 9 9 9 9v Yt
 
 
4 4 4< ,0"	H H H H HT    23$ 3$ 3$ 3$ 3$j       26# # # # #L UY     	5 	5 	5 	5 	5$ $ $3 3 3j% % %" *? *? *?X%) %) %) %) %)N6 6 6 6 602 2 2 2 2       J J J :>          rJ   r  )rR   rY   rZ   r[   ro   )r{   r   rZ   r  r   )ir   
__future__r   r   r  r  sysr   collections.abcr   r   	functoolsr   typingr   r   r	   r
   r   r  r   r   rK  r   astroid.constr   r   r   r   r   astroid.contextr   r   r   r   astroid.exceptionsr   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+    astroid.nodes.scoped_nodes.mixinr,   r-    astroid.nodes.scoped_nodes.utilsr.   astroid.nodes.utilsr/   astroid.typingr0   r1   r2   version_infor5   r6   typing_extensionsastroid.decoratorsr7   r8   r  	frozensetr  lazy_importr=   r  rB   rX   rl   r|   r   r   rQ  rk  rv  r|  r  FilterStmtsBaseNoder  MultiLineBlockNode	Statementr   r  r  r-  r5  r8  r  rE   rJ   rH   <module>r     s  
  # " " " " " 				     				 



  / / / / / / / /       G G G G G G G G G G G G G G       0 0 0 0 0 0       O O O O O O O O O O O O O O           
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 5 4 4 4 4 4 R R R R R R R R R R * * * * * * M M M M M M M M M M M M M M Q Q Q Q Q Q Q Q ; ; ; ; ; ; ( ( ( ( ( ( T T T T T T T T T Tv E))))))))))))DDDDDD  +"K#ABB 
$
9
%
%iTTT   WT]]# # #L!. !. !. !.H
 
 
(  e e e e e e e ePP# P# P# P# P#% P# P# P#f`# `# `# `# `#! `# `# `#FQ# Q# Q# Q# Q#  Q# Q# Q#hA# A# A# A# A#! A# A# A#H" " "JRC RC RC RC RC[,.> RC RC RCjM M M M M+0+2G M M M`    {   &	 	 	 	 	    D   D  ([ [ [ [ [#%5{7L[ [ [ [ [rJ   