o
    2g                     @  sJ  d Z ddlmZ ddlZddlZddlZddlZddlZddl	m
Z
mZ ddlmZmZmZ ddlmZ ddlmZ ddlmZmZmZmZmZmZmZmZmZmZ dd	lm Z m!Z!m"Z"m#Z#m$Z$m%Z% G d
d de#Z&G dd de#Z'd4ddZ(	d5ddddd6d!d"Z)G d#d$ d$Z*G d%d& d&e Z+d7d(d)Z,d8d+d,Z-	d9d:d2d3Z.dS );zTStub generator for C modules.

The public interface is via the mypy.stubgen module.
    )annotationsN)FunctionType
ModuleType)AnyCallableMapping)parse_type_comment)is_c_module)
ArgSigFunctionSigSigfind_unique_signatures!infer_arg_sig_from_anon_docstringinfer_prop_type_from_docstring&infer_ret_type_sig_from_anon_docstring!infer_ret_type_sig_from_docstringinfer_sig_from_docstringparse_all_signatures)BaseStubGenerator	ClassInfoFunctionContextSignatureGeneratorinfer_method_arg_typesinfer_method_ret_typec                   @  s<   e Zd Z	ddddZedddZdddZdddZdS )ExternalSignatureGeneratorN	func_sigsdict[str, str] | None
class_sigsreturnNonec                 C  s   |pi | _ |pi | _dS )z
        Takes a mapping of function/method names to signatures and class name to
        class signatures (usually corresponds to __init__).
        N)r   r   )selfr   r    r!   E/home/garg/my-data/venv/lib/python3.10/site-packages/mypy/stubgenc.py__init__*   s   
z#ExternalSignatureGenerator.__init__doc_dirstrc           
   	   C  s   g }g }t  | dD ]&}t|}t| \}}W d   n1 s%w   Y  ||7 }||7 }qtt|}tt|}	t||	S )z+Instantiate from a directory of .rst files.z/*.rstN)globopenr   	readlinesdictr   r   )
clsr$   all_sigsall_class_sigspathfloc_sigsloc_class_sigssigsr   r!   r!   r"   from_doc_dir4   s   


z'ExternalSignatureGenerator.from_doc_dirdefault_sigr   ctxr   list[FunctionSig] | Nonec                 C  s   |j r(|jdv r(|j| jvr(|j j| jv r(t|jt| j|j j t|jdgS |j| jvr0d S t|jt| j|j d dg}|j rJ| ||j jS |S )N__new__r#   nameargsret_type)	
class_infor9   r   r   r   r   r   remove_self_typeself_varr    r3   r4   inferredr!   r!   r"   get_function_sigB   s,   
	z+ExternalSignatureGenerator.get_function_sigdefault_type
str | Nonec                 C  s   d S Nr!   )r    rB   r4   r!   r!   r"   get_property_typed   s   z,ExternalSignatureGenerator.get_property_type)NN)r   r   r   r   r   r   )r$   r%   r   r   r3   r   r4   r   r   r5   rB   rC   r4   r   r   rC   )__name__
__module____qualname__r#   classmethodr2   rA   rE   r!   r!   r!   r"   r   )   s    

"r   c                   @  s    e Zd ZdddZdddZdS )DocstringSignatureGeneratorr3   r   r4   r   r   r5   c                 C  s   t |j|j}|r|jd usJ t|j|jr|d= |jr>|s6|jdkr6t |jj|jj}|r6dd |D }| ||jjS |S )Nr#   c                 S  s   g | ]}|j d dqS )r#   r9   )_replace.0sigr!   r!   r"   
<listcomp>x       z@DocstringSignatureGenerator.get_function_sig.<locals>.<listcomp>)r   	docstringr9   )is_pybind11_overloaded_function_docstringr<   r=   r>   r?   r!   r!   r"   rA   i   s   z,DocstringSignatureGenerator.get_function_sigrB   rC   c                 C  sD   |j dur t|j }|r|S t|j |j}|r|S t|j }|S dS )z:Infer property type from docstring or docstring signature.N)rU   r   r   r9   r   )r    rB   r4   r@   r!   r!   r"   rE   }   s   


z-DocstringSignatureGenerator.get_property_typeNrF   rG   )rH   rI   rJ   rA   rE   r!   r!   r!   r"   rL   h   s    
rL   rU   r%   r9   r   boolc                 C  s   |  | dS )Nz((*args, **kwargs)
Overloaded function.


startswith)rU   r9   r!   r!   r"   rV      s   rV    Finclude_privateexport_lessinclude_docstringsmodule_nametargetknown_modules	list[str]r$   r\   r]   r^   r   c                C  s   t j|}|rt j|st | t| |||||d}|  | }	t|ddd}
|
	|	 W d   dS 1 s=w   Y  dS )a  Generate stub for C module.

    Signature generators are called in order until a list of signatures is returned.  The order
    is:
    - signatures inferred from .rst documentation (if given)
    - simple runtime introspection (looking for docstrings and attributes
      with simple builtin types)
    - fallback based special method names or "(*args, **kwargs)"

    If directory for target doesn't exist it will be created. Existing stub
    will be overwritten.
    r[   wzutf-8)encodingN)
osr-   dirnameisdirmakedirsInspectionStubGeneratorgenerate_moduleoutputr'   write)r_   r`   ra   r$   r\   r]   r^   subdirgenrk   filer!   r!   r"   generate_stub_for_c_module   s    
"rp   c                   @  sF   e Zd ZdZddd
dZeddddZeddddZdddZdS )CFunctionStubzR
    Class that mimics a C function in order to provide parseable docstrings.
    Fr9   r%   docis_abstractrW   r   r   c                 C  s   || _ || _|| _d S rD   )rH   __doc____abstractmethod__)r    r9   rr   rs   r!   r!   r"   r#      s   
zCFunctionStub.__init__rR   r   c                 C  s   t |j| d d |S N)rq   r9   
format_sig)r*   rR   rs   r!   r!   r"   	_from_sig   s   zCFunctionStub._from_sigr1   list[FunctionSig]c                 C  s"   t |d jddd |D |S )Nr   
c                 s  s     | ]}|  d d V  qd S rv   )rx   rP   r!   r!   r"   	<genexpr>   s    z+CFunctionStub._from_sigs.<locals>.<genexpr>)rq   r9   join)r*   r1   rs   r!   r!   r"   
_from_sigs   s   zCFunctionStub._from_sigsc                 C  s   dS )z
        This exists to make this object look like a method descriptor and thus
        return true for CStubGenerator.ismethod()
        Nr!   r    r!   r!   r"   __get__   s   zCFunctionStub.__get__N)F)r9   r%   rr   r%   rs   rW   r   r   )rR   r   rs   rW   r   rq   )r1   rz   rs   rW   r   rq   r   r   )	rH   rI   rJ   rt   r#   rK   ry   r~   r   r!   r!   r!   r"   rq      s    rq   c                      sJ  e Zd ZdZ						dhdi fddZdjddZdkddZdld!d"Zdmd%d&Zdnd'd(Z	dod)d*Z
dpd,d-Zdqd/d0Zdrd1d2Zdnd3d4Zdsd8d9Zdsd:d;Zdtd=d>Zednd?d@ZedsdAdBZedudEdFZdndGdHZdvdKdLZddMdwdOdPZdxdRdSZdydTdUZ	dzd{dZd[Zd|d^d_Zd}d`daZd~dddeZddfdgZ  Z S )ri   zStub generator that does not parse code.

    Generation is performed by inspecting the module's contents, and thus works
    for highly dynamic modules, pyc files, and C modules (via the CStubGenerator
    subclass).
    rZ   NFr_   r%   ra   rb   r$   _all_list[str] | Noner\   rW   r]   r^   moduleModuleType | Noner   r   c	           	        sv   || _ |d u rt|| _n|| _t| j| _|| _| j| _t |||| || _	| jr9| j
dg di d S d S )Ntyping)r   r   ClassVarDictIterableIteratorListLiteral
NamedTupleOptionalTupleUnion)r$   	importlibimport_moduler   r	   ra   resort_memberssuperr#   r_   known_importsupdate)	r    r_   ra   r$   r   r\   r]   r^   r   	__class__r!   r"   r#      s   z InspectionStubGenerator.__init__funcobjectr4   r   r   c                   s  d }j szt|}W n	 ty   Y nw |d u r@|jd ur0t|jt|j|jjt	|jdS t|jt
ddt
ddgd dS |j|j|j}|j}|j |j}|jd" fd	d
g d# fdd}d$fdd}|| |rt
d| | n	|rt
d d%fdd}	|||	 |rt
d| | |jd urtdd D rt|j|jjd d! D }
|
d ur|
dpt	|j}t|j|S )&Nr8   *argsrN   **kwargskeyr%   r   rC   c                   s8   |  vrd S  |  }|d u rdS t |ts|S |S )Nr   )
isinstancer%   get_type_fullname)r   argtype)r   r    r!   r"   get_annotation*  s   

zHInspectionStubGenerator.get_default_function_sig.<locals>.get_annotationr:   rb   get_default_value#Callable[[int, str], object | None]r   c                   s   t | D ]@\}}|||}|d ur8| v r | }n|}|dkr-d}| d}t||dd qt||dd qd S )Nr   _typeshed.Incompletez | NoneT)defaultF)	enumerateget_type_annotationadd_nameappendr
   )r:   r   iargdefault_valuer   
incomplete)r   arglistr   r    r!   r"   add_args7  s   




zBInspectionStubGenerator.get_default_function_sig.<locals>.add_argsr   int_arg
Any | Nonec                   s4   r| t  t  kr| t  t    S d S rD   )len)r   r   )r:   defaultsr!   r"   get_pos_defaultL  s   zIInspectionStubGenerator.get_default_function_sig.<locals>.get_pos_default*_ir   c                   s    r  |S d S rD   )get)r   r   )kwonlydefaultsr!   r"   get_kw_default[  s   
zHInspectionStubGenerator.get_default_function_sig.<locals>.get_kw_defaultz**c                 s  s$    | ]}|j d u o|jdu V  qd S )NF)typer   rQ   r   r!   r!   r"   r|   h  s    
zCInspectionStubGenerator.get_default_function_sig.<locals>.<genexpr>c                 S  s   g | ]}|j r|j qS r!   rN   r   r!   r!   r"   rS   l  rT   zDInspectionStubGenerator.get_default_function_sig.<locals>.<listcomp>)r   r%   r   rC   )r:   rb   r   r   r   r   )r   r   r   r%   r   r   )r   r   r   r%   r   r   )r	   inspectgetfullargspec	TypeErrorr<   r   r9   infer_c_method_argsr>   r   r
   r:   r   varargsvarkwr   
kwonlyargsr   r   allr   )r    r   r4   argspecr   kwargsr   r   r   r   new_argsr;   r!   )r   r   r:   r   r   r   r    r"   get_default_function_sig  sb   



z0InspectionStubGenerator.get_default_function_siglist[SignatureGenerator]c                 C  s0   | j sg S t g}| jr|dt| j |S Nr   )r	   rL   r$   insertr   r2   )r    sig_generatorsr!   r!   r"   get_sig_generatorst  s   z*InspectionStubGenerator.get_sig_generators	type_namec                 C  s<   d| j g}t|dddd }|dusJ || || j|S )a  Strips unnecessary module names from typ.

        If typ represents a type that is inside module or is a type coming from builtins, remove
        module declaration from it. Return stripped name of the type.

        Arguments:
            typ: name of the type
        builtinsr   N   )r_   r   print_annotationra   )r    r   local_modulesparsed_typer!   r!   r"   strip_or_import~  s   
	z'InspectionStubGenerator.strip_or_importobjrC   c                 C  s   t |ddS )z!Return module name of the object.rI   Ngetattrr    r   r!   r!   r"   get_obj_module     z&InspectionStubGenerator.get_obj_modulec                 C  s   |  |}|du p|| jkS )z<Check if object is considered defined in the current module.N)r   r_   )r    r   r   r!   r!   r"   is_defined_in_module  s   
z,InspectionStubGenerator.is_defined_in_modulec                 C  s  |  | j}| jrt|dd d}g }|D ]}\}}t|ra|j| jv ra|j}|| j	d rS|
dd\}}|t| j	d  pAd}| j|||fg | j| q| j|| | j| q| |rst|ss|||f q| |}	|	r| j|	|d fg | j||	ddr| j| q| dd	 |D  | jrg }
g }g }ng }| }
 }}|D ](\}}| |r| j|||
d
 qt|r| j|||d
 q| j|||d
 qg | _| jr-|D ]
}| j|d  q|D ] }|dr| jr| jd r| jd | j|d  q| jr|
r| jd |
D ]}| j|d  q nQt|D ]L\}}| jr[|dr[| jd drnt||d kr[||d  dsn| jrt| jd drt|dst| jd | j|d  q1|   d S )Nc                 S  s   | d S r   r!   xr!   r!   r"   <lambda>  s    z9InspectionStubGenerator.generate_module.<locals>.<lambda>r   .r   F)name_is_aliasc                 S  s   h | ]\}}t |s|qS r!   )r   ismodule)rQ   r9   r   r!   r!   r"   	<setcomp>  s    z:InspectionStubGenerator.generate_module.<locals>.<setcomp>)rk   r{   classrM       def)get_membersr   r   sortedr   r   rH   ra   rY   r_   rsplitr   import_trackeradd_import_fromreexport
add_importr   r   r   should_reexportset_defined_namesis_functiongenerate_function_stubisclassgenerate_class_stubgenerate_variable_stub_outputr   check_undefined_names)r    	all_itemsitemsr9   r   r_   pkg_namemod_name
rel_moduleobj_module_name	functionstypes	variablesrk   liner   r!   r!   r"   rj     s   


 &z'InspectionStubGenerator.generate_moduleattrc                 C  s$   |dv p|| j v pt|pt|S )N)r   __getattribute____str____repr__rt   __dict__rI   __weakref____annotations____firstlineno____static_attributes____annotate__)IGNORED_DUNDERSis_pybind_skipped_attributekeyword	iskeyword)r    r  r!   r!   r"   is_skipped_attribute  s   z,InspectionStubGenerator.is_skipped_attributelist[tuple[str, Any]]c              	   C  sX   t |d}g }|D ] }| |rq	zt ||}W n	 ty!   Y q	w |||f q	|S )Nr  )r   r  AttributeErrorr   )r    r   obj_dictresultsr9   valuer!   r!   r"   r     s   

z#InspectionStubGenerator.get_membersc                 C  sn   |du s
|t du rdS t|rd| | dS t|tr$| dS t|tr0| jdddS | t |S )	z
        Given an instance, return a string representation of its type that is valid
        to use as a type annotation.
        Nr   ztype[]ztyping.Callableztypes.ModuleTypeF)require)r   r   r   r   r   r   r   r   r   r!   r!   r"   r     s   



z+InspectionStubGenerator.get_type_annotationc                 C  s   | j rt|S t|S rD   )r	   r   	isbuiltin
isfunctionr   r!   r!   r"   r     s   

z#InspectionStubGenerator.is_functionr<   r   r9   c                 C  s>   | j rt|pt|ttjttjttjfv S t|S rD   )	r	   r   ismethoddescriptorr   r%   index__add__r7   r  r    r<   r9   r   r!   r!   r"   	is_method  s   
z!InspectionStubGenerator.is_methodc                 C  s(   | j rt|pt|jdv S t|S )N)rK   classmethod_descriptor)r	   r   r  r   rH   ismethodr  r!   r!   r"   is_classmethod)  s   
z&InspectionStubGenerator.is_classmethodClassInfo | Nonec                 C  sH   |d u rdS | j rt|jd}|||}t|tS tt|j|tS )NFr  )r	   r   r*   r   r   staticmethodr   getattr_static)r    r<   r9   r   
raw_lookup	raw_valuer!   r!   r"   is_staticmethod2  s   
z'InspectionStubGenerator.is_staticmethodc                 C  s   t | ddS )Nru   Fr   )r   r!   r!   r"   is_abstract_method<  r   z*InspectionStubGenerator.is_abstract_methodc                 C  s   t |p	t|dS )Nfget)r   isdatadescriptorhasattr)r<   r9   r   r!   r!   r"   is_property@     z#InspectionStubGenerator.is_propertypropr   c                 C  s   t | do	| jd u S )Nfset)r*  r.  )r-  r!   r!   r"   is_property_readonlyD  r,  z,InspectionStubGenerator.is_property_readonlyc                 C  s   | j r
t|jdv S dS )z=For c-modules, whether the property behaves like an attribute)pybind11_static_propertyStaticPropertyF)r	   r   rH   r   r!   r!   r"   is_static_propertyH  s   z*InspectionStubGenerator.is_static_propertyr@   rz   c                 C  s\   t |D ]'\}}|jD ]}|jd ur| |j|_q|jd ur+|j| |jd||< qd S )N)r;   )r   r:   r   r   r;   rO   )r    r@   r   rR   r   r!   r!   r"   process_inferred_sigsP  s   


z-InspectionStubGenerator.process_inferred_sigs)r<   rk   c                C  sz  t |dd}t|tsd}t| j||| ||d}| ||js&| |r(dS | 	|j
 | ||}| || j|}| | g }	t|dkrT|	d| d |jrb|	d| d |dur| |||rs|	d n/|D ]}
|
jr|
jd	 j
d
vr|
jd	t|jd qu|d	 jr|d	 jd	 j
dkr|	d |r| |}|| j||	|d | ||| dS )a(  Generate stub for a single function or method.

        The result (always a single line) will be appended to 'output'.
        If necessary, any required names will be added to 'imports'.
        The 'class_name' is used to find signature of __init__ or __new__ in
        'class_sigs'.
        rt   NrU   rs   r<   r   z@{}ztyping.overloadzabc.abstractmethodz@staticmethodr   )r    r*   rN   r*   z@classmethod)
decoratorsrU   )r   r   r%   r   r_   r'  is_private_namefullnameis_not_in_allrecord_namer9   r   get_signaturesr   r3  r   r   formatr   rs   r&  r:   r   r
   r>   _indent_docstringextendformat_func_def	_fix_iter)r    r9   r   rk   r<   rU   r4   r3   r@   r5  rR   r!   r!   r"   r   X  sD   




z.InspectionStubGenerator.generate_function_stubrU   c                   s   |j dd}| jd  t|dkr5t fdd|D s5t|dd D ]\}}| r4 | ||d < q$|d d	rRt|dkrH|  n
|d dd |d< d
|S )zQFix indentation of docstring extracted from pybind11 or other binding generators.T)keependsr   r   c                 3  s$    | ]}|  p|  V  qd S rD   )rY   strip)rQ   r   indentr!   r"   r|     s   " z<InspectionStubGenerator._indent_docstring.<locals>.<genexpr>NrM   r{   rZ   )	
splitlines_indentr   r   r   rA  endswithr   r}   )r    rU   linesr   r   r!   rB  r"   r<    s   

z)InspectionStubGenerator._indent_docstringc                 C  s   |j rG|j jdurI|jdkrKd|j jjvrMd}|D ]}|jr+|jd jdkr+|j} nq|du r2dS tdd| d}| jd|||j d dS dS dS dS dS )	zqEnsure that objects which implement old-style iteration via __getitem__
        are considered iterable.
        N__getitem____iter__rM   r   z&def __iter__(self) -> typing.Iterator[z]
rk   r<   )	r<   r*   r9   r  r:   r   r;   rq   r   )r    r4   r@   rk   	item_typerR   r   r!   r!   r"   r?    s*   
z!InspectionStubGenerator._fix_iterraw_objstatic_propertiesrw_propertiesro_propertiesc              
   C  s  t |dd}t |dd}	|	r#t |	dd}
|
r|r|d|
 7 }n|
r#|
}t| j||d|d}| ||js9| |r;dS | |j | |}| 	|}|rV| 
| |}n	| ||}|j}| || j|}|durp| 
|}|r| d}|r{dnd	}|du r| d
}|| j | d| d| d|  dS |r|| j d t|tdg|}||j| jd dS |du r| d
}|| j | d|  dS )a  Generate property stub using introspection of 'obj'.

        Try to infer type from docstring, append resulting lines to 'output'.

        raw_obj : object before evaluation of descriptor (if any)
        obj : object after evaluation of descriptor
        rt   Nr(  r{   Fr4  typing.ClassVarz  # read-onlyrZ   r   : [] = ...z	@propertyr    rB  )r   r   r_   r6  r7  r8  r9  r9   r2  r/  r   r   r   r;   rE   r   r   r   rE  r   r
   rx   )r    r9   rL  r   rM  rN  rO  r<   rU   r(  
alt_docstrr4   staticreadonlyr;   r3   inferred_typeclassvartrailing_commentrR   r!   r!   r"   generate_property_stub  sL   





z.InspectionStubGenerator.generate_property_stubtypr   c                 C  sN   |t u rdS t|d|j}| |}|dusJ ||dkr%| d| }|S )z,Given a type, return a string representationr   rJ   Nr   r   )r   r   rH   r   )r    r[  typenamer_   r!   r!   r"   r     s   
z)InspectionStubGenerator.get_type_fullnamec                   s   t |}|d tu r|d= |r|d jdkr|d= |dd  }g }|D ] t fdd|D s6|  q$fdd|D S )NrM   pybind11_objectr   c                 3  s    | ]}t | V  qd S rD   )
issubclass)rQ   b)baser!   r"   r|     s    z9InspectionStubGenerator.get_base_types.<locals>.<genexpr>c                   s   g | ]
}   |qS r!   )r   r   )rQ   r`  r   r!   r"   rS     s    z:InspectionStubGenerator.get_base_types.<locals>.<listcomp>)r   mror   rH   anyr   )r    r   	all_basesbasesr!   )r`  r    r"   get_base_types  s   

z&InspectionStubGenerator.get_base_types
class_namer*   c              
   C  s  t |d}| |}| jrt|dd d}dd |D }g }g }g }	g }
g }g }| | |   t|dt |dd	|}|D ]r\}}|||}| |||sV| 	|||r|d
krad|v r_q>d}| 
|||rld|_n| 	|||rwd|_nd|_| j||||d q>| |||r| ||||	|
|| q>t|r| |r| ||| q>|||f q>|D ]+\}}|dkr|d	u rq| | |}| d}|	| j | d| d| d q|   | |}|rdd| }nd}|s|	s|
s|s|re|| j d| | d |D ]'}|r0|d r0|d  ds0| dr0|d || q|	D ]}|| q9|
D ]}|| qD|D ]}|| qO|D ]}|| qZd	S || j d| | d d	S )zGenerate stub for a single class using runtime introspection.

        The result lines will be appended to 'output'. If necessary, any
        required names will be added to 'imports'.
        r  c                 S  s   t | d S r   )method_name_sort_keyr   r!   r!   r"   r     s    z=InspectionStubGenerator.generate_class_stub.<locals>.<lambda>r   c                 S  s   h | ]}|d  qS )r   r!   )rQ   r   r!   r!   r"   r      s    z>InspectionStubGenerator.generate_class_stub.<locals>.<setcomp>rZ   rt   Nr7   r#   r*   r    rJ  __hash__rP  rQ  rR  rS  z(%s)z, zclass :rM   r   z: ...)r   r   r   r   r9  rC  r   r   r  r   r&  r>   r   r+  rZ  r   r   r   r   r   r   r   r   rE  dedentre  r}   rA  rY   )r    rf  r*   rk   r$  r   namesmethodsr   rM  rN  rO  attrsr<   r  r  r%  prop_type_namerX  rd  	bases_strr   r!   r!   r"   r     s   


	
$

 z+InspectionStubGenerator.generate_class_stubc                 C  sX   |  || j d| s| |rdS | | | | |}|| d|  dS )zGenerate stub for a single variable using runtime introspection.

        The result lines will be appended to 'output'. If necessary, any
        required names will be added to 'imports'.
        r   NrQ  )r6  r_   r8  r9  r   r   r   )r    r9   r   rk   type_strr!   r!   r"   r   w  s
   "
z.InspectionStubGenerator.generate_variable_stub)rZ   NFFFN)r_   r%   ra   rb   r$   r%   r   r   r\   rW   r]   rW   r^   rW   r   r   r   r   )r   r   r4   r   r   r   )r   r   )r   r%   r   r%   )r   r   r   rC   )r   r   r   rW   r   r  r%   r   rW   )r   r   r   r  )r   r   r   r%   )r<   r   r9   r%   r   r   r   rW   )r<   r!  r9   r%   r   r   r   rW   )r-  r   r   rW   )r@   rz   r   r   )
r9   r%   r   r   rk   rb   r<   r!  r   r   )rU   r%   r   r%   )r4   r   r@   rz   rk   rb   r   r   rD   )r9   r%   rL  r   r   r   rM  rb   rN  rb   rO  rb   r<   r!  r   r   )r[  r   r   r%   )r   r   r   rb   )rf  r%   r*   r   rk   rb   r   r   )r9   r%   r   r   rk   rb   r   r   )!rH   rI   rJ   rt   r#   r   r   r   r   r   rj   r  r   r   r   r  r   r&  r"  r'  r+  r/  r2  r3  r   r<  r?  rZ  r   re  r   r   __classcell__r!   r!   r   r"   ri      sP    
+
l





N





	


	
4
 
C

ari   tuple[int, str]c                 C  s4   | dv rd| fS |  dr| drd| fS d| fS )ziSort methods in classes in a typical order.

    I.e.: constructor, normal methods, special methods.
    r6   r   __   r   )rY   rF  rN   r!   r!   r"   rg    s
   rg  r  c                 C  s
   |  dS )N__pybind11_module_local_rX   )r  r!   r!   r"   r    s   
r  r    r>   	arg_namesr   list[ArgSig]c                 C  s  d }|  dr| dr| dd } | dv rg }n| dkr$tddg}n| dkr3tddtd	dg}n| d
v r>tddg}n}| dkrMtddtddg}nn| dkrTg }ng| dkr_tddg}n\| dv rktdd	dg}nP| dv rvtddg}nE| dv r}g }n>| dkrtddtddg}n/| dkrtddtddg}n | dkrtddg}n| dkrtdddtdddtd d!dg}|d u rt| ||}nt|dg| }|d u rtd"dtd#dg}|S )$Nrt  ru  )hashiternextsizeofcopydeepcopyreducegetinitargsr   floattrunccomplexrW   absbytesdirr   reversedroundr  entergetitemr  rN   setitemr   )delattrr   r9   setattrr  getstatesetstatestate)eqneltlegtgeother)r9   r   )(addraddsubrsubmulrmulmodrmodfloordiv	rfloordivtruedivrtruedivdivmodrdivmodpowrpowxorrxororrorandrandlshiftrlshiftrshiftrrshiftcontainsdelitemiaddiand	ifloordivilshiftimodimulioripowirshiftisubitruedivixor)negposinvertr   instanceownerset	reduce_exprotocolexitr   ztype[BaseException] | NonezBaseException | None	tracebackztypes.TracebackType | Noner   r   )rY   rF  r
   r   )r9   r>   rw  r:   r!   r!   r"   r     sP   *


r   )rU   r%   r9   r%   r   rW   )rZ   )r_   r%   r`   r%   ra   rb   r$   r%   r\   rW   r]   rW   r^   rW   r   r   )r9   r%   r   rs  rq  )r    N)r9   r%   r>   r%   rw  r   r   rx  )/rt   
__future__r   r&   r   r   r  os.pathre   r   r   r   r   r   r   r   mypy.fastparser   mypy.moduleinspectr	   mypy.stubdocr
   r   r   r   r   r   r   r   r   r   mypy.stubutilr   r   r   r   r   r   r   rL   rV   rp   rq   ri   rg  r  r   r!   r!   r!   r"   <module>   sB   0 
?
$)     
4
