o
    o^                     @   sl   d Z ddlmZ ddlmZ ddlmZ ddlZddlZddlmZ ddlm	Z	 G dd	 d	e
Zd
d ZdS )z$Inline constants in a python module.    )absolute_import)division)print_functionN)	ast_utils)scopec                   @   s   e Zd ZdS )InlineErrorN)__name__
__module____qualname__ r   r   4lib/python3.10/site-packages/pasta/augment/inline.pyr      s    r   c                    s  t | }|j  }t|jtjstd t|jf |	|j}t|tj
s.td  |j}t|	|tjs@td  |jD ]}tt|ddtjrUtd  qC|jD ]}t|	||t| qYt|jdkr{t|	|| dS  fdd	|jD }||_dS )
z%Inline a constant name into a module.z$%r is not a constant; it has type %rz#%r is not declared in an assignmentz%r is not a top-level namectxNz%r is not a constant   c                    s&   g | ]}t |tjr|j ks|qS r   )
isinstanceastNameid).0Ztgtnamer   r   
<listcomp>?   s    

zinline_name.<locals>.<listcomp>)r   Zanalyzenamesr   Z
definitionr   r   r   typeparentZAssignvalueZModuleZreadsgetattrZStorer   Zreplace_childcopyZdeepcopylentargetsZremove_child)tr   ZscZ	name_nodeZassign_noder   refZtgt_listr   r   r   inline_name    s,   





r!   )__doc__Z
__future__r   r   r   r   r   Z
pasta.baser   r   	Exceptionr   r!   r   r   r   r   <module>   s   