
    ,h1                        S SK Jr  S SKrS SKrS SKJr  S SKrS SKrS SKrS SK	r	SSK
Jr  SSKJr  SSKJr  S	S
KJr  \R"                  R$                   " S S\5      5       rg)    )annotationsN)Path   )TestBase   )config)eq_   )utilc                      \ rS rSrSr\R                  " SS9S 5       r\R                  " SS9S 5       rS r	\R                  " 5       S	 5       r
\R                  S
 5       r\S 5       rS r  SS jrSrg)MypyTest   )no_sqlalchemy2_stubsfunction)scopec              #  @   #    U R                  5        S h  vN   g  N7fN	_cachedirselfs    X/var/www/auris/envauris/lib/python3.13/site-packages/sqlalchemy/testing/fixtures/mypy.pyper_func_cachedirMypyTest.per_func_cachedir        >>###   classc              #  @   #    U R                  5        S h  vN   g  N7fr   r   r   s    r   cachedirMypyTest.cachedir!   r   r   c              #    #    Sn[         R                  " 5        n[        [        U5      S-  S5       nUR	                  SU S35        S S S 5        [        [        U5      S-  S5       nUR	                  SU S35        S S S 5        Uv   S S S 5        g ! , (       d  f       NQ= f! , (       d  f       N,= f! , (       d  f       g = f7f)	N sqla_mypy_config.cfgwz
                    [mypy]

                    plugins = sqlalchemy.ext.mypy.plugin

                    show_error_codes = True

                    z
                    disable_error_code = no-untyped-call

                    [mypy-sqlalchemy.*]
                    ignore_errors = True

                    plain_mypy_config.cfgz^
                    [mypy]

                    show_error_codes = True

                    z
                    disable_error_code = var-annotated,no-untyped-call
                    [mypy-sqlalchemy.*]
                    ignore_errors = True

                    )tempfileTemporaryDirectoryopenr   write)r   	mypy_pathr   config_files       r   r   MypyTest._cachedir%   s     	((*hX!77!! K  	
  X!88#!! K  
 N? +*   # +*sK   CB6B	 B6)B%?B6	C
B"	B6%
B3	/B66
C Cc                (   ^^ SSK Jm  SUU4S jjnU$ )Nr   )apic           	       > Uc  T
nSSSUS[         R                  R                  UU(       a  SOS5      /n[         R                  R                  U 5      n[         R                  R                  X$5      nX:w  a  [        R
                  " X5        UR                  U5        [         R                  R                  SS 5        T	R                  U5      u  pgnXgU4$ )Nz--strictz--raise-exceptionsz--cache-dirz--config-filer#   r%   MYPY_FORCE_COLOR)
ospathjoinbasenameshutilcopyfileappendenvironpoprun)r2   
use_pluginuse_cachedirargsfilenametest_programstdoutstderrexitcoder.   r   s            r   r:   !MypyTest.mypy_runner.<locals>.runN   s    #'$  & /4D* ww''-H77<<?L#3KK% JJNN-t4'*wwt}$FH8++    )FN)mypyr.   )r   r   r:   r.   s    ` @r   mypy_runnerMypyTest.mypy_runnerJ   s    #	, #	,J 
rD   c                   ^ ^ SUU 4S jjnU$ )Nc                `   > TR                  U 5      nT" XS9u  p4nTR                  XX4U5        g )N)r;   )_collect_messages_check_output)r2   r;   expected_messagesr@   rA   rB   rF   r   s         r   r:   )MypyTest.mypy_typecheck_file.<locals>.runw   s8     $ 6 6t <'24'O$FHrD   )F )r   rF   r:   s   `` r   mypy_typecheck_fileMypyTest.mypy_typecheck_fileu   s    	 	 
rD   c                P   [         R                  R                  U 5      (       a  U nO_[        R                  " 5       S   R
                  n[         R                  R                  [         R                  R                  U5      U 5      n[        [        U5      R                  S5      5      n[        R                  R                   H^  nU(       d  M  [         R                  R                  U5      (       d  M2  UR                  [        U5      U -  R                  S5      5        M`     U$ )Nr   z**/*.py)r1   r2   isabsinspectstackr>   r3   dirnamelistr   globr   optionsmypy_extra_test_pathsisdirextend)rU   r2   caller_pathfiles	extra_dirs        r   file_combinationsMypyTest.file_combinations   s    77==!!D!--/!,55K77<< <gFDT$Z__Y/0==IyRWW]]955d9o7==iHI > rD   c           
     T  ^ SSK Jn  / n[        R                  " S5      n[        R                  " S5      n[	        U5       n/ n[        US5       GH  u  mnUR                  U5      n	U	(       au  U	R                  S5      R                  S5      u  pn[        R                  [        U
5      [        U5      4:  a(  [        R                  " SU	R                  S5      -  5        M  UR                  U5      n	U	(       Ga  [        U	R                  S5      5      n[        U	R                  S5      5      n[        U	R                  S	5      5      n[        U	R                  S
5      5      n[        R                  " SSU	R                  S5      5      nU(       a2  [        R                  " SS U5      n[        R                  " SS U5      nU(       as  U(       dc  [        R                  " SS U5      n[        R                  " SS U5      n[        R                  " SSU5      n[        R                  " SS U5      nS=pSU S3nU(       a@  [         R"                  (       a+  US   [        R                  " U(       a  SOSS USS  5      -   nU(       a.  [         R$                  (       a  [        R                  " S S! U5      nUR'                  XUR)                  5       45        GM  U(       d  GM  UR+                  U4S" jU 5       5        / US S & GM     S S S 5        U$ ! , (       d  f       U$ = f)#Nr   )mypy_14z0\s*# EXPECTED(_MYPY)?(_RE)?(_ROW)?(_TYPE)?: (.+)z%^#\s*PYTHON_VERSION\s?>=\s?(\d+\.\d+)r   .zRequires python >= %sr   r
      z# noqa[:]? ?.*r"      zRow\[([^\]]+)\]c                P    SU R                  S5       SU R                  S5       S3$ )Nztuple[r   z!, fallback=sqlalchemy.engine.row.r   ]groupms    r   <lambda>,MypyTest._collect_messages.<locals>.<lambda>   s*    qwwqzl ;445GGAJ<q'BrD   zOptional\[(.*)\]c                ,    SU R                  S5       S3$ )NzUnion[r   z, None]rh   rj   s    r   rl   rm      s    qwwqzl'&BrD   z([\[\]])c                *    SU R                  S5       3$ )N\r   rh   rj   s    r   rl   rm      s    Qqwwqzl*;rD   z([\w_]+)c                ,    SU R                  S5       S3$ )Nz	(?:.*\.)?r   \*?rh   rj   s    r   rl   rm          Yqwwqzl#*FrD   Listzbuiltins.listz\b(int|str|float|bool)\bc                ,    SU R                  S5       S3$ )Nz	builtins.r   rr   rh   rj   s    r   rl   rm      rs   rD   TzRevealed type is ""z\b(List|Tuple|Dict|Set)\bz\b(List|Tuple|Dict|Set|Type)\bc                @    U R                  S5      R                  5       $ )Nr   )ri   lowerrj   s    r   rl   rm      s    aggaj&6&6&8rD   zOptional\[(.*?)\]c                *    U R                  S5       S3$ )Nr   z | Nonerh   rj   s    r   rl   rm      s    G&<rD   c              3  6   >#    U  H  u  nnnTXU4v   M     g 7fr   rN   ).0is_mypyis_reexpected_msgnums       r   	<genexpr>-MypyTest._collect_messages.<locals>.<genexpr>   s/      - 5	#!(	 gl;
 5s   )sqlalchemy.ext.mypy.utilrb   recompiler(   	enumeratematchri   	partitionsysversion_infointr   	skip_testboolsubr   py39py310r7   stripr[   )r   r2   rb   rL   expected_re	py_ver_refile_current_assert_messageslinerk   major_minorr|   r}   is_rowis_typer~   r   s                     @r   rJ   MypyTest._collect_messages   s   4jj?
 JJGH	$Z5&(#&ua0	TOOD)&'ggaj&:&:3&?OEe''3u:s5z*BB((3qwwqzB %%d+"1771:.G ,E!!''!*-F"1771:.G#%66*;R#LL')vv.B(	( (*vv/B(( $
 ,.66 + ; ,,L ,.66 + F ,,L ,.66 &,L ,.66 ; F ,,L +/.);L>'K499 (4A $+ !=%F8(,: ( 4:: (*vv0<((
 ,22 ););)=> -,%,, - 5-  24+A.W 1 ^ ! _ Z^ ! s   J#L)%L
L'c                   / n[         R                  R                  U5      nU(       Gaz  / nUR                  S5      n	U	(       Ga  U	R	                  S5      n
[
        R                  " SU
5      (       a  UR                  SU
45        O[
        R                  " SU
5      (       aQ  U	(       aI  U	R	                  S5      n[
        R                  " SU5      (       d  U	R                  SU5        OeU	(       a  MI  O[[
        R                  " SU
[
        R                  5      (       a  O/[
        R                  " SU
5      (       a  UR                  S	U
45        U	(       a  GM  U H  u  ppUR                  S
S5      nU(       d  SOSn[        U5       Hc  u  nu  nnU(       a.  [
        R                  " SU SU SU SU U 3	U5      (       a    O>M>  U SU SU SU U 3UR                  S
S5      ;   d  Mc    O   UR                  U5        M  UU	 M     U(       aM  SR                  U5      n[        SUSS9  U(       a#  SR                  S U 5       5      n[        SUSS9   S5       eU(       a?  [        [        U5       S35        [        SR                  S U 5       5      5         S5       eg US:w  a
  [        X4SS9  [        USUS9  g )N
r   z.+\.py:\d+: error: .*errorz/.+\.py:\d+: note: +(?:Possible overload|def ).*z.+\.py:\d+: note: +def .*z*.+\.py:\d+: note: .*(?:perhaps|suggestion)z.+\.py:\d+: note: .*note'rv   z[SQLAlchemy Mypy plugin] r"   z.*z\:z\: :z: z"Couldn't locate expected messages:)sepc              3  *   #    U  H	  u  pUv   M     g 7fr   rN   r{   r   msgs      r   r   )MypyTest._check_output.<locals>.<genexpr>?  s     %?fac   zRemaining messages:z'expected messages not found, see stdoutz& messages from mypy were not consumed:c              3  *   #    U  H	  u  pUv   M     g 7fr   rN   r   s      r   r   r   E  s     9&&r   z&errors and/or notes remain, see stdout)r   )r1   r2   r4   splitr9   r   r   r7   insertIreplacer   r3   printlenr	   )r   r2   rL   r@   rA   rB   not_locatedr>   output	raw_lineseolr   r|   r}   r   prefixidxtyperrmsgmissingextras                         r   rK   MypyTest._check_output  s    77##D)
 FT*IMM!$884a88MM7A,/XXF  $&]]1-!xx(DbII%,,Q3!	 $)
 XXA1bdd  XX5q99MM61+.# )& ->(ekk#s+<C4*3F*;&C#v88!(2cU#cU#fXcUK"  "	 $*AcU"SEF8C5A!>>#s34  +<  &&s+3K% ->( ))K0:GN II%?%??E/DAGGGuV%KLMdii9&99:FFFu  1}f$/!(rD   rN   N)r@   str)__name__
__module____qualname____firstlineno____requires__r   fixturer   r   r   rF   rO   staticmethodr_   rJ   rK   __static_attributes__rN   rD   r   r   r      s    ,L^^*%$ &$ ^^'"$ #$#J ^^( (T ^^   w!rE)/2E)rD   r   )
__future__r   rS   r1   pathlibr   r   r5   r   r&   baser   r"   r   
assertionsr	   r   add_to_markerrE   r   rN   rD   r   <module>r      sU    #  	  	  
      r)x r) r)rD   