3
‡Œði-  ã               @   sJ   d Z ddlmZ ddlmZ ddlmZ dZdd„ ZG d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/tmp/pip-build-6m2fasei/future/libpasteurize/fixes/fix_annotations.pyÚparam_without_annotations   s    r	   c               @   s$   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)ÚwarnedÚ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	rR|jjtjks2tdƒ‚| j|td� |jjƒ  |jƒ  |dkr^dS |jt	j
kr¤x`|jD ],}|jt	jkrr| j|td� |jt|ƒƒ qrW n(|jt	jkrÌ| j|td� |jt|ƒƒ dS )zK
        This just strips annotations from the funcdef completely.
        ÚparamsÚretNzInvalid return annotation)r   )ÚgetZprev_siblingÚtyper   ÚRARROWÚAssertionErrorr   Úwarning_textÚremover   Ztypedargslistr   ÚtnameÚreplacer	   )r   r   Úresultsr   r   Ú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   