
c'oT1  ã               @   se   d  Z  d d l m Z d d l m Z d d l m Z d Z d d „  Z Gd d	 „  d	 e j	 ƒ Z
 d
 S)z&
Fixer to remove function annotations
é    )Ú
fixer_base)Útoken)Úsymsz)Removing function annotations completely.c             C   s   |  j  d S)Nr   )Úchildren)Únode© r   úE/usr/lib/python3/dist-packages/libpasteurize/fixes/fix_annotations.pyÚparam_without_annotations   s    r	   c               @   s4   e  Z d  Z d Z d d „  Z d Z d d „  Z d S)ÚFixAnnotationsFc             C   s)   |  j  s% d |  _  |  j | d | ƒd  S)NTÚreason)ÚwarnedZwarning)Úselfr   r   r   r   r   Ú	warn_once   s    		zFixAnnotations.warn_oncezm
              funcdef< 'def' any parameters< '(' [params=any] ')' > ['->' ret=any] ':' any* >
              c             C   s"  | j  d ƒ } | j  d ƒ } | d k	 ru | j j t j k sK t d ƒ ‚ |  j | d t ƒ| j j ƒ  | j ƒ  | d k r… d S| j t	 j
 k ræ x„ | j D]> } | j t	 j k r¡ |  j | d t ƒ| j t | ƒ ƒ q¡ Wn8 | j t	 j k r|  j | d t ƒ| j t | ƒ ƒ d S)zK
        This just strips annotations from the funcdef completely.
        ÚparamsÚretNzInvalid return annotationr   )ÚgetZprev_siblingÚtyper   ÚRARROWÚAssertionErrorr   Úwarning_textÚremover   Ztypedargslistr   ZtnameÚreplacer	   )r   r   Zresultsr   r   Zparamr   r   r   Ú	transform   s"    !
 zFixAnnotations.transformN)Ú__name__Ú
__module__Ú__qualname__r   r   ZPATTERNr   r   r   r   r   r
      s   r
   N)Ú__doc__Zlib2to3r   Zlib2to3.pgen2r   Zlib2to3.fixer_utilr   r   r	   ZBaseFixr
   r   r   r   r   Ú<module>   s   