
    ik                      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Zddl	Z	ddl
Z
ddlZddlZddlZddlZddlZddlZddl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 ddl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$ 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,Z'ddl-Z'ddl.Z'ddl/Z'ddl'm0Z0 ddl1m2Z2 ddl3m4Z4m5Z5 ddl6m7Z7 ddl8m9Z9 ddl:m;Z;m<Z<m=Z=m>Z>  G d d          Z? e?            Z@deAd<    e"d          ZBeBe?z  ZCdeAd<    G d d          ZD eD            ZEdeAd<    e;ejF        ejG        d          ZHdeAd<   dd"ZIdd%ZJ G d& d'eK          ZL G d( d)          ZMdd,ZNdd.ZOedd5            ZPdd9ZQejR        dd;            ZSePT                    e0jU                  dd=            ZVdd@ZWddCZX ejY        dD          ZZddHZ[ddJZ\ddKZ]ddMZ^ePT                    e0j_                  ddNddQ            Z`ddRZaddVZbdd\Zcdd]ZdddaZe G db dce!eB                   Zf	 dddgZgddiZhePT                    e0ji                  ddk            ZjePT                    e?          ddl            ZkePT                    e0jl                  ddn            ZmePT                    e0jn                  ddp            ZoePT                    e0jp                  ddr            ZqePT                    e0jr                  ddt            ZsdduZtddwZuddyZvddzZwdd~ZxddZyePT                    e0jz                  dd            Z{ePT                    e0j|                  dd            Z} e~h d          ZdeAd<    e~h d          ZdeAd<   ddZddZddZddZddZ G d de'j        j                  Z e            ZddZddZddZ	 dddZi adeAd<   dddZddZ	 dddZddZddZ G d d          Z e~h d          ZdeAd<   dddZddZddZddZedk    r ej         e                       dS dS )ziTests for stubs.

Verify that various things in stubs are consistent with how things behave at runtime.

    )annotationsN)defaultdict)Iterator)redirect_stderrredirect_stdout)singledispatch)Path)AnyFinalGenericTypeVarUnion
get_origin)is_typeddict)nodes)parse_config_file)UNKNOWNevaluate_expression)map_instance_to_supertype)Options)FancyFormatterbytes_to_human_readable_repr	is_dunderplural_sc                      e Zd ZdZddZdS )MissingzGMarker object for things that are missing (from a stub or the runtime).returnstrc                    dS )NMISSING selfs    L/root/projects/qq-shell/venv/lib64/python3.11/site-packages/mypy/stubtest.py__repr__zMissing.__repr__8   s    y    Nr   r   __name__
__module____qualname____doc__r%   r!   r&   r$   r   r   5   s.        QQ     r&   r   r   r    Tztyping_extensions.TypeAliasMaybeMissingc                      e Zd ZdZddZdS )Unrepresentablez5Marker object for unrepresentable parameter defaults.r   r   c                    dS )N<unrepresentable>r!   r"   s    r$   r%   zUnrepresentable.__repr__E   s    ""r&   Nr'   r(   r!   r&   r$   r0   r0   B   s.        ??# # # # # #r&   r0   UNREPRESENTABLEF
_formattermessager   kwargsr
   r   c                R    |                     dd           t          j        | fi |S )z.Wrapper around mypy.util for fancy formatting.colornone)
setdefaultr4   style)r5   r6   s     r$   _styler<   O   s1    
gv&&&G..v...r&   lengthintc                L    t          |           |k    r| d |dz
           dz   S | S )N   ...)len)r5   r=   s     r$   	_truncaterC   U   s0    
7||f|!|$u,,Nr&   c                      e Zd ZdS )StubtestFailureNr)   r*   r+   r!   r&   r$   rE   rE   [   s        Dr&   rE   c                  H    e Zd ZdddddZddZddZddZddZdddZdS )ErrorN	stub_descruntime_descobject_path	list[str]r5   r   stub_objectMaybeMissing[nodes.Node]runtime_objectMaybeMissing[Any]rJ   
str | NonerK   r   Nonec                  || _         d                    |          | _        || _        || _        || _        |pt          t          |d|                    | _        |qt          |          }|$t          t          |          d          | _        dS t          j        |          }t          ||          }	t          |	d          | _        dS || _        dS )a  Represents an error found by stubtest.

        :param object_path: Location of the object with the error,
            e.g. ``["module", "Class", "method"]``
        :param message: Error message
        :param stub_object: The mypy node representing the stub
        :param runtime_object: Actual object obtained from the runtime
        :param stub_desc: Specialised description for the stub object, should you wish
        :param runtime_desc: Specialised description for the runtime object, should you wish

        .typeNd   is_async)rL   joinobject_descr5   rN   rP   r   getattrrJ   safe_inspect_signaturerC   reprrK   inspectiscoroutinefunctiondescribe_runtime_callable)
r#   rL   r5   rN   rP   rJ   rK   runtime_sigruntime_is_asyncdescriptions
             r$   __init__zError.__init__`   s    * '88K00&,"Tc'+v{*S*S&T&T0@@K"$-d>.B.BC$H$H!!!#*#>~#N#N 7N^___$-k3$?$?!!! ,Dr&   boolc                6    t          | j        t                    S )z@Whether or not the error is for something missing from the stub.)
isinstancerN   r   r"   s    r$   is_missing_stubzError.is_missing_stub   s    $*G444r&   c                    d| j         v S )zOWhether or not the error is for something being (or not being) positional-only.zshould be positionalr5   r"   s    r$   is_positional_only_relatedz Error.is_positional_only_related   s     &55r&   c                    d| j         v S )z6Whether or not the error is related to @disjoint_base.z@disjoint_baserk   r"   s    r$   is_disjoint_base_relatedzError.is_disjoint_base_related   s      4<//r&   c                6    | j                             d          S )zIWhether or not the error is related to @type_check_only on private types.z$Maybe mark it as "@type_check_only"?)r5   endswithr"   s    r$   "is_private_type_check_only_relatedz(Error.is_private_type_check_only_related   s     |$$%KLLLr&   Fconcisec                   |r!t          | j        d          dz   | j        z   S d}d}t          | j        t
                    s| j        j        }t          | j        d                   }|	|j	        pd}d}|r|dt          |           z  }|r||rdnd	 | z  }d}d}t          | j        t
                    si	 t          j        | j                  d
         }n# t          t          t           f$ r Y nw xY w	 t          j        | j                  }n# t          $ r Y nw xY wd}|r|dt          |           z  }|r||rdnd	 | z  }t          ddd          t          | j        d          d| j        ddt          |d          dt          | j        dz   dd          dt          |d          dt          | j        dz   dd          g}	d                    |	          S )zxReturns a description of the error.

        :param concise: Whether to return a concise, one-line description

        T)bold Nr    z	 in file :z	 at line    zerror: redr8   rt   
zStub:)dimblue)r8   r|   zRuntime:)r<   r[   r5   rh   rN   r   lineget_stubrL   pathr	   rP   r_   getsourcelinesOSError	TypeErrorSyntaxErrorgetsourcefilerJ   rK   rZ   )
r#   rr   	stub_line	stub_file	stub_nodestub_loc_strruntime_lineruntime_fileruntime_loc_stroutputs
             r$   get_descriptionzError.get_description   sh     	L$*666<t|KK		$*G44 	.(-IT-a011	 !.$I 	:9Y999L 	Ni@ss[M)MMML$-w77 	&5d6IJJ1MY4   &4T5HII     	@?4+=+=???O 	W"F##;VVVVO 9E5554#$///L<T***4>D(DAAA?---4$t+6tDDD
 wwvs$   :C C43C48D 
DD)rL   rM   r5   r   rN   rO   rP   rQ   rJ   rR   rK   rR   r   rS   )r   rf   F)rr   rf   r   r   )	r)   r*   r+   re   ri   rl   rn   rq   r   r!   r&   r$   rH   rH   _   s         !%#'%- %- %- %- %- %-N5 5 5 56 6 6 6
0 0 0 0
M M M M
8 8 8 8 8 8 8r&   rH   module_nametypes.ModuleTypec           	        t          t          j        d          5 }t          j                    5  t          |          5  t          |          5  t          j        d           t          j	        |           }t          | dg           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   |S )Nwignore*)fromlist)openosdevnullwarningscatch_warningsr   r   simplefilter	importlibimport_module
__import__)r   r   runtimes      r$   silent_import_moduler      s   	bj#		 4'$&& 	4 	4(@(@ 	4 	4/RYBZBZ 	4 	4!(+++-k::G {cU3333	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	44 4 4 4 4 4 4 4 4 4 4 4 4 4 4 Ns{   CCB-;B	
B-BB-BB-!C-B11C4B15C8CC	CC	CC"CIterator[Error]c              #    K   t          |           }|ut          |                     d          d                   sK| t          j        v rt          t          j        |                    nd}t          | gdt          d|          V  dS 	 t          |           }np# t          $ r  t          $ rY}d}t          |t                    rd}t          | gd	| d
t          |          j         d| |t                    V  Y d}~dS d}~ww xY wt          j                    5  t          j        d           	 t%          ||| g          E d{V  n# t&          $ r}t)          t+          j        |j                            d         d         }|j                            dd          }|dk    s|                    d          d         dk    r t          | gdt          |          j         d| ||ddt+          j                                                    z             V  Y d}~nd}~ww xY wddd           dS # 1 swxY w Y   dS )zTests a given module's stub against introspecting it at runtime.

    Requires the stub to have been built already, accomplished by a call to ``build_stubs``.

    :param module_name: The module to test

    NrU   N/Azfailed to find stubsrK   rv   z7 Maybe install the runtime package or alter PYTHONPATH?zfailed to import.ru   : r   r   r)   __main__mypyzencountered unexpected error, zThis is most likely the fault of something very dynamic in your library. It's also possible this is a bug in stubtest.
If in doubt, please open an issue at https://github.com/python/mypy

rI   )r   is_probably_privatesplitsysmodulesr^   rH   r    r   KeyboardInterruptBaseExceptionrh   ModuleNotFoundErrorrV   r)   r   r   r   verify	Exceptionlist	tracebackwalk_tb__traceback__	f_globalsget
format_excstrip)r   stubrK   r   enotebottom_framebottom_modules           r$   test_moduler      s      K  D|";#4#4S#9#9"#=>> 	=HCK=W=W4K 8999]bL5wS_      	&{33      a,-- 	MLDMMtMMd1gg6FMM!MMtU\
 
 	
 	
 	
 	 
	 	"	"  h'''	dGk];;;;;;;;;; 	 	 		 1!/ B BCCBGJL(266z2FFM 
**m.A.A#.F.Fq.IV.S.SHa1AHHQHHJ  *,,22445          		                 sV   
B D.ADDH93EH9
H)C	H$H9$H))H99H= H=r   rO   r   rQ   rL   rM   c              #  2   K   t          |d| |          V  dS )zEntry point for comparing a stub to a runtime object.

    We use single dispatch based on the type of ``stub``.

    :param stub: The mypy node representing a part of the stub
    :param runtime: The runtime object corresponding to ``stub``

    zis an unknown mypy nodeN)rH   r   r   rL   s      r$   r   r     s)       6g
F
FFFFFFr&   nodes.MypyFileruntime_all_as_setset[str]c           	   #    K   d|j         v sJ d |j                                         D             }t          ||z
            }t          ||z
            }|s|sd S t          | dgz   dt          t          d| d|           V  d S )N__all__c                &    h | ]\  }}|j         |S r!   )module_public.0mos      r$   	<setcomp>z)_verify_exported_names.<locals>.<setcomp>2  s#    PPP$!QPAPPPr&   znames exported from the stub do not correspond to the names exported at runtime. This is probably due to things being missing from the stub or an inaccurate `__all__` in the stubz/Names exported in the stub but not at runtime: z/Names exported at runtime but not in the stub: )rN   rP   rJ   rK   )namesitemssortedrH   r    )rL   r   r   public_names_in_stubnames_in_stub_not_runtimenames_in_runtime_not_stubs         r$   _verify_exported_namesr   -  s       
""""PP$**:*:*<*<PPP &';>P'P Q Q &'9<P'P Q Q% )B 
yk!p `E^``Y>WYY       r&   symtable.SymbolTable | Nonec                    	 t          j        |           }n# t          t          t          f$ r Y dS w xY w	 t          j        || j        d          S # t          $ r Y dS w xY w)zRetrieve the symbol table for the module (or None on failure).

    1) Use inspect to retrieve the source code of the module
    2) Use symtable to parse the source (and use what symtable knows for its purposes)
    Nexec)r_   	getsourcer   r   r   symtabler)   )r   sources     r$   _module_symbol_tabler   J  s    "7++Y,   tt )96BBB   tts    22A 
AAMaybeMissing[types.ModuleType]c              #  \  K   t          t                    rt          |d|           V  d S t          t          j                  st          |d|           V  d S t          d          rSt          j                  }d| j        v rt          || |          E d {V  n t          |dgz   dt                    V  nd }d | j                                        D             }dd||nfdt                    D             }|                    |           |                    t                     t!          |          D ]`}|| j        v r| j        |         j        nt          }|| j        v r| j        |         j        x}r|                    dd          d         }	nBt          |t(          j                  r&|j        x}
r|
                    dd          d         }	nd }	|	r|	| j        k    r
|	t.          v rt          |t(          j                  r|J t3          |          r6t          |          s&t          |t                    st5          |          s	 t7          |t                    }n# t8          $ r Y Aw xY wt;          ||||gz             E d {V  bd S )Nis not present at runtimezis not a moduler   is not present in stubc                &    h | ]\  }}|j         |S r!   )module_hiddenr   s      r$   r   z"verify_mypyfile.<locals>.<setcomp>v  s#    HHHdaHHHHr&   rr   attrr   r   rf   c                   t          | |          }t          |t          j                  rdS t	          |           }|S	 |                    |          }|                                rdS |                                rdS n# t          $ r Y nw xY w	 |j	        }t          |t                    rt          || j        k              S n# t          $ r Y nw xY wdS )zFHeuristics to determine whether a name originates from another module.FNT)r\   rh   types
ModuleTyper   lookupis_importedis_assignedKeyErrorr*   r   rf   r)   r   )r   r   objsymbol_tablesymbolobj_mods         r$   _belongs_to_runtimez,verify_mypyfile.<locals>._belongs_to_runtimex  s   ac5+,, 	5+A..# %,,T22 %%'' ! 5 %%''  4     	3nG '3'' 3Gqz12223  	 	 	D	
 ts#   B 
BBC 
CCc                J    h | ]}t          |           |          | S r!   )r   )r   r   r   r   s     r$   r   z"verify_mypyfile.<locals>.<setcomp>  sN     
 
 
&q))
 $#GQ//

 
 
r&   rU   rx   r   )r   r   r   r   r   rf   )rh   r   rH   r   r   hasattrsetr   r   r   r    r   dirupdatedifference_updateIGNORED_MODULE_DUNDERSr   node	cross_refrsplitr   
SymbolNodefullname
_all_stubsMypyFiler   _is_decoratabler\   r   r   )r   r   rL   r   to_checkruntime_public_contentsentry
stub_entryxreforig_modulenameruntime_entryr   s    `          @r$   verify_mypyfiler  \  sc      '7## K!<dGLLLLLgu/00 K!2D'BBBBB w	"" 	" 11
"" .k4ASTTTTTTTTTTyk13KWV]^^^^^^! IHdj..00HHHH   F ) 	
 
 
 
 
\\
 
 
  OO+,,,5666!! !L !L/4
/B/BTZ&++
DJz%(22t #"kk#q11!4J(899 #zGZ?Zt #"kk#q11!4" {dm;;z@Y@Yj%.11 	%%%&&	GU++	 z733	 $J//		 	#GUG<<MM 	 	 	 H	 *m[E75JKKKKKKKKKKC!L !Ls   'I>>
JJnodes.SymbolNoderf   c                    t          | t          j                  sdS | j        rdS | j        5t          d | j        j                                        D                       S dS )NFc              3  h   K   | ]-}|                                 ot          j        |           V  .d S N)isidentifierkeyword	iskeywordr   r  s     r$   	<genexpr>z"_is_decoratable.<locals>.<genexpr>  sU       
 
 ?(9$(?(?$?
 
 
 
 
 
r&   T)rh   r   TypeInfo
is_newtypetypeddict_typeallr   keys)r   s    r$   r   r     sz    dEN++ u u& 
 
+16688
 
 
 
 
 	
 4r&   nodes.TypeInfo	type[Any]c           
   #    K   	  G d d|          }n_# t           $ rG | j        s=t          |t          j                  s#t          |d| |t          |                     V  Y nt          $ r Y nw xY w	 t          |dd          }n# t          $ r d}Y nw xY w|r,| j        s't          |d| |t          |                     V  d S d S d S )Nc                      e Zd ZdS )_verify_final.<locals>.SubClassNrF   r!   r&   r$   SubClassr    s        Dr&   r  zIcannot be subclassed at runtime, but isn't marked with @final in the stubrJ   	__final__FzChas `__final__` attribute, but isn't marked with @final in the stub)	r   is_final
issubclassenumEnumrH   r^   r   r\   )r   r   rL   r  runtime_finals        r$   _verify_finalr$    sj     	 	 	 	 	w 	 	 	 	  	 	 	} 	Z%C%C 	[t**          	e<<     
T] 
Q4jj
 
 
 	
 	
 	
 	
 	

 
 
 
s(    AA/#	A/.A/3B BBPt1type[object]t2c                   t           j        dk    r | j        |j        k    p| j        |j        k    S | j        s|j        r | j        |j        k    p| j        |j        k    S | j        }|j        s| j        t
          z   |k    r
|t
          z  }|j        s| j        t
          z   |k    r
|t
          z  }|j        s|j        |k    r
|t
          z  }||j        k    S )znCheck whether two types differ in shape.

    Mirrors the shape_differs() function in typeobject.c in CPython.)r@      )r   version_info__basicsize____itemsize____weakrefoffset__SIZEOF_PYOBJECT__dictoffset__)r&  r(  t_sizes      r$   _shape_differsr2    s     7""2#33Yr"/7YY
 ? 	^bo 	^#r'77]2?bo;]]!# 	&(<(NRX(X(Xo%F  	&R%6%HF%R%Ro%F# 	&(<(F(Fo%F)))r&   typc                f    | t           u rdS | j        }|J d|  d            t          | |          S )zqReturn whether a type is a disjoint base at runtime, mirroring CPython's logic in typeobject.c.

    See PEP 800.TNzType z has no base)object__base__r2  )r3  bases     r$   _is_disjoint_baser8    sI     f}}t<D6S666#t$$$r&   c           	   #  ~  K   t          |          }|r[| j        sT|j                            d          s:| j        s3| j        r| j        s%t          |d| |t          |                     V  d S | j        r|s#t          |d| |t          |                     V  |j                            d          r%t          |d| |t          |                     V  d S | j        r%t          |d| |t          |                     V  d S | j        r.| j        r)t          |d| |t          |                     V  d S d S d S d S )N	__slots__zOis a disjoint base at runtime, but isn't marked with @disjoint_base in the stubr  zOis marked with @disjoint_base in the stub, but isn't a disjoint base at runtimezFis marked as @disjoint_base, but also has slots; add __slots__ insteadzMis marked as @disjoint_base, but also marked as @final; remove @disjoint_basezjis marked as @disjoint_base, but is an enum with members, which is implicitly final; remove @disjoint_base)	r8  is_disjoint_base__dict__r   r  is_enumenum_membersrH   r^   )r   r   rL   is_disjoint_runtimes       r$   _verify_disjoint_baser@  &  s      ,G44 	/%/  $$[11/ 	/
 /
 #'"3/ ]4jj
 
 
 	
 	
 	
 	
 	
 
	 !" 	at**      ,, 	Xt**        ] 	_t**        \ 	d/ 	(t**       5! !2	 	 	 	r&   is_runtime_typeddictc             #  l  K   | j         s| j        s|st          |          }|t          ur!| j        t	          |d| |d|           V  d S |t          u r[| j        Vt
          j                            | j        d          s3t	          |d| || j        j        j         d          V  d S d S d S d S d S d S d S )Nz"is inconsistent, metaclass differsr   rI   )zabc.ABCMetazbuiltins.typezmetaclass mismatch)	is_protocolr=  rV   metaclass_typerH   r   r   is_named_instancer   )r   r   rL   rA  runtime_metaclasss        r$   _verify_metaclassrG  ^  s;       DL 9M  MMD((T-@-H4 13        %%#/ J00#%E  0 $!05>@"       -      &%////r&   is_alias_targetMaybeMissing[type[Any]]rI  c          	   #    
K   | j         r<|s:t          |t                    s#t          |d| |t	          |                     V  d S t          |t                    r@d}t          | j                  r|dz  }t          ||| |t	          |                     V  d S t          |t                    s%t          |d| |t	          |                     V  d S t          | ||          E d {V  t          | ||          E d {V  | j
        d uot          |          }t          | |||          E d {V  d | j        D             }|                    d t          |          D                        | j        r|                    d	           |r|                    d
           t%          |          D ]

}
                    d          r4
                    d          sd| j                            d           
 }t-          
fd| j        D             t0                    }|J 	 	 t3          ||          }	n+# t4          $ r t7          j        ||t0                    }	Y nw xY wn# t:          $ r Y w xY w|	t0          ur8t          |          |ur't3          |	dd           t          |          u rt0          }	
dv r1|	t0          ur(|t<          urt3          |	dd           t<          u rt0          }	t          |t                    r+t          |	t>          j                   rtC          |d          stE          ||	|
gz             E d {V  d S )N;is marked as "@type_check_only", but also exists at runtimer  r   z&. Maybe mark it as "@type_check_only"?zis not a type)rA  c                :    h | ]}|                                 |S r!   )r  r  s     r$   r   z"verify_typeinfo.<locals>.<setcomp>  s)    CCCt/@/@/B/BCCCCr&   c              3  J   K   | ]}t          |          s|t          v|V  d S r  )r   IGNORABLE_CLASS_DUNDERS)r   r   s     r$   r  z"verify_typeinfo.<locals>.<genexpr>  sG        (;A(>(>CDLcCcCcCcCcCcCc r&   re   __new_____c              3  N   K   | ]}|j         v |j                  j        V   d S r  )r   r   )r   tr  s     r$   r  z"verify_typeinfo.<locals>.<genexpr>  s:      YYqQRQXHXHXqwu~2HXHXHXHXYYr&   __objclass__)__setattr____delattr__Texclude_special)#is_type_check_onlyrh   r   rH   r^   r   r  rV   r$  r@  r  r   rG  r   r   varsrC  discardr   
startswithrp   lstripnextmror    r\   AttributeErrorr_   getattr_staticr   r5  r   WrapperDescriptorTyper   r   )r   r   rL   rI  msgrA  r   mangled_entrystub_to_verifyruntime_attrr  s             @r$   verify_typeinforh    sF         '7++ 	Mt**      	'7## )ty)) 	<;;CKdGtDzzJJJJJJgt$$ K$4PT::VVVVVVT7K888888888$T7K@@@@@@@@@.d:T|G?T?T g{9M          DCCCCHOO  ==       %$$$ $###!! -S -SD!! 	?%..*>*> 	?>	 0 0 5 5>u>>MYYYYDHYYY[bcc)))	W&w>>! W W W&5g}gVVW 	 	 	 H	 ''WW,,nd;;tG}}LL"L 333G++v%%nd;;vEE"L ~w//	S<)DEE	S ->>>	S
 nlK5'<QRRRRRRRRR[-S -Ss0   .H?>I+?%I'$I+&I''I++
I87I8c                    t          j        | d                   }| dd          D ]1}	 t          j        ||          }# t          $ r t
          cY c S w xY w|S )Nr   rx   )r   r   r_   rb  ra  r    )rL   static_runtimer  s      r$   _static_lookup_runtimerk    sx    ,[^<<NQRR  	$3NEJJNN 	 	 	 NNNNN		
 s   >AAnodes.FuncBaserj  Iterator[str]c              #    K   | j         dv rd S t          j        |          r@t          t	          |dd           t
                    }|r| j        sdV  |s| j        rdV  d S |t          u rd S t          |t                    r| j        sdV  t          |t                    s| j        rdV  t          |t                    r| j
        sdV  t          |t                    s| j
        rdV  d S d S d S )N)rP  __init_subclass____class_getitem____self__z(runtime is a classmethod but stub is notz(stub is a classmethod but runtime is notz)runtime is a staticmethod but stub is notz)stub is a staticmethod but runtime is not)r  r_   	isbuiltinrh   r\   rV   is_classr    classmethodstaticmethod	is_static)r   r   rj  rL   probably_class_methods        r$   _verify_static_class_methodsrx    sQ      yIII!!  !+77J+M+Mt T T  	= 	=<<<<$ 	= 	=<<<<  .+.. 9t} 98888nk22 9t} 98888.,// : :9999nl33 : :999999: : : :r&   stub_argnodes.Argumentruntime_arginspect.Parameterfunction_namec              #    K   t          |d          rdS | j        j        |j        k    s(| j        j                            d          |j        k    rdS ddh}|j        |v rdS dd}|j        t
          j        j        k    r || j        j        |j                  rdS | j        j        dk    rdS d| j        j         d|j         dV  dS )z$Checks whether argument names match.TrX  NrQ  r5  argsar   br   rf   c                    |                      d          } |                     d          }|                     |          p:|                    |           p%t          |           dk    pt          |          dk    S )NrR  rx   )r   r]  rB   )r  r  s     r$   names_approx_matchz,_verify_arg_name.<locals>.names_approx_match,  s]    GGCLLGGCLL||AO!,,q//OSVVq[OCFFaKOr&   _selfstub parameter "z"" differs from runtime parameter "")r  r   r  r   r   rf   )r   variabler  removeprefixkindr_   	ParameterPOSITIONAL_ONLY)ry  r{  r}  nonspecific_namesr  s        r$   _verify_arg_namer    s1     
 555  	+"222!..t448HHH!6*,,,P P P P 7,<<<ASAS 0B B< 	((	?8,1 	? 	?+6+;	? 	? 	?    r&   c              #    K   |j         t          j        j        ur|| j                                        rd|j         dV  dS | j        j        }t          |j         |          }| j        j        p| j
        }t          |t          j        j                  r|j        }|H|Ft          |j                   t           ur+|j         dur"t#          ||          sd|j         d| d| V  | j        t'          | j                  }|t(          ur|dur|j         t*          urud}t          |          t          |j                   urd	}n,	 t-          ||j         k              }n# t.          $ r d	}Y nw xY w|s!d|j         d
|j         d|V  dS dS dS dS dS dS | j                                        rd| j        j         dV  dS dS )z6Checks whether argument default values are compatible.runtime parameter "z1" has a default value but stub parameter does nottype_contextN.z" has a default value of type z1, which is incompatible with stub parameter type TFz" has a default value of z1, which is different from stub parameter default r  z4" has a default value but runtime parameter does not)defaultr_   r  emptyr  is_requiredr  r  rV   get_mypy_type_of_runtime_valuetype_annotationrh   r   r   TypeVarTypeupper_boundr5  is_subtype_helperinitializerr   r   r3   rf   r   is_optional)ry  r{  r  runtime_type	stub_typestub_defaultdefaults_matchs          r$   _verify_arg_default_valuer  ?  s      '"3"999=$$&& 9	Bk&6 B B B    
 $,1L9#,  L !).J(2JI)TZ%;<< 2%1	(),--V;;'s22),	BB 3R+*: R R3?R RFOR R  
 #/283GHH //$C//#+?BB%)N L))k6I1J1JJJ).3-1,+BU2U-V-VNN( 3 3 3 .3NNN	3
 * _+2B _ _6A6I_ _NZ_ _    + 0/ 0///BB  =$$&& 	28#4#9 2 2 2    	 	s   E! !E0/E0r  r  list[nodes.Argument]c                R    |r$| dv r |d         j         j        dk    r
|dd          S |S )N)ro  rp  r   clsrx   r  r  )r  r  s     r$   maybe_strip_clsr    s>     BBB 7 E))8OKr&   c                  f    e Zd ZddZddZedd	            Zedd            Zedd            ZdS )	Signaturer   rS   c                >    g | _         i | _        d | _        d | _        d S r  )poskwonlyvarposvarkwr"   s    r$   re   zSignature.__init__  s"    $& $#


r&   r   c                   dddddd	dfd
t          | j                                        fd          }d}|d                    fd| j        D             | j        rd | j                  z   gn| j        rdgng z   fd|D             z   | j        rd | j                  z   gng z             z  }|dz  }|S )Nargr
   r   r   c                    t          | t          j                  r| j        S t          | t          j                  r| j        j        S t          r  )rh   r_   r  r  r   Argumentr  AssertionErrorr  s    r$   get_namez#Signature.__str__.<locals>.get_name  sC    #w011  x#u~.. )|((  r&   rR   c                    t          | t          j                  rd S t          | t          j                  r t          | j        j        p| j                  S t          r  )
rh   r_   r  r   r  r   r  rV   r  r  r  s    r$   get_typez#Signature.__str__.<locals>.get_type  sR    #w011 t#u~.. E3<,C0CDDD  r&   rf   c                    t          | t          j                  r| j        t          j        j        uS t          | t
          j                  r| j                                        S t          r  )
rh   r_   r  r  r  r   r  r  r  r  r  s    r$   has_defaultz&Signature.__str__.<locals>.has_default  sY    #w011 B{'*;*AAA#u~.. .x++---  r&   c                d     |           } |           |rd| ndz    |           rdndz   S )Nr   rv   z = ...r!   )r  arg_typer  r  r  s     r$   get_descz#Signature.__str__.<locals>.get_desc  sR    x}}H&.6????B8*{3//788R9r&   c                0     |            |           fS r  r!   )r  r  r  s    r$   <lambda>z#Signature.__str__.<locals>.<lambda>  s    kk!nnhhWXkk=Z r&   keyzdef (z, c                &    g | ]} |          S r!   r!   r   r  r  s     r$   
<listcomp>z%Signature.__str__.<locals>.<listcomp>  s!    ///sXXc]]///r&   r   c                &    g | ]} |          S r!   r!   r  s     r$   r  z%Signature.__str__.<locals>.<listcomp>  s!    000xx}}000r&   z**))r  r
   r   r   )r  r
   r   rR   )r  r
   r   rf   )r   r  valuesrZ   r  r  r  )r#   kw_onlyretr  r  r  r  s      @@@@r$   __str__zSignature.__str__  s_   	! 	! 	! 	!	! 	! 	! 	!	! 	! 	! 	!	 	 	 	 	 	 	 	 ++--3Z3Z3Z3Z3Z[[[tyy////dh///04_hht{+++,,4;B^3%%\^a00000001 15
Bxx
+++,,D
 
 	
 	s

r&   r   nodes.FuncItemSignature[nodes.Argument]c                   t                      }t          | j        | j                  }|D ]}|j                                        r|j                            |           6|j                                        r||j	        |j
        j        <   d|j        t          j        k    r||_        |j        t          j        k    r||_        t           |S r  )r  r  r  	argumentsr  is_positionalr  appendis_namedr  r  r   ARG_STARr  	ARG_STAR2r  r  )r   stub_sig	stub_argsry  s       r$   from_funcitemzSignature.from_funcitem  s    .7kk#DIt~>>	! 
	% 
	%H}**,, 	%##H----'')) %:B 1 677%.00"*%/11!)$$r&   	signatureinspect.SignatureSignature[inspect.Parameter]c                   t                      }| j                                        D ]}|j        t          j        j        t          j        j        fv r|j        	                    |           F|j        t          j        j
        k    r||j        |j        <   p|j        t          j        j        k    r||_        |j        t          j        j        k    r||_        t"          |S r  )r  
parametersr  r  r_   r  r  POSITIONAL_OR_KEYWORDr  r  KEYWORD_ONLYr  r  VAR_POSITIONALr  VAR_KEYWORDr  r  )r  rb   r{  s      r$   from_inspect_signaturez Signature.from_inspect_signature  s    4=KK$/6688 	% 	%K!1!7$   &&{3333!W%6%CCC7B";#344!W%6%EEE%0""!W%6%BBB$/!!$$r&   nodes.OverloadedFuncDefc                    t           j        d          }t          t                    }t	          t
           j                  D ]}|J d j                    t           j        |j	                  }t          |          D ]\  }}|j        j                            d          sU|j        sN|sL|j        j                            d          dk    s)|dk    rI|j        j                            d          d	k    r&||j        j                                     d           ||j        j                                     d
           Ői t	          t
           j                  D ]}|J d j                    t           j        |j	                  }t          |          D ]N\  }}|j        j        }||         dhk    rd| }                    |g                               ||f           Odfd}dfd}	d fd}
t%                      }t'          |          D ]}|         d         d         j        j        }t)          j        t)          j        | |	|                    dd |
|          t/          d |         D                                 }|j                                        r|j                            |           |j                                        r||j        |j        j        <   |j        t(          j        k    r||_        |j        t(          j        k    r	||_         tB          |S )a  Returns a Signature from an OverloadedFuncDef.

        If life were simple, to verify_overloadedfuncdef, we'd just verify_funcitem for each of its
        items. Unfortunately, life isn't simple and overloads are pretty deceitful. So instead, we
        try and combine the overload's items into a single signature that is compatible with any
        lies it might try to tell.

        TrX  Nz(Failed to resolve decorated overload of rQ  rR  r#   r   r  Farg_namer   r   r>   c                B    t          d |          D                       S )Nc              3      K   | ]	\  }}|V  
d S r  r!   )r   rR  indexs      r$   r  zISignature.from_overloadedfuncdef.<locals>.get_position.<locals>.<genexpr>  s&      @@Eu@@@@@@r&   )max)r  all_argss    r$   get_positionz6Signature.from_overloadedfuncdef.<locals>.get_position  s%    @@Xh-?@@@@@@r&   mypy.types.ProperTypec                    t           j        j                            d          5  d |          D             }t           j                            d |D                       cd d d            S # 1 swxY w Y   d S )NTc                :    g | ]\  }}|j         j        p|j        S r!   )r  rV   r  r   r  rR  s      r$   r  zFSignature.from_overloadedfuncdef.<locals>.get_type.<locals>.<listcomp>  s6       AGaCL%<)<  r&   c                    g | ]}||S r!   r!   r   rT  s     r$   r  zFSignature.from_overloadedfuncdef.<locals>.get_type.<locals>.<listcomp>  s    :U:U:UST:U1:U:U:Ur&   )r   statestrict_optional_settypeopsmake_simplified_union)r  	all_typesr  s     r$   r  z2Signature.from_overloadedfuncdef.<locals>.get_type  s    !55d;; W W KST\K]  	 |99:U:Ui:U:U:UVV	W W W W W W W W W W W W W W W W W Ws   ;A..A25A2nodes.ArgKindc                   d |          D             }t           j        |v rt           j        S t           j        |v rt           j        S t          |                    t          j                  k     pt           j        |v pt           j        |v }t           j        |v pt           j        |v }|r|rt           j        nt           j        S |rt           j        nt           j        S )Nc                "    h | ]\  }}|j         S r!   )r  r  s      r$   r   zESignature.from_overloadedfuncdef.<locals>.get_kind.<locals>.<setcomp>  s    ???&#qSX???r&   )	r   r  r  rB   r   ARG_OPTARG_NAMED_OPTARG_POS	ARG_NAMED)r  kindsis_optis_posr  r   s       r$   get_kindz2Signature.from_overloadedfuncdef.<locals>.get_kind  s    ??HX,>???E~&&~%%''&
 HX&''#dj//9 0=E)0&%/ 
 ]e+Eu}/EF H(.Gu}}E4GG$*?5==?r&   r  c              3  *   K   | ]\  }}|j         V  d S r  )pos_onlyr  s      r$   r  z3Signature.from_overloadedfuncdef.<locals>.<genexpr>7  s(      KKfc1S\KKKKKKr&   )r  r  r  r  )r  r   r   r>   )r  r   r   r  )r  r   r   r  )"r   r  r   r   map _resolve_funcitem_from_decoratorr   r   r  r  	enumerater  r]  r  r   addr:   r  r  r   r   r  Varr  r  r  r  r  r  r  r  r  r  r  )r   assume_positional_onlyis_arg_pos_onlyfuncr  r  r  r  r  r  r  sigr  example_arg_namer  s   `             @r$   from_overloadedfuncdefz Signature.from_overloadedfuncdef  s    "+49d!K!K!K7B37G7G8$*EE 	B 	BD##%aPTP]%a%a###"49dn==D'oo 
B 
B
sL%0066	B|	B .	B |(..s33v==

s|'8'>'>s'C'Cu'L'L#CL$56::4@@@@#CL$56::5AAAA
B AC8$*EE 	C 	CD##%aPTP]%a%a###"49dn==D'oo 
C 
C
s |("4(TF22'<<D##D"--44c5\BBBB
C	A 	A 	A 	A 	A 	A	W 	W 	W 	W 	W 	W	@ 	@ 	@ 	@ 	@ 	@ 	@& *3x\::: 	% 	%H'1!4Q7@E.	*HHX,>,>?? $ Xh''KK8JKKKKK  C x%%'' 	%s####""$$ %03
3<,--U^++ 

U_,,		$$
r&   Nr   rS   r'   )r   r  r   r  )r  r  r   r  )r   r  r   r  )	r)   r*   r+   re   r  ru  r  r  r	  r!   r&   r$   r  r    s        $ $ $ $' ' ' 'R    \     \$ _ _ _ \_ _ _r&   r  r  r  warn_runtime_is_object_initc              #    K   t          | j        |j                  D ]\  }}t          |||          E d {V  t          ||          E d {V  |j        t
          j        j        k    r|j        s|j	        j
                            d          s`|j	        j
                            d          dk    r=|j	        j
                            d          dk    rd|j	        j
         d|j
         dV  |j        t
          j        j        k    r|j        s|j	        j
                            d          r|j
                            d          si|j	        j
                            d          dk    rF|j	        j
                            d          dk    r#t          |d	          sd|j	        j
         d
V  t          | j                  t          |j                  k    r|j        | j        t          |j                  d          D ]P}|j	        j
        |j        vr)d|j	        j
         d}|j        |dz  }n|r|dz  }|V  >d|j	        j
         dV  Q| j        d| j        j	        j
         dV  nt          | j                  t          |j                  k     r\|j        t          | j                  d          D ]:}|j
        | j        vrt%          |          sd|j
         dV  -d|j
         dV  ;t          | j                  t          |j                  k    s|j        E| j        |j        d|j        j
         dV  | j        |j        d| j        j	        j
         dV  t'          t)          | j                  t)          |j                  z            D ]I}| j        |         |j        |         }}t          |||          E d {V  t          ||          E d {V  J|j        9t)          |j                                      t)          | j                            st'          t)          | j                  t)          |j                  z
            D ]\}|d |j        D             v r6|d |j        t          | j                  d          D             vrd| dV  Kd| d}|r|dz  }|V  ]t'          t)          |j                  t)          | j                  z
            D ]t}|d | j        D             v r=|j        -|d | j        t          |j                  d          D             v sd| dV  Rt%          |j        |                   sd| dV  u| j        f|j        _d | j        D             }t)          |j                                      t)          | j                  |z            sd|j        j
         dV  | j         |j        d| j        j	        j
         dV  d S d S d S )NrQ  rR  r#   r  r  z," should be positional-only (add "/", e.g. "z, /")TrX  z." should be positional or keyword (remove "/")z!runtime does not have parameter "r  z7. Maybe you forgot to make it keyword-only in the stub?z>. You may need to write stubs for __new__ instead of __init__.z" is not keyword-onlyz'runtime does not have *args parameter "zstub does not have parameter "r  z$stub does not have *args parameter "c                    h | ]	}|j         
S r!   r  r   r{  s     r$   r   z$_verify_signature.<locals>.<setcomp>  s    GGGK{'GGGr&   c                    h | ]	}|j         
S r!   r  r  s     r$   r   z$_verify_signature.<locals>.<setcomp>  s    ```K{/```r&   c                &    h | ]}|j         j        S r!   r  r   ry  s     r$   r   z$_verify_signature.<locals>.<setcomp>  s    CCCh8$)CCCr&   c                &    h | ]}|j         j        S r!   r  r  s     r$   r   z$_verify_signature.<locals>.<setcomp>  s    ```xH-2```r&   c                &    h | ]}|j         j        S r!   r  r  s     r$   r   z$_verify_signature.<locals>.<setcomp>  s    JJJX(+0JJJr&   z'stub does not have **kwargs parameter "z*runtime does not have **kwargs parameter ")zipr  r  r  r  r_   r  r  r  r  r  r]  r   r   rB   r  r  r  _is_private_parameterr   r   issubset)	r   r   r}  r  ry  r{  rd  r  stub_pos_namess	            r$   _verify_signaturer  F  s#      "%TXw{!;!;  +#Hk=IIIIIIIII,X{CCCCCCCCC 1 AAA% B%*55d;; B !&,,S11V;;!&,,S11U::;8#4#9 ; ;#.#3; ; ;  
  1 AAA" B&.&7&<&G&G&M&M B$//55 B !&,,S11V;;!&,,S11U::mTBBB ;8#4#9      48}}s7;''''
 >! HS%5%5%7%78 [ [ $)??Wh>O>TWWWC}0XX4 `__IIIIZX->-CZZZZZZZ{&\@T@Y\\\\\\	TXW[))	)	)";s48}}7 	T 	TKt{22,[99 ON;;KNNNNNNSK,<SSSSSSS 48}}GK((((GN,B;7>#=O9LOOOOOO;"w~'=XDK<P<UXXXXXX c$+&&W^)<)<<== D D $C 0'.2E+#Hk=IIIIIIIII,X{CCCCCCCCCC }C$7$7$@$@T[AQAQ$R$R #dk**S-@-@@AA 		 		CGG7;GGGGG``7;sSWS[}}C_`````JJJJJJJ@#@@@. \[[C				c'.))C,<,<<== 
> 
>CC$(CCCCC &``48CPWP[L\L\L^L^C_`````CCCCCCC()<== >=s====== zgm7 KJJJJ7>""++C,<,<~,MNN 	RQGM<NQQQQQQz'-"7V4:;N;SVVVVVVVV "7"7r&   r  c                    | j                             d          o2| j                             d           o| j        t          j        j        uS )NrR  rQ  )r  r]  r  r_   r  r  r  s    r$   r  r    sJ    C   	7##D)))	7Kw066r&   r  c              #    K   t          |t                    rt          |d| |          V  d S t          |          s%t          |d| |          V  t	          |          sd S t          |          }t          | t          j                  rOt          | |          D ]}t          ||| |          V  t          | ||          D ]}t          ||| |          V  t          | |||          D ]}t          |d|z   | |          V  t          |          }t          j        |          }|rUt                              |           }t                              |          }	t#          ||          }
t%          |          }nd\  }
}|r| j        st          |d| |||
          V  |sd S t)          ||	| j        |t,          j        u           D ]}t          |d|z   | ||
	          V  d S )
Nr   is not a functionis inconsistent, rX   )NNz:is an "async def" function at runtime, but not in the stubrI   r}  r  r   )rh   r   rH   is_probably_a_functioncallablerk  r   FuncDef_verify_abstract_status_verify_final_methodrx  r]   r_   r`   r  r  r  ra   r   is_coroutiner  r  r5  re   )r   r   rL   rj  
error_textr5   r  runtime_is_coroutiner  rb   runtime_sig_descrJ   s               r$   verify_funcitemr(    s      '7## K!<dGLLLLL!'** K!4dGDDDDD   	F ,K88N$&& @1$@@ 	@ 	@JZw??????.tWnMM 	@ 	@JZw??????/g~{[[ O OK!4w!>gNNNNNN&w//I"6w?? 1**40066yAA4YI]^^^MM		&0#)
  
D$5 
H)
 
 
 	
 	
 	
  $i$+v$>	   
 
 '))
 
 
 	
 	
 	
 	

 
r&   c              #  H   K   |t           u rd S t          |d| |          V  d S )Nr   )r    rH   r   s      r$   verify_missingr*    s9       '
5tW
E
EEEEEEr&   	nodes.Varc           	   #    K   t          |t                    r)t          |          dk    rt          |d| |          V  d S | j        r1t          |          r"| j        s| j        st          |d| |          V  t          || j	                  }d}|(| j	         t          || j	                  s
d}t          |t          j                  rt          |j                  }|t          || j	                  rd}t          j                            | j	                  }t          |t          j        j                  r_|j	        j        t          j        j        v rB| j                            d          }|	|j	        |d}nt          ||j	                  rd}nd	}|rt          |d
| | | |          V  d S d S | j        5| j        |k    r,t          |d| |t/          | j                            V  d S d S d S )N   r   +is read-only at runtime but not in the stubr  rv   TF_value_z (incompatible '_value_')z#variable differs from runtime type zDis inconsistent, stub value for Final var differs from runtime valuer  )rh   r   rB   rH   is_initialized_in_classis_read_only_propertyis_settable_propertyis_propertyr  rV   r  r!  r"  valuer   r   get_proper_typeInstancer   ELLIPSIS_TYPE_NAMESinfor   final_valuer^   )r   r   rL   r  r   should_errorproper_typevalue_ts           r$   
verify_varr=    sx      '7## {q  %@$PPPPP 	$_!'**_ &_ /3.>_
 K!NPTV]^^^^^1'	RRRLD I!!,	:: "  gty)) 	79'-HHL',=lDI,V,V'$ *44TY??K;
(;<<
7$-1OOO)--	22?gl&:l>R#(LL&|W\BB 7#(LL6D 	JlJDJJ	      	 	 
		%$*:g*E*ER4+,,
 
 
 	
 	
 	
 	
 	
 
&	%*E*Er&   r  c              #    K   t          |t                    rt          |d| |          V  d S | j        r%t	          |          rt          |d| |          V  d S t          |          s%t          |d| |          V  t          |          sd S | j        d         }t          |t          j	                  r3|j
        r,t          |j        |          D ]}t          ||| |          V  t          |          }t          | |||          D ]}t          |d|z   | |          V  t          |          }|sd S t                               |           }t                               |          }	t'          ||	| j        |t*          j        u           D ]M}d|v r|dz  }t          |d|z   | |t/          | j                  d	| z   d
t/          |          z             V  Nd S )Nr   r.  r  r   r  r  zhas a default value of typezc. This is often caused by overloads failing to account for explicitly passing in the default value.z
Inferred signature: def rI   )rh   r   rH   r3  r1  r  r   r   r   	Decoratoris_overloadr"  r  rk  rx  r]   r  r	  r  r  r  r5  re   r   rV   )
r   r   rL   
first_partrd  rj  r5   r  r  rb   s
             r$   verify_overloadedfuncdefrC  Q  sg     
 '7## K!<dGLLLLL  )) 	c%RTXZabbbbb!'** K!4dGDDDDD   	F AJ*eo.. 9:3I 9*:?GDD 	9 	9CS$888888 ,K88N/g~{[[ O OK!4w!>gNNNNNN
 'w//I //55H229==K$i$+v$>	   
 
 )G33(G ')49~~)L()L)LL#i..0
 
 
 	
 	
 	
 	

 
r&   nodes.TypeVarExprc              #     K   t          |t                    r#| j        dk    rd S t          |d| |          V  d S t          |t                    st          |d| |          V  d S d S )N_NTr   zis not a TypeVar)rh   r   r  rH   r   r   s      r$   verify_typevarexprrG    s       '7##  9FK!<dGLLLLLgw'' K!3T7CCCCC r&   nodes.ParamSpecExprc              #  :  K   t          |t                    rt          |d| |          V  d S t          t          dd           t          t
          dd           f}t          d |D                       }|rt          ||          st          |d| |          V  d S d S )Nr   	ParamSpecc              3     K   | ]}||V  	d S r  r!   r  s     r$   r  z'verify_paramspecexpr.<locals>.<genexpr>  s"      NN!ANNr&   zis not a ParamSpec)rh   r   rH   r\   typingtyping_extensionstuple)r   r   rL   maybe_paramspec_typesparamspec_typess        r$   verify_paramspecexprrQ    s       '7## K!<dGLLLLLT**!;55 NN'<NNNNNO *Wo"F"F K!5tWEEEEE r&   c                    t          |           j        dk    rdS 	 t          | j                  S # t          $ r Y dS w xY w)Ncached_propertyF)rV   r)   rf   r  r   r   s    r$   _is_django_cached_propertyrU    sU    
 G}}!222uGL!!!   uus   0 
>>nodes.Decoratorc              #    K   | j         j        sJ t          |t                    r(t	          | j         |j        t                    E d {V  d S t          |t          j                  r(t	          | j         |j         t                    E d {V  d S t          |          r(t	          | j         |j         t                    E d {V  d S t          j        |          rd S t          |          }t          | j         j        t          j        j                  r| j         j        j        nd }||t%          ||          rd S dV  d S )NzGis inconsistent, cannot reconcile @property on stub with runtime object)r  r3  rh   propertyr#  fgetr    	functoolsrS  rU  r_   isdatadescriptorr  rV   r   r   CallableTyperet_typer  )r   r   r  	func_types       r$   _verify_readonly_propertyr_    sb     9    '8$$ '	7<IIIIIIIII'9455 '	7<IIIIIIIII!'** '	7<IIIIIIIII((  2'::L#-dindj>U#V#V`	\`  	 !lI66 " 	
SSSSSSr&   nodes.FuncDefc              #     K   | j         t          j        k    }t          |dd          }|r|s| j        rdnd}d| dV  d S d S d S )N__isabstractmethod__FrX  methodzis inconsistent, runtime z is abstract but stub is not)abstract_statusr   IS_ABSTRACTr\   r3  )r   r   stub_abstractruntime_abstract	item_types        r$   r"  r"    s      (E,==Mw(>FF R R"&"2@JJ	Q)QQQQQQQQR R R Rr&   c              #     K   | j         rd S t          |dd          s|t          urt          |dd          rdV  d S d S d S )Nr  Fz8is decorated with @final at runtime, but not in the stub)r  r\   r    )r   r   rj  s      r$   r#  r#    sh       } wU++ Ig%%'.+u*U*U%HHHHHH 	&%%%r&   decnodes.OverloadPartnodes.FuncItem | Nonec                d    t           t          j                  r S  j        j        rdS d fd} j        } j        D ]} |||          }|t          j                             j	                  }d}t          |t          j        j
                  r$t          j                            d	||d
          }n!t          |t          j        j                  r|}t          j                            |          }t          |t          j        j                  rt           |          c S  dS |}|S )zReturns a FuncItem that corresponds to the output of the decorator.

    Returns None if we can't figure out what that would be. For convenience, this function also
    accepts FuncItems.
    N	decoratornodes.Expressionr  r  r   rl  c                   t          | t          j                  r>t          | j        t          j                  r| j        j        t          j        j        v r|S t          | t          j                  sd S | j        sd S | j        dv sH| j        t          j        j	        v s0| j        t          j        j
        v s| j        t          j        j        v r|S | j        dk    rr|j        d         j        j        dvr/t          d|j        d         j        j        dj                   t!          j        |          }|j        dd          |_        |S d S )N)zbuiltins.staticmethodzabc.abstractmethodzbuiltins.classmethodr   _clsr  mcsmetaclsz unexpected class parameter name z in rx   )rh   r   CallExprcalleeRefExprr   r   r   DEPRECATED_TYPE_NAMESOVERLOAD_NAMESOVERRIDE_DECORATOR_NAMESFINAL_DECORATOR_NAMESr  r  r  rE   copy)rn  r  r  rj  s      r$   apply_decorator_to_funcitemzE_resolve_funcitem_from_decorator.<locals>.apply_decorator_to_funcitem   sW    y%.11	9+U];;	  )TZ-MMMK)U]33 	4! 	4"QQQ!TZ%>>>!TZ%HHH!TZ%EEEK!777~a ).6WWW%)t~a7H7Q7V ) ),) )  
 )D//CM!""-CMJ tr&   __call__T)is_operator)rn  ro  r  r  r   rl  )rh   r   FuncItemr  r3  original_decoratorsr   r   r5  rV   r6  subtypesfind_memberr\  $_resolve_funcitem_from_callable_type)rj  r}  r  rn  resulting_funcdec_typecallable_types   `      r$   r   r     sR    #u~&& 

x t" " " " " "H 8D,  	44YEE! z11#(;;H M(DJ$788 ) $ 9 9( !: ! ! Hdj&=>> ) ( J66}EEM-)@AA P;COOOOO44Kr&   mypy.types.CallableTypenodes.FuncDef | Nonec           
        |j         t          j        t          j        gk    r|                                x}t          t          j                            |j	                  t          j        j
                  rY|                                x}Ct          t          j                            |j	                  t          j        j
                  rd S g }t          t          |j        |j         |j        d                    D ]g\  }\  }}}||nd| }	t          j        |	|          }
|d u o|t          j        k    }|                    t          j        |
|d ||                     h| j        j        r/|sd S |d         j        j        dvrd S |                    d           t          j        |j        pd|t          j        g           |          }| j        j        |_        |S )	NT)strict__arg)r  r  r  r  r  r   rq  rv   )r  r  bodyr3  )	arg_kindsr   r  r  var_argrh   r   r   r5  r3  AnyTypekw_argr  r  	arg_types	arg_namesr  r  r  r  r  rs  r  r  popr!  Block)rj  r3  r  	var_kwargr  ir  arg_kindr  var_namevarr  r  s                r$   r  r  =  s    	%.%/:::%W2tz11'+>>
@RSS 3**,,&Y3tz11)-@@$*BTUU 4 t!#D-6CM3=#-EEE. . 
 
))Hh  (388i(++t#AEM(AN ( !  	
 	
 	
 	
 x  	47 (III4
-SX^t%+b//WZ
[
[
[C8$CLJr&   c           	   #    K   | j         j        r:t          |t                    s#t	          |d| |t          |                     V  d S t          |t                    rt	          |d| |          V  d S | j         j        rUt          | |          D ]}t	          ||| |          V  t          | j         |          D ]}t	          ||| |          V  d S t          |           }|t          |||          E d {V  d S d S )NrL  r  r   )r  rZ  rh   r   rH   r^   r3  r_  r"  r   r   )r   r   rL   r5   r  s        r$   verify_decoratorr  h  s]      y#  '7++ 	Mt**      	'7## K!<dGLLLLLy 0w?? 	= 	=GWdG<<<<<<.ty'BB 	= 	=GWdG<<<<<<+D11D$55555555555 r&   nodes.TypeAliasc           	   #    K   t           j                            | j                  }d| }t	          |t
                    rt          |d| ||          V  d S t          |          p|}t	          |t           j        j                  rt	          |t                    st          |d| ||          V  d S |j	        }	 |j
        }n&# t          $ r t          |dt                    }Y nw xY wt	          |t                    rut          |dt                    }t	          |t                    rJ|dk    s
|dk    r|d	v rd
}| d| }	t          j        dt          j        |j                   |	          rd S t'          |||d          E d {V  d S t	          |t           j        j                  rX|t*          urMt,          j        dk    rt	          |t          j                  s#t          |d| |t          |                    V  d S t	          |t           j        j                  r0t2          t          |dd          vrt          |d| ||          V  d S t	          |t           j        j                  r+|t6          j        j        urt          |d| ||          V  d S t	          |t           j        j                  rd S t          |d| ||          V  d S )NzType alias for r   r  z&is inconsistent, runtime is not a typer)   r*   zcollections.abcre>   MatchPatternrL  rU   z_?TrH  )r@   
   zis not a Union__mro__r!   zis not a subclass of tuplez is not a type alias for Callablezis not a recognised type alias)r   r   r5  targetrh   r   rH   r   r6  rV   r+   ra  r\   r    r   r  	fullmatchescaper   rh  	UnionTyper   r   r+  	TupleTyperN  r\  collectionsabcCallabler  )
r   r   rL   stub_targetrJ   runtime_originstub_originruntime_nameruntime_moduleruntime_fullnames
             r$   verify_typealiasr    se      *,,T[99K/+//I'7## K!<dGW`aaaaaa((3GN+tz233 ".$// 	8#      F!&	H)6LL 	H 	H 	H">:wGGLLL	HlC(( 
	%,^\7%S%SN.#.. !%666"d**|?S/S/S%-N&4#E#E|#E#E < Gbi0D&E&E G GIYZZ F
 #;]abbbbbbbbbb+tz344 &&!W,,GU_1U1U,%5tWPST_P`P`aaaaaa+tz344 	2>>>>94T]      	+tz677 !999?wZc      	+tz122 
=tWXa
b
b
bbbbbbs   ?C  C*)C*>   r,   __file__r)   __path____spec__
__author__
__cached__
__loader____getattr____package____version____annotate____builtins____copyright____annotations____warningregistry____conditional_annotations__r   >.   __cmp____div__r,   __args__r<  __hash__r  r:  
__origin__
__reduce__r  __nonzero__rV  __unicode____weakref__r  __ctype_be____ctype_le____getstate____setstate____reduce_ex____slotnames____getnewargs____new_member____orig_bases____parameters____pyx_vtable__r  __firstlineno____getinitargs____subclasshook____annotate_func____classdictcell____instancecheck____subclasscheck____protocol_attrs____text_signature____abstractmethods____dataclass_fields____dataclass_params____vectorcalloffset____annotations_cache____static_attributes____ctypes_from_outparam____non_callable_proto_members____callable_proto_members_only__rO  c                L    |                      d          ot          |            S )NrR  )r]  r   r  s    r$   r   r   +  s"    ??37	$$77r&   c                   t          | t          j        t          j        t          j        t          j        f          pKt          j        |           ot          |           p(t          | t          j	                  ot          |           S r  )
rh   r   FunctionTypeBuiltinFunctionType
MethodTypeBuiltinMethodTyper_   ismethoddescriptorr   MethodWrapperTyperT  s    r$   r  r  /  s|    ") '		
 	
 
	P &w//EHW4E4E
	P w 788NXg=N=Nr&   r5  c                >    t          | t                    o| j        d u S r  )rh   rX  fsetrT  s    r$   r1  r1  ?  s    gx((AW\T-AAr&   inspect.Signature | Nonec                   t          | d          r>| j        dk    r2t          | d          r!| j        dk    rt          | d          rt          | j        d          r| j        j        	 t	          j        | j                  }t          j        j        }|j        r^t          t          |j                                                            }|j        t          j        j        k    rt          j        j        }|                    t	          j        d|          g|j                                                  S # t          $ r Y nw xY wt          | d          r| j        dk    rt          | d          rp| j        d	k    rdt          | d
          rSt          | j        d          r=| j        j        0d}t          | j        d          r4t          | j        j        d          r| j        j        j        | j        u rd}|s	 t	          j        | j                  }t          j        j        }|j        r^t          t          |j                                                            }|j        t          j        j        k    rt          j        j        }|                    t	          j        d|          g|j                                                  S # t          $ r Y nw xY w	 	 t	          j        |           S # t$          $ r t          | d          rd| j        v r| j                            dd          }t	          j        t          j        | |          }t+          |t          j                  sJ d |j                                        D             }|                    |          cY S  w xY w# t          $ r Y d S w xY w)Nr)   re   r  z($self, /, *args, **kwargs)rU  r#   )r  rP  z($type, *args, **kwargs)rq  FTr  r2   rA   c                Z    g | ](}|j         d u r|                    t                    n|)S ).)r  )r  replacer3   )r   	parameters     r$   r  z*safe_inspect_signature.<locals>.<listcomp>  sQ        " %,33 "))/)BBB&	  r&   )r   r)   r  rU  r_   r  r  r  r  r_  iterr  r  r  r  r   rq  re   
ValueError_signature_fromstrr  rh   )r   sparameter_kindfirst_parameterhas_initr  
new_paramss          r$   r]   r]   C  s   $$
**G122 +&*GGGG^,, HG(*>?? H  3?	!'"677A5<5F5\N| G"&tAL,?,?,A,A'B'B"C"C"'7+<+LLL%,%6%FN99#-fnEE^H[H[H]H]^      	 	 	D	 	$$$	))G122 *&*DDDGZ(( EG$&:;; E /; G$j11	(1>BB	  )6':JJJH 	%g&677!(!2!H< K&*40C0C0E0E+F+F&G&GO&+w/@/PPP)0):)Jyy ' 1% H Ha1<K^K^K`K`a !       	$W--- 	 	 	!566'7+EEE 0889LeTT01BGSQQ!#w'899999  &)^%:%:%<%<  
 {{j{99999)	*    
 ttsQ   .CE   
EECK 
K+*K+0L B3N;7N> 9N;;N> >
OOr  r  rY   c                   |rdnd d|  S )Nzasync rv   r?  r!   )r  rY   s     r$   ra   ra     s    "*hh;;	;;;r&   c                  ,     e Zd ZdZd	 fdZd
dZ xZS )_TypeCheckOnlyBaseMapperzNRewrites @type_check_only instances to the nearest runtime-visible base class.rT  mypy.types.Instancer   mypy.types.Typec               r   t           j                            t                                          |                    }t          |t           j        j                  sJ |j        j        rJ|j        j	        dd          D ]}|j        st          ||          c S d|j        j        d}J |            |S )Nrx   zall base classes of z are @type_check_only)r   r   r5  supervisit_instancerh   r6  rV   rZ  r`  r   r   )r#   rT  instance	base_inford  	__class__s        r$   r  z'_TypeCheckOnlyBaseMapper.visit_instance  s    :--egg.D.DQ.G.GHH(DJ$788888=+ 	%].qrr2 J J	 3 J4XyIIIIIJ Y)?XXXC#r&   mypy.types.TypeAliasTypec                   |S r  r!   )r#   rT  s     r$   visit_type_alias_typez._TypeCheckOnlyBaseMapper.visit_type_alias_type  s    r&   )rT  r  r   r  )rT  r
  r   r  )r)   r*   r+   r,   r  r  __classcell__)r	  s   @r$   r  r    sW        XX            r&   r  r  c                p    t           j                            |                     t                              S r  )r   r   r5  accept_TYPE_CHECK_ONLY_BASE_MAPPER)r3  s    r$   _relax_type_check_only_typer    s%    :%%cjj1M&N&NOOOr&   leftr  rightc                   t          t          j                            |                     } t          t          j                            |                    }t	          | t          j        j                  rEt	          | j        t                    r+| j        dv r"t          j                            |d          rdS t	          |t          j        j	                  r"t          j                            | d          rdS t          j
        j
                            d          5  t          j                            | |          cddd           S # 1 swxY w Y   dS )z2Checks whether ``left`` is a subtype of ``right``.)r   rx   zbuiltins.boolTzbuiltins.dictN)r  r   r   r5  rh   LiteralTyper4  r>   rE  TypedDictTyper  r  r  
is_subtype)r  r  s     r$   r  r    se   &tz'A'A$'G'GHHD'
(B(B5(I(IJJE4/00tz3'' J&  J((@@ ! t%122 tz7S7So8 8  t			-	-d	3	3 5 5}''e445 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5s   " EEEmodule	type_namemypy.nodes.SymbolNode | Nonec                b    t          |           }|d S ||j        vrd S |j        |         j        S r  )r   r   r   )r  r  r   s      r$   get_mypy_node_for_namer    s;    FD|t
""t:i %%r&   r  mypy.types.Type | Nonec                   | t           j                                        S t          | t                    rdS ddt          | t          j        t          j        t          j        t          j        f          rt          d          }|J |j
        d         j        }t          |t          j                  sJ t           j                            |             g          }t          |           }|rg }g }g }|j                                        D ]}	|                                            |                    |	j        t(          j        j        k    rdn|	j                   |	j        t(          j        j        u }
|	j        t(          j        j        k    r.|                    |
rt          j        nt          j                   |	j        t(          j        j        k    r.|                    |
rt          j        nt          j                   |	j        t(          j        j        k    r/|                    |
rt          j        nt          j                   G|	j        t(          j        j         k    r!|                    t          j!                   |	j        t(          j        j"        k    r!|                    t          j#                   tH          n0                          g}t          j!        t          j#        g}ddg}t           j        %                    |||             |d          S d	}|rt           j        &                    |          }t          |t           j        j%                  r&t          |j'        t           j        j(                  rd}t          |t           j        j)                  r&t          |j*        t           j        j(                  rd}t          | tV                    r|sdd}tY          | j-        | j.                  }t          |t          j                  rbd}t           j/        0                    ||          }t           j1        2                    |          rt           j3        4                    |          }|S tY          tW          |           j-        tW          |           j.                  }|dS t          |t          j5                  r|j+        S t          |t          j                  sdS t          | tl                    rcd | D             }fd|D             }t           j                            |             g          }t           j        7                    ||          S t           j                            |fd|j8        D                       }tW          |           | j9        k    r|S t          | tt          j;                  r"t          | j        tx                    r| j        }nLt          | tz                    rt}          |           }n't          | t~          t          tx          f          r| }n|S t           j        A                    ||          S )zReturns a mypy type object representing the type of ``runtime``.

    Returns None if we can't find something that works.

    Nr   mypy.types.AnyTypec                 h    t           j                            t           j        j        j                  S r  )r   r   r  	TypeOfAnyunannotatedr!   r&   r$   anytypez/get_mypy_type_of_runtime_value.<locals>.anytype  s     z!!$*"6"BCCCr&   builtinsfunctionT)r]  fallbackis_ellipsis_argsFr  r   r  c                |   |                      dd          }t          |d         |d                   }t          |t          j                  sJ t
          j                            t
          j        j        j	                  }t
          j        
                    ||gt          |j        j                  z            S )NrU   rx   )maxsplitr   )r   r  rh   r   r  r   r   r  r!  special_formr6  rB   defn	type_vars)r  partsr   any_types       r$   _named_typez3get_mypy_type_of_runtime_value.<locals>._named_type5  s    KKaK00E)%(E!H==DdEN33333z))$**>*KLLH:&&thZ#di>Q:R:R-RSSSr&   c                ,    g | ]}t          |          S r!   )r  )r   vs     r$   r  z2get_mypy_type_of_runtime_value.<locals>.<listcomp>S  s!    MMM8;;MMMr&   c                ,    g | ]}||n	             S r  r!   )r   r  r#  s     r$   r  z2get_mypy_type_of_runtime_value.<locals>.<listcomp>T  s'    MMMq}!!''))MMMr&   c                $    g | ]}             S r!   r!   )r   rR  r#  s     r$   r  z2get_mypy_type_of_runtime_value.<locals>.<listcomp>X  s    .V.V.VQwwyy.V.V.Vr&   )r4  r&  )r   r  )r  r   r   r  )Br   r   NoneTyperh   rX  r  r  r  r  r   r   r   r   r  r6  r]   r  r  r  r  r_   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r\  r5  r]  r  TypeTypeitemrV   r  r*   r)   r  type_object_type	checkexpris_type_type_context	erasetypeerase_typevarsr  rN  r  r,  r	  r!  r"  r   bytesr   rf   r>   r  )r   r  r$  	type_infor&  r  r  r  r  r  
no_defaultskip_type_object_typer/  resultoptional_itemsr   r4  r#  s                    @r$   r  r    s    z""$$$'8$$ tD D D D 		U68H%Jab  ,
 J''###N:.3	)U^44444:&&y7799+>>*733	 	%III +2244 ) )  +++  H(9(IIIDDsx   ![G,=,CC
8w0@@@$$j%SU]]emTTTTX!2!HHH$$j%SU]]emTTTTX!2!???$$
%[U__H[\\\\X!2!AAA$$U^4444X!2!>>>$$U_5555((#)& !GGII.I9ItIz&&WYY! ' 
 
 	
 " - z11,??lDJ$;<< 	-,/1GHH -(,%lDJ$788 	-,+TZ-CDD -(,%'4   )> 	T 	T 	T 	T +7+=w?OPP	i00 	-1F\229kJJF~22<@@ ? 66v>>M 'tG}}'?gAWXXIt)UY'' ~i00 t'5!! 5MMWMMMMMMMnMMM:&&y7799+>>z##E8444z""9.V.V.V.V)BU.V.V.VWWHG}})))  '49%% *W\3*G*G 	GU	#	# ,W55	GdC-	.	. :!!!AAAr&   zdict[str, nodes.MypyFile]r   r   optionsr   find_submodulesc           	     T   t           j                                        }t           j                            g ||          }t           j                            |d|          }g g }| D ]1}                    |           |s`|                    |          }t          |t                    sE|                    t           j        
                    ||d                     z|                    |          }	|                    |	                               fd|	D                        	 t          |          }
                    fdt          j        |
j        |
j        dz             D                        # t$          $ r  t&          $ r Y /w xY w|r	 t           j                            ||          }n/# t           j        j        $ r}t-          d|           |d}~ww xY w|j        r*t-          dd	                    |j                  z             |j        aS )
a  Uses mypy to construct stub objects for the given modules.

    This sets global state that ``get_stub`` can access.

    Returns all modules we might want to check. If ``find_submodules`` is False, this is equal
    to ``modules``.

    :param modules: List of modules to build stubs for.
    :param options: Mypy options for finding and building stubs.
    :param find_submodules: Whether to attempt to find submodules of the given modules as well.

    N)fscacherB  c              3  8   K   | ]}|j         v|j         V  d S r  r  )r   r  all_moduless     r$   r  zbuild_stubs.<locals>.<genexpr>  s2      ^^A!(R]B]B]qxB]B]B]B]^^r&   c              3  8   K   | ]}|j         v|j         V  d S r  r  )r   r   rH  s     r$   r  zbuild_stubs.<locals>.<genexpr>  s>       # #v[00 F0000# #r&   rU   )sourcesrB  zfailed mypy compile:
zmypy build errors:
r{   )r   builddefault_data_dirmodulefindercompute_search_pathsFindModuleCacher  find_modulerh   r   BuildSourcefind_modules_recursiveextendr   pkgutilwalk_packagesr  r)   r   r   errorsCompileErrorrE   rZ   filesr   )r   rB  rC  data_dirsearch_pathfind_module_cacherJ  r  module_pathfound_sourcesr   resr   rH  s                @r$   build_stubsr_  s  s|    z**,,H#88WhOOK)99T7 :   KG  6""" 	+77??Kk3// NN4,88fdSSTTTT-DDVLLMNN=)))^^^^^^^^^^
.v66"" # # # #$273CWEUX[E[\\# # #    
 %         		G*""7G"DDCC{' 	G 	G 	G!">1">">??QF	G: 	R!"8499SZ;P;P"PQQQ Y
s+   /AFFF!G G-G((G-nodes.MypyFile | Nonec                6    t                               |           S )z?Returns a stub object for the given module, if we've built one.)r   r   rG  s    r$   r   r     s    >>&!!!r&   custom_typeshed_dirrR   r+  tuple[int, int] | Nonec                8   t           j                            |           t          j        dd         dfd}| rt          |           }n.t          t           j                                                  d	z  }|d
z  }t                      }|	                    d          D ]r}|j
        dk    r|j        }d                    |                    |          j        dd         |j
        fz             } ||          r|                    |           s|S )zJReturns a list of stdlib modules in typeshed (for current Python version).Nr   r-  r  r   r   rf   c                    J |                      d          }t          t          |          dd          D ]@}d                    |d |                   }|v r|         \  }}|k    o	|d u p|k    c S AdS )NrU   r   r   F)r   rangerB   rZ   )r  r-  r  current_moduleminvermaxverstdlib_py_versionsr+  s         r$   exists_in_versionz6get_typeshed_stdlib_modules.<locals>.exists_in_version  s    '''S!!s5zz1b)) 	] 	]A XXeBQBi00N!333!3N!C#v-\6T>3[\U[E[\\\ 4 ur&   typeshedstdlibz*.pyire   rU   r   )r  r   r   rf   )r   rM  load_stdlib_py_versionsr   r+  r	   rK  rL  r   rglobstemparentrZ   relative_tor-  r  )	rb  r+  rk  typeshed_dir
stdlib_dirr   r   r  rj  s	    `      @r$   get_typeshed_stdlib_modulesru    s6    *BBCVWW'!,        H/00DJ7799::ZG(JG  ))    9
"";D$**:66<SbSATYLPQQV$$ 	 KKNr&   c                    t                      } t          j        D ]}|t          v r	 t	          |          }|                     |           n# t          $ r Y >w xY w	 |j        }|j        }n# t          $ r Y ^w xY wt          j        ||dz             D ]s}|j        }|                    d          s|                    d          r4	 t	          |           |                     |           Z# t          $ r  t           $ r Y pw xY w| S )z0Return all importable stdlib modules at runtime.rU   z	.__main__)zidlelib.ztest.)r   r   stdlib_module_namesANNOYING_STDLIB_MODULESr   r  ImportErrorr  r)   ra  rT  rU  r  rp   r]  r   r   )importable_stdlib_modulesr   r   runtime_pathr  	submodulesubmodule_names          r$   get_importable_stdlib_modulesr~    s   *-%%. /> />111	7*;77G &))+6666  	 	 	H	
	"+L"+LL 	 	 	H	 !.|\C=OPP 	> 	>I&^N &&{33 ~7P7P%8 8  
>$^444 *--n==== %    !   5	>> %$s5   A
AAA--
A:9A:
C//DDallowlist_filec              #     K   dd}t          |           5 }|D ]} ||          }|r|V  	 d d d            d S # 1 swxY w Y   d S )Nr  r   r   c                    	 | d |                      d                                                   S # t          $ r |                                 cY S w xY w)N#)r  r   r  )r  s    r$   strip_commentsz-get_allowlist_entries.<locals>.strip_comments	  s[    	^qwws||^$**,,, 	 	 	7799	s   .1 AA)r  r   r   r   )r   )r  r  fr~   r  s        r$   get_allowlist_entriesr  	  s          
n		  	 	D"N4((E 	                 s   ;??c                      e Zd ZU ded<   ded<   ded<   ded<   ded<   ded<   ded	<   ded
<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   dS )
_ArgumentsrM   r   rf   rr   ignore_missing_stubignore_positional_onlyignore_disjoint_basesstrict_type_check_only	allowlistgenerate_allowlistignore_unused_allowlistrR   mypy_config_filerb  check_typeshedr   versionshow_tracebackpdbN)r)   r*   r+   r  r!   r&   r$   r  r  	  s         MMM        !!!!    ####LLLIIIIIr&   r  >   thisr   antigravity_ios_supportrx  use_builtins_fixturesc                   d | j         D             }d |D             }t                      }| j        }| j        re| j        r"t	          t          ddd          d           dS t          | j                  }t                      }t          ||z  t          z
            }|s"t	          t          ddd          d	           dS t                      }d
|_        | j        |_        |j        r)t          j                            |j                  |_        | j        |_        ||_        | j        |_        | j        |_        d
|_        |j        r0d#d}	t/          ||	|j        t0          j        t0          j                   d$d}
d%d}|                    |
           |                    |
|           |                                 	 t=          ||| j                   }n;# t>          $ r.}t	          t          ddd          d|            Y d}~dS d}~ww xY wd}d}|D ]}tA          |          D ]}| j!        r|"                                r| j#        r|$                                r;| j%        r|&                                rW| j'        s|(                                rs|j)        |v rd||j)        <   d
}|D ]+}||         *                    |j)                  r	d||<   d} n,|rd}| j+        r|,                    |j)                   t[          |.                    | j/                             |dz  }!| j0        sA|D ]>}||         s4||         *                    d          sd}|dz  }t	          d|            ?| j+        r$t          |          D ]}t	          |           d}n| j/        s|rTt	          t          d| dtc          |           dte          |           dtc          |           d 	dd                     n?t	          t          d!te          |           dtc          |           d"d                     |S )&z.This is stubtest! It's time to test the stubs!c                8    i | ]}t          |          D ]}|d S r   )r  )r   r  r  s      r$   
<dictcomp>ztest_stubs.<locals>.<dictcomp>6	  sI       *>::   	u   r&   c                8    i | ]}|t          j        |          S r!   )r  compile)r   r  s     r$   r  ztest_stubs.<locals>.<dictcomp>;	  s$    IIIe
5 1 1IIIr&   error:ry   Trz   z7cannot pass both --check-typeshed and a list of modulesrx   zno modules to checkFr   rS   c                     d S r  r!   r!   r&   r$   set_strict_flagsz$test_stubs.<locals>.set_strict_flags]	  s    Fr&   rd  r   typing.NoReturnc                n    t          t          ddd          |            t          j        d           d S )Nr  ry   Trz   rx   )printr<   r   exitrd  s    r$   error_callbackz"test_stubs.<locals>.error_callbackb	  s2    fXU666<<<r&   c                F    t          t          ddd          |            d S )Nzwarning:yellowTrz   )r  r<   r  s    r$   warning_callbackz$test_stubs.<locals>.warning_callbackf	  s'    fZxd;;;SAAAAAr&   )r  )r  r  )rC  znot checking stubs due to Nr   )rr   rv   znote: unused allowlist entry zFound z errorz
 (checked z moduler  zSuccess: no issues found in greenr
  )rd  r   r   r  )rd  r   r   rS   )3r  r   r   r  r  r<   ru  rb  r~  r   rx  r   incrementalr   r   abspathabs_custom_typeshed_dirr  config_filer  r  r  pos_only_special_methodsr   r   stdoutstderrprocess_error_codesprocess_incomplete_featuresprocess_strict_bytesr_  rE   r   r  ri   r  rl   r  rn   r  rq   r[   r  r  r  
safe_printr   rr   r  r   rB   )r  r  r  allowlist_regexesgenerated_allowlistr   typeshed_modulesruntime_modulesrB  r  r  r  stubtest_failure	exit_codeerror_countr  erroris_allowlistedr   r   s                       r$   
test_stubsr  2	  s    "n  I
 JIyIII %%lG 	Y< 	xu4888I   16t7OPP799*_<@WWXX fXU6668MNNNqiiGG"&":G" W*,'//':U*V*V'/G$9G!!0G(GK',G$ b	 	 	 	 	'#3W5H#*VYV`aaa   B B B B ~>>>''%8H (      """gwDDW@WXXX   85t444;)9;;	
 	
 	
 qqqqq IK   (( 	 	E' E,A,A,C,C * u/O/O/Q/Q ) e.L.L.N.N . 53[3[3]3]  I--/3	%+,"N  $Q'11%2CDD #'IaL%)NE   I& #''(9:::u,,T\,BBCCC1KK9	> ' ; 	; 	;A Q< ;(9!(<(F(Fr(J(J ;	q 9a99:::  +,, 	 	A!HHHH		\  	K[ K K0E0E K K!$WK K6>w6G6GK K K	      [3w<<[[QXHYHY[[!     s   G   
H*#HHtextrS   c                    t           j        j        }|,|                     |d                              |d          } t          |            dS )zBPrint a text replacing chars not representable in stdout encoding.Nr  )rV  )r   r  encodingencodedecoder  )r  out_encodings     r$   r  r  	  sN    
 :&L {{<	{::AA,W`Aaa	$KKKKKr&   c                r   t          j        d          }|                    ddd           |                    ddd	
           |                    ddd
           |                    ddd
           |                    ddd
           |                    ddd
           |                    ddddg d           |                    dddd
           |                    dddd
           |                    ddd !           |                    d"d#d$!           |                    d%dd&
           |                    d'd(d)t          j        j        z   *           |                    d+dd,
           |                    d-d.dd/
           |                    | t                      0          S )1Nz8Compares stubs to objects introspected from the runtime.)rd   r   r   zModules to test)nargshelpz	--concise
store_truez8Makes stubtest's output more concise, one line per error)actionr  z--ignore-missing-stubzAIgnore errors for stub missing things that are present at runtimez--ignore-positional-onlyzLIgnore errors for whether an argument should or shouldn't be positional-onlyz--ignore-disjoint-basesz1Disable checks for PEP 800 @disjoint_base classesz--strict-type-check-onlyzIRequire @type_check_only on private types that are not present at runtimez--allowlistz--whitelistr  FILEzUse file as an allowlist. Can be passed multiple times to combine multiple allowlists. Allowlists can be created with --generate-allowlist. Allowlists support regular expressions.)r  metavarr  r  z--generate-allowlistz--generate-whitelistz:Print an allowlist (to stdout) to be used with --allowlistz--ignore-unused-allowlistz--ignore-unused-whitelistzIgnore unused allowlist entriesz--mypy-config-filezFUse specified mypy config file to determine mypy plugins and mypy path)r  r  z--custom-typeshed-dirDIRzUse the custom typeshed in DIRz--check-typeshedz$Check all stdlib modules in typeshedz	--versionr  z	%(prog)s )r  r  z--pdbzInvoke pdb on fatal errorz--show-tracebackz--tbzShow traceback on fatal error)	namespace)argparseArgumentParseradd_argumentr   r  r  
parse_argsr  )r  parsers     r$   parse_optionsr  	  s   $N  F 	3DEEE
G    
 P    
 "[     !@    
 "X    
 +     I	     ##.	     V    
 5U     <6\     I{T\=U/U     ;VWWW
F<>]     TZ\\:::r&   c                     t           j                            d           t          t	          t
          j        dd                              S )Nstubtestrx   )r   utilcheck_python_versionr  r  r   argvr!   r&   r$   mainr  
  s8    I"":...mCHQRRL11222r&   r   )r5   r   r6   r
   r   r   )r5   r   r=   r>   r   r   )r   r   r   r   )r   r   r   r   )r   rO   r   rQ   rL   rM   r   r   )rL   rM   r   r   r   r   r   r   )r   r   r   r   )r   r   r   r   rL   rM   r   r   )r   r	  r   rf   )r   r  r   r  rL   rM   r   r   )r&  r'  r(  r'  r   rf   )r3  r'  r   rf   )r   r  r   r'  rL   rM   r   r   )
r   r  r   r  rL   rM   rA  rf   r   r   )
r   r  r   rJ  rL   rM   rI  rf   r   r   )rL   rM   r   rQ   )
r   rl  r   r
   rj  rQ   rL   rM   r   rm  )ry  rz  r{  r|  r}  r   r   rm  )ry  rz  r{  r|  r   rm  )r  r   r  r  r   r  r   )
r   r  r   r  r}  r   r  rf   r   rm  )r  r|  r   rf   )r   r  r   rQ   rL   rM   r   r   )r   r   r   rQ   rL   rM   r   r   )r   r+  r   rQ   rL   rM   r   r   )r   r  r   rQ   rL   rM   r   r   )r   rD  r   rQ   rL   rM   r   r   )r   rH  r   rQ   rL   rM   r   r   )r   r
   r   rf   )r   rV  r   r
   r   rm  )r   r`  r   r
   r   rm  )r   r`  r   r
   rj  rQ   r   rm  )rj  rk  r   rl  )rj  rV  r3  r  r   r  )r   rV  r   rQ   rL   rM   r   r   )r   r  r   rQ   rL   rM   r   r   )r  r   r   rf   )r   r5  r   rf   )r   r
   r   r  )r  r  rY   rf   r   r   )r3  r  r   r  )r  r  r  r  r   rf   )r  r   r  r   r   r  r  )r   r
   r  r  r   r  )r   rM   rB  r   rC  rf   r   rM   )r  r   r   r`  )rb  rR   r+  rc  r   r   )r   r   )r  r   r   rm  )r  r  r  rf   r   r>   )r  r   r   rS   )r  rM   r   r  )r   r>   )r,   
__future__r   r  collections.abcr  r|  r!  rZ  r   r_   r  r   rT  r  structr   r   r   r   rL  rM  r   r   r   
contextlibr   r   r   pathlibr	   r
   r   r   r   r   r   r   
mypy.buildr   mypy.checkexprmypy.erasetypemypy.modulefinder
mypy.nodes
mypy.statemypy.subtypes
mypy.typesmypy.versionr   mypy.config_parserr   mypy.evalexprr   r   mypy.maptyper   mypy.optionsr   	mypy.utilr   r   r   r   r   r    r  r-   r.   r0   r3   r  r  r4   r<   rC   r   rE   rH   r   r   r   r   	lru_cacher   registerr   r  r   r$  calcsizer/  r2  r8  r@  rG  r  rh  rk  rx  r  r  r  r  r  r  r  r(  r*  r  r=  OverloadedFuncDefrC  TypeVarExprrG  ParamSpecExprrQ  rU  r_  r"  r#  r   r  r@  r  	TypeAliasr  	frozensetr   rO  r   r  r1  r]   ra   TypeTranslatorr  r  r  r  r  r  r   r_  r   ru  r~  r  r  rx  r  r  r  r  r)   r  r!   r&   r$   <module>r     s=     # " " " " "                  				  				   



            # # # # # # $ $ $ $ $ $ 7 7 7 7 7 7 7 7 $ $ $ $ $ $       B B B B B B B B B B B B B B B B * * * * * *                                           0 0 0 0 0 0 6 6 6 6 6 6 6 6 2 2 2 2 2 2             W W W W W W W W W W W W            GCLL,-K 7 7 7 7# # # # # # # # )** * * * * #N3:sz5AA
 A A A A/ / / /   	 	 	 	 	i 	 	 	s s s s s s s sv	 	 	 	5 5 5 5p G G G G   :    "   nL nL nL ! nLb
 
 
 
$
 $
 $
 $
N "&/#&&* * * *,% % % %5 5 5 5p# # # #L    "hS hS hS hS hS ! hSV
 
 
 
: : : ::" " " "JD D D DN   t t t t t
 t t tv ).	tW tW tW tW tWn      ?
 ?
 ?
 ! ?
D F F F F <
 <
 <
 <
~ ())A
 A
 A
 *)A
H "##   $# $%%   &% 
 
 
 
T T T T:R R R RI I I IE E E EP( ( ( (V !!6 6 6 "!6> !!Dc Dc Dc "!DcX !*	  ! !     0 "+9 9 9;" ;"  ; ; ; ;|8 8 8 8    B B B B_ _ _ _D< < < <    tz8   ,  8799 P P P P5 5 5 5.& & & & :>BB BB BB BB BBT )+
 * * * *: : : : :z" " " " MQ    D4% 4% 4% 4%n          & "++^+^+^!_!_  _ _ _ _I I I I IX
 
 
 
J; J; J; J;Z3 3 3 3
 zCHTTVV r&   