a
    X%b-                     @   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   s/Users/vegardjervell/Documents/master/model/venv/lib/python3.9/site-packages/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   | d}| d}|durR|jjtjks2J d| j|td |j  |  |du r^dS |jtj	kr|j
D ],}|jtjkrp| j|td |t| qpn(|jtjkr| j|td |t| dS )zK
        This just strips annotations from the funcdef completely.
        paramsretNzInvalid return annotationr   )getZprev_siblingtyper   RARROWr   warning_textremover   Ztypedargslistr   Z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   