+
    i1                    ~   R t ^ RIHt ^ RIt^ RIHt ^ RIHtHtH	t	H
t
HtHt ^ RIHtHt ^ RIHtHtHtHtHt ^ RIHt ^ RIHt ^ R	IHt R*R
 R lltR R ltR R ltR*R R lltR*R R llt R*R R llt!R*R R llt"R*R R llt#R*R R llt$R*R R llt%R R lt&R  R! lt'R" R# lt(R$ R% lt)R*R& R' llt*R( R) lt+R# )+zVarious helper utilities.)annotationsN)	Generator)basesmanagernodesobjectsraw_buildingutil)CallContextInferenceContext)AstroidTypeErrorAttributeInferenceErrorInferenceErrorMroError_NonDeducibleTypeHierarchy)scoped_nodes)InferenceResult)
safe_inferc               $    V ^8  d   QhRRRRRR/# )   nodez1nodes.NodeNG | bases.Proxy | util.UninferableBasecontextInferenceContext | NonereturnInferenceResult | None )formats   "1/usr/lib/python3/dist-packages/astroid/helpers.py__annotate__r      s&     
2 
2
;
2$
2 
2    c                T    \         P                  ! R \        ^R7       \        WR7      # )zRImport safe_infer from astroid.util; this shim in astroid.helpers will be removed.)
stacklevelr   )warningswarnDeprecationWarningreal_safe_inferr   r   s   &&r   r   r      s&    
 MM\
 411r   c               $    V ^8  d   QhRRRRRR/# )r   cls_namestrbuiltinsnodes.Moduler   nodes.ClassDefr   )r   s   "r   r   r   '   s!         r   c                2    \         P                  ! W4      pV# N)r   build_class)r)   r+   proxys   && r   _build_proxy_classr2   '   s    $$X8ELr   c               $    V ^8  d   QhRRRRRR/# )r   functionz6nodes.Lambda | nodes.FunctionDef | bases.UnboundMethodr+   r,   r   r-   r   )r   s   "r   r   r   ,   s&     2 2D22 2r   c                   \        V \        P                  \        P                  34      '       d&   V P	                  4       P
                  R 8X  d   RpM(RpM%\        V \        P                  4      '       d   RpMRp\        W!4      # )r+   builtin_function_or_methodr4   method)	
isinstancer   LambdaFunctionDefrootnamer   BoundMethodr2   )r4   r+   r)   s   && r   _function_typer>   ,   sh     (\00,2J2JKLL==?:-3H!H	He//	0	0h11r   c               $    V ^8  d   QhRRRRRR/# )r   r   r   r   r   r   z!Generator[InferenceResult | None]r   )r   s   "r   r   r   <   s)     P P
P$;P&Pr   c              #    "   \         P                  ! 4       pVP                  pT;'       g    \        4       pV P	                  VR 7       EF  p\        V\        P                  4      '       d=   VP                  VR 7      pV'       d   Vx  KD  VP                  R4      ^ ,          x  K`  \        V\        P                  \        P                  \        P                  34      '       d   \        WC4      x  K  \        V\        P                  4      '       d   \!        RV4      x  K  \        V\"        P$                  4      '       d   \&        h\        V\(        P*                  4      '       d   Vx  EK+  \        V\        P,                  \"        P.                  \0        P2                  34      '       d   VP4                  x  EK{  \7        R\9        V4       R24      h	  R# 5i)r"   typemodulezWe don't handle z
 currentlyN)r   AstroidManagerbuiltins_moduler   inferr8   r   ClassDef	metaclassgetattrr9   r   UnboundMethodr:   r>   Moduler2   r   Unknownr   r	   UninferableBaseProxySlicer   Super_proxiedAssertionErrorrA   )r   r   astroid_managerr+   inferredrG   s   &&    r   _object_typerT   <   s[     ,,.O..H++)+GJJwJ/h 5 566 **7*;I""6*1--  %"5"5|7O7OP
 
 !44,"5"566$Xx88%--00  $"6"677N5;;W]]"KLL### #3DN3C:!NOO+ 0s   BG!EG!c               $    V ^8  d   QhRRRRRR/# )r   r   r   r   r   r   r   r   )r   s   "r   r   r   [   s$      
$;r   c                     \        \        W4      4      p\        T4      ^8w  d   \        P                  # \        \        T4      4      #   \         d    \        P                  u # i ; i)a>  Obtain the type of the given node.

This is used to implement the ``type`` builtin, which means that it's
used for inferring type calls, as well as used in a couple of other places
in the inference.
The node will be inferred first, so this function can support all
sorts of objects, as long as they support inference.
)setrT   r   r	   Uninferablelennextiter)r   r   typess   && r   object_typer]   [   s[     L/0 5zQU	    s   A
 
A('A(c               (    V ^8  d   QhRRRRRRRR/# )	r   obj_typer   class_or_seqlist[InferenceResult]r   r   r   util.UninferableBase | boolr   )r   s   "r   r   r   p   s0      $' % !	r   c                   \        V \        P                  4      '       g!   \        V \        P                  4      '       g   \        P
                  # V Uu. uF5  p\        V\        P                  4      '       g   TM\        P
                  NK7  	  ppV F\  p\        V\        P                  4      '       d   \        R \        V4      : 24      hV P                  4        F  pWe8X  g   K    R# 	  K^  	  R# u upi )z,arg 2 must be a type or tuple of types, not TF)r8   r	   rL   r   rF   rX   r   Instancer   rA   mro)r_   r`   r   item	class_seqklassobj_subclasss   &&&    r   _object_type_is_subclassrj   p   s    
 (D0011%..: : 
 ! D tU^^44$:J:JJ    eT1122">tE{oN  %LLNL$ +  !s   ;C6c               (    V ^8  d   QhRRRRRRRR/# )	r   r   r   r`   ra   r   r   r   rb   r   )r   s   "r   r   r      s6     M M
M'M %M !	Mr   c                    \        W4      p\        V\        P                  4      '       d   \        P                  # \        W1VR7      # )zCheck if a node 'isinstance' any node in class_or_seq.

:raises AstroidTypeError: if the given ``classes_or_seq`` are not types
r"   )r]   r8   r	   rL   rX   rj   )r   r`   r   r_   s   &&& r   object_isinstancerm      s:     4)H(D0011#HGLLr   c               (    V ^8  d   QhRRRRRRRR/# )	r   r   nodes.NodeNGr`   ra   r   r   r   rb   r   )r   s   "r   r   r      s6     I I
I'I %I !	Ir   c                    \        V \        P                  4      '       g   \        V  R\	        V 4      : 24      h\        WVR7      # )zCheck if a type is a subclass of any node in class_or_seq.

:raises AstroidTypeError: if the given ``classes_or_seq`` are not types
:raises AstroidError: if the type of the given node cannot be inferred
    or its type's mro doesn't work
z" needs to be a ClassDef node, not r"   )r8   r   rF   	TypeErrorrA   rj   )r   r`   r   s   &&&r   object_issubclassrr      s=     dENN++4& B4:.QRR#DHHr   c               $    V ^8  d   QhRRRRRR/# )r   r   r   r   r   r   ra   r   )r   s   "r   r   r      s$      
$;r   c           	     ~    \        V P                  VR 7      4      p\	        T\
        P                  4      '       d8    TP                   U u. uF  p \        T P                  TR 7      4      NK   	  pp T# T.pT#   \         d   p\        YR7      ThRp?ii ; iu up i   \         d   p\        X TR7      ThRp?ii ; i)r"   r'   N)rZ   rE   StopIterationr   r8   r   Tupleelts)r   r   
node_infereclass_containers   &&   r   class_or_tuple_to_containerr{      s    @$**W*56

 *ekk**	D>Hoo>MdTZZZ01o    &,  @$8a?@  	D dG<!C	Ds@   A9 B $B0B 9BBBB B<)B77B<c                    V ^8  d   QhRRRR/# )r   r   r   r   boolr   )r   s   "r   r   r      s      $; t r   c                    V P                   #   \         d     Mi ; iT P                   FP  p\        Y!R7      p\	        T\
        P                  4      '       d   Y0J g   \        Y1R7      '       d   KH  RT n          R# 	  RT n         R# )z=Return whether all base classes of a class could be inferred.r"   FT)_all_bases_knownAttributeErrorr   r&   r8   r   rF   has_known_bases)rh   r   baseresults   &&  r   r   r      sz    %%%  7 6<#8#899"6;;%*E"  "Es    c                   V ^8  d   QhRR/# r   r   r}   r   )r   s   "r   r   r      s     0 0 0r   c                    \        \        \        W34      4      '       g   \        h WP	                  4       R R 9   #   \
         d   p\        ThR p?ii ; i)N)allmapr   r   re   r   )type1type2ry   s   && r   _type_checkr      sO    s?UN344((0		CR((( 0(a/0s   = AAAc                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r      s     1 1 1r   c                    \        WR7      # )z)Check if *type1* is a subtype of *type2*.r   r   r   r   s   &&r   
is_subtyper      s    U00r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r      s     % %$ %r   c                    \        W4      # )z+Check if *type2* is a supertype of *type1*.r   r   s   &&r   is_supertyper      s    u$$r   c                    V ^8  d   QhRRRR/# )r   r   zbases.Instancer   znodes.Const | Noner   )r   s   "r   r   r      s      . 5G r   c                   \        4       p V P                  RVR7       F  p\        V\        P                  4      '       g   K%  Wn        \        . VR7      Vn        VP                  WR7       FK  p\        V\        P                  4      '       g   K%  \        VP                  \        4      '       g   KG  Vu u # 	  K  	  R#   \         d     R# i ; i)zGet the value as an index for the given instance.

If an instance provides an __index__ method, then it can
be used in some scenarios where an integer is expected,
for instance when multiplying or subscripting a list.
	__index__r"   )argscalleeN)r   igetattrr8   r   r=   	boundnoder
   callcontextinfer_call_resultr   Constvalueintr   )r   r   rS   r   s   &   r   class_instance_as_indexr      s      Gk7CHh(9(9:: $"-2h"GG"44T4Kfekk22z&,,PS7T7T!M L D   s$   BC C 5C ;C CCc                   V ^8  d   QhRR/# )r   r   r   r   )r   s   "r   r   r     s     L L5 Lr   c                   ^ RI Hp \        WR7      pV P                  4       p\	        V\
        P                  4      '       d   VP                  R8X  d{   \	        V\        P                  4      '       d[   VP                  VP                  8X  d@   RP                  V P                  V P                  4       P                  4      p\!        V4      hVe!   \	        V\"        P$                  4      '       d   \!        V R7      h\	        V\&        P(                  4      '       d<   \	        VP*                  \,        \.        34      '       d   \1        VP*                  4      # \	        V\&        P2                  \&        P4                  \&        P6                  V34      '       d   \1        VP8                  4      # \	        V\&        P:                  4      '       d   \1        VP<                  4      # \?        W1R7      pV'       g   \!        V R7      h \A        VPC                  RVR7      4      pTPM                  Y4      p	\	        T	\"        P$                  4      '       d   \!        YR	7      h\A        T	R4      p
\	        T
\&        P(                  4      '       d"   T
PK                  4       R
8X  d   T
P*                  # T
e8   \	        T
\        PN                  4      '       d   T
PQ                  R
4      '       d   ^ # \G        RT
 R24      h  \D         d   p\G        \/        T4      4      ThRp?i\H         d$   p\G        RTPK                  4        R24      ThRp?ii ; i)a  Infer length of given node object.

:param Union[nodes.ClassDef, nodes.Instance] node:
:param node: Node to infer length of

:raises AstroidTypeError: If an invalid node is returned
    from __len__ method or no __len__ method exists
:raises InferenceError: If the given node cannot be inferred
    or if multiple nodes are inferred or if the code executed in python
    would result in a infinite recursive check for length
:rtype int: Integer length of node
)	FrozenSetr"   __len__zNSelf referential __len__ function will cause a RecursionError on line {} of {}N)r   zobject of type 'z' has no len()r'   zbuiltins.int'z,' object cannot be interpreted as an integer))astroid.objectsr   r&   framer8   r   r:   r<   r   rM   rP   parentr   linenor;   filer   r	   rL   r   r   r   bytesr*   rY   ListSetrv   rw   Dictitemsr]   rZ   r   ru   r   r   pytyper   rd   is_subtype_of)r   r   r   inferred_node
node_framemessage	node_typelen_callry   rS   result_of_lens   &&         r   
object_lenr     s    *#D:M J:|7788OOy(}ekk22""j&7&7766<fTYY[--7 	 W%%
=$:N:N O O$''---*eS\3 3 =&&''-%**eiii!PQQ=%%&&-,,=&&''M;I$''	**9g*FG ))$8H(D0011$884(M=%++..  "n4"""=%..11''77 

M?FG -  .s1v&A-" y//12.A
	s*   K6 6MLM#M$MMc                    V ^8  d   QhRRRR/# )r   r   ro   r   znodes.FunctionDef | Noner   )r   s   "r   r   r   T  s       2J r   c                    T pVP                   '       d9   \        VP                   \        P                  4      '       g   VP                   pKJ  V'       d   VP                   '       d   VP                   # R# )a  Search for the first function which encloses the given
scope.

This can be used for looking up in that function's
scope, in case looking up in a lower scope for a particular
name fails.

:param node: A scope node.
:returns:
    ``None``, if no parent function scope was found,
    otherwise an instance of :class:`astroid.nodes.scoped_nodes.Function`,
    which encloses the given node.
N)r   r8   r   r:   )r   currents   & r   _higher_function_scoper   T  sI     G
...GNNE<M<M!N!N..7>>>~~r   r/   ),__doc__
__future__r   r#   collections.abcr   astroidr   r   r   r   r   r	   astroid.contextr
   r   astroid.exceptionsr   r   r   r   r   astroid.nodesr   astroid.typingr   astroid.utilr   r&   r2   r>   rT   r]   rj   rm   rr   r{   r   r   r   r   r   r   r   r   r   r   <module>r      s   
   "  % F F 9  ' * 6
2
2 P>*<MI 0(01
%
.L^r   