
    cy                       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	 ddl
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  ej        d          Z ej        d          Zej        dk    rddl
m Z  nddl!m Z  erddlmZ ddl"m#Z# dZ$ e%e$          Z&d Z'dMd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+          Z0 G d' d(e+e/          Z1 G d) d*e1          Z2 G d+ d,e)          Z3 G d- d.e3          Z4 G d/ d0e4          Z5 G d1 d2e4          Z6 G d3 d4e4          Z7 G d5 d6e4          Z8i d7e5d8e7d9e8d:e6d;e6d<e6d=e6d>e6d?e6d@e6dAe6dBe6dCe6dDe6dEe6dFe6dGe6e6e6dHZ9 G dI dJe)          Z: G dK dLe)          Z;dS )Na  
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)	lru_cache)TYPE_CHECKINGAny)basesnodesutil)InferenceContextcopy_context)AttributeInferenceErrorInferenceError	NoDefault)AstroidManager)node_classesobjectsbuilder)      )Literal)r   )Propertyattr_c                (   t          j        |           fdt          |                                          D             }d |                                D             }                    t          t          ||                               S )Nparentc                <    g | ]}t          j        |           S )valuer   r   Const).0r   objs     ?lib/python3.11/site-packages/astroid/interpreter/objectmodel.py
<listcomp>z _dunder_dict.<locals>.<listcomp>=   s6       8=s333      c                    g | ]
}|d          S ) )r    elems     r"   r#   z _dunder_dict.<locals>.<listcomp>D   s    7774d2h777r$   )r   Dictlistkeysvaluespostinitzip)instance
attributesr+   r,   r!   s       @r"   _dunder_dictr1   9   s    

8
,
,
,C   AEjooFWFWAXAX  D 87:#4#4#6#6777FLLc$''(()))Jr$   modelObjectModelreturnr   c                J    	 | j         j        S # t          $ r
 | j         cY S w xY wN)	_instance_proxiedAttributeError)r2   s    r"   _get_bound_noder:   J   s;    ''   s    ""c                      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dS )r3   c                    d | _         d S r6   r7   selfs    r"   __init__zObjectModel.__init__S   s    r$   c                   g }t          |           j        }d}t          |          dz   }t          |                                           D ]}dt          |          z
  |z
  }t          j        |d|                              d          }|d         g}|dd          D ]}	|                    d|z  |	z              |                    |           ||d	d|z  z   	                    |          d
z  S )Nz%(cname)s(%(fields)s)   P      )indentwidthTr    z,
)cnamefields)
type__name__lensortedr0   pprintpformat
splitlinesappendjoin)
r?   resultrH   string	alignmentfieldrF   linesinnerlines
             r"   __repr__zObjectModel.__repr__V   s   T

#(JJN	DOO--.. 	! 	!EUOi/EN5%@@@KKDQQE1XJEabb	 5 5S9_t34444MM%    sY.44V<<
 
 
 	
r$   c                    || _         | S r6   r=   )r?   r/   s     r"   __call__zObjectModel.__call__i   s    !r$   Nc                     | |          S r6   r'   )r?   r/   clss      r"   __get__zObjectModel.__get__m   s     tH~~r$   r4   boolc                .    ||                                  v S r6   )r0   r?   names     r"   __contains__zObjectModel.__contains__w   s    t((((r$   	list[str]c                4    d t          |           D             S )z;Get the attributes which are exported by this object model.c                `    g | ]+}|                     t                    |t          d          ,S r6   )
startswithIMPL_PREFIXLEN_OF_IMPL_PREFIX)r    os     r"   r#   z*ObjectModel.attributes.<locals>.<listcomp>}   s5    WWW1Q\\+=V=VW$%%&WWWr$   )dirr>   s    r"   r0   zObjectModel.attributesz   s     XWD		WWWWr$   c                    ||                                  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)r0   getattrri   r   r7   rb   s     r"   lookupzObjectModel.lookup   sE     4??$$$ 	54t!3444%T^tLLLLr$   bases.BoundMethodc                    t          j        d          }t                      j        d         |_        t          j        |t          |                     S )zECalling cls.__new__(type) on an object returns an instance of 'type'.z$def __new__(self, cls): return cls()objectproxyboundr   extract_noder   builtins_moduler   r   BoundMethodr:   r?   nodes     r"   attr___new__zObjectModel.attr___new__   sN     #*"66#
 #

 %&&6x@ t?43H3HIIIIr$   c                    t          j        d          }t                      j        d         |_        t          j        |t          |                     S )z-Calling cls.__init__() normally returns None.z0def __init__(self, *args, **kwargs): return Noneru   rv   ry   r}   s     r"   attr___init__zObjectModel.attr___init__   sN     #*"6B#
 #

 %&&6x@ t?43H3HIIIIr$   r6   )r4   r`   )r4   re   r4   rs   )rK   
__module____qualname__r@   rZ   r\   r_   rd   r   r0   rr   propertyr   r   r'   r$   r"   r3   r3   R   s          
 
 
&     ) ) ) ) Y[[X X X [XM M M 	J 	J 	J X	J J J J X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dS )ModuleModelc                \    t                      j        }|j                            d          S )N__dict__)r   r{   special_attributesrr   )r?   builtins_ast_modules     r"   	_builtinszModuleModel._builtins   s(    ,..>"5<<ZHHHr$   c                *    |                                  S r6   )r   r>   s    r"   attr_builtinszModuleModel.attr_builtins   s    ~~r$   c                      j         j        st           j         d           fd j         j        D             }t	          j         j                   }|                    |           |S )N__path__rn   c                    g | ]Q}t          j        |                    d           s|nt          j                            |          j                  RS )z__init__.pyr   )r   r   endswithospathdirnamer7   )r    r   r?   s     r"   r#   z-ModuleModel.attr___path__.<locals>.<listcomp>   sk     
 
 
  }}]33+ddW__T**~	  
 
 
r$   r   )r7   packager   r   r   Listr-   )r?   	path_objs	containers   `  r"   attr___path__zModuleModel.attr___path__   s    ~% 	W):VVVV
 
 
 
 +
 
 
	 !%T^<<<	9%%%r$   c                L    t          j        | j        j        | j                  S Nr   r   r   r7   rc   r>   s    r"   attr___name__zModuleModel.attr___name__       !(;DNSSSSr$   c                j    t          j        t          | j        j        dd           | j                  S Nr   r   r   r   rq   r7   doc_noder>   s    r"   attr___doc__zModuleModel.attr___doc__   5    !$.17DAA>
 
 
 	
r$   c                L    t          j        | j        j        | j                  S r   )r   r   r7   filer>   s    r"   attr___file__zModuleModel.attr___file__   r   r$   c                @    t          | j        | j        j                  S r6   )r1   r7   globalsr>   s    r"   attr___dict__zModuleModel.attr___dict__   s    DNDN,BCCCr$   c                n    | j         j        sd}n| j         j        }t          j        || j                   S )N r   )r7   r   rc   r   r   )r?   r   s     r"   attr___package__zModuleModel.attr___package__   s8    ~% 	(EEN'E!dnEEEEr$   c                (    t          j                    S r6   r   Unknownr>   s    r"   attr___spec__zModuleModel.attr___spec__        #%%%r$   c                (    t          j                    S r6   r   r>   s    r"   attr___loader__zModuleModel.attr___loader__   r   r$   c                (    t          j                    S r6   r   r>   s    r"   attr___cached__zModuleModel.attr___cached__   r   r$   N)rK   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r'   r$   r"   r   r      s@       I I I     X    X& T T XT 
 
 X
 T T XT D D XD F F XF & & X& & & X& & & X& & &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!dS )FunctionModelc                L    t          j        | j        j        | j                  S r   r   r>   s    r"   r   zFunctionModel.attr___name__   r   r$   c                j    t          j        t          | j        j        dd           | j                  S r   r   r>   s    r"   r   zFunctionModel.attr___doc__   r   r$   c                f    t          j        | j                                        | j                  S r   r   r   r7   qnamer>   s    r"   attr___qualname__zFunctionModel.attr___qualname__   s(    !(<(<(>(>t~VVVVr$   c                    | j         }|j        j        st          j        d |          S t          j        |          }|                    |j        j                   |S )Nr   r   )r7   argsdefaultsr   r   Tupler-   )r?   funcdefaults_objs      r"   attr___defaults__zFunctionModel.attr___defaults__  s^    ~y! 	?%D>>>>#)666di0111r$   c                ,   t          j        | j                  | j        j        sd }n| j        j        }| j        j        }t          j        t          |j        pg |j                  t          |j	        |j
                  t          |j        pg |j                            }d |D             }|j        r|j        ||j        <   |j        r|j        ||j        <   |r||d<   fd |j                    D             }                    |           S )Nr   c                (    i | ]\  }}||j         |S r'   rc   )r    arg
annotations      r"   
<dictcomp>z6FunctionModel.attr___annotations__.<locals>.<dictcomp>  s5     
 
 
%6c:j
Hj
 
 
r$   r4   c                F    g | ]\  }}t          j        |           |fS )r   r   )r    keyr   r!   s      r"   r#   z6FunctionModel.attr___annotations__.<locals>.<listcomp>&  sB     
 
 
e C000%8
 
 
r$   )r   r)   r7   returnsr   	itertoolschainr.   r   
kwonlyargskwonlyargs_annotationsposonlyargsposonlyargs_annotationsvarargannotationvarargkwargannotationkwargitemsr-   )r?   r   r   pair_annotationsr   r   r!   s         @r"   attr___annotations__z"FunctionModel.attr___annotations__  sD   t~666~% 	-GGn,G~"$?	R!122!<== &B(DEE
 

 
:J
 
 
   	='+'<K$ 	;&*&:K
# 	,$+K!
 
 
 
 1 1 3 3
 
 

 	U
r$   c                6    t          j        | j                  S Nr   r   r)   r7   r>   s    r"   r   zFunctionModel.attr___dict__.       7777r$   c                    d }| j         j        }t          j        | j                   }t	           |||                    }|                    t          |                                                     |S )Nc              3     K   | j         D ]O}	 |                     |j                  }n# t          $ r Y *w xY wt	          j        |j        |          }||fV  Pd S r   )r   default_valuerc   r   r   r   )r   r   r   defaultrc   s        r"   _default_argsz8FunctionModel.attr___kwdefaults__.<locals>._default_args6  s       $ $"00::GG    H $)#(6BBBGm####$ $s   (
55r   )r7   r   r   r)   dictr-   r*   r   )r?   r   r   r!   r   s        r"   attr___kwdefaults__z!FunctionModel.attr___kwdefaults__4  st    	$ 	$ 	$ ~"t~666dC0011T(..**++,,,
r$   c                |    t          j        | j                                                                                  S r6   r   r   r7   rootr   r>   s    r"   attr___module__zFunctionModel.attr___module__G  -    !$."5"5"7"7"="="?"?@@@r$   c                t    | j          G fddt          j                  } || j         | j                   S )Nc                  F    e Zd ZdZd
dZ	 dd fdZe fd	            ZdS )9FunctionModel.attr___get__.<locals>.DescriptorBoundMethodz_Bound method which knows how to understand calling descriptor
            binding.
            r4   
Literal[0]c                    dS Nr   r'   r>   s    r"   implicit_parameterszMFunctionModel.attr___get__.<locals>.DescriptorBoundMethod.implicit_parametersT  s	     qr$   NcontextInferenceContext | Nonec              3    K   t          |j                  dk    st          |j                  dk     rt          d| |          t          |          }	 t	          |j        d                             |                    }n/# t          $ r"}t          ||j        d                   |d }~ww xY w|t          j        u rt          d| |          t          t          j                  rV  d S                     j        j        j        j        	          }|                    j        j        j        j        j        
           t          j        |          }t          j        ||          V  d S )NrD   rB   z(Invalid arguments for descriptor bindingro   r   r   r   )r   r~   zInvalid class inferred)rc   lineno
col_offsetr   )r   rv   )rL   r   r   r   nextinferStopIterationastroidUninferable
isinstancer   r|   	__class__rc   r   r   r   r-   body
decoratorsr   r   UnboundMethod)r?   callerr   r^   enew_funcrw   r   s          r"   infer_call_resultzKFunctionModel.attr___get__.<locals>.DescriptorBoundMethod.infer_call_resultY  s      v{##a' 3v{+;+;a+? (B# '    'w//Vv{1~33G3DDEECC$ V V V(v{1~NNNTUUV '-- (0w    dE$566 JJJF  >>;#;	 *   !!IIOL!] "    +H55'e3????????s   .B 
B1B,,B1c                D   j         j                                         }|                    t          j        d                     j         j                                        }t          j        j         j                  }|                    ||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*.
                rJ   r   r   )r   r   r   r   kw_defaultsr   )	r   copyrQ   r   
AssignNamer   	Argumentsr   r-   )r?   positional_or_keyword_paramspositional_only_params	argumentsr   s       r"   r   z>FunctionModel.attr___get__.<locals>.DescriptorBoundMethod.args  s     04y~/B/B/D/D,,33G4FF4S4S4STTT)-)>)C)C)E)E&#-TY5EFFF	""5 6! " " #    ! r$   )r4   r   r6   r   r   )rK   r   r   __doc__r   r  r   r   r   s   r"   DescriptorBoundMethodr   O  s             BF.@ .@ .@ .@ .@ .@ .@` ! ! ! ! X! ! !r$   r  rv   )r7   r   r|   )r?   r  r   s     @r"   attr___get__zFunctionModel.attr___get__K  sh    ~U	! U	! U	! U	! U	! U	! U	!E$5 U	! U	! U	!n %$4>PPPPr$   c                (    t          j                    S r6   r   r>   s    r"   attr___ne__zFunctionModel.attr___ne__  s    #%%%r$   N)"rK   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__r'   r$   r"   r   r      s       T T XT 
 
 X
 W W XW   X   XB 8 8 X8 %  X$ A A XA ZQ ZQ XZQz & & X& (L!O#M!O$KKK!O#'MLM N"MMMr$   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                n    t                      | _        t                                                       d S r6   )r
   r   superr@   )r?   r  s    r"   r@   zClassModel.__init__  s,    '))r$   c                |    t          j        | j                                                                                  S r6   r   r>   s    r"   r   zClassModel.attr___module__  r   r$   c                >    t          j        | j        j                  S r6   r   r>   s    r"   r   zClassModel.attr___name__  s    !$."5666r$   c                X    t          j        | j                                                  S r6   r   r>   s    r"   r   zClassModel.attr___qualname__  s!    !$."6"6"8"8999r$   c                \    t          j        t          | j        j        dd                     S Nr   r   r>   s    r"   r   zClassModel.attr___doc__  $    !'$.*A7D"Q"QRRRr$   c                    | j         j        st          | j         d          | j                                         }t	          j        | j                   }|                    |           |S )N__mro__rn   r   )r7   newstyler   mror   r   r-   )r?   r9  r!   s      r"   attr___mro__zClassModel.attr___mro__  sd    ~& 	V)9UUUUn  "" 777S
r$   c                    | j         j        st          | j         d          |  G fddt          j                  }| j                                         }|j        d         d         } |||          S )Nr9  rn   c                       e Zd Z	 dd fdZdS )+ClassModel.attr_mro.<locals>.MroBoundMethodNr   r   c              3     K   j         V  d S r6   )r:  )r?   r  r   
other_selfs      r"   r  z=ClassModel.attr_mro.<locals>.MroBoundMethod.infer_call_result  s       !------r$   r6   r  rK   r   r   r  )r?  s   r"   MroBoundMethodr=    s;        AE. . . . . . . . .r$   rA  r   rv   )r7   r8  r   r   r|   implicit_metaclasslocals)r?   rA  rB  
mro_methodr?  s       @r"   attr_mrozClassModel.attr_mro  s    ~& 	R)5QQQQ
	. 	. 	. 	. 	. 	. 	.U. 	. 	. 	. "^>>@@'.u5a8
~J6HIIIIr$   c                    t          j                    }t                      }t          | j                            |                    }|                    |           |S )Nelts)r   r   r
   r*   r7   _inferred_basesr-   )r?   r!   r   rH  s       r"   attr___bases__zClassModel.attr___bases__  sQ     """$$DN227;;<<$
r$   c                B    ddl m} |                    | j                  S Nr   )helpersr   rM  object_typer7   r?   rM  s     r"   r)  zClassModel.attr___class__  ,     	$#####""4>222r$   c                     j         j        st           j         d           j                                          j                                         } fd|                    t          j                  D             }t          j	         j                   
                    |            G fddt          j                  } j                                         }|j        d         d         } |||          S )	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__rn   c                b    g | ]+}|j         k    |                    j                   )|,S )r   )r7   is_subtype_ofr   )r    r^   r   r?   s     r"   r#   z2ClassModel.attr___subclasses__.<locals>.<listcomp>  sU     
 
 
dn$
 *-):):5$,):)W)W

 
 
r$   r   c                       e Zd Z	 dd fdZdS )=ClassModel.attr___subclasses__.<locals>.SubclassesBoundMethodNr   r   c              3     K   V  d S r6   r'   r?   r  r   r!   s      r"   r  zOClassModel.attr___subclasses__.<locals>.SubclassesBoundMethod.infer_call_result         					r$   r6   r  r@  r!   s   r"   SubclassesBoundMethodrW    ;        AE        r$   r\  r   rv   )r7   r8  r   r   r   nodes_of_classr   ClassDefr   r   r-   r   r|   rB  rC  )r?   r   classesr\  rB  subclasses_methodr!   r   s   `     @@r"   attr___subclasses__zClassModel.attr___subclasses__  s:    ~& 	)~1A    $$&&~""$$
 
 
 
 
**5>::
 
 
 t~666W	 	 	 	 	 	 	E$5 	 	 	 "^>>@@.56FGJ$$+<DVWWWWr$   c                6    t          j        | j                  S r   r   r>   s    r"   r   zClassModel.attr___dict__&  r   r$   c                4    | j                                         S )z-Calling a class A() returns an instance of A.)r7   instantiate_classr>   s    r"   r(  zClassModel.attr___call__*  s     ~//111r$   )rK   r   r   r@   r   r   r   r   r   r:  rE  rJ  r)  rb  r   r(  __classcell__r  s   @r"   r-  r-    sn            A A XA 7 7 X7 : : X: S S XS   X J J XJ$   X 3 3 X3 X X XX@ 8 8 X8 2 2 X2 2 2 2 2r$   r-  c                  f    e Zd Zed             Zed             Zed             Zed             ZdS )
SuperModelc                    | j         j        S r6   )r7   mro_pointerr>   s    r"   attr___thisclass__zSuperModel.attr___thisclass__1      ~))r$   c                    | j         j        S r6   )r7   _self_classr>   s    r"   attr___self_class__zSuperModel.attr___self_class__5  rm  r$   c                    | j         j        S r6   )r7   rJ   r>   s    r"   attr___self__zSuperModel.attr___self__9  s    ~""r$   c                    | j         j        S r6   r7   r8   r>   s    r"   r)  zSuperModel.attr___class__=      ~&&r$   N)rK   r   r   r   rl  rp  rr  r)  r'   r$   r"   ri  ri  0  s~        * * X* * * X* # # X# ' ' X' ' 'r$   ri  c                  \    e Zd Zed             Zed             Zed             ZeZeZeZ	dS )UnboundMethodModelc                B    ddl m} |                    | j                  S rL  rN  rP  s     r"   r)  z!UnboundMethodModel.attr___class__C  rQ  r$   c                    | j         j        S r6   rt  r>   s    r"   attr___func__z UnboundMethodModel.attr___func__J  ru  r$   c                8    t          j        d | j                  S r   )r   r   r7   r>   s    r"   rr  z UnboundMethodModel.attr___self__N  s    !T^DDDDr$   N)
rK   r   r   r   r)  rz  rr  attr_im_funcattr_im_classattr_im_selfr'   r$   r"   rw  rw  B  sq        3 3 X3 ' ' X' E E XE !L"M LLLr$   rw  c                  B    e Zd ZdZedd            Zedd            ZdS )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
    r4   rs   c                    t          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.
        zdef __enter__(self): ...ru   rv   ry   r}   s     r"   attr___enter__z"ContextManagerModel.attr___enter__^  sJ     #*"67U"V"V %&&6x@ t?43H3HIIIIr$   c                    t          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.
        z7def __exit__(self, exc_type, exc_value, traceback): ...ru   rv   ry   r}   s     r"   attr___exit__z!ContextManagerModel.attr___exit__n  sN     #*"6I#
 #

 %&&6x@ t?43H3HIIIIr$   Nr   )rK   r   r   r  r   r  r  r'   r$   r"   r  r  W  sh          J J J XJ J J J XJ J Jr$   r  c                  :    e Zd Zed             Zed             ZdS )BoundMethodModelc                $    | j         j        j        S r6   rt  r>   s    r"   rz  zBoundMethodModel.attr___func__  s    ~&//r$   c                    | j         j        S r6   )r7   rx   r>   s    r"   rr  zBoundMethodModel.attr___self__  s    ~##r$   N)rK   r   r   r   rz  rr  r'   r$   r"   r  r    sH        0 0 X0 $ $ X$ $ $r$   r  c                  J     e Zd Z fdZed             Zed             Z xZS )GeneratorModelc                2    t                      j        | g|R i |}t                      j        d         }|j                                        D ]E\  }}|d         }|fd}t          t          |          t          |z   t          |                     F|S )N	generatorr   c                    |S r6   r'   r^   meths     r"   patchedz'GeneratorModel.__new__.<locals>.patched      r$   )
r/  __new__r   r{   rC  r   setattrrJ   ri   r   )
r^   r   kwargsretr  rc   r,   methodr  r  s
            r"   r  zGeneratorModel.__new__  s    eggoc3D333F33"$$4[A	%,2244 	F 	FLD&AYF"(     DII{T18G3D3DEEEE
r$   c                V    t          j        | j        j        j        | j                  S r   )r   r   r7   r   rc   r>   s    r"   r   zGeneratorModel.attr___name__  s+    !.',T^
 
 
 	
r$   c                t    t          j        t          | j        j        j        dd           | j                  S r   )r   r   rq   r7   r   r   r>   s    r"   r   zGeneratorModel.attr___doc__  s8    !$./8'4HH>
 
 
 	
r$   )rK   r   r   r  r   r   r   rf  rg  s   @r"   r  r    sn             
 
 X

 
 
 X
 
 
 
 
r$   r  c                       e Zd Z fdZ xZS )AsyncGeneratorModelc                ~    t                      j        | g|R i |}t                      j        }|                    d          }||                    d          }|j                                        D ]E\  }}|d         }|fd}	t          t          |          t          |z   t          |	                     F|S )Nasync_generatorr  r   c                    |S r6   r'   r  s     r"   r  z,AsyncGeneratorModel.__new__.<locals>.patched  r  r$   )r/  r  r   r{   getrC  r   r  rJ   ri   r   )r^   r   r  r  astroid_builtinsr  rc   r,   r  r  r  s             r"   r  zAsyncGeneratorModel.__new__  s    eggoc3D333F33)++;$(():;;	 	:(,,[99I%,2244 	F 	FLD&AYF"(     DII{T18G3D3DEEEE
r$   )rK   r   r   r  rf  rg  s   @r"   r  r    s8                r$   r  c                  f    e Zd Zed             Zed             Zed             Zed             ZdS )InstanceModelc                    | j         j        S r6   rt  r>   s    r"   r)  zInstanceModel.attr___class__  ru  r$   c                |    t          j        | j                                                                                  S r6   r   r>   s    r"   r   zInstanceModel.attr___module__  r   r$   c                \    t          j        t          | j        j        dd                     S r4  r   r>   s    r"   r   zInstanceModel.attr___doc__  r5  r$   c                @    t          | j        | j        j                  S r6   )r1   r7   instance_attrsr>   s    r"   r   zInstanceModel.attr___dict__  s    DNDN,IJJJr$   N)rK   r   r   r   r)  r   r   r   r'   r$   r"   r  r    s        ' ' X' A A XA S S XS K K XK K Kr$   r  c                  <    e Zd Zedd            Zed             ZdS )ExceptionInstanceModelr4   nodes.Tuplec                6    t          j        | j                  S r   )r   r   r7   r>   s    r"   	attr_argsz ExceptionInstanceModel.attr_args  s    {$.1111r$   c                ~    t                      j        }|t          j        j                 }|                                S r6   )r   r{   typesTracebackTyperK   re  )r?   r   traceback_types      r"   attr___traceback__z)ExceptionInstanceModel.attr___traceback__  s3    ,..>,U-@-IJ//111r$   N)r4   r  )rK   r   r   r   r  r  r'   r$   r"   r  r    sM        2 2 2 X2 2 2 X2 2 2r$   r  c                  $    e Zd Zed             ZdS )SyntaxErrorInstanceModelc                *    t          j        d          S Nr   r   r>   s    r"   	attr_textz"SyntaxErrorInstanceModel.attr_text      !"%%%r$   N)rK   r   r   r   r  r'   r$   r"   r  r    -        & & X& & &r$   r  c                  T    e Zd Zed             Zed             Zed             ZeZdS )OSErrorInstanceModelc                *    t          j        d          S r  r   r>   s    r"   attr_filenamez"OSErrorInstanceModel.attr_filename  r  r$   c                *    t          j        d          S r   r   r>   s    r"   
attr_errnozOSErrorInstanceModel.attr_errno  s    !!$$$r$   c                *    t          j        d          S r  r   r>   s    r"   attr_strerrorz"OSErrorInstanceModel.attr_strerror  r  r$   N)rK   r   r   r   r  r  r  attr_filename2r'   r$   r"   r  r    sd        & & X& % % X% & & X& #NNNr$   r  c                  :    e Zd Zed             Zed             ZdS )ImportErrorInstanceModelc                *    t          j        d          S r  r   r>   s    r"   	attr_namez"ImportErrorInstanceModel.attr_name  r  r$   c                *    t          j        d          S r  r   r>   s    r"   	attr_pathz"ImportErrorInstanceModel.attr_path  r  r$   N)rK   r   r   r   r  r  r'   r$   r"   r  r    sH        & & X& & & X& & &r$   r  c                  $    e Zd Zed             ZdS )UnicodeDecodeErrorInstanceModelc                *    t          j        d          S r  r   r>   s    r"   attr_objectz+UnicodeDecodeErrorInstanceModel.attr_object  r  r$   N)rK   r   r   r   r  r'   r$   r"   r  r    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                  l    e Zd Zed             Zd Zed             Zed             Zed             ZdS )	DictModelc                    | j         j        S r6   rt  r>   s    r"   r)  zDictModel.attr___class__  ru  r$   c                     G fddt           j                  }t          | 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dS )@DictModel._generic_dict_attribute.<locals>.DictMethodBoundMethodNr   r   c              3     K   V  d S r6   r'   rY  s      r"   r  zRDictModel._generic_dict_attribute.<locals>.DictMethodBoundMethod.infer_call_result%  rZ  r$   r6   r  r@  r[  s   r"   DictMethodBoundMethodr  $  r]  r$   r  Nrv   )r   r|   r   r7   r8   igetattr)r?   r!   rc   r  r  s    `   r"   _generic_dict_attributez!DictModel._generic_dict_attribute!  sv    	 	 	 	 	 	 	G$7 	 	 	 DN+44T::DAA$$4t~FFFFr$   c                l   g }t          j        | j                  }| j        j        D ]F\  }}t          j        |          }|                    ||f           |                    |           G|                    |           t                              |          }| 	                    |d          S )Nr   rG  r   )
r   r   r7   r   r   r-   rQ   r   	DictItemsr  )r?   elemsr!   r   r   r(   s         r"   
attr_itemszDictModel.attr_items-  s    t~666.. 	 	JC%S111DMM3,'''LL%   $$++C999r$   c                    d | j         j        D             }t          j        | j                   }|                    |           t
                              |          }|                     |d          S )Nc                    g | ]\  }}|S r'   r'   )r    r   _s      r"   r#   z'DictModel.attr_keys.<locals>.<listcomp><  s    999a999r$   r   rG  r+   )r7   r   r   r   r-   r   DictKeysr  )r?   r+   r!   s      r"   	attr_keyszDictModel.attr_keys:  sl    99DN$8999t~666$s##++C888r$   c                    d | j         j        D             }t          j        | j                   }|                    |           t
                              |          }|                     |d          S )Nc                    g | ]\  }}|S r'   r'   )r    r  r   s      r"   r#   z)DictModel.attr_values.<locals>.<listcomp>E  s    ???JQ%???r$   r   r,   )r7   r   r   r   r-   r   
DictValuesr  )r?   r,   r!   s      r"   attr_valueszDictModel.attr_valuesC  sj    ??$.*>???t~666V  %%++C:::r$   N)	rK   r   r   r   r)  r  r  r  r  r'   r$   r"   r  r    s        ' ' X'
G 
G 
G 
: 
: X
: 9 9 X9 ; ; X; ; ;r$   r  c                      e Zd ZdZd Zed             Zed             Zed             Zed             Z	ed             Z
dS )	PropertyModelzModel for a builtin property.c           
         t          j        || j                  }t          j        |          }|                    g g g g g g g g            |                    |g            |S )Nrc   r   r   )r   r   r   r
  r   r   r   r   r   r  )r   FunctionDefr7   r  r-   )r?   rc   functionr   s       r"   _init_functionzPropertyModel._init_functionP  s~    $$t~FFFh///$&#% 	 		
 		
 		
 	t"---r$   c                    | j          G fddt          j                  } |d| j                   }|                    j        j                   |S )Nc                       e Zd Z	 dd fdZdS )5PropertyModel.attr_fget.<locals>.PropertyFuncAccessorNr   r   c              3     K   |r*t          |j                  dk    rt          d| |          j                            ||          E d {V  d S )NrB   zfget() needs a single argumentr   r  r   )rL   r   r   r  r  )r?   r  r   r   s      r"   r  zGPropertyModel.attr_fget.<locals>.PropertyFuncAccessor.infer_call_resultg  s        c&+..!3 (8w     =::!7 ;           r$   NNr  r@  r  s   r"   PropertyFuncAccessorr  f  s;        FJ        r$   r  fgetr  r  )r7   r   r  r-   r   r  )r?   r  property_accessorr   s      @r"   	attr_fgetzPropertyModel.attr_fgetb  s~    ~	 	 	 	 	 	 	5#4 	 	 	 10fT^TTT""		"BBB  r$   c                
   | j         }dd} ||          st          d|j        j                    G fddt          j                  } |d	| j         
          }|                    j        j                   |S )Nr   r   r4   astroid.FunctionDef | Nonec                      fd j                                         D             D ]A}|                                D ]*}|                     j        j        dz             r|c c S +BdS )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
            c                >    g | ]}|j         j        j         k    |S r'   )rc   r  )r    tr   s     r"   r#   z@PropertyModel.attr_fset.<locals>.find_setter.<locals>.<listcomp>  s:       4=CU9U  r$   z.setterN)r   get_childrendecoratornamesr   r  rc   )r   ro   dec_names   `  r"   find_setterz,PropertyModel.attr_fset.<locals>.find_setter|  s       ;3355   & & !' 5 5 7 7 & &H(();i)GHH &%&& 4r$   z&Unable to find the setter of property c                       e Zd Z	 dd fdZdS )5PropertyModel.attr_fset.<locals>.PropertyFuncAccessorNr   r   c              3     K   |r*t          |j                  dk    rt          d| |                              ||          E d {V  d S )NrD   zfset() needs two argumentsr   r  )rL   r   r   r  )r?   r  r   func_setters      r"   r  zGPropertyModel.attr_fset.<locals>.PropertyFuncAccessor.infer_call_result  sy        c&+..!3 (4T7    '88PW8XXXXXXXXXXXr$   r  r  r@  )r   s   r"   r  r    sD        FJY Y Y Y Y Y Y Y Yr$   r  fsetr  r  )r   r   r4   r  )	r7   r   r  rc   r   r  r-   r   r  )r?   r   r  r  r  r   s        @r"   	attr_fsetzPropertyModel.attr_fsetx  s    ~	 	 	 	 "k$'' 	 M9KMM  		Y 		Y 		Y 		Y 		Y 		Y 		Y5#4 		Y 		Y 		Y 10fT^TTT""(8{?O"PPP  r$   c                ,    |                      d          S )Nsetterr  r>   s    r"   attr_setterzPropertyModel.attr_setter      ""8,,,r$   c                ,    |                      d          S )Ndeleterr  r>   s    r"   attr_deleterzPropertyModel.attr_deleter  s    ""9---r$   c                ,    |                      d          S )Ngetterr  r>   s    r"   attr_getterzPropertyModel.attr_getter  r  r$   N)rK   r   r   r  r  r   r  r  r  r
  r  r'   r$   r"   r  r  M  s        ''  $ ! ! X!* %! %! X%!N - - X- . . X. - - X- - -r$   r  )r2   r3   r4   r   )<r  
__future__r   r   r   rN   sysr  	functoolsr   typingr   r   r   r   r   r	   astroid.contextr
   r   astroid.exceptionsr   r   r   astroid.managerr   astroid.nodesr   lazy_importr   r   version_infor   typing_extensionsastroid.objectsr   ri   rL   rj   r1   r:   r3   r   r   r-  ri  rw  r  r  r  r  r  r  r  r  r  r  BUILTIN_EXCEPTIONSr  r  r'   r$   r"   <module>r     s   
 & # " " " " "     				  



        % % % % % % % %  & & & & & & & & & & : : : : : : : : Q Q Q Q Q Q Q Q Q Q * * * * * * & & & & & &
$
9
%
%
$
9
%
%v *)))))) )((((((S%%   "   PJ PJ PJ PJ PJ PJ PJ PJfJ& J& J& J& J&+ J& J& J&ZM  M  M  M  M K M  M  M `k2 k2 k2 k2 k2 k2 k2 k2\' ' ' ' ' ' ' '$! ! ! ! ! ! ! !*'J 'J 'J 'J 'J+ 'J 'J 'JT$ $ $ $ $} $ $ $
 
 
 
 
]$7 
 
 
:    .   *K K K K KK K K K*	2 	2 	2 	2 	2] 	2 	2 	2& & & & &5 & & &# # # # #1 # # # & & & & &5 & & && & & & &&< & & &44 "#B
 ,  4  4 !"6 &';  4 &'; $%9  4 !"6  !5  !"6!" "#7#$  4%& $81)   0.; .; .; .; .; .; .; .;b]- ]- ]- ]- ]-K ]- ]- ]- ]- ]-r$   