
    X-Ph                       U d Z ddlmZ ddlZddlZddlZddlZddlm	Z	 ddl
mZ ddlmZmZmZ ddlmZ ddlmZmZ dd	lmZ ddlZdd
lmZ ddlmZmZ ddlmZm Z m!Z!m"Z"m#Z# ddl$m%Z%m&Z& ddl'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/ dZ0dddddddddddddddZ1de2d<    G d de3          Z4	 dXdYd%Z5dZd*Z6d[d,Z7e	 d\d]d2            Z8d^d_d7Z9d`d:Z:edad=            Z;edbd>            Z;dcd@Z;dddBZ< G dC dDe,          Z= G dE dF          Z> G dG dH          Z?dedJZ@	 dfdgdPZA ed-Q           G dR dS                      ZB G dT dU          ZC ed-Q           G dV dW                      ZDdS )hzDUtilities for mypy.stubgen, mypy.stubgenc, and mypy.stubdoc modules.    )annotationsN)abstractmethod)defaultdict)IterableIteratorMapping)contextmanager)Finaloverload)
mypyc_attr)ModuleNotFoundReason)InspectErrorModuleInspect)PARAM_SPEC_KINDTYPE_VAR_TUPLE_KINDClassDefFuncDefTypeAliasStmt)ArgSigFunctionSig)AnyTypeNoneTypeTypeTypeListTypeStrVisitorUnboundType	UnionType
UnpackType builtins.strzbuiltins.tuplezbuiltins.listzbuiltins.dictzbuiltins.setzbuiltins.frozensetzbuiltins.type)ztyping.Textztyping.Tupleztyping.Listztyping.Dictz
typing.Setztyping.FrozenSetztyping.Typeztyping_extensions.Textztyping_extensions.Tupleztyping_extensions.Listztyping_extensions.Dictztyping_extensions.Setztyping_extensions.FrozenSetztyping_extensions.Typer
   TYPING_BUILTIN_REPLACEMENTSc                      e Zd ZddZdS )	
CantImportmodulestrmessagereturnNonec                "    || _         || _        d S N)r$   r&   )selfr$   r&   s      M/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/mypy/stubutil.py__init__zCantImport.__init__:   s        N)r$   r%   r&   r%   r'   r(   __name__
__module____qualname__r-   r   r.   r,   r#   r#   9   s(             r.   r#   Finspectr   packages	list[str]verboseboolr'   Iterator[str]c              #    K   |D ]}|t           v rt          | d           |rt          d|d           	 |                     |          }nS# t          $ rF |r2t	          j                    }t          j                            |           t          |           Y w xY w|j
        V  |j        rt          | |j        |          E d{V  |j        E d{V  dS )a  Iterates through all packages and sub-packages in the given list.

    This uses runtime imports (in another process) to find both Python and C modules.
    For Python packages we simply pass the __path__ attribute to pkgutil.walk_packages() to
    get the content of the package (all subpackages and modules).  However, packages in C
    extensions do not have this attribute, so we have to roll out our own logic: recursively
    find all modules imported in the package that have matching names.
    z: Skipped (blacklisted)Trying to import  for runtime introspectionN)NOT_IMPORTABLE_MODULESprintget_package_propertiesr   	traceback
format_excsysstderrwritereport_missingnameis_c_modulewalk_packagessubpackages)r3   r4   r6   package_nameproptbs         r,   rG   rG   ?   s>      ! ( (111\:::;;; 	RPlPPPQQQ	11,??DD 	 	 	 %)++
  $$$<(((H	 i 	($Wd.>HHHHHHHHHH''''''''''( (s   AABBr$   r%   sys_path
str | Nonec                >   |                      dd          dz   t          j                            |                      dd          d          f}|D ]L}|D ]G}t          j                            ||          }t          j                            |          r|c c S HMd S )N./z.pyz__init__.py)replaceospathjoinisfile)r$   rL   relative_candidatesbaserelative_pathrS   s         r,   find_module_path_using_sys_pathrY   `   s    sC  5(
V^^C--}==   0 	 	M7<<m44Dw~~d## 	 4r.   *tuple[str | None, list[str] | None] | Nonec                d   |t           v rt          |d          |rt          d|d           	 |                     |          }nU# t          $ rH}t          |t          j                  }|t          |t          |                    ||dfcY d}~S d}~ww xY w|j	        rdS |j
        |j        fS )zFind module and determine __all__ for a Python 3 module.

    Return None if the module is a C or pyc-only module.
    Return (module_path, __all__) if it is a Python module.
    Raise CantImport if import failed.
     r:   r;   N)r<   r#   r=   r>   r   rY   rA   rS   r%   rF   fileall)r3   r$   r6   moderS   s         r,   find_module_path_and_all_py3ra   m   s     '''$$$  HF&FFFGGG,,V44   .vsx@@<VSVV,,!3Tz  t8SWs   A 
B=BBBTr_   targetignore_errorsIterator[None]c              #     K   |rt          d|             	 dV  |rt          d|            dS dS # t          $ r+}|s|t          d| t          j                   Y d}~dS d}~ww xY w)zTIgnore or report errors during stub generation.

    Optionally report success.
    zProcessing NzCreated zStub generation failed for)r]   )r=   	ExceptionrA   rB   )r_   rb   rc   r6   r`   s        r,   generate_guardedrg      s        #!C!!"""
'  	'%V%%&&&&&	' 	'  F F F 	FG .#*EEEEEEEEEEFs   4 
A) A$$A)r\   r&   r?   r(   c                <    |rd|z   }t          |  d|            d S )Nz with error: z: Failed to import, skipping)r=   )r_   r&   r?   s      r,   rD   rD      s6     ,!G+	S
7
7g
7
788888r.   reasonr   c                |    |t           j        u rd}n|t           j        u rd}nd| d}t          d|  d|           )Nz(consider using --search-path)z5(module likely exists, but is not PEP 561 compatible)z(unknown reason 'z')zCan't find module 'z' )r   	NOT_FOUNDFOUND_WITHOUT_TYPE_HINTS
SystemExit)r_   ri   clarifications      r,   fail_missingro      s]    %///8	'@	@	@O6F666
A3AA-AA
B
BBr.   sourcebytesc                    d S r*   r   rp   s    r,   remove_misplaced_type_commentsrt      s    <?Cr.   c                    d S r*   r   rs   s    r,   rt   rt      s    8;r.   str | bytesc                   t          | t                    r|                     d          }n| }t          j        dd|t          j                  }t          j        dd|t          j                  }t          j        dd|t          j                  }t          j        d	d|t          j                  }t          | t                    r|                    d          S |S )
zRemove comments from source that could be understood as misplaced type comments.

    Normal comments may look like misplaced type comments, and since they cause blocking
    parse errors, we want to avoid them.
    latin1z ^[ \t]*# +type: +["\'a-zA-Z_].*$r\   )flagsz""" *\n[ \t\n]*# +type: +\(.*$z"""
z''' *\n[ \t\n]*# +type: +\(.*$z'''
z%^[ \t]*# +type: +\([^()]+(\)[ \t]*)?$)
isinstancerq   decoderesub	MULTILINEencode)rp   texts     r,   rt   rt      s     &%   }}X&& 65r4r|TTTD 63Wd",WWWD63Wd",WWWD 6:BBLYYYD&%   {{8$$$r.   pathsc                   | sdS t           j                            t           j                            | d                             }| dd          D ]r}	 t           j                            t           j                            |                    }|t           j        z                       |t           j        z             r|}nos|pdS )NrO   r      )rR   rS   dirnamenormpathsep
startswith)r   currS   s      r,   common_dir_prefixr      s     s
'//"'**5844
5
5Cabb	  	7??27#3#3D#9#9::Dbf((77 		 :#r.   c                  j     e Zd ZdZ	 	 dd fd
Zd fdZddZd dZd!dZd"dZ	d# fdZ
d$dZ xZS )%AnnotationPrintera  Visitor used to print existing annotations in a file.

    The main difference from TypeStrVisitor is a better treatment of
    unbound types.

    Notes:
    * This visitor doesn't add imports necessary for annotations, this is done separately
      by ImportTracker.
    * It can print all kinds of types, but the generated strings may not be valid (notably
      callable types) since it prints the same string that reveal_type() does.
    * For Instance types it prints the fully qualified names.
    NstubgenBaseStubGeneratorknown_moduleslist[str] | Nonelocal_modulesr'   r(   c                    t                                          t          j                                                   || _        || _        |pdg| _        d S )N)optionsbuiltins)superr-   mypyr   Optionsr   r   r   )r+   r   r   r   	__class__s       r,   r-   zAnnotationPrinter.__init__   sR     	!5!5!7!7888**:zlr.   tr   r%   c                    t                                          |          }| j        j                            |           |S r*   )r   	visit_anyr   import_trackerrequire_name)r+   r   sr   s      r,   r   zAnnotationPrinter.visit_any   s8    GGa  #00333r.   r   c                    |j         } j                            |          }|dk    r&d                     fd|j        D                       S |dk    rUt          |j                  dk    r#|j        d                                         dS  j                            d          S |t          v r' j                            t          |         d	
          } j	        d|v r j
        t           j	        d	          z   D ]A}|                    |dz             r'| j
        v r|t          |          dz   d          }|} nB|d |                    d                   }| j
        vr! j        j                            |d	
           n(|dk    rd}n j        j                            |           |j        r"|d                     |j                   dz  }n|j        r|dz  }|S )Nztyping.Union | c                :    g | ]}|                               S r   accept.0itemr+   s     r,   
<listcomp>z8AnnotationPrinter.visit_unbound_type.<locals>.<listcomp>  s%    DDDTt{{400DDDr.   ztyping.Optionalr   r   z | Nonez_typeshed.IncompleteTrequirerO   )reverser   r(   []z[()])rE   r   resolve_namerT   argslenr   add_namer!   r   r   sortedr   rindexr   
add_importr   args_strempty_tuple_index)r+   r   r   fullnamemodule_name
arg_modules   `     r,   visit_unbound_typez$AnnotationPrinter.visit_unbound_type  s"   F<,,Q//~%%::DDDDQVDDDEEE(((16{{a&)**4009999<(()?@@@222%%&A(&KUY%ZZA)cQhh  $1F4;MW[4\4\4\\ 0 0<<c 122 "d&888c+..2445!,JE	 #/
!333+66z46PPP*__ AAL'44Q7776 	-T]]16**----AA  	KAr.   r   c                    dS )Nr(   r   r+   r   s     r,   visit_none_typez!AnnotationPrinter.visit_none_type'  s    vr.   r   c                >    d|                      |j                   dS )Nr   r   )list_stritemsr   s     r,   visit_type_listz!AnnotationPrinter.visit_type_list*  s!    ,4==)),,,,r.   r   c                P     d                      fd|j        D                       S )Nr   c                :    g | ]}|                               S r   r   r   s     r,   r   z6AnnotationPrinter.visit_union_type.<locals>.<listcomp>.  s%    AAA4;;t,,AAAr.   )rT   r   r   s   ` r,   visit_union_typez"AnnotationPrinter.visit_union_type-  s,    zzAAAAAAABBBr.   r   c                    | j         j        dk    rd|j                            |            S t	                                          |          S )N)      *)r   python_versiontyper   r   visit_unpack_type)r+   r   r   s     r,   r   z#AnnotationPrinter.visit_unpack_type0  sG    <&'11,qv}}T**,,,ww((+++r.   r   Iterable[Type]c                   ddg}g }|D ]d}|                     |           }t          |t                    r#|j        |v r|                    d| d           O|                    |           ed                    |          S )zConvert an array of arguments to strings and join the results with commas.

        The main difference from list_str is the preservation of quotes for string
        arguments
        zbuiltins.bytesr    ', )r   rz   r   original_str_fallbackappendrT   )r+   r   typesresargarg_strs         r,   r   zAnnotationPrinter.args_str5  s     ">2 	$ 	$Cjj&&G#{++ $0IU0R0R

>w>>>****

7####yy~~r.   NN)r   r   r   r   r   r   r'   r(   )r   r   r'   r%   )r   r   r'   r%   )r   r   r'   r%   )r   r   r'   r%   )r   r   r'   r%   )r   r   r'   r%   )r   r   r'   r%   )r0   r1   r2   __doc__r-   r   r   r   r   r   r   r   __classcell__)r   s   @r,   r   r      s         $ +/*.		; 	; 	; 	; 	; 	; 	;     
" " " "H   - - - -C C C C, , , , , ,
       r.   r   c                      e Zd Z	 	 	 dddZdS )	ClassInfoNrE   r%   self_var	docstringrM   clstype | NoneparentClassInfo | Noner'   r(   c                L    || _         || _        || _        || _        || _        d S r*   )rE   r   r   r   r   )r+   rE   r   r   r   r   s         r,   r-   zClassInfo.__init__G  s+     	 "r.   )NNN)rE   r%   r   r%   r   rM   r   r   r   r   r'   r(   r/   r   r.   r,   r   r   F  s8        
 !%#'      r.   r   c                  6    e Zd Z	 	 	 dddZedd            ZdS )FunctionContextNFr   r%   rE   r   rM   is_abstractr7   
class_infor   r'   r(   c                Z    || _         || _        || _        || _        || _        d | _        d S r*   )r   rE   r   r   r   	_fullname)r+   r   rE   r   r   r   s         r,   r-   zFunctionContext.__init__W  s4     '	"&$%)r.   c                ,   | j         | j        rjg }| j        }|#|                    |j                   |j        }|#d                    t          |                    }| j         d| d| j         | _         n| j         d| j         | _         | j         S )NrO   )r   r   r   rE   r   rT   reversedr   )r+   parentsr   	namespaces       r,   r   zFunctionContext.fullnamef  s    >! 	C/3
 ,NN:?333!+!2J !,  HHXg%6%677	$($4!N!Ny!N!N49!N!N$($4!B!Bty!B!B~r.   )NFN)r   r%   rE   r%   r   rM   r   r7   r   r   r'   r(   r'   r%   )r0   r1   r2   r-   propertyr   r   r.   r,   r   r   V  sX        
 !%!'+* * * * *    X  r.   r   rE   c                    |                      d          r=|                     d          r(| dd         } | dv r| S | dv rdS | dv rdS | d	v rd
S | dv rdS dS )z,Infer return types for known special methods__   )floatr7   rq   intcomplexr%   )eqneltlegtgecontainsr7   )r   length_hintindexhashsizeoftruncfloorceilr   )formatreprr%   )initsetitemdeldelitemr(   N)r   endswithrE   s    r,   infer_method_ret_typer	  v  s    t t!4!4 AbDzFFFKEEE6```5'''5:::64r.   r+   r   	arg_namesr   list[ArgSig] | Nonec                n   d}|                      d          r|                     d          rr|r)t          |          dk    r|d         dk    r
|dd         }| dd         } | dk    r7|g d	}t          |          d
k    rg d}d t          ||          D             }|t	          |          g|z   S dS )z.Infer argument types for known special methodsNr   r   r   r+   r   r   exit)r   valuer?   r   )ztype[BaseException] | NonezBaseException | Noneztypes.TracebackType | Nonec                6    g | ]\  }}t          ||           S ))rE   r   )r   )r   arg_namearg_types      r,   r   z*infer_method_arg_types.<locals>.<listcomp>  s9       *( x888  r.   r  )r   r  r   zipr   )rE   r   r
  r   	arg_typess        r,   infer_method_arg_typesr    s     !%Dt t!4!4  	&Y1,,11G1G!!""IAbDz6>> :::	9~~""  	
 .1)Y.G.G   H%%%&--4r.   )allow_interpreted_subclassesc                  J    e Zd ZdZddZedd            Zedd            ZdS )SignatureGeneratorzLAbstract base class for extracting a list of FunctionSigs for each function.inferredlist[FunctionSig] | Noner   r%   r'   c                r    |r4|D ]1}|j         r(|j         d         j        |k    rd|j         d         _        2|S )z-Remove type annotation from self/cls argumentr   N)r   rE   r   )r+   r  r   	signatures       r,   remove_self_typez#SignatureGenerator.remove_self_type  sO      	6% 6 6	> 6 ~a(-9915	q).r.   default_sigr   ctxr   c                    dS )zReturn a list of signatures for the given function.

        If no signature can be found, return None. If all of the registered SignatureGenerators
        for the stub generator return None, then the default_sig will be used.
        Nr   )r+   r  r  s      r,   get_function_sigz#SignatureGenerator.get_function_sig  s	     	r.   default_typerM   c                    dS )z%Return the type of the given propertyNr   )r+   r!  r  s      r,   get_property_typez$SignatureGenerator.get_property_type  s	     	r.   N)r  r  r   r%   r'   r  )r  r   r  r   r'   r  )r!  rM   r  r   r'   rM   )r0   r1   r2   r   r  r   r   r#  r   r.   r,   r  r    sn        VV	 	 	 	    ^    ^  r.   r  c                  H    e Zd ZdZddZ	 dddZdddZddZddZddZ	dS )ImportTrackerz0Record necessary imports during stub generation.r'   r(   c                |    i | _         i | _        i | _        t                      | _        t                      | _        d S r*   )
module_fordirect_importsreverse_aliassetrequired_names	reexportsr+   s    r,   r-   zImportTracker.__init__  s:      24.0-/ ), $'55r.   Fr$   r%   nameslist[tuple[str, str | None]]r   r7   c                    |D ]w\  }}|r|| j         |<   || j        |<   n%|| j         |<   | j                            |d            |r|                     |p|           | j                            |p|d            xd S r*   )r'  r)  popr   r(  )r+   r$   r.  r   rE   aliass         r,   add_import_fromzImportTracker.add_import_from  s     ! 	9 	9KD% 3)/&,0"5)) )/%"&&tT222 1!!%-4000##EMT48888	9 	9r.   Nr2  rM   c                Z   |r:d|vsJ d | j         |<   || j        |<   |r| j                            |           d S d S |}|r| j                            |           |rNd | j         |<   || j        |<   | j                            |d            |                    d          d         }|Ld S d S )NrO   r   )r'  r)  r+  addr(  r1  
rpartition)r+   r$   r2  r   rE   s        r,   r   zImportTracker.add_import  s     	/e####%)DOE"(.Du% /#''...../ / D .#''--- /(,%,2#D)"&&tT222s++A.	  / / / / /r.   rE   c                    || j         vr-d|v r)|                    dd          d         }|| j         vrd|v )| j                            |           d S )NrO   r   r   )r(  rsplitr+  r5  r+   rE   s     r,   r   zImportTracker.require_name  se    $---#++;;sA&&q)D $---#++%%%%%r.   c                d    |                      |           | j                            |           dS )zMark a given non qualified name as needed in __all__.

        This means that in case it comes from a module, it should be
        imported with an alias even if the alias is the same as the name.
        N)r   r,  r5  r9  s     r,   reexportzImportTracker.reexport
  s4     	$4     r.   r5   c                    g }t          t                    }t           j         fd          D ]}| j        vr j        |         }|H| j        v r j        |          d| }n| j        v r| d| }||                             |           c| j        v r* j        |         }|                    d| d| d           | j        v r#d|vsJ |                    d| d| d           |                    d| d           t          |                                          D ]A\  }}|                    d| d	d
	                    t          |                     d           B|S )a  The list of required import lines (as strings with python code).

        In order for a module be included in this output, an identifier must be both
        'required' via require_name() and 'imported' via add_import_from()
        or add_import()
        c                <    | j         v rj         |          | fn| dfS )Nr\   )r)  )nr+   s    r,   <lambda>z,ImportTracker.import_lines.<locals>.<lambda>#  s-    T=O8O8O4-a0!44VWY[U\ r.   )keyNz as zimport 
rO   zfrom z import r   )
r   listr   r+  r'  r)  r,  r   r   rT   )r+   result
module_maprE   mrp   r$   r.  s   `       r,   import_lineszImportTracker.import_lines  s    
 /:$.?.?
\\\\
 
 
 	6 	6D
 4?**%A} 4---"06BBDBBDDT^++"....D1$$T**** 4---!/5FMM"@F"@"@"@"@"@AAAAT^++d????MM">D">">d">">">????MM"4D"4"4"45555 $J$4$4$6$677 	P 	PMFEMMN&NN$))F5MM2J2JNNNOOOOr.   r'   r(   F)r$   r%   r.  r/  r   r7   r'   r(   NF)r$   r%   r2  rM   r   r7   r'   r(   rE   r%   r'   r(   )r'   r5   )
r0   r1   r2   r   r-   r3  r   r   r;  rF  r   r.   r,   r%  r%    s        ::) ) ) )6 QV9 9 9 9 9 / / / / /(& & & &
! ! ! !. . . . . .r.   r%  c                     e Zd ZU h dZded<   dZded<   h dZded<   	 	 	 	 dIdJdZdKdZdLdZ	dMdNdZ
dOdZdPdZdPdZdPd ZdQd"ZdRd#ZdSd$ZdSd%ZdTd&ZdUd'ZdVd*ZdSd+ZdWd2ZdXd5Z	 	 	 dYdZd;Zd[d>Z	 	 d\d]dCZdUdDZd^d_dEZd`dHZdS )ar   >   __all____str____uri____file__r0   __path____repr____spec__	__about__	__email__	__slots__	__title__
__author__
__cached__
__loader____license____package____summary____builtins____getstate____setstate____copyright__r
   IGNORED_DUNDERS)typingtyping_extensionsTYPING_MODULE_NAMES>   pyasn1_modules.rfc2437.univpyasn1_modules.rfc2459.charpyasn1_modules.rfc2459.univEXTRA_EXPORTEDNF_all_r   include_privater7   export_lessinclude_docstringsr'   r(   c                &   || _         || _        || _        || _        g | _        g | _        d| _        g | _        t                      | _	        t                      | _        |                                 | _        d| _        dgg ddgddgd| _        d S )Nr\   
Incomplete)AnyTypeVar
NamedTuple	TypedDict	Generator	ParamSpecTypeVarTuple)	_typeshedrb  zcollections.abcrc  )ri  _include_private_include_docstringsrk  _import_lines_output_indent_toplevel_namesr%  r   r*  defined_namesget_sig_generatorssig_generatorsr   known_imports)r+   ri  rj  rk  rl  s        r,   r-   zBaseStubGenerator.__init__g  s     
 /#5 &(*"$*,+oo'*uu"5577 " 'CCC +}"-~!>	
 
r.   list[SignatureGenerator]c                    g S r*   r   r-  s    r,   r~  z$BaseStubGenerator.get_sig_generators  s    	r.   rE   r%   c                0   d|vrM| j         j                            |          }| j         j                            ||          }||| j        vrd}n9|                    dd          \  }}| j         j                            ||          }||n| d| }|S )z:Return the full name resolving imports and import aliases.rO   Nr   r   )r   r'  getr)  r}  split)r+   rE   real_module
real_shortname_moduleresolved_names         r,   r   zBaseStubGenerator.resolve_name  s    d??-8<<TBBK,:>>tTJJJ"z9K'K'K(&*jja&8&8#K-;??[YYK&1&9

+?\?\PZ?\?\r.   Tr   r   c                    |                     dd          \  }}|| j        v rd|z   nd}|| j        v rd|z   }|| j        v |dk    s|r | j                            |||fg|           |p|S )zAdd a name to be imported and return the name reference.

        The import will be internal to the stub (i.e don't reexport).
        rO   r   _Nr   r   )r8  r}  r   r3  )r+   r   r   r$   rE   r2  s         r,   r   zBaseStubGenerator.add_name  s    
  sA.."d&888d

dt)))%KE t)))Z5//$QX/YYY}r.   linec                P    || j         vr| j                             |           dS dS )zDAdd a line of text to the import section, unless it's already there.N)ry  r   )r+   r  s     r,   add_import_linez!BaseStubGenerator.add_import_line  s5    t)))%%d+++++ *)r.   c                    d}| j         r|d                    | j                   z  }|d                    | j                                                  z  }|S )z*Return the import statements for the stub.r\   )ry  rT   r   rF  )r+   importss     r,   get_importszBaseStubGenerator.get_imports  sU     	3rwwt1222G2774.;;==>>>r.   c                D   g }|                                  x}r|                    |           |                                 x}r|                    |           | j        r-|                    d                    | j                             d                    |          S )zReturn the text for the stub.r\   rA  )r  r   get_dunder_allrz  rT   )r+   piecesr  
dunder_alls       r,   outputzBaseStubGenerator.output  s    &&(((7 	#MM'""",,...: 	&MM*%%%< 	1MM"''$,//000yy   r.   c                *    | j         rd| j         dS dS )z%Return the __all__ list for the stub.z
__all__ = rA  r\   )ri  r-  s    r,   r  z BaseStubGenerator.get_dunder_all  s&    : 	1
 1
0000rr.   stringc                :    | j                             |           dS )zAdd text to generated stub.N)rz  r   )r+   r  s     r,   r5  zBaseStubGenerator.add  s    F#####r.   c                    | j         dk    S )z*Are we processing the top level of a file?r\   r{  r-  s    r,   is_top_levelzBaseStubGenerator.is_top_level  s    |r!!r.   c                &    | xj         dz  c_         dS )zAdd one level of indentation.z    Nr  r-  s    r,   indentzBaseStubGenerator.indent  s    r.   c                .    | j         dd         | _         dS )z Remove one level of indentation.Nr  r-  s    r,   dedentzBaseStubGenerator.dedent  s    |CRC(r.   c                f    |                                  r| j                            |           dS dS )zbMark a name as defined.

        This only does anything if at the top level of a module.
        N)r  r|  r   r9  s     r,   record_namezBaseStubGenerator.record_name  s?    
  	. ''-----	. 	.r.   c                <    |                                  o|| j        v S )z'Has this name been recorded previously?)r  r|  r9  s     r,   is_recorded_namez"BaseStubGenerator.is_recorded_name  s!      ""Ctt/C'CCr.   r}  set[str]c                    || _         | j        pdD ]}| j                            |           | j                                        D ]&\  }}|D ]}|                     | d| d           'd S )Nr   rO   Fr   )r}  ri  r   r;  r  r   r   )r+   r}  rE   pkgr  r   s         r,   set_defined_namesz#BaseStubGenerator.set_defined_names  s    *J$" 	/ 	/D((.... .4466 	; 	;LC ; ; llqllE::::;	; 	;r.   c                      fd j         pg D             }|r\ j        r                     d                                d           t          |          D ]}                     d| d           d S d S )Nc                &    g | ]}|j         v|S r   )r|  )r   rE   r+   s     r,   r   z;BaseStubGenerator.check_undefined_names.<locals>.<listcomp>  s&    aaaDDL`@`@`4@`@`@`r.   rA  z'# Names in __all__ with no definition:
z#   )ri  rz  r5  r   )r+   undefined_namesrE   s   `  r,   check_undefined_namesz'BaseStubGenerator.check_undefined_names  s    aaaaDJ,<"aaa 	*| HH?@@@// * *))))	* 	** *r.   default_signaturer   r  func_ctxr   list[FunctionSig]c                J    |D ]}|                     ||          }|r|c S |gS r*   )r   )r+   r  r  r  sig_genr  s         r,   get_signaturesz BaseStubGenerator.get_signatures  sJ     & 	  	 G//0A8LLH    """r.   r!  rM   c                H    |D ]}|                     ||          }|r|c S |S r*   )r#  )r+   r!  r  r  r  r  s         r,   r#  z#BaseStubGenerator.get_property_type  sF     & 	  	 G00xHHH    r.   sigsis_coroutine
decoratorsr   r5   c                    g }|g }|D ]^}|D ] }|                     | j         |            !|                     |                    | j        || j        r|nd                      _|S )N)r  is_asyncr   )r   r{  
format_sigrx  )r+   r  r  r  r   linesr  decos           r,   format_func_defz!BaseStubGenerator.format_func_def  s     J 	 	I" 6 64d445555LL$$<)+/+CMii %      r.   o"TypeAliasStmt | FuncDef | ClassDefc                   |j         sdS t          |           g }|j         D ]}|j        t          k    rd}n|j        t          k    rd}nd}|j        rd|j                                       }n4|j        r+dd                    fd|j        D                        d}nd}|j	        rd	|j	                                       }nd}|
                    | |j         | |            d
d                    |          z   dz   S )Nr\   z**r   z: z: (r   c              3  B   K   | ]}|                               V  d S r*   r   )r   vps     r,   	<genexpr>z5BaseStubGenerator.format_type_args.<locals>.<genexpr>:  s-      1W1W!!((1++1W1W1W1W1W1Wr.   )z = r   r   )	type_argsr   kindr   r   upper_boundr   valuesrT   defaultr   rE   )r+   r  type_args_listtype_argprefixbound_or_valuesr  r  s          @r,   format_type_argsz"BaseStubGenerator.format_type_args+  sN   { 	2d##$& 	X 	XH}//"555# %"Gx';'B'B1'E'E"G"G %"Z		1W1W1W1Wx1W1W1W(W(W"Z"Z"Z"$ < 0 7 7 : :<<!!V"VX]"VO"VW"V"VWWWWTYY~...44r.   r   r   r   r   c                N    t          | ||          }|                    |          S r*   )r   r   )r+   r   r   r   printers        r,   print_annotationz"BaseStubGenerator.print_annotationD  s'     $D-GGxx   r.   c                |    |                      |          rdS | j        r|                                 o|| j        vS dS rI  )is_private_nameri  r  r9  s     r,   is_not_in_allzBaseStubGenerator.is_not_in_allM  sK    %% 	5: 	B$$&&A4tz+AAur.   c                   d|v rdS | j         rdS || j        v rdS |dk    rdS |                    d          sdS | j        r|| j        v rdS |                    d          r|                    d          r	|| j        v S dS )Nz__mypy-TFr  r   )rw  rh  r   ri  r  ra  )r+   rE   r   s      r,   r  z!BaseStubGenerator.is_private_nameT  s    4  	5t***53;;5s## 	5: 	$$*,,5??4   	0T]]4%8%8 	04///tr.   full_modulename_is_aliasc                ^   |s| j         r| j         dz   |z   | j        v rdS |rdS | j        rdS | j         sdS |                     ||dz   |z             }|rdS |                    d          d         }| j                             dd          d         }||d|z   fvrdS | j        r	|| j        v S dS )NrO   TFr   r   r  )r   rh  rk  r  r  ri  )r+   rE   r  r  
is_private	top_levelself_top_levels          r,   should_reexportz!BaseStubGenerator.should_reexporte  s    	 	 !C'$.43FFF 4 	5 	5 	5))$c0AD0HII
 	5%%c**1-	)//Q77:^S>-ABBB 5: 	&4:%%tr.   )NFFF)
ri  r   rj  r7   rk  r7   rl  r7   r'   r(   )r'   r  )rE   r%   r'   r%   )T)r   r%   r   r7   r'   r%   )r  r%   r'   r(   r   )r  r%   r'   r(   )r'   r7   rG  rJ  )rE   r%   r'   r7   )r}  r  r'   r(   )r  r   r  r  r  r   r'   r  )r!  rM   r  r  r  r   r'   rM   )FNN)
r  r  r  r7   r  r   r   rM   r'   r5   )r  r  r'   r%   r   )r   r   r   r   r   r   r'   r%   r*   )rE   r%   r   rM   r'   r7   )rE   r%   r  r%   r  r7   r'   r7   )r0   r1   r2   ra  __annotations__rd  rh  r-   r~  r   r   r  r  r  r  r5  r  r  r  r  r  r  r  r  r#  r  r  r  r  r  r  r   r.   r,   r   r   D  s          O    0 "A@@@@  N     #' %!#(
 
 
 
 
B          , , , ,
   	! 	! 	! 	!   $ $ $ $" " " "   ) ) ) ). . . .D D D D
; 
; 
; 
;* * * *# # # #     #'+ $    25 5 5 58 +/*.	! ! ! ! !       "     r.   r   rH  )r3   r   r4   r5   r6   r7   r'   r8   )r$   r%   rL   r5   r'   rM   )r3   r   r$   r%   r6   r7   r'   rZ   )TF)
r_   r%   rb   r%   rc   r7   r6   r7   r'   rd   )r\   r\   )r_   r%   r&   rM   r?   r%   r'   r(   )r_   r%   ri   r   r'   r(   )rp   rq   r'   rq   )rp   r%   r'   r%   )rp   rv   r'   rv   )r   r5   r'   r%   )rE   r%   r'   rM   )r+   N)rE   r%   r   r%   r
  r   r'   r  )Er   
__future__r   os.pathrR   r|   rA   r?   abcr   collectionsr   collections.abcr   r   r   
contextlibr	   rb  r
   r   mypy_extensionsr   mypy.optionsr   mypy.modulefinderr   mypy.moduleinspectr   r   
mypy.nodesr   r   r   r   r   mypy.stubdocr   r   
mypy.typesr   r   r   r   r   r   r   r   r<   r!   r  rf   r#   rG   rY   ra   rg   rD   ro   rt   r   r   r   r   r	  r  r  r%  r   r   r.   r,   <module>r     s   J J J " " " " " "  				 



           # # # # # # 7 7 7 7 7 7 7 7 7 7 % % % % % % " " " " " " " " & & & & & &     2 2 2 2 2 2 : : : : : : : : ] ] ] ] ] ] ] ] ] ] ] ] ] ] , , , , , , , ,	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	  
 "$"" ,",/--+#7-!& &     (        BG( ( ( ( (B
 
 
 
   8 GL' ' ' ' ',9 9 9 9 9C C C C 
 ? ? ? 
 ? 
 ; ; ; 
 ;   <
 
 
 
` ` ` ` ` ` ` `F               @   & FJ    8 ...       /.>} } } } } } } }@ ...y y y y y y y /.y y yr.   