
    yIfb                    ~   U 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Zddl	Z	ddl
Z
ddlmZ ddlmZmZ ddlmZmZ ddlmZmZ ddlmZmZ dd	lmZ dd
lmZ  ej        e          Zee	j         e	j!        e	j"        e	j#        e	j$        e	j%        f         Z& e'ej(                  Z) e*d          Z+ e*e,          Z- e*d          Z.dIdZ/dJdZ0efdIdZ1dIdZ2dKdZ3dLdMdZ4	 dNdOdZ5	 	 	 	 	 	 dPdQd(Z6dRd-Z7dLdSd0Z8dTd6Z9dUd9Z:dVd:Z;dWd;Z<dVd<Z=	 	 dXdYd=Z>dZd@Z?d[dBZ@ G dC dD          ZAi ZBdEeCdF<   d\dGZDdJdHZEdS )]zthis module contains a set of functions to create astroid trees from scratch
(build_* functions) or from living object (object_build_* functions)
    )annotationsN)Iterable)redirect_stderrredirect_stdout)AnyUnion)basesnodes)_EMPTY_OBJECT_MARKERIS_PYPY)AstroidManager)node_classes.namestrreturnNonec                >    ||_         |                     |           d S N)r   add_local_node)parentnoder   s      H/var/www/piapp/venv/lib/python3.11/site-packages/astroid/raw_building.py_attach_local_noder   /   s#    DI
$    c                    |j         }t          |dd          }|sdS d |j        D             }t          |||j                  }|g| j        d<   dS )zFAdd a __class__ member to the given func node, if we can determine it.__name__Nc                    g | ]	}|j         
S  r   ).0ancestors     r   
<listcomp>z%_add_dunder_class.<locals>.<listcomp>:   s    HHHx"HHHr   	__class__)r#   getattr	__bases__build_class__doc__instance_attrs)funcmember
python_clscls_name	cls_bases	ast_klasss         r   _add_dunder_classr/   4   sg    !Jz:t44H HH:3GHHHIHi1CDDI(1{D$$$r   c                \    t          j                    }||_        t          | ||           dS )zdcreate a dummy node and register it in the locals of the given
    node with the specified name
    N)r
   	EmptyNodeobjectr   )r   r   runtime_objectenodes       r   attach_dummy_noder5   ?   s0     OE!ELtUD)))))r   c                b    || j         vr%t          | t          j        |          |           dS dS )zdcreate a Const node and register it in the locals of the given
    node with the specified name
    N)special_attributesr   r
   const_factory)r   r   values      r   attach_const_noder:   H   s=     4***4!4U!;!;TBBBBB +*r   modname
membernamec                X    t          j        ||dfg          }t          | ||           dS )zicreate a ImportFrom node and register it in the locals of the given
    node with the specified name
    N)r
   
ImportFromr   )r   r;   r<   	from_nodes       r   attach_import_noder@   P   s6      J+=*>??ItY
33333r   doc
str | Nonenodes.Modulec                    t          j        | dd          }|                    g |rt          j        |          nd           |S )z,create and initialize an astroid Module nodeF)pure_pythonpackager9   N)bodydoc_node)r
   ModulepostinitConst)r   rA   r   s      r   build_modulerM   X   sW    <%???DMM+.83''''D     Kr   r   	basenamesIterable[str]nodes.ClassDefc           	         t          j        | ddddt          j                                                  fd|D             g d|rt          j        |          nd           S )z/Create and initialize an astroid ClassDef node.r   lineno
col_offset
end_linenoend_col_offsetr   c           
     D    g | ]}t          j        |d d dd          S )r   N)r   rS   rT   r   rU   rV   )r
   Name)r    baser   s     r   r"   zbuild_class.<locals>.<listcomp>o   sN     

 

 

  J#  

 

 

r   NrG   r	   rH   
decoratorsrI   )r
   ClassDefUnknownrK   rL   )r   rN   rA   r   s      @r   r&   r&   b   s     >}  D 	MM

 

 

 

 "

 

 

 +.83''''D      Kr   argslist[str] | Noneposonlyargsdefaultslist[Any] | None
kwonlyargskwonlydefaultsnodes.FunctionDefc           
        t          j        | ddt          j                    dd          }t          j        |dd          |fd|D             }nd}|d}	n7g }	|D ]2}
t          j        |
          }|_        |	                    |           3|d}n7g }|D ]2}t          j        |          }|_        |                    |           3                    ||	fd|pdD             |g fd|pdD             g g 	           |                    g |rt          j	        |
          nd           |rt          |           |S )z1create and initialize an astroid FunctionDef noder   )rS   rT   r   rV   rU   N)r   varargkwargc           
     D    g | ]}t          j        |d d dd          S r   N)r   r   rS   rT   rU   rV   r
   
AssignNamer    argargsnodes     r   r"   z"build_function.<locals>.<listcomp>   O     

 

 

  #  

 

 

r   c           
     D    g | ]}t          j        |d d dd          S rj   rk   rm   s     r   r"   z"build_function.<locals>.<listcomp>   sO     

 

 

  #  

 

 

r   r   c           
     D    g | ]}t          j        |d d dd          S rj   rk   rm   s     r   r"   z"build_function.<locals>.<listcomp>   rp   r   )r^   ra   rc   kw_defaultsr   r`   kwonlyargs_annotationsposonlyargs_annotationsrG   )r^   rH   rI   )r
   FunctionDefr   r]   	Argumentsr8   r   appendrK   rL   register_arguments)r   r^   r`   ra   rA   rc   rd   r)   	argumentsdefault_nodesdefaultdefault_nodekwonlydefault_nodeskwonlydefaultkwonlydefault_nodero   s                  @r   build_functionr      s    #%%  D d4tDDDH
 

 

 

 

 

 

 

		 	  	/ 	/G .w77L"*L  .... " + 	; 	;M!&!4]!C!C(0%&&'9:::: 

 

 

 

 "'R

 

 

 (

 

 

 

 #(b

 

 

  " "9    < 	MM+.83''''D    
  !4   Kr   fromnamenames	list[str]nodes.ImportFromc                @    t          j        | d |D                       S )z<create and initialize an astroid ImportFrom import statementc                    g | ]}|d fS r   r   )r    r   s     r   r"   z%build_from_import.<locals>.<listcomp>   s    &F&F&Fd|&F&F&Fr   )r
   r>   )r   r   s     r   build_from_importr      s$    H&F&F&F&F&FGGGr   r)   list | Nonec                   |r| j         j        r%|                     | j         j        | j                    | j         j        r%|                     | j         j        | j                    | j         j         }|dS |D ]M}t	          |t
          j                  r|                     |j        |           8t          | |j	                   NdS )z{add given arguments to local

    args is a list that may contains nested lists
    (i.e. def func(a, (b, c, d)): ...)
    N)
r^   rg   	set_localrh   
isinstancer
   rl   r   ry   elts)r)   r^   rn   s      r   ry   ry      s     |9 	8NN49+TY7779? 	7NN49?DI666y~<F / /c5+,, 	/NN38S))))tSX....	/ /r   r   nodes.Module | nodes.ClassDefr*   type	localnamec                J    d |j         D             }t          | |||          S )z(create astroid for a living class objectc                    g | ]	}|j         
S r   r   )r    rY   s     r   r"   z&object_build_class.<locals>.<listcomp>  s    <<<4<<<r   )r   )r%   _base_class_object_build)r   r*   r   rN   s       r   object_build_classr     s1     =<6+;<<<I#D&)yQQQQr   _FunctionTypes<tuple[list[str], list[str], list[Any], list[str], list[Any]]c                8   t          j        |           }g }g }g }g }g }|j                                        D ][\  }}|j        t           j        j        k    r|                    |           n|j        t           j        j        k    r|                    |           n|j        t           j        j	        k    r|                    |           n|j        t           j        j
        k    r|                    |           nc|j        t           j        j        k    rI|                    |           |j        t           j        j        ur|                    |j                   )|j        t           j        j        ur|                    |j                   ]|||||fS )zjReturns args, posonlyargs, defaults, kwonlyargs.

    :note: currently ignores the return annotation.
    )inspect	signature
parametersitemskind	ParameterPOSITIONAL_ONLYrx   POSITIONAL_OR_KEYWORDVAR_POSITIONALVAR_KEYWORDKEYWORD_ONLYr|   empty)	r*   r   r^   ra   r`   rc   rd   
param_nameparams	            r   _get_args_info_from_callabler     s~    !&))IDHKJ "N&17799 + +
E:*:::z****Z7,BBBKK
####Z7,;;;KK
####Z7,888KK
####Z7,999j)))}G$5$;;;%%em444= 1 777OOEM***h
NBBr   c           	         t          |          \  }}}}}t          t          |dd          p|||||j        ||          }|                     ||           dS )z+create astroid for a living function objectr   N)rc   rd   )r   r   r$   r'   r   )	r   r*   r   r^   r`   ra   rc   kwonly_defaultsr)   s	            r   object_build_functionr   .  s     	%V,, 
D))6Y&  D 	i(((((r   c                &    t          | |g |          S )z2create astroid for a living data descriptor object)r   )r   r*   r   s      r   object_build_datadescriptorr   G  s     $D&"d;;;r   c                    t          t          |dd          p||j                  }|                     ||           t	          ||           dS )z4create astroid for a living method descriptor objectr   N)rA   )r   r$   r'   r   r/   )r   r*   r   r)   s       r   object_build_methoddescriptorr   N  s^     
D))6YFN  D 	i(((dF#####r   c                   |pt          |dd          p|}t          |t                    sJ t          |||j                  }t          |t
                    |_        |                     ||           	 t          |t                    r |            j
        }nt          	 |                                D ]8\  }}	t          j                    }
|	|
_        ||
_        d|
_        |
g|j        |<   9n# t          $ r Y nw xY w|S )zbcreate astroid for a living class object, with a given set of base names
    (e.g. ancestors)
    r   N   )r$   r   r   r&   r'   r   	_newstyler   
issubclass	Exception__dict__	TypeErrorr   r
   r1   r2   r   rS   r(   )r   r*   rN   r   r   
class_nameklassinstdict	item_nameobjvalnodes              r   r   r   \  s,    GT::GiJj#&&&&& E
 !..EOy)))8
 fi(( 	vxx(HHO  'nn.. 	8 	8NIso''G GN"GNGN/6iE ++	8     Ls   4,C/ /
C<;C<moduletypes.ModuleTypec                (   	 |j         }n# t          $ r d }Y nw xY wt          |dd           }|*t          |t                    sJ t          | ||           d S |t          |dd           k    rt          | ||           d S t          | ||           d S )Nco_filename__file__)__code__AttributeErrorr$   r   r2   r   r5   r   )r   r   r*   r   codefilenames         r   _build_from_functionr     s         t]D11H&&)))))%dFD99999	WVZ66	6	6$f-----dFD11111s   
 boolc                F    	 t          | |          S # t          $ r Y dS w xY w)zwRequired because unexpected RunTimeError can be raised.

    See https://github.com/pylint-dev/astroid/issues/1958
    F)hasattrr   )r   r*   s     r   _safe_has_attributer     s9    
sF###   uus    
  c                  J    e Zd ZU dZdZded<   ddd
Z	 	 dddZddZddZ	dS ) InspectBuilderzclass for building nodes from living object

    this is actually a really minimal representation, including only Module,
    FunctionDef and ClassDef nodes and some others as guessed.
    Fr   bootstrappedNmanager_instanceAstroidManager | Noner   r   c                B    |pt                      | _        i | _        |  d S r   )r   _manager_done)selfr   s     r   __init__zInspectBuilder.__init__  s'    (<N,<,<SU
&&&r   r   r   r;   rB   pathrC   c                   || _         ||j        }	 t          ||j                  }n# t          $ r t          |          }Y nw xY w||x|_        |_        n7t          j                            |          g|_        |j        d         |_        ||_	        | j
                            |           t          |d          |_        i | _        |                     ||           |S )zbuild astroid from a living module (i.e. using inspect)
        this is used when there is no python source code available (either
        because it's a built-in module or because the .py is not available)
        Nr   __path__)_moduler   rM   r'   r   r   fileosabspathr   r   cache_moduler   rF   r   object_build)r   r   r;   r   r   s        r   inspect_buildzInspectBuilder.inspect_build  s     ?oG	)88DD 	) 	) 	)((DDD	) <$((DI		../DI	!DI	""4(((vz22
$'''s   ( AAr   r   r   types.ModuleType | typec                    || j         v rdS || j         |<   t          |          D ]}t          o|dk    }	 t          j                    5  t          j        d           t          ||          }ddd           n# 1 swxY w Y   n # t          $ r t          ||           Y }w xY wt          j
        |          r	|s|j        }t          j        |          rt          |||| j                   t          j        |          s|r+|                     |||          rt#          |||           t          j        |          r|                     |||          r8|| j         v r]| j         |         }t'          |t(          j                  sJ ||j                            |d          vr|                    ||           n't3          |||          }|                     ||           |dk    r|j        | j         | j                 |_        t          j        |          rt#          |||           t          j        |          rt=          |||           9t'          |t>                    rtA          |||           at          j!        |          rt          |||| j                   tE          |d          r8tG          |          }tI          |||           |                     ||           t          |||           dS )z}recursive method which create a partial ast from real objects
        (only function, class, and method are handled)
        N__class_getitem__ignorer   r#   __all__)%r   dirr   warningscatch_warningssimplefilterr$   r   r5   r   ismethod__func__
isfunctionr   r   	isbuiltinimported_memberr   isclassr   r
   r\   localsgetr   r   r   r   ismethoddescriptorisdatadescriptorr   
_CONSTANTSr:   	isroutiner   rM   r   )r   r   r   r   pypy__class_getitem__r*   
class_noder   s           r   r   zInspectBuilder.object_build  s    $*4
3HH 3	6 3	6D %,$K8K0K!,.. 0 0)(333$S$//F0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 "   !$--- '' )0E )!&)) %6$T4FFFF"6** #6.C #6''fd;; -dFDAAAA(( 6''fd;; TZ''!%F!3J%j%.AAAAA!r)B)BBB++J===!3D&$!G!GJ%%j&999;&&:+<+D(,
4<(@J%+F33 6-dFDAAAA)&11 6+D&$????FJ// 6!$f5555"6** 6 %T4FFFF$VY77 6%d++"4666!!&&1111 "$f5555ts5   B	%A:.B:A>	>BA>	BB#"B#r   r   c                   	 t          |dd          }n# t          $ r d}Y nw xY w|$|dv rt          j        }nt	          |||           dS |dk    r| j        j        dk    sdS dd	i                    ||          }|| j        j        k    rS	 t          t          j	                              5 }t          t          j	                              5 }t          t          j        |         |           |                                }|r-t                              d
|t          j        |         |           |                                }	|	r-t                              d|t          j        |         |	           ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   t#          |||           n(# t$          t&          f$ r t	          |||           Y nw xY wdS dS )z1verify this is not an imported class or handle it
__module__N>   __new____subclasshook__T_iobuiltinsFgtkgtk_gtkz,Captured stderr while getting %s from %s:
%sz,Captured stdout while getting %s from %s:
%s)r$   r   r   r   r5   r   r   r   ioStringIOr   sysmodulesgetvalueloggererrorinfor@   KeyErrorr   )
r   r   r*   r   r;   	real_namestderrstdoutstderr_valuestdout_values
             r   r   zInspectBuilder.imported_member  s   
	flD99GG 	 	 	GGG	?666 #+!$f555t
 eDL$9Z$G$G5I&**7G<<	---8$R[]]33 vKMM@ @ CK0$777#)??#4#4L# K K0(	   $*??#4#4L# K K0(	                               . #4$7777 n- 6 6 6!$f555556 4usg    ## F6 .!FB'F6FF	F	F	
FF6 FF6  F!F6 6"GGr   )r   r   r   r   NN)r   r   r;   rB   r   rB   r   rC   )r   r   r   r   r   r   )r   r   r   r   )
r   r   __qualname__r'   r   __annotations__r   r   r   r   r   r   r   r   r     s           L' ' ' ' ' #	    <= = = =~8 8 8 8 8 8r   r   zdict[type, nodes.ClassDef]_CONST_PROXYc                0    t           | j        j                 S r   )r  r9   r#   )consts    r   _set_proxiedr  Q  s    -..r   c            
     	   t                      } |                     t                    }t          j                                        D ]\  }}|t          u rt          d          }||_        n||t          u rt          d          }||_        n\|t          u rt          d          }||_        n<|                    |j                  d         }t          |t          j                  sJ |t           t"          t$          t&          fv r||_        |t*          |<   t-          t.                    t          j        _        t          j        t2          j        j        ddddt          j                              }||_        t2          j        j        r$t          j        t2          j        j                  nd}|                    g g d|           |t<          j        _        |                      t<          j        j        t2          j                   tC          t2          d	          rt          j        t2          j"        j        ddddt          j                              }||_        t2          j"        j        r$t          j        t2          j"        j                  nd}|                    g g d|           |t<          j#        _        |                      t<          j#        j        t2          j"                   tC          t2          d
          rt          j        t2          j$        j        ddddt          j                              }	||	_        t2          j$        j        r$t          j        t2          j$        j                  nd}
|	                    g g d|
           |	t<          j$        _        |                      t<          j$        j        t2          j$                   t2          j%        t2          j        t2          j&        t          t          t2          j'        t2          j(        t2          j)        t2          j*        t2          j+        f
}|D ]}|j        |vrt          j        |j        ddddt          j                              }||_        |                    g g d|j        rt          j        |j                  nd           |                      ||           |||j        <   dt           _,        ddl-m.}  |             dS )z)astroid bootstrapping the builtins moduleNoneTypeNotImplementedTypeEllipsisr   rR   rG   NrZ   AsyncGeneratorType	UnionTypeT)on_bootstrap)/r   r   r   r   	CONST_CLSr   	TYPE_NONEr&   r   TYPE_NOTIMPLEMENTEDTYPE_ELLIPSISr$   r   r   r
   r\   dictlistsettuple_proxiedr  propertyr  rL   typesGeneratorTyper]   r'   rK   r	   	Generatorr   r   r  AsyncGeneratorr  GetSetDescriptorTypeMemberDescriptorTypeFunctionType
MethodTypeBuiltinFunctionType
ModuleTypeTracebackTyper   %astroid.brain.brain_builtin_inferencer  )builderastroid_builtinclsnode_clsproxy_GeneratorTypegenerator_doc_node_AsyncGeneratorTypeasync_generator_doc_node_UnionTypeTypeunion_type_doc_nodebuiltin_types_typer   r  s                  r   _astroid_bootstrappingr;  V  s    G++H55O%/5577 & &X)
++E*ELL''' 455E*ELLM!!
++E*ELL#++CL99!<EeU^444444sE*** %H %L $L11EK^$}  N ,N &	%-56666 
 #	      .EO153FGGGu*++ V#n$-=??
 
 
 &5" '/EKe6>???? 	!
 	$$-	 	% 	
 	
 	
 )<%U1:E<TUUUuk"" HO$=??
 
 
 !0 &EKeo56666 	
 	(	 	  	
 	
 	
 $2 U_5uGGG 	""!M  4 4>00N }  E +ELNN=B]T5=9999PT	       ....3OEN+"&N CBBBBB LNNNNNr   )r   r   r   r   )r   r   )r;   r   r<   r   r   r   r   )r   r   rA   rB   r   rC   )r   N)r   r   rN   rO   rA   rB   r   rP   )NNNNNN)r   r   r^   r_   r`   r_   ra   rb   rA   rB   rc   r_   rd   rb   r   re   )r   r   r   r   r   r   )r)   re   r^   r   r   r   )r   r   r*   r   r   r   r   rP   )r*   r   r   r   )r   r   r*   r   r   r   r   r   )r   r   r*   r   r   r   r   rP   r
  )r   r   r*   r   rN   r   r   rB   r   rB   r   rP   )
r   r   r   r   r*   r   r   r   r   r   )r*   r   r   r   )r   rP   )Fr'   
__future__r   r   r   r   loggingr   r   r"  r   collections.abcr   
contextlibr   r   typingr   r   astroidr	   r
   astroid.constr   r   astroid.managerr   astroid.nodesr   	getLoggerr   r  r(  r)  r*  WrapperDescriptorTypeMethodDescriptorTypeClassMethodDescriptorTyper   r  r  r   r   r  NotImplementedr  r  r   r/   r5   r:   r@   rM   r&   r   r   ry   r   r   r   r   r   r   r   r   r   r  r  r  r;  r   r   r   <module>rJ     s  
   # " " " " "   				  				 



   $ $ $ $ $ $ 7 7 7 7 7 7 7 7                         7 7 7 7 7 7 7 7 * * * * * * & & & & & &		8	$	$ 						#% U<)**
DJJ	d>** S		       
3 3 3 3 7K * * * * *C C C C4 4 4 4     AE    B "$(!%#''+d d d d dNH H H H
/ / / / /.R R R RC C C CD) ) ) )2< < < <$ $ $ $$  % % % % %P2 2 2 2.   c c c c c c c cP ,. - - - -/ / / /
J J J J J Jr   