
    e                       d Z ddlmZ ddlZddlZddlZddlZddlmZ ddl	m
Z
 ddlmZmZmZ ddlZddlmZmZmZ ddlmZmZ dd	lmZmZmZ dd
lmZ ddlmZ ddlmZm Z  erddl!m"Z" dZ# e$e#      Z%d Z&dGdZ' G d d      Z( G d de(      Z) G d de(      Z* G d de(      Z+ G d de(      Z, G d de(      Z- G d de(      Z. G d d e*      Z/ G d! d"e*e.      Z0 G d# d$e0      Z1 G d% d&e(      Z2 G d' d(e2      Z3 G d) d*e3      Z4 G d+ d,e3      Z5 G d- d.e3      Z6 G d/ d0e3      Z7i d1e4d2e6d3e7d4e5d5e5d6e5d7e5d8e5d9e5d:e5d;e5d<e5d=e5d>e5d?e5d@e5dAe5e5e5dBZ8 G dC dDe(      Z9 G dE dFe(      Z:y)Ha  
Data object model, as per https://docs.python.org/3/reference/datamodel.html.

This module describes, at least partially, a data object model for some
of astroid's nodes. The model contains special attributes that nodes such
as functions, classes, modules etc have, such as __doc__, __class__,
__module__ etc, being used when doing attribute lookups over nodes.

For instance, inferring `obj.__class__` will first trigger an inference
of the `obj` variable. If it was successfully inferred, then an attribute
`__class__ will be looked for in the inferred object. This is the part
where the data model occurs. The model is attached to those nodes
and the lookup mechanism will try to see if attributes such as
`__class__` are defined by the model or not. If they are defined,
the model will be requested to return the corresponding value of that
attribute. Thus the model can be viewed as a special part of the lookup
mechanism.
    )annotationsN)Iterator)	lru_cache)TYPE_CHECKINGAnyLiteral)basesnodesutil)InferenceContextcopy_context)AttributeInferenceErrorInferenceError	NoDefault)AstroidManager)node_classes)InferenceResultSuccessfulInferenceResult)Propertyattr_c                   t        j                  | | j                  | j                  | j                  | j
                        }t        |j                               D cg c]  }t        j                  ||       }}|j                         D cg c]  }|d   	 }}|j                  t        t        ||                   |S c c}w c c}w )Nparentlineno
col_offset
end_linenoend_col_offsetvaluer   )r   Dictr   r   r   r   listkeysConstvaluespostinitzip)instance
attributesobjr   r#   elemr%   s          A/usr/lib/python3/dist-packages/astroid/interpreter/objectmodel.py_dunder_dictr-   1   s    


&&&&..C BFjooFWAX8=s3D  $.#4#4#674d2h7F7LLc$'()J 8s   CC	ObjectModelc                f    	 | j                   j                  S # t        $ r | j                   cY S w xY wN)	_instance_proxiedAttributeError)models    r,   _get_bound_noder5   H   s0    ''' s    00c                  j    e Zd Zd Zd Zd ZddZddZedd       Z	d Z
edd	       Zedd
       Zy)r.   c                    d | _         y r0   r1   selfs    r,   __init__zObjectModel.__init__Q   s	        c                   g }t        |       j                  }d}t        |      dz   }t        | j	                               D ]r  }dt        |      z
  |z
  }t        j                  |d|      j                  d      }|d   g}|dd  D ]  }	|j                  d|z  |	z           |j                  |       t ||d	d|z  z   j                  |      d
z  S )Nz%(cname)s(%(fields)s)   P      )indentwidthTr    z,
)cnamefields)
type__name__lensortedr)   pprintpformat
splitlinesappendjoin)
r:   resultrD   string	alignmentfieldrB   linesinnerlines
             r,   __repr__zObjectModel.__repr__T   s    T
##(JN	DOO-. 	!EUOi/ENN5%@KKDQE1XJEab	 5S9_t345MM% 	! sY.44V<
 
 	
r<   c                    || _         | S r0   r8   )r:   r(   s     r,   __call__zObjectModel.__call__g   s    !r<   Nc                     | |      S r0    )r:   r(   clss      r,   __get__zObjectModel.__get__k   s     H~r<   c                &    || j                         v S r0   )r)   r:   names     r,   __contains__zObjectModel.__contains__u   s    t(((r<   c                x    t        |       D cg c]!  }|j                  t              s|t        d # c}S c c}w )z;Get the attributes which are exported by this object model.N)dir
startswithIMPL_PREFIXLEN_OF_IMPL_PREFIX)r:   os     r,   r)   zObjectModel.attributesx   s0     14D	W1Q\\+=V$%&WWWs   77c                z    || j                         v rt        | t        |z         S t        | j                  |      )zLook up the given *name* in the current model.

        It should return an AST or an interpreter object,
        but if the name is not found, then an AttributeInferenceError will be raised.
        target	attribute)r)   getattrrd   r   r1   r^   s     r,   lookupzObjectModel.lookup}   s6     4??$$4t!344%T^^tLLr<   c                    ddl m} |j                  d      }t               j                  d   |_        t        j                  |t        |             S )zECalling cls.__new__(type) on an object returns an instance of 'type'.r   builderz$def __new__(self, cls): return cls()objectproxybound	astroidro   extract_noder   builtins_moduler   r	   BoundMethodr5   r:   ro   nodes      r,   attr___new__zObjectModel.attr___new__   sI     	$")"6"66#

 %&66x@  t?43HIIr<   c                    ddl m} |j                  d      }t               j                  d   |_        t        j                  |t        |             S )z-Calling cls.__init__() normally returns None.r   rn   z0def __init__(self, *args, **kwargs): return Nonerp   rq   rt   ry   s      r,   attr___init__zObjectModel.attr___init__   sK     	$
 #*"6"6B#

 %&66x@  t?43HIIr<   r0   )returnbool)r~   z	list[str]r~   zbases.BoundMethod)rG   
__module____qualname__r;   rV   rX   r\   r`   r   r)   rl   propertyr{   r}   rZ   r<   r,   r.   r.   P   sc    
&) X XM J J J Jr<   c                      e Zd Zd Zed        Zed        Zed        Zed        Zed        Z	ed        Z
ed        Zed	        Zed
        Zed        Zy)ModuleModelc                `    t               j                  }|j                  j                  d      S )N__dict__)r   rw   special_attributesrl   )r:   builtins_ast_modules     r,   	_builtinszModuleModel._builtins   s(    ,.>>"55<<ZHHr<   c                "    | j                         S r0   )r   r9   s    r,   attr_builtinszModuleModel.attr_builtins   s    ~~r<   c                   | j                   j                  st        | j                   d      | j                   j                  D cg c]S  }t	        j
                  |j                  d      s|nt        j                  j                  |      | j                         U }}t	        j                  | j                         }|j                  |       |S c c}w )N__path__rh   z__init__.pyr   r   )r1   packager   pathr   r$   endswithosdirnameListr&   )r:   r   	path_objs	containers       r,   attr___path__zModuleModel.attr___path__   s    ~~%%):VV ++
  }}]3 WW__T*~~	
	 
 !%%T^^<	9%
s   ACc                l    t        j                  | j                  j                  | j                        S Nr   r   r$   r1   r_   r9   s    r,   attr___name__zModuleModel.attr___name__   #    !!(;(;DNNSSr<   c                    t        j                  t        | j                  j                  dd       | j                        S Nr   r   r   r$   rk   r1   doc_noder9   s    r,   attr___doc__zModuleModel.attr___doc__   2    !!$..117DA>>
 	
r<   c                l    t        j                  | j                  j                  | j                        S r   )r   r$   r1   filer9   s    r,   attr___file__zModuleModel.attr___file__   r   r<   c                V    t        | j                  | j                  j                        S r0   )r-   r1   globalsr9   s    r,   attr___dict__zModuleModel.attr___dict__   s    DNNDNN,B,BCCr<   c                    | j                   j                  sd}n| j                   j                  }t        j                  || j                         S )N r   )r1   r   r_   r   r$   )r:   r   s     r,   attr___package__zModuleModel.attr___package__   s:    ~~%%ENN''E!!dnnEEr<   c                *    t        j                         S r0   r   Unknownr9   s    r,   attr___spec__zModuleModel.attr___spec__        ##%%r<   c                *    t        j                         S r0   r   r9   s    r,   attr___loader__zModuleModel.attr___loader__   r   r<   c                *    t        j                         S r0   r   r9   s    r,   attr___cached__zModuleModel.attr___cached__   r   r<   N)rG   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rZ   r<   r,   r   r      s    I      & T T 
 
 T T D D F F & & & & & &r<   r   c                      e Zd Zed        Zed        Zed        Zed        Zed        Zed        Z	e	Z
ed        Zed        Zed	        Zed
        ZeZeZeZeZeZeZeZeZeZeZeZeZeZeZeZeZeZeZ eZ!y)FunctionModelc                l    t        j                  | j                  j                  | j                        S r   r   r9   s    r,   r   zFunctionModel.attr___name__   r   r<   c                    t        j                  t        | j                  j                  dd       | j                        S r   r   r9   s    r,   r   zFunctionModel.attr___doc__   r   r<   c                t    t        j                  | j                  j                         | j                        S r   r   r$   r1   qnamer9   s    r,   attr___qualname__zFunctionModel.attr___qualname__   s&    !!(<(<(>t~~VVr<   c                    | j                   }|j                  j                  st        j                  d |      S t        j
                  |      }|j                  |j                  j                         |S )Nr   r   )r1   argsdefaultsr   r$   Tupler&   )r:   funcdefaults_objs      r,   attr___defaults__zFunctionModel.attr___defaults__  sY    ~~yy!!%%D>>#))6dii001r<   c                   t        j                  | j                  | j                  j                  | j                  j                  | j                  j
                  | j                  j                        }| j                  j                  sd }n| j                  j                  }| j                  j                  }t        j                  t        |j                  xs g |j                        t        |j                  |j                        t        |j                  xs g |j                               }|D ci c]  \  }}|s	|j"                  | }}}|j$                  r|j$                  ||j&                  <   |j(                  r|j(                  ||j*                  <   |r||d<    |j,                         D 	cg c]  \  }}	t        j.                  ||      |	f  }
}}	|j1                  |
       |S c c}}w c c}	}w )Nr   r~   r   )r   r!   r1   r   r   r   r   returnsr   	itertoolschainr'   r   
kwonlyargskwonlyargs_annotationsposonlyargsposonlyargs_annotationsr_   varargannotationvarargkwargannotationkwargitemsr$   r&   )r:   r*   r   r   pair_annotationsarg
annotationr   keyr   r   s              r,   attr___annotations__z"FunctionModel.attr___annotations__  s   >>>>((~~00~~00>>88
 ~~%%Gnn,,G~~""$??		R!1!12!<!<=  &B(D(DE
 ;K
%6c:jCHHj 
 
   '+'<'<K$&*&:&:K

#$+K! !2 1 1 3
e C0%8
 

 	U
!

s   8
G3G3:#G9c                    t        j                  | j                  | j                  j                  | j                  j                  | j                  j
                  | j                  j                        S Nr   r   r!   r1   r   r   r   r   r9   s    r,   r   zFunctionModel.attr___dict__6  P      >>>>((~~00~~00>>88
 	
r<   c                   d }| j                   j                  }t        j                  | j                   | j                   j                  | j                   j
                  | j                   j                  | j                   j                        }t         |||            }|j                  t        |j                                      |S )Nc              3     K   | j                   D ]E  }	 | j                  |j                        }t	        j
                  |j                  |      }||f G y # t        $ r Y Tw xY wwNr   )r   default_valuer_   r   r   r$   )r   r   r   defaultr_   s        r,   _default_argsz8FunctionModel.attr___kwdefaults__.<locals>._default_argsD  sg      $"00:G $))#((6BGm#$ ! s'   A'A*A'	A$!A'#A$$A'r   )r1   r   r   r!   r   r   r   r   dictr&   r"   r   )r:   r   r   r*   r   s        r,   attr___kwdefaults__z!FunctionModel.attr___kwdefaults__B  s    	$ ~~"">>>>((~~00~~00>>88
 dC01T(..*+,
r<   c                x    t        j                  | j                  j                         j	                               S r0   r   r$   r1   rootr   r9   s    r,   attr___module__zFunctionModel.attr___module__[  )    !!$.."5"5"7"="="?@@r<   c                    | j                    G fddt        j                        } || j                   | j                         S )Nc                  H    e Zd ZdZddZ	 d	 	 	 	 	 d fdZe fd       Zy)	9FunctionModel.attr___get__.<locals>.DescriptorBoundMethodz_Bound method which knows how to understand calling descriptor
            binding.
            c                     yNr   rZ   r9   s    r,   implicit_parameterszMFunctionModel.attr___get__.<locals>.DescriptorBoundMethod.implicit_parametersh  s     r<   Nc              3  j  K   t        |j                        dkD  st        |j                        dk  rt        d| |      t        |      }	 t	        |j                  d   j                  |            }t        |t        j                        rt        d| |      t        t        j                        r y j                  j                  j                  j                  j                   j"                  j$                  	      }|j'                  j                  j(                  j*                  j,                  j.                  
       t        j0                  |      }t        j                  ||       y # t        $ r }t        ||j                  d         |d }~ww xY ww)Nr@   r>   z(Invalid arguments for descriptor bindingri   contextr   r   )r   rz   zInvalid class inferredr_   r   r   r   r   r   )r   rq   )rH   r   r   r   nextinferStopIteration
isinstancer   UninferableBaser	   rx   	__class__r_   r   r   r   r   r   r&   body
decoratorsr   r   UnboundMethod)r:   callerr   r[   enew_funcrr   r   s          r,   infer_call_resultzKFunctionModel.attr___get__.<locals>.DescriptorBoundMethod.infer_call_resultm  s|    
 v{{#a'3v{{+;a+?(B# '  'w/Vv{{1~33G3DEC c4#7#78(0w  dE$5$56J  >>;;#;;##'#6#6 *  !!IIIIOOLL!]] "  ++H5''e3??G % V(v{{1~NTUUVs+   A
F3(F 6DF3	F0F++F00F3c           
     v   t        j                  j                  j                  dd      }j                  j                  j	                         }|j                  t        j                  ddd|dd             j                  j                  j	                         }|j                  ||g g g g g g        |S )a  Overwrite the underlying args to match those of the underlying func.

                Usually the underlying *func* is a function/method, as in:

                    def test(self):
                        pass

                This has only the *self* parameter but when we access test.__get__
                we get a new object which has two parameters, *self* and *type*.
                Nr   r   r   rF   r   r   )r   r   r   r   kw_defaultsr   r   r   )	ru   	Argumentsr   r   copyrM   
AssignNamer   r&   )r:   	argumentspositional_or_keyword_paramspositional_only_paramsr   s       r,   r   z>FunctionModel.attr___get__.<locals>.DescriptorBoundMethod.args  s     $--99++D	 04yy~~/B/B/D,,33&&# #$(#''+	 *.)>)>)C)C)E&""5 6! " "+-,. # 	 ! r<   )r~   z
Literal[0]r0   )r    SuccessfulInferenceResult | Noner   InferenceContext | Noner~   zIterator[bases.BoundMethod])rG   r   r   __doc__r   r   r   r   r   s   r,   DescriptorBoundMethodr   c  sL     482@82@ 12@ -	2@h (! (!r<   r  rq   )r1   r	   rx   )r:   r  r   s     @r,   attr___get__zFunctionModel.attr___get___  s8    ~~g	!E$5$5 g	!R %4>>PPr<   c                *    t        j                         S r0   r   r9   s    r,   attr___ne__zFunctionModel.attr___ne__  s    ##%%r<   N)"rG   r   r   r   r   r   r   r   r   r   attr___globals__r   r   r  r  attr___subclasshook__attr___str__attr___sizeof__attr___setattr___attr___repr__attr___reduce__attr___reduce_ex__attr___lt__attr___eq__attr___gt__attr___format__attr___delattr___attr___getattribute__attr___hash__attr___dir__attr___call__attr___class__attr___closure__attr___code__rZ   r<   r,   r   r      sA   T T 
 
 W W   % %N 
 
 % 0 A A lQ lQ^ & & (L!O#M!O$KKK!O#'MLM N"Mr<   r   c                       e Zd Z fdZed        Zed        Zed        Zed        Zed        Z	ed        Z
ed        Zed	        Zed
        Zed        Zed        Z xZS )
ClassModelc                @    t               | _        t        |           y r0   )r   r   superr;   )r:   r   s    r,   r;   zClassModel.__init__  s    ')r<   c                x    t        j                  | j                  j                         j	                               S r0   r   r9   s    r,   r   zClassModel.attr___module__  r   r<   c                T    t        j                  | j                  j                        S r0   r   r9   s    r,   r   zClassModel.attr___name__  s    !!$.."5"566r<   c                \    t        j                  | j                  j                               S r0   r   r9   s    r,   r   zClassModel.attr___qualname__  s     !!$.."6"6"899r<   c                j    t        j                  t        | j                  j                  dd             S Nr   r   r9   s    r,   r   zClassModel.attr___doc__  &    !!'$..*A*A7D"QRRr<   c                    | j                   j                  st        | j                   d      | j                   j                         }t	        j
                  | j                         }|j                  |       |S )N__mro__rh   r   )r1   newstyler   mror   r   r&   )r:   r2  r*   s      r,   attr___mro__zClassModel.attr___mro__  sW    ~~&&)9UUnn  "  7S
r<   c                   | j                   j                  st        | j                   d      |  G fddt        j                        }| j                   j                         }|j                  d   d   } |||      S )Nr2  rh   c                  (    e Zd Z	 d	 	 	 	 	 d fdZy)+ClassModel.attr_mro.<locals>.MroBoundMethodNc              3  *   K   j                    y wr0   )r3  )r:   r   r   
other_selfs      r,   r   z=ClassModel.attr_mro.<locals>.MroBoundMethod.infer_call_result  s     
 !---s   r0   )r   r	  r   r
  r~   zIterator[node_classes.Tuple]rG   r   r   r   )r8  s   r,   MroBoundMethodr6    s)     48.8. 1. .	.r<   r:  r   rq   )r1   r1  r   r	   rx   implicit_metaclasslocals)r:   r:  r;  
mro_methodr8  s       @r,   attr_mrozClassModel.attr_mro	  sp    ~~&&)5QQ
	.U.. 	. "^^>>@'..u5a8
J6HIIr<   c                    t        j                         }t               }t        | j                  j                  |            }|j                  |       |S )Nelts)r   r   r   r"   r1   _inferred_basesr&   )r:   r*   r   rA  s       r,   attr___bases__zClassModel.attr___bases__  sD      ""$DNN227;<$
r<   c                D    ddl m} |j                  | j                        S Nr   )helpersru   rF  object_typer1   r:   rF  s     r,   r"  zClassModel.attr___class__&       	$""4>>22r<   c                   | j                   j                  st        | j                   d      | j                   j                         }| j                   j	                         }|j                  t        j                        D cg c]0  }|| j                   k7  r|j                  || j                        r|2 }}t        j                  | j                         j                  |        G fddt        j                        }| j                   j                         }|j                   d   d   } |||      S c c}w )	zGet the subclasses of the underlying class.

        This looks only in the current module for retrieving the subclasses,
        thus it might miss a couple of them.
        __subclasses__rh   r   r   c                  (    e Zd Z	 d	 	 	 	 	 d fdZy)=ClassModel.attr___subclasses__.<locals>.SubclassesBoundMethodNc              3     K    y wr0   rZ   r:   r   r   r*   s      r,   r   zOClassModel.attr___subclasses__.<locals>.SubclassesBoundMethod.infer_call_resultE       
 	   	r0   )r   r	  r   r
  r~   zIterator[node_classes.List]r9  r*   s   r,   SubclassesBoundMethodrN  D  s)     488 1 -	r<   rT  r   rq   )r1   r1  r   r   r   nodes_of_classr
   ClassDefis_subtype_ofr   r   r   r&   r	   rx   r;  r<  )	r:   r   r   r[   classesrT  r;  subclasses_methodr*   s	           @r,   attr___subclasses__zClassModel.attr___subclasses__-  s    ~~&&)~~1A  $$&~~""$ **5>>:
dnn$):):5$,,):)W 
 
 t~~6W	E$5$5 	 "^^>>@.556FGJ$+<DVWW'
s   5D=c                    t        j                  | j                  | j                  j                  | j                  j                  | j                  j
                  | j                  j                        S r   r   r9   s    r,   r   zClassModel.attr___dict__P  r   r<   c                6    | j                   j                         S )z-Calling a class A() returns an instance of A.)r1   instantiate_classr9   s    r,   r!  zClassModel.attr___call__Z  s     ~~//11r<   )rG   r   r   r;   r   r   r   r   r   r3  r>  rC  r"  rZ  r   r!  __classcell__r   s   @r,   r&  r&    s     A A 7 7 : : S S   J J(   3 3  X  XD 
 
 2 2r<   r&  c                  L    e Zd Zed        Zed        Zed        Zed        Zy)
SuperModelc                .    | j                   j                  S r0   )r1   mro_pointerr9   s    r,   attr___thisclass__zSuperModel.attr___thisclass__a      ~~)))r<   c                .    | j                   j                  S r0   )r1   _self_classr9   s    r,   attr___self_class__zSuperModel.attr___self_class__e  re  r<   c                .    | j                   j                  S r0   )r1   rF   r9   s    r,   attr___self__zSuperModel.attr___self__i  s    ~~"""r<   c                .    | j                   j                  S r0   r1   r2   r9   s    r,   r"  zSuperModel.attr___class__m      ~~&&&r<   N)rG   r   r   r   rd  rh  rj  r"  rZ   r<   r,   ra  ra  `  sP    * * * * # # ' 'r<   ra  c                  H    e Zd Zed        Zed        Zed        ZeZeZeZ	y)UnboundMethodModelc                D    ddl m} |j                  | j                        S rE  rG  rI  s     r,   r"  z!UnboundMethodModel.attr___class__s  rJ  r<   c                .    | j                   j                  S r0   rl  r9   s    r,   attr___func__z UnboundMethodModel.attr___func__z  rm  r<   c                D    t        j                  d | j                        S r   )r   r$   r1   r9   s    r,   rj  z UnboundMethodModel.attr___self__~  s    !!T^^DDr<   N)
rG   r   r   r   r"  rr  rj  attr_im_funcattr_im_classattr_im_selfrZ   r<   r,   ro  ro  r  sO    3 3 ' ' E E !L"M Lr<   ro  c                  4    e Zd ZdZedd       Zedd       Zy)ContextManagerModelzModel for context managers.

    Based on 3.3.9 of the Data Model documentation:
    https://docs.python.org/3/reference/datamodel.html#with-statement-context-managers
    c                    ddl m} |j                  d      }t               j                  d   |_        t        j                  |t        |             S )a.  Representation of the base implementation of __enter__.

        As per Python documentation:
        Enter the runtime context related to this object. The with statement
        will bind this method's return value to the target(s) specified in the
        as clause of the statement, if any.
        r   rn   zdef __enter__(self): ...rp   rq   rt   ry   s      r,   attr___enter__z"ContextManagerModel.attr___enter__  sG     	$")"6"67U"V %&66x@  t?43HIIr<   c                    ddl m} |j                  d      }t               j                  d   |_        t        j                  |t        |             S )aL  Representation of the base implementation of __exit__.

        As per Python documentation:
        Exit the runtime context related to this object. The parameters describe the
        exception that caused the context to be exited. If the context was exited
        without an exception, all three arguments will be None.
        r   rn   z7def __exit__(self, exc_type, exc_value, traceback): ...rp   rq   rt   ry   s      r,   attr___exit__z!ContextManagerModel.attr___exit__  sI     	$")"6"6I#

 %&66x@  t?43HIIr<   Nr   )rG   r   r   r  r   rz  r|  rZ   r<   r,   rx  rx    s3     J J" J Jr<   rx  c                  ,    e Zd Zed        Zed        Zy)BoundMethodModelc                B    | j                   j                  j                  S r0   rl  r9   s    r,   rr  zBoundMethodModel.attr___func__  s    ~~&&///r<   c                .    | j                   j                  S r0   )r1   rs   r9   s    r,   rj  zBoundMethodModel.attr___self__  s    ~~###r<   N)rG   r   r   r   rr  rj  rZ   r<   r,   r~  r~    s(    0 0 $ $r<   r~  c                  >     e Zd Z fdZed        Zed        Z xZS )GeneratorModelc                    t        	|   | g|i |}t               j                  d   }|j                  j                         D ]5  \  }}|d   }|fd}t        t        |      t        |z   t        |             7 |S )N	generatorr   c                    |S r0   rZ   r[   meths     r,   patchedz'GeneratorModel.__new__.<locals>.patched      r<   )
r(  __new__r   rw   r<  r   setattrrF   rd   r   )
r[   r   kwargsretr  r_   r%   methodr  r   s
            r,   r  zGeneratorModel.__new__  s    goc3D3F3"$44[A	%,,224 	FLD&AYF"(  DI{T18G3DE	F 
r<   c                    t        j                  | j                  j                  j                  | j                        S r   )r   r$   r1   r   r_   r9   s    r,   r   zGeneratorModel.attr___name__  s.    !!..'',,T^^
 	
r<   c                    t        j                  t        | j                  j                  j
                  dd       | j                        S r   )r   r$   rk   r1   r   r   r9   s    r,   r   zGeneratorModel.attr___doc__  s8    !!$..//88'4H>>
 	
r<   )rG   r   r   r  r   r   r   r^  r_  s   @r,   r  r    s0     
 

 
 
r<   r  c                       e Zd Z fdZ xZS )AsyncGeneratorModelc                B   t        
|   | g|i |}t               j                  }|j	                  d      }||j	                  d      }|j
                  j                         D ]5  \  }}|d   }|fd}	t        t        |      t        |z   t        |	             7 |S )Nasync_generatorr  r   c                    |S r0   rZ   r  s     r,   r  z,AsyncGeneratorModel.__new__.<locals>.patched  r  r<   )r(  r  r   rw   getr<  r   r  rF   rd   r   )r[   r   r  r  astroid_builtinsr  r_   r%   r  r  r   s             r,   r  zAsyncGeneratorModel.__new__  s    goc3D3F3)+;;$(():;	(,,[9I%,,224 	FLD&AYF"(  DI{T18G3DE	F 
r<   )rG   r   r   r  r^  r_  s   @r,   r  r    s     r<   r  c                  L    e Zd Zed        Zed        Zed        Zed        Zy)InstanceModelc                .    | j                   j                  S r0   rl  r9   s    r,   r"  zInstanceModel.attr___class__  rm  r<   c                x    t        j                  | j                  j                         j	                               S r0   r   r9   s    r,   r   zInstanceModel.attr___module__  r   r<   c                j    t        j                  t        | j                  j                  dd             S r-  r   r9   s    r,   r   zInstanceModel.attr___doc__  r.  r<   c                V    t        | j                  | j                  j                        S r0   )r-   r1   instance_attrsr9   s    r,   r   zInstanceModel.attr___dict__  s    DNNDNN,I,IJJr<   N)rG   r   r   r   r"  r   r   r   rZ   r<   r,   r  r    sV    ' ' A A S S K Kr<   r  c                  .    e Zd Zedd       Zed        Zy)ExceptionInstanceModelc                B    t        j                  | j                        S r   )r
   r   r1   r9   s    r,   	attr_argsz ExceptionInstanceModel.attr_args  s    {{$..11r<   c                    t               j                  }|t        j                  j                     }|j                         S r0   )r   rw   typesTracebackTyperG   r]  )r:   r   traceback_types      r,   attr___traceback__z)ExceptionInstanceModel.attr___traceback__  s6    ,.>>,U-@-@-I-IJ//11r<   N)r~   znodes.Tuple)rG   r   r   r   r  r  rZ   r<   r,   r  r    s(    2 2 2 2r<   r  c                      e Zd Zed        Zy)SyntaxErrorInstanceModelc                ,    t        j                  d      S Nr   r   r$   r9   s    r,   	attr_textz"SyntaxErrorInstanceModel.attr_text      !!"%%r<   N)rG   r   r   r   r  rZ   r<   r,   r  r        & &r<   r  c                  @    e Zd Zed        Zed        Zed        ZeZy)OSErrorInstanceModelc                ,    t        j                  d      S r  r  r9   s    r,   attr_filenamez"OSErrorInstanceModel.attr_filename  r  r<   c                ,    t        j                  d      S r   r  r9   s    r,   
attr_errnozOSErrorInstanceModel.attr_errno  s    !!!$$r<   c                ,    t        j                  d      S r  r  r9   s    r,   attr_strerrorz"OSErrorInstanceModel.attr_strerror!  r  r<   N)rG   r   r   r   r  r  r  attr_filename2rZ   r<   r,   r  r    sC    & & % % & & #Nr<   r  c                  ,    e Zd Zed        Zed        Zy)ImportErrorInstanceModelc                ,    t        j                  d      S r  r  r9   s    r,   	attr_namez"ImportErrorInstanceModel.attr_name)  r  r<   c                ,    t        j                  d      S r  r  r9   s    r,   	attr_pathz"ImportErrorInstanceModel.attr_path-  r  r<   N)rG   r   r   r   r  r  rZ   r<   r,   r  r  (  s(    & & & &r<   r  c                      e Zd Zed        Zy)UnicodeDecodeErrorInstanceModelc                ,    t        j                  d      S r  r  r9   s    r,   attr_objectz+UnicodeDecodeErrorInstanceModel.attr_object3  r  r<   N)rG   r   r   r   r  rZ   r<   r,   r  r  2  r  r<   r  zbuiltins.SyntaxErrorzbuiltins.ImportErrorzbuiltins.UnicodeDecodeErrorzbuiltins.OSErrorzbuiltins.BlockingIOErrorzbuiltins.BrokenPipeErrorzbuiltins.ChildProcessErrorzbuiltins.ConnectionAbortedErrorzbuiltins.ConnectionErrorzbuiltins.ConnectionRefusedErrorzbuiltins.ConnectionResetErrorzbuiltins.FileExistsErrorzbuiltins.FileNotFoundErrorzbuiltins.InterruptedErrorzbuiltins.IsADirectoryErrorzbuiltins.NotADirectoryErrorzbuiltins.PermissionError)zbuiltins.ProcessLookupErrorzbuiltins.TimeoutErrorc                  R    e Zd Zed        Zd Zed        Zed        Zed        Zy)	DictModelc                .    | j                   j                  S r0   rl  r9   s    r,   r"  zDictModel.attr___class__Q  rm  r<   c                     G fddt         j                        }t        | j                  j                  j                  |      d      } ||| j                        S )z7Generate a bound method that can infer the given *obj*.c                  (    e Zd Z	 d	 	 	 	 	 d fdZy)@DictModel._generic_dict_attribute.<locals>.DictMethodBoundMethodNc              3     K    y wr0   rZ   rP  s      r,   r   zRDictModel._generic_dict_attribute.<locals>.DictMethodBoundMethod.infer_call_resultY  rQ  rR  r0   r   r	  r   r
  r~   zIterator[InferenceResult]r9  rS  s   r,   DictMethodBoundMethodr  X  s)     488 1 +	r<   r  Nrq   )ru   rx   r   r1   r2   igetattr)r:   r*   r_   r  r  s    `   r,   _generic_dict_attributez!DictModel._generic_dict_attributeU  sI    	G$7$7 	 DNN++44T:DA$4t~~FFr<   c                l   ddl m} g }t        j                  | j                        }| j                  j
                  D ]?  \  }}t        j                  |      }|j                  ||f       |j                  |       A |j                  |       |j                  |      }| j                  |d      S )Nr   objectsr   r@  r   )ru   r  r   r   r1   r   r   r&   rM   	DictItemsr  )r:   r  elemsr*   r   r   r+   	items_objs           r,   
attr_itemszDictModel.attr_itemsc  s    #t~~6.... 	JC%%S1DMM3,'LL	 	% %%c*	++Iw??r<   c                   ddl m} | j                  j                  D cg c]  \  }}|	 }}}t	        j
                  | j                        }|j                  |       |j                  |      }| j                  |d      S c c}}w )Nr   r  r   r@  r#   )	ru   r  r1   r   r   r   r&   DictKeysr  )r:   r  r   _r#   r*   keys_objs          r,   	attr_keyszDictModel.attr_keysr  sp    #$(NN$8$89a99t~~6$##C(++Hf== :s   Bc                   ddl m} | j                  j                  D cg c]  \  }}|	 }}}t	        j
                  | j                        }|j                  |       |j                  |      }| j                  |d      S c c}}w )Nr   r  r   r%   )	ru   r  r1   r   r   r   r&   
DictValuesr  )r:   r  r  r   r%   r*   
values_objs          r,   attr_valueszDictModel.attr_values}  so    #*...*>*>?JQ%??t~~6V'',
++JAA @s   BN)	rG   r   r   r   r"  r  r  r  r  rZ   r<   r,   r  r  P  sZ    ' 'G @ @ > > B Br<   r  c                  f    e Zd ZdZd Zed        Zed        Zed        Zed        Z	ed        Z
y)	PropertyModelzModel for a builtin property.c           
     x   t        j                  || j                  | j                  j                  | j                  j                  | j                  j
                  | j                  j                        }t        j                  |d d       }|j                  g g g g g g g g        |j                  |g        |S )Nr_   r   r   r   r   r   r  )r   r   r   r  r   r   r   r   r   r   )	r
   FunctionDefr1   r   r   r   r   r  r&   )r:   r_   functionr   s       r,   _init_functionzPropertyModel._init_function  s    $$>>>>((~~00~~00>>88
 ht4H$&#% 	 		
 	t"-r<   c                t   | j                    G fddt        j                        } |d| j                   | j                   j                  | j                   j                  | j                   j
                  | j                   j                        }|j                  j                  j                         |S )Nc                  (    e Zd Z	 d	 	 	 	 	 d fdZy)5PropertyModel.attr_fget.<locals>.PropertyFuncAccessorNc              3     K   |r&t        |j                        dk7  rt        d| |      j                  j	                  ||      E d {    y 7 w)Nr>   zfget() needs a single argumentr   r   r   )rH   r   r   r  r   )r:   r   r   r   s      r,   r   zGPropertyModel.attr_fget.<locals>.PropertyFuncAccessor.infer_call_result  sX      c&++.!3(8w   ==::!7 ;   s   A	AAAr0   r  r9  r  s   r,   PropertyFuncAccessorr    s)     488 1 +	r<   r  fgetr  r  )
r1   r
   r  r   r   r   r   r&   r   r   )r:   r  property_accessorr   s      @r,   	attr_fgetzPropertyModel.attr_fget  s    ~~	5#4#4 	  1>>>>((~~00~~00>>88
 	""				"B  r<   c                   | j                   }dd} ||      s"t        d|j                  j                          G fddt        j
                        } |d| j                   | j                   j                  | j                   j                  | j                   j                  | j                   j                        }|j                  j                  j                         |S )	Nc                6   | j                   j                         D cg c](  }|j                  | j                  j                  k(  s'|* c}D ]E  }|j	                         D ]0  }|j                  | j                  j                  dz         s,|c c S  G yc c}w )z
            Given a property, find the corresponding setter function and returns it.

            :param func: property for which the setter has to be found
            :return: the setter function or None
            z.setterN)r   get_childrenr_   r  decoratornamesr   )r   tri   dec_names       r,   find_setterz,PropertyModel.attr_fset.<locals>.find_setter  s      ;;3354==CUCU9U & !' 5 5 7 &H((););i)GH%&& s   (BBz&Unable to find the setter of property c                  (    e Zd Z	 d	 	 	 	 	 d fdZy)5PropertyModel.attr_fset.<locals>.PropertyFuncAccessorNc              3     K   |r&t        |j                        dk7  rt        d| |      j                  ||      E d {    y 7 w)Nr@   zfset() needs two argumentsr   r  )rH   r   r   r   )r:   r   r   func_setters      r,   r   zGPropertyModel.attr_fset.<locals>.PropertyFuncAccessor.infer_call_result  sL      c&++.!3(4T7  '88PW8XXXs   ?A
AA
r0   r  r9  )r  s   r,   r  r    s-     48
Y8
Y 1
Y +	
Yr<   r  fsetr  r  )r   r   r~   zastroid.FunctionDef | None)r1   r   r  r_   r
   r  r   r   r   r   r&   r   r   )r:   r   r  r  r  r  s        @r,   	attr_fsetzPropertyModel.attr_fset  s    ~~	 "$' 89K9K8LM 	Y5#4#4 	Y 1>>>>((~~00~~00>>88
 	""(8(8{?O?O"P  r<   c                $    | j                  d      S )Nsetterr  r9   s    r,   attr_setterzPropertyModel.attr_setter      ""8,,r<   c                $    | j                  d      S )Ndeleterr  r9   s    r,   attr_deleterzPropertyModel.attr_deleter  s    ""9--r<   c                $    | j                  d      S )Ngetterr  r9   s    r,   attr_getterzPropertyModel.attr_getter  r   r<   N)rG   r   r   r  r  r   r  r  r  r  r  rZ   r<   r,   r  r    so    '2 ! !< .! .!` - - . . - -r<   r  )r4   r.   r~   r   );r  
__future__r   r   r   rJ   r  collections.abcr   	functoolsr   typingr   r   r   ru   r	   r
   r   astroid.contextr   r   astroid.exceptionsr   r   r   astroid.managerr   astroid.nodesr   astroid.typingr   r   astroid.objectsr   rd   rH   re   r-   r5   r.   r   r   r&  ra  ro  rx  r~  r  r  r  r  r  r  r  r  BUILTIN_EXCEPTIONSr  r  rZ   r<   r,   <module>r     sE  
& #  	   $  . .  & & : Q Q * & E(% .TJ TJnJ&+ J&Zq K q hu2 u2p' '$! !*+J+ +J\$} $
]$7 
:. *KK K*	2] 	2&5 &#1 # &5 &&&< &44 "#B
 ,  4  4 !"6 &';  4 &'; $%9  4 !"6  !5  !"6!" "#7#$  4%& $81) 06B 6Brv-K v-r<   