
    3g                         d dl Z d dlZd dlmZ d dlmZmZmZ  G d de      Z G d de      Z	 G d d	e      Z
 G d
 de
      Z G d de      Z G d de
      Z G d de
e      Z G d de      Zy)    N)utils)MutationResignMutationOperator	copy_nodec                       e Zd ZddZy)%AbstractOverriddenElementModificationNc                 d   t        |j                  t        j                        s
t	               |s|j
                  }|j                  }g }|rt        |t        j                        s|j                  |j
                         t        |t        j                        s$t        |t        j                        s
t	               |j                  }|rd }	  || j                  t        |            }t        j                  |      dd D ]  }t        ||      s y y# t        $ r t	               w xY w)Nc                 8    t        j                  t        ||       S N)	functoolsreducegetattr)objattrs     /home/xtuchyna/.var/app/com.visualstudio.code/data/virtualenvs/gen-test-bench-v8TMe8KL/lib/python3.12/site-packages/mutpy/operators/inheritance.py<lambda>zEAbstractOverriddenElementModification.is_overridden.<locals>.<lambda>   s    	(8(8$(L       TF)
isinstanceparentastClassDefr   nameModuleappendmodulereversedAttributeErrortypemrohasattr)selfnoder   r   parent_namesgetattr_recklass
base_klasss           r   is_overriddenz3AbstractOverriddenElementModification.is_overridden	   s    $++s||4 ""99Dfcjj1##FKK0fcll3Jvszz<Z$&&]]F  M	#Xl-CDE ((5/!B/Jz4( 0   	# ""	#s   D D/r   )__name__
__module____qualname__r)    r   r   r   r      s    r   r   c                   (    e Zd Zd Zd Zed        Zy)HidingVariableDeletionc                    t        |j                        dkD  r
t               t        |j                  d   t        j
                        r>| j                  ||j                  d   j                        rt	        j                         S t        |j                  d   t        j                        r5t        |j                  t        j                        r| j                  |      S t               )Nr   r   )r   )lentargetsr   r   r   Namer)   idPassTuplevaluemutate_unpackr#   r$   s     r   mutate_Assignz$HidingVariableDeletion.mutate_Assign"   s    t||q  ""dll1osxx0T5G5GSWS_S_`aSbSeSe5G5f88:Q3
4::syy8Y%%d++ ""r   c           	         |j                   d   }|j                  }g }g }t        |j                  |j                        D ]E  \  }}| j	                  |t        |dd             r$|j                  |       |j                  |       G t        |      t        |j                        k(  r
t               |st        j                         S t        |      dk(  r||_         |d   |_        |S ||_        ||_        |S )Nr   r4   r   )r2   r7   zipeltsr)   r   r   r1   r   r   r5   )r#   r$   targetr7   new_targets
new_valuestarget_elementvalue_elements           r   r8   z$HidingVariableDeletion.mutate_unpack,   s    a


-0ejj-I)NM%%dGND$,OP"">2!!-0 .J {s6;;// ""88:"&DL#ADJK%FK#EJKr   c                      y)NIHDr-   clss    r   r   zHidingVariableDeletion.nameB       r   N)r*   r+   r,   r:   r8   classmethodr   r-   r   r   r/   r/   !   s     #,  r   r/   c                       e Zd Zd Zd Zd Zy) AbstractSuperCallingModificationc                    t        |t        j                        xr; t        |j                  t        j                        xr t        |j                  j
                  t        j                        xr t        |j                  j
                  j                  t        j                        xr t        |j                  j
                  j                  j
                  t        j                        xrf |j                  j
                  j                  j
                  j                  dk(  xr- |j                  j
                  j                  |j                  k(  S )Nsuper)r   r   Exprr7   Callfunc	Attributer3   r4   r   r   )r#   r$   stmts      r   is_super_callz.AbstractSuperCallingModification.is_super_callH   s    $) 1jSXX.N 1$**//3==91>HI^I^`c`h`h>i1$**////44chh?1DHJJOODYDYD^D^DaDaelDl1 zz##tyy0	1r   c                 J    t        |j                  t        j                        S r   )r   r   r   r   r9   s     r   should_mutatez.AbstractSuperCallingModification.should_mutateN   s    $++s||44r   c                 l    t        |j                        D ]  \  }}| j                  ||      s ||fS  y)N)NN)	enumeratebodyrR   r#   r$   indexrQ   s       r   get_super_callz/AbstractSuperCallingModification.get_super_callQ   s=    $TYY/KE4!!$- d{ 0 r   N)r*   r+   r,   rR   rT   rZ   r-   r   r   rJ   rJ   G   s    15r   rJ   c                   >     e Zd Z fdZed        Zed        Z xZS )%OverriddenMethodCallingPositionChangec                 V    t         |   |      xr t        |j                        dkD  S )Nr   )rL   rT   r1   rW   r#   r$   	__class__s     r   rT   z3OverriddenMethodCallingPositionChange.should_mutate[   s%    w$T*As499~/AAr   c                 D   | j                  |      s
t               | j                  |      \  }}|
t               |j                  |   }|j                  |= |dk(  rb| j	                  ||j                  d   j
                         | j                  |j                  d       |j                  j                  |       |S | j	                  ||j                  d   j
                         | j                  |j                  d       |j                  j                  d|       |S )Nr   r   r   )	rT   r   rZ   rW   
set_linenolinenoshift_linesr   insert)r#   r$   rY   rQ   
super_calls        r   mutate_FunctionDefz8OverriddenMethodCallingPositionChange.mutate_FunctionDef^   s    !!$' ""))$/t= ""YYu%
IIeA:OOJ		"(<(<=TYY+IIZ(
  OOJ		!(;(;<TYY*IIQ
+r   c                      y)NIOPr-   rE   s    r   r   z*OverriddenMethodCallingPositionChange.nameq   rG   r   )	r*   r+   r,   rT   r   rf   rH   r   __classcell__r_   s   @r   r\   r\   Z   s1    B  $  r   r\   c                   "    e Zd Zd Zed        Zy)OverridingMethodDeletionc                 `    | j                  |      rt        j                         S t               r   )r)   r   r5   r   r9   s     r   rf   z+OverridingMethodDeletion.mutate_FunctionDefw   s%    d#88:r   c                      y)NIODr-   rE   s    r   r   zOverridingMethodDeletion.name|   rG   r   N)r*   r+   r,   rf   rH   r   r-   r   r   rl   rl   v   s    
  r   rl   c                       e Zd Zed        Zy)SuperCallingDeletionc                     | j                  |      s
t               | j                  |      \  }}|
t               t        j                  |j
                  |   j                        |j
                  |<   |S )N)rb   )rT   r   rZ   r   r5   rW   rb   )r#   r$   rY   _s       r   rf   z'SuperCallingDeletion.mutate_FunctionDef   sf    !!$' ""&&t,q= ""88499U+;+B+BC		%r   N)r*   r+   r,   r   rf   r-   r   r   rq   rq      s     r   rq   c                   r     e Zd ZdZ fdZed        Zed        Zed        Z	ed        Z
ed        Z xZS )SuperCallingInsertPython27)      c                 H    t         |   |      xr | j                  |      S r   )rL   rT   r)   r^   s     r   rT   z(SuperCallingInsertPython27.should_mutate   s#    w$T*Gt/A/A$/GGr   c                    | j                  |      s
t               | j                  |      \  }}|
t               |j                  j	                  d| j                  |             | j                  |j                  dd  d       |S )Nr   r   )rT   r   rZ   rW   rd   create_super_callrc   rX   s       r   rf   z-SuperCallingInsertPython27.mutate_FunctionDef   sz    !!$' ""))$/t ""		D2248912*r   c                 ,   t        j                  dj                  |j                              j                  d   }|j
                  j
                  dt        |j
                  j                         xs d  D ]X  }|j                  j
                  j                  t        j                  |j                  t        j                                      Z t        |j
                  j
                  t        |j
                  j                         d  |j
                  j                        D ]I  \  }}|j                  j                  j                  t        j                   |j                  |             K t        |j
                  j"                  |j
                  j$                        D ]I  \  }}|j                  j                  j                  t        j                   |j                  |             K |j
                  j&                  r&| j)                  ||j
                  j&                         |j
                  j*                  r&| j-                  ||j
                  j*                         | j/                  ||j                  d   j0                         |S )Nzsuper().{}()r   r   r4   ctxargr7   )r   
create_astformatr   rW   argsr1   defaultsr7   r   r   r3   r   Loadr<   keywordskeyword
kwonlyargskw_defaultsvarargadd_vararg_to_super_callkwargadd_kwarg_to_super_callra   rb   )r#   r$   re   r   defaults        r   rz   z,SuperCallingInsertPython27.create_super_call   s   %%n&;&;DII&FGLLQO
99>>!S););%<$<$DEC!!((SWW#((*)MN F		DII4F4F0G/G/H I499K]K]^LC%%,,S[[SWWG-TU _		 4 4dii6K6KLLC%%,,S[[SWWG-TU M99))*dii6F6FG99??((TYY__E
DIIaL$7$78r   c                 t    t        j                  |t        j                               | j                  _        y Nr|   )r   r3   r   r7   kwargsre   r   s     r   r   z2SuperCallingInsertPython27.add_kwarg_to_super_call   s!    "%((e"D
r   c                 t    t        j                  |t        j                               | j                  _        y r   )r   r3   r   r7   starargsre   r   s     r   r   z3SuperCallingInsertPython27.add_vararg_to_super_call   s!    $'HHCHHJ$G
!r   c                      y)NSCIr-   rE   s    r   r   zSuperCallingInsertPython27.name   rG   r   )r*   r+   r,   __python_version__rT   r   rf   rz   staticmethodr   r   rH   r   ri   rj   s   @r   ru   ru      sw    H     E E H H  r   ru   c                   0    e Zd ZdZed        Zed        Zy)SuperCallingInsertPython35)      c           
          | j                   j                  j                  t        j                  d t        j
                  |j                  t        j                                            y )Nr|   r~   )r7   r   r   r   r   r3   r   r   r   s     r   r   z2SuperCallingInsertPython35.add_kwarg_to_super_call   sC    !!((SXXQVQZQZ`c`h`h`jEk)lmr   c           
          | j                   j                  j                  t        j                  t        j
                         t        j                  |j                  t        j
                                            y )Nr|   )r}   r7   )r7   r   r   r   Starredr   r3   r   r   s     r   r   z3SuperCallingInsertPython35.add_vararg_to_super_call   sI    $$S[[SXXZsxxSYS]S]cfckckcmGn%opr   N)r*   r+   r,   r   r   r   r   r-   r   r   r   r      s2    n n q qr   r   )r   r   mutpyr   mutpy.operators.baser   r   r   r   r/   rJ   r\   rl   rq   ru   r   r-   r   r   <module>r      s    
   L L,< 2#B #L'7 &,L 8D 	; 	+!ACh +\	q!; 	qr   