o
    noiN                    @   s   d dl Z d dlmZ d dlmZmZmZmZ d dlm	Z	 d dl
Zd dl
mZ d dlmZ d dlmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ d dlm Z m!Z! G d	d
 d
ej"Z#de$deej%eej&ef f fddZ'G dd de!Z(dS )    N)dedent)castMappingSequenceTuple)mock)ensure_type)MetadataWrapper)_gen_dotted_namesAnnotationScope
AssignmentBuiltinAssignmentBuiltinScope
ClassScopeComprehensionScopeFunctionScopeGlobalScopeImportAssignment
LocalScopeQualifiedNameQualifiedNameSourceScopeScopeProvider)data_providerUnitTestc                   @   s   e Zd ZefZdS )DependentVisitorN)__name__
__module____qualname__r   METADATA_DEPENDENCIES r    r    ]/home/ubuntu/.local/lib/python3.10/site-packages/libcst/metadata/tests/test_scope_provider.pyr   #   s    
r   
module_strreturnc                 C   s2   t tt| }|jtttjtf |	t
fS N)r	   cstparse_moduler   moduler   r   CSTNoder   resolver   )r"   wrapperr    r    r!   get_scope_metadata_provider'   s   r+   c                   @   s  e Zd ZdddZdddZdddZed	d
eddfddZdddZ	dddZ
dddZdddZdddZdddZdddZdddZdddZddd Zdd!d"Zdd#d$Zdd%d&Zdd'd(Zdd)d*Zdd+d,Zdd-d.Zdd/d0Zdd1d2Zdd3d4Zdd5d6Zdd7d8Zdd9d:Zdd;d<Z dd=d>Z!dd?d@Z"ddAdBZ#ddCdDZ$ddEdFZ%ddGdHZ&ddIdJZ'ddKdLZ(ddMdNZ)ddOdPZ*ddQdRZ+ddSdTZ,ddUdVZ-ddWdXZ.ddYdZZ/dd[d\Z0dd]d^Z1dd_d`Z2ddadbZ3ddcddZ4edee56dfgdgdhe56die56dfgdgdjg dgdkg dgdle56dfgdgdmg dgdng dgdoe56dpe56dqgdgdre56dsgdgdt	duedve7e5j8 ddfdwdxZ9ddydzZ:dd{d|Z;dd}d~Z<dddZ=dddZ>dddZ?dddZ@dddZAdddZBdddZCdddZDdS )ScopeProviderTestr#   Nc                 C   s*   t d\}}|| }| |d t  d S )Nz
            pass
            not_in_scope)r+   assertEqualset)selfmscopesglobal_scoper    r    r!   test_not_in_scope4   s
   z#ScopeProviderTest.test_not_in_scopec                 C   s  t d\}}|| }| |t t|d }| t|d |d }| t|jd ttt|jd t	j
jd t	jjt	jjd }ttt|jd t	j
jd t	jjt	jjd }| dd |jD |j|jh t|jd t	jj}|jd }	||	 }
| |
t |
d }| t|d t|d }| t|jd ttt|jd t	j
jd t	jjt	jjd }| d	d |jD |jh tt	d
}|t  tt	d}|t  d S )Nz
            foo = 'toplevel'
            fn1(foo)
            fn2(foo)
            def fn_def():
                foo = 'shadow'
                fn3(foo)
            foo   r      c                 S      h | ]}|j qS r    node.0accessr    r    r!   	<setcomp>\       z2ScopeProviderTest.test_accesses.<locals>.<setcomp>   c                 S   r8   r    r9   r;   r    r    r!   r>   o   r?   zfrom a import b
zdef a():
    from b import c

)r+   assertIsInstancer   listr.   len
referencesr   bodyr%   SimpleStatementLineExprvalueCallargsFunctionDefr   r	   r&   visitr   )r0   r1   r2   scope_of_moduleglobal_foo_assignmentsfoo_assignmentfn1_call_argfn2_call_arg	func_bodyfunc_foo_statementscope_of_func_statementfunc_foo_assignmentsfn3_call_argr*   r    r    r!   test_accesses=   sp   


zScopeProviderTest.test_accessesc                 C   s   t d\}}|| }| |t t|j}| t|d tt|jd t	j
jd t	j}t|d jd }| |t t|trJ| |j| d S d S )NzD
            from a import b
            f"{b}" "hello"
            r6   r   )r+   rA   r   rB   accessesr.   rC   r   rE   r%   rF   
ImportFrom	referentsr   
isinstancer:   )r0   r1   r2   r3   global_accessesimport_node
b_referentr    r    r!   test_fstring_accessesx   s   

z'ScopeProviderTest.test_fstring_accesses))any)True)	Exception)r   builtinc           	      C   s   t d\}}|| }| |t | t|| d | t|d d |j}| |t | t|| d | t|d d t|jd t	j
j}|jd }|| }| |t | t|| d | t|d d d S )Nz8
            def fn():
                pass
            r6   something_not_a_builtinr   )r+   rA   r   r.   rC   parentr   r   rE   r%   rK   r   )	r0   rc   r1   r2   rM   scope_of_builtinrR   func_pass_statementrT   r    r    r!   test_builtins   s"   
zScopeProviderTest.test_builtinsc                 C   s  t d\}}|| }tt|jd tjjd tj}| || | |j}t|tj	s:|D ]
}| || | q/t
ddgdgg ddggD ]\}}|D ]{}	| t||	 d|	 d	 ttt||	 d }
| |
j|	d
|
j d|	 d t|j| tjjd }| |
j|d|
j d|  | t|tjtjf |j}| t|tj	 |d }|jr|jjn|j}| |
j|d|
j d|  qNqHd S )Nz
            import foo.bar
            import fizz.buzz as fizzbuzz
            import a.b.c
            import d.e.f as g
            r   r5   foo.barfizzbuzz)aa.ba.b.cgr6    should be in scope.zImportAssignment name  should equal to .The node of ImportAssignment #The alias name of ImportAssignment )r+   r%   r   rE   rF   Importr.   namesr[   
ImportStar	enumeraterC   r   r   rB   namer:   
assertTruerY   assertFalseasnameas_name)r0   r1   r2   rM   import_0import_aliasesaliasidx	in_scopesin_scope
assignmentr]   ru   r|   r    r    r!   test_import   s^   zScopeProviderTest.test_importc           
      C   sT  t d\}}|| }t|jd tj}tt|jd tjjtj}| d|v  | d|v  | 	|j
d t  ttt|d d }t|jd }| 	|j
d |h | 	|j|j ttt|d d }t|jd }	| 	|j
d |	h | 	|	jt|jd jtjj | d|v  | 	t|d d jt  | 	|j
d t  d S )NzB
            import a.b.c, x.y
            a.b.c(x.z)
            r6   r   rm   rk   xzx.y)r+   r   rE   r%   rF   rG   rH   rI   ry   r.   rX   r/   r   r   rB   rD   r:   funcr   rJ   	Attribute)
r0   r1   r2   rM   first_statementcalla_b_c_assignmenta_b_c_accessx_assignmentx_accessr    r    r!   test_dotted_import_access   s0   z+ScopeProviderTest.test_dotted_import_accessc                 C   s   t d\}}|| }t|jd tj}tt|jd tjjtj}tt	t
|d d }t
|jd }| |j| |h | |j|j d S )Nz:
            import a.b.c
            a.b.c()
            r6   r   rm   )r+   r   rE   r%   rF   rG   rH   rI   r   r   rB   rD   r.   rX   r:   r   )r0   r1   r2   rM   r   r   r   r   r    r    r!   +test_dotted_import_access_reference_by_node   s   z=ScopeProviderTest.test_dotted_import_access_reference_by_nodec                 C   sz   t d\}}|| }t|jd tj}|jd }| d|v  ttt	|d d }t	|j
d }| |j| |h d S )Nzl
            import decorator

            @decorator
            def f():
                pass
            r6   r   	decorator)r+   r   rE   r%   rK   
decoratorsry   r   r   rB   rD   r.   rX   )r0   r1   r2   rM   function_defr   decorator_assignmentdecorator_accessr    r    r!   'test_decorator_access_reference_by_node  s   	
z9ScopeProviderTest.test_decorator_access_reference_by_nodec           	      C   s  t d\}}|| }t|jd tj}ttttt|jd tjjtjjtj	jtjjtj	j}| 
d|v  | 
d|v  ttt|d d }t|j}| t|d |d }| |jd t  | |jd |h | |jd t  | |j| d S )NzS
            import os.path
            os.path.join("A", "B").lower()
            r6   r   zos.pathoszos.path.join)r+   r   rE   r%   rF   rG   rH   rI   r   r   ry   r   r   rB   rD   assertNotEqualrC   r.   rX   r/   r:   )	r0   r1   r2   rM   r   attros_path_join_assignment"os_path_join_assignment_referencesos_path_join_accessr    r    r!   #test_dotted_import_with_call_access&  sD   
z5ScopeProviderTest.test_dotted_import_with_call_accessc              
   C   s  t d\}}|| }tt|jd tjjd tj}| || | |j}t|tj	s:|D ]
}| || | q/dD ]~\}}}	| t
|| d| d ttt|| d }
| |
j|d|
j d| d t|j| tjjd }| |
j|d	|
j d|  | t|tjtjf |j}| t|tj	 ||	 }|jr|jjn|j}| |
j|d
|
j d|  q<dD ]}| t
|| d| d qd S )Nzz
            from foo.bar import a, b as b_renamed
            from . import c
            from .foo import d
            r   ))r   rk   r   )r   	b_renamedr6   )r6   cr   )r7   dr   r6   ro   zThe name of ImportAssignment rp   rq   rr   rs   )r5   barri   bz should not be in scope.)r+   r%   r   rE   rF   rY   r.   ru   r[   rv   rC   r   r   rB   rx   r:   ry   rt   rz   r{   r|   )r0   r1   r2   rM   import_fromr~   r   r   r   imported_object_idximport_assignmentr]   ru   r|   r-   r    r    r!   test_import_fromI  s^   
z"ScopeProviderTest.test_import_fromc                 C   s   t d\}}|| }t|jd tj}| || ||j  |jjd }|| }| |t | 	d|v  | 	d|v  | 	d|v | 	d|v  | 	d|v | 	d|v  | 	d|v | 	d|v  d S )Nzm
            global_var = None
            def foo(arg, **kwargs):
                local_var = 5
            r6   r   
global_varargkwargs	local_var)
r+   r   rE   r%   rK   r.   rx   rA   r   ry   )r0   r1   r2   rM   func_deffunc_body_statementscope_of_funcr    r    r!   test_function_scope  s"   z%ScopeProviderTest.test_function_scopec                 C   sX  t d\}}|| }| |t t|d }| t|d tt|d }t|j	d t
j}| |j| | || ||j  |j	}|j	d }|| }	| |	t t|j	d t
jj	}
|
j	d }|| }| |t | d|v  | d|	v  | d|v  | d|v  | d|	v  | d|v  | d|v | d|	v  | d|v d S )Nz
            global_var = None
            @cls_attr
            class Cls(cls_attr, kwarg=cls_attr):
                cls_attr = 5
                def f():
                    pass
            Clsr6   r   r   cls_attr)r+   rA   r   rB   r.   rC   r   r   r   rE   r%   ClassDefr:   rx   r   rK   r   ry   )r0   r1   r2   rM   cls_assignmentscls_assignmentcls_defcls_bodycls_body_statementscope_of_classrR   r   r   r    r    r!   test_class_scope  s8   


z"ScopeProviderTest.test_class_scopec                 C   s<  t d\}}|| }| |t ttt|jd tjjd tjjtj	}||j
 }| |t ttt|jd tjjd tjjtj}||j
 }| |t ttt|jd tjjd tjjtj}||j }	| |	t ttt|jd tjjd tjjtj}
||
j
 }| |t | d|v  | d|v  | d|v  | d|	v  | d|v  | d|v  | d|v  | d|v  | d|	v  | d|v  | d	|v | d	|v | d	|v | d	|	v | d	|v | d
|v | d
|v  | d
|v  | d
|	v  | d
|v  d S )Na&  
            iterator = None
            condition = None
            [elt for target in iterator if condition]
            {elt for target in iterator if condition}
            {elt: target for target in iterator if condition}
            (elt for target in iterator if condition)
            r7   r   r@         iterator	conditionelttarget)r+   rA   r   r   rE   r%   rF   rG   rH   ListCompr   r   SetCompDictCompkeyGeneratorExpry   )r0   r1   r2   rM   	list_compscope_of_list_compset_compscope_of_set_comp	dict_compscope_of_dict_compgenerator_exprscope_of_generator_exprr    r    r!   test_comprehension_scope  sz   




z*ScopeProviderTest.test_comprehension_scopec                 C   s  t d\}}|| }| |t ttt|jd tjjd tjjtj	}||j
 }| |t | || | | ||j
 | | ||j | | ||jj | | ||jj | t|jjtj}| || | | ||j | | ||j | d S )Nz:
            [y for x in iterator for y in x]
            r   )r+   rA   r   r   rE   r%   rF   rG   rH   r   r   r   assertIsfor_initerr   inner_for_inCompFor)r0   r1   r2   rM   r   r   r   r    r    r!   test_nested_comprehension_scope  s.   
z1ScopeProviderTest.test_nested_comprehension_scopec           
      C   s   d}|D ]`}t |\}}|| }| |t | d|v  t|jd tj}||jjd  }| |t | d|v  t|jjd tj	}||jjd  }	| |	t
 | d|	v  | |	d |d  qd S )N)zz
            class Cls:
                def f():
                    global var
                    var = ...
            z
            class Cls:
                def f():
                    global var
                    import f as var
            varr   )r+   rA   r   ry   r   rE   r%   r   r   rK   r   r.   )
r0   codescoder1   r2   rM   clsscope_of_clsf
scope_of_fr    r    r!   test_global_scope_overwrites-  s    z.ScopeProviderTest.test_global_scope_overwritesc                 C   s  d}|D ]}t |\}}|| }| |t | d|v t|jd tj}tt|jjd tjjd tj	}|| }| |t
 | d|v  | t|d d t|jjd tj}	||	jjd  }
| |
t | d|
v  t|	jjd tj}tt|jjd tjjd tj	}|| }| |t
 | d|v  | t|d d | dd |d D t|tjr|jd jn|t|tjr|jd jn|h qd S )N)z
            def outer_f():
                var = ...
                class Cls:
                    var = ...
                    def inner_f():
                        nonlocal var
                        var = ...
            z
            def outer_f():
                import f as var
                class Cls:
                    var = ...
                    def inner_f():
                        nonlocal var
                        var = ...
            z
            def outer_f():
                var = ...
                class Cls:
                    var = ...
                    def inner_f():
                        nonlocal var
                        import f as var
            r   r   r7   r6   c                 S      h | ]}t t|jqS r    r   r   r:   )r<   r   r    r    r!   r>         
zCScopeProviderTest.test_nonlocal_scope_overwrites.<locals>.<setcomp>)r+   rA   r   ry   r   rE   r%   rK   rF   r(   r   r.   rC   r   r   r[   Assigntargetsr   )r0   r   r   r1   r2   rM   outer_fouter_f_body_varscope_of_outer_fr   r   inner_finner_f_body_varscope_of_inner_fr    r    r!   test_nonlocal_scope_overwritesM  sR   

z0ScopeProviderTest.test_nonlocal_scope_overwritesc           
      C   s   t d\}}|| }| |t | d|v  t|jd tj}||jjd  }| |t | d|v  t	|d d }| 
tt|j| t|jjd tj}||jjd  }| |t | d|v  t	|d d }	| 
tt|	j| d S )NzW
            def f():
                def f():
                    f = ...
            r   r   )r+   rA   r   ry   r   rE   r%   rK   r   rB   r.   r   r   r:   )
r0   r1   r2   rM   r   r   out_f_assignmentr   r   inner_f_assignmentr    r    r!   )test_local_scope_shadowing_with_functions  s$   z;ScopeProviderTest.test_local_scope_shadowing_with_functionsc                 C   s  t d\}}|| }| |t | d|v  t|jd tj}||jjd  }| |t |j	d }|j
j
d }t|jtj}t|jtj}	t|j
jtj}
|j
jd }t|jtj}t|jtj}|j
jd }t|j
jtj}t|jtjj}| || | | || | | || | | ||	 | | ||
 | | || | | || | | || | | || | | || | | || | | d|v | d|v  | d|v | d|v  | d|v | d|v  | d|v | d|v  | d	|v | d	|v  | ttt|d d j| | ttt|d d j|
 | ttt|d d j| | ttt|d d j| | ttt|d	 d j| d S )
Nzx
            @decorator
            def f(x: T=1, *vararg, y: T=2, z, **kwarg) -> RET:
                pass
            r   r   r6   r   varargyzkwarg)r+   rA   r   ry   r   rE   r%   rK   r   r   params
annotation
AnnotationdefaultBaseExpressionstar_argParamkwonly_params
star_kwargreturnsr.   r   r   rB   r:   )r0   r1   r2   rM   r   r   r   r   xToner   r   yTtwor   r   retr    r    r!   test_func_param_scope  s\   
    $z'ScopeProviderTest.test_func_param_scopec                 C   s`  t d\}}|| }| |t ttt|jd tjjd tjjtj	}||j }| |t
 |jjd }t|jtj}t|jjtj}|jjd }	t|	jtj}
|jjd }t|jjtj}| || | | || | | || | | ||	 | | || | | ||
 | | || | | d|v | d|v  | d|v | d|v  | d|v | d|v  | d|v | d|v  | d|v | d|v  | ttt|d d j| | ttt|d d j| | ttt|d d j|	 | ttt|d d j| | ttt|d d j| d S )	Nz@
            lambda x=1, *vararg, y=2, z, **kwarg:x
            r   r6   r   r   r   r   r   )r+   rA   r   r   rE   r%   rF   rG   rH   Lambdar   r   r   r   r   r   r   r   r.   ry   r   r   rB   r:   )r0   r1   r2   rM   r   r   r   r   r   r   r   r   r   r    r    r!   test_lambda_param_scope  sV   
    $z)ScopeProviderTest.test_lambda_param_scopec                 C   sr   t d\}}|| }| |t | d|v  | ttt|d d jt	t	|j
d tjjd jtjj dS )aU  
        The ``except as`` is a special case. The asname is only available in the excep body
        block and it'll be removed when existing the block.
        See https://docs.python.org/3.4/reference/compound_stmts.html#except
        We don't create a new block for except body because we don't handle del in our Scope Analysis.
        zj
            try:
                ...
            except Exception as ex:
                ...
            exr   N)r+   rA   r   ry   r.   r   r   rB   r:   r   rE   r%   Tryhandlersrx   AsNamer0   r1   r2   rM   r    r    r!   test_except_handler"  s   z%ScopeProviderTest.test_except_handlerc                 C   sr   t d\}}|| }| |t | d|v  | ttt|d d jt	t	|j
d tjjd jtjj d S )NzH
            with open(file_name) as f:
                ...
            r   r   )r+   rA   r   ry   r.   r   r   rB   r:   r   rE   r%   Withitemsr{   r  rx   r  r    r    r!   test_with_asname;  s   z"ScopeProviderTest.test_with_asnamec                 C   s  t d\}}t|jd tj}t|jjd tj}|| }| |t|jtj	j
t d tt|jjd tjjd tjj}|| }| |t | ||tdtjh | ||tdtjh tt|jd tjjd tjj}| |t | ||tdtjh tt|jjd tjjd tjjd j}	| ||	tdtjh tt|jjd	 tjjd tjjd j}
| ||
tdtjh d
D ]}| |tj|dtd| tjhd| d q| |tjddt d d S )Nz
            from a.b import c
            class Cls:
                def f(self) -> "c":
                    c()
                    d = {}
                    d['key'] = 0
            def g():
                pass
            g()
            r6   r   zHGet qualified name given a SimpleString type annotation is not supportedrm   r@   rn   zCls.f.<locals>.dr7   )mapintdictrH   z	builtins.zTest builtin: rq   r   z Test variable d in global scope.)r+   r   rE   r%   r   rK   r.   get_qualified_names_forr   r   r   r/   rF   rG   rH   rA   r   r   r   IMPORTr   LOCALr   r   r   NameBUILTIN)r0   r1   r2   r   r   rM   c_callr   g_calld_named_subscriptrc   r    r    r!   test_get_qualified_names_forL  s   
z.ScopeProviderTest.test_get_qualified_names_forc                 C   s  t d\}}t|jd tj}t|jjd tj}|| }| |t | |	|t
dtjh tt|jjd tjjd tjj}|| }| |t | |	|t
dtjh t|jjd tj}tt|jjd tjjd tjj}	||	 }
| |
t | |
	|	t
dtjh t|jd tj}t|jjd tj}|| }| |t | |	|t
dtjh |jjd }|| }| |t | |	|t
dtjh d S )	Na  
            class A:
                def f1(self):
                    def f2():
                        pass
                    f2()

                def f3(self):
                    class B():
                        ...
                    B()
            def f4():
                def f5():
                    class C:
                        pass
                    C()
                f5()
            r   zA.f1r6   zA.f1.<locals>.f2zA.f3.<locals>.Bzf4.<locals>.f5zf4.<locals>.f5.<locals>.C)r+   r   rE   r%   r   rK   rA   r   r.   r  r   r   r  rF   rG   rH   r   )r0   r1   r2   cls_afunc_f1scope_of_cls_afunc_f2_callscope_of_f1func_f3call_bscope_of_f3func_f4func_f5scope_of_f4cls_cscope_of_f5r    r    r!   )test_get_qualified_names_for_nested_cases  sb   z;ScopeProviderTest.test_get_qualified_names_for_nested_casesc                 C   s`   t d\}}ttt|jd tjjd tjjtj}|| }| |	|j
tdtjh d S )NzF
                from a import b, bc
                bc()
            r6   r   za.bc)r+   r   rE   r%   rF   rG   rH   rI   r.   r  r   r   r   r  )r0   r1   r2   r   module_scoper    r    r!   ,test_get_qualified_names_for_the_same_prefix  s   
z>ScopeProviderTest.test_get_qualified_names_for_the_same_prefixc           	      C   s   t d\}}ttt|jd tjjd tjjtj}|| }| |	|j
tdtjh | |	|jd jtdtjh tt|jd tjjd tj}t|jd jtj}t|jtj}|j}| |	|tdtjh | |	|tdtjh | |	|tdtjh d S )NzC
                import a.b.c
                a(a.b.d)
            r6   r   rk   za.b.drm   rl   )r+   r   rE   r%   rF   rG   rH   rI   r.   r  r   r   r   r  rJ   rt   ru   rx   r   )	r0   r1   r2   r   r$  import_stmta_b_ca_brk   r    r    r!   +test_get_qualified_names_for_dotted_imports  sJ   
z=ScopeProviderTest.test_get_qualified_names_for_dotted_importsc                 C   s   t d\}}tt|jd tjjd tjj}|| }| |t | 	|
|tdtjdtdtjdh | 	|
dtdtjdtdtjdh d S )Nz
                if 1:
                    from a import b as c
                elif 2:
                    from d import e as c
                c()
            r6   r   rl   rx   sourcezd.er   )r+   r   rE   r%   rF   rG   rH   rA   r   r.   r  r   r   r  r0   r1   r2   r   scoper    r    r!   test_multiple_assignments  s,   	z+ScopeProviderTest.test_multiple_assignmentsc                 C   s  t d\}}tt|jd tjjd tjjd j}tt|jd tjjd tjj	}|| }|j
| }| t|d t|d }| tt|j| | dd |jD |h |j| }| t|d | t|d j| | dd t|d jD |h | ||jv  | ||j
v  | ||jv  | ||j
v  t|jd tj}	ttt|	jtjjd tjjd tjjd j}
||
 }|j
d }| t|d | ttt|d j|
 tttt|	jtjjd tjjd tjj	tj}|jd j	}|jd j	}d	d
 |jD }| t|d | dd |D ||h tt|	jtjjd tj}tt|jjd tjjd tj}|jd j}|j	}|| }| dd |jD |h | dd |j
D |h | tt| d d S )Nz
                a = 1
                def f():
                    a = 2
                    a, b
                    def g():
                        b = a
                a
            r   r7   r6   c                 S   r8   r    r9   r<   ir    r    r!   r>   V  r?   zBScopeProviderTest.test_assignments_and_accesses.<locals>.<setcomp>c                 S   r   r    r   r/  r    r    r!   r>   ^      rk   c                 S   s   g | ]}|qS r    r    r/  r    r    r!   
<listcomp>  s    zCScopeProviderTest.test_assignments_and_accesses.<locals>.<listcomp>c                 S   r8   r    r9   r/  r    r    r!   r>     r?   c                 S   r8   r    r9   r/  r    r    r!   r>     r?   c                 S   r   r    r   r/  r    r    r!   r>     r1  r@   )r+   r   rE   r%   rF   r   r   r   rG   rH   assignmentsr.   rC   rB   r   r   r:   rD   rX   rZ   ry   rK   IndentedBlockr   elementsr/   values)r0   r1   r2   a_outer_assigna_outer_accessrM   a_outer_assignmentsa_outer_assignmenta_outer_assessesr   a_inner_assignr   a_inner_assignmentstupa_inner_accessb_inner_accessall_inner_accessesrn   inner_most_assignb_inner_most_assigna_inner_most_access
scope_of_gr    r    r!   test_assignments_and_accesses:  s   



z/ScopeProviderTest.test_assignments_and_accessesc                 C   s  t d\}}tt|jd tjjd tj}|| }t|d d }| |t | 	t
|jd t|j}| |d j t|d d }| |t | 	t
|jd t|j}| |d j |d j}| |tj t|tjr{| 	|jd t|d d }| |t | 	t
|jd t|d d }| |t | 	t
|jd t|j}| |d j | |d j t|d d }| |t | 	t
|jd t|d	 d }| |t | 	t
|jd t|j}| |d j | |d j |d j}| |tj t|tjr| 	|jd	 t|d
 d }| |t | 	t
|jd t|d d }| |t | 	t
|jd t|d d }| |t | 	t
|jd t|j}| |d j | |d j |d j}| |tj t|tjr| 	|jd t|d d }| |t | 	t
|jd t|d d }| |t | 	t
|jd t|j}| |d j | |d j |d j}| |tj t|tjr| 	|jd t|d d }| |t | 	t
|jd t|j}| |d j t|d d }| |t | 	t
|jd t|j}| |d j t|d d }| |t | 	t
|jd t|j}| |d j |d j}| |tj t|tjrr| 	|jd t|d d }| |t | 	t
|jd t|d d }| |t | 	t
|jd t|j}|d j}| |tj t|tjr| 	|jd t|d d }| |t | 	t
|jd t|j}d S )Na  
                from typing import Literal, NewType, Optional, TypeVar, Callable, cast
                from a import A, B, C, D, D2, E, E2, F, G, G2, H, I, J, K, K2, L, M
                def x(a: A):
                    pass
                def y(b: "B"):
                    pass
                def z(c: Literal["C"]):
                    pass
                DType = TypeVar("D2", bound=D)
                EType = TypeVar("E2", bound="E")
                FType = TypeVar("F")
                GType = NewType("G2", "Optional[G]")
                HType = Optional["H"]
                IType = Callable[..., I]

                class Test(Generic[J]):
                    pass
                castedK = cast("K", "K2")
                castedL = cast("L", M)
            r6   r   ABCDD2EE2FGzOptional[G]G2HIJKK2LM)r+   r   rE   r%   rF   rY   rB   rA   r   r.   rC   rD   ry   is_annotationr:   SimpleStringr[   evaluated_valuerz   is_type_hint)r0   r1   r2   impr-  r   rD   reference_noder    r    r!   test_annotation_access  s   















z(ScopeProviderTest.test_annotation_accessc                 C      t d\}}tt|jd tjjd tj}ttt|jd tjjd tjjtj}|j	d j}|| }t
t|d }| |t | t|jd | t|jd j| d S )Nz
                from typing import TypeVar, Optional
                from a import G
                TypeVar("G2", bound="Optional[\"G\"]")
            r6   r   r7   rO  )r+   r   rE   r%   rF   rY   rG   rH   rI   rJ   nextr   rA   r   r.   rC   rD   rB   r:   r0   r1   r2   r\  r   boundr-  r   r    r    r!   test_insane_annotation_access+  &   z/ScopeProviderTest.test_insane_annotation_accessc                 C   r_  )Nz~
                from typing import TypeVar
                import a.G
                TypeVar("G2", bound="a.G")
            r6   r   r7   za.G)r+   r   rE   r%   rF   rt   rG   rH   rI   rJ   r`  r   rA   r   r.   rC   rD   rB   r:   ra  r    r    r!   test_dotted_annotation_accessC  rd  z/ScopeProviderTest.test_dotted_annotation_accessc           	      C   s   t d\}}t|jd tj}tt|jjd tjjd tjj}|| }| |t	 | 
tt	|j| t|jd tj}tt|jjd tjjd tjj}|| }| |t | 
tt|j| d S )Nz
                def f1():
                    target()

                class C:
                    attr = target()
            r   r6   )r+   r   rE   r%   rK   rF   rG   rH   rA   r   r.   r   r:   r   r   r   )	r0   r1   r2   f1target_callf1_scoper   target_call_2c_scoper    r    r!   test_node_of_scopes[  s*   	z%ScopeProviderTest.test_node_of_scopesc                 C   s   t d\}}t|jd tjjd }|| d }| t|d | ttt	|d j
| t|jd tj}|jd j}| || |tdtjdh tt|jd tjjd tjj}| || |tdtjdh d S )	Nz
                import unittest.mock

                with unittest.mock.patch("something") as obj:
                    obj.f1()

                unittest.mock
            r   unittestr6   zunittest.mock.patchr*  r7   zunittest.mock)r+   r   rE   r%   rF   r.   rC   r   r   rB   r:   r  r  itemr  r   r   r  rG   rH   )r0   r1   r2   import_r3  with_fn_callr   r    r    r!   test_with_statementt  s2   
z%ScopeProviderTest.test_with_statementc                 C   s  t d\}}ttt|jd tjjd tjjd tjj}tt|jd tjjd tj	}|| }t
|d }| t|d |d }| |t | tt|j| | t|jd ttt|jd tjjd tj	jtj}| dd |jD |j|jh t
|d	 }| t|d |d }	| |	t t|jd tjjd }
| tt|	j|
 | t|	jd tt|jd
 tjjd tj	}| dd |	jD t|jtjjh | |d t  d S )Nz
                import a
                dic = {}
                del dic
                del dic["key"]
                del a.b
            r6   r   r7   dicr@   c                 S   r8   r    r9   r/  r    r    r!   r>     r?   z;ScopeProviderTest.test_del_context_names.<locals>.<setcomp>rk   r   c                 S   r8   r    r9   r/  r    r    r!   r>     r?   r   )r+   r   rE   r%   rF   r   r   AssignTargetr   DelrB   r.   rC   rA   r   r   r:   rD   	SubscriptassertSetEqualrH   r   r/   )r0   r1   r2   rr  del_dicr-  r3  
dic_assigndel_dic_subscripta_assignimport_adel_a_br    r    r!   test_del_context_names  sb   	
z(ScopeProviderTest.test_del_context_namesc                 C   sZ   t d\}}tt|jd tjjd tjj}|| }| |t | 	t
|d d d S )Nzcall(arg=val)r   r   )r+   r   rE   r%   rF   rG   rH   rA   r   r.   rC   r,  r    r    r!   test_keyword_arg_in_call  s   z*ScopeProviderTest.test_keyword_arg_in_callc                 C   sP   t  }t|j}t|j}| d|v  | t|j| | t|j| d S )Ndoesnt_exist)r   rB   r3  rX   rz   r.   )r0   gscopebefore_assignmentsbefore_accessesr    r    r!   !test_global_contains_is_read_only  s   

z3ScopeProviderTest.test_global_contains_is_read_onlyc           	   	   C   s  t tttfD ]y}| j|di t }||tdd}t|j	}t|j
}t|j }t|jj	}t|jj
}| d|v  | t|j
| | t|j	| | t|j | | t|jj	| | t|jj
| W d    n1 szw   Y  qd S )N)r-  lol)re   r:   r  )r   r   r   r   subTestr   r%   r  rB   r3  rX   _scope_overwritesr  re   rz   r.   )	r0   sr  r-  r  r  before_overwritesbefore_parent_assignmentsbefore_parent_accessesr    r    r!   test_contains_is_read_only  s,   

z,ScopeProviderTest.test_contains_is_read_onlyc                 C   s   t d d S )Nz	foo().bar)r+   )r0   r    r    r!   test_attribute_of_function_call  s   z1ScopeProviderTest.test_attribute_of_function_callc                 C   s&   t d\}}|| }| d|j d S )Nzfoo[0].bar.baz()r5   )r+   assertInrX   r0   r1   r2   r-  r    r    r!   "test_attribute_of_subscript_called  s   z4ScopeProviderTest.test_attribute_of_subscript_calledc                 C   s:   t t}t|  W d    d S 1 sw   Y  d S r$   )open__file__r+   read)r0   r   r    r    r!   	test_self  s   
"zScopeProviderTest.test_selfc                 C   sd   t d\}}|jd }|| }t|j}t|j}|d | t|j| | t|j| d S )Nz?
                import a
                import b
            r   r  )r+   rE   rB   r3  rX   r  r.   )r0   r1   r2   rk   r-  assignments_beforeaccesses_beforer    r    r!   )test_get_qualified_names_for_is_read_only  s   



z;ScopeProviderTest.test_get_qualified_names_for_is_read_onlyc              
   C   s   dd t tjddD }| |dh dd t tjtjddtjdddD }| |ddh d	d t tjtjtjtjtjddtjdddtjd
ddg dtjdddD }| |h d d S )Nc                 S      h | ]\}}|qS r    r    r<   rx   r:   r    r    r!   r>     s    z:ScopeProviderTest.test_gen_dotted_names.<locals>.<setcomp>rk   r  c                 S   r  r    r    r  r    r    r!   r>         r   )rH   r   rl   c                 S   r  r    r    r  r    r    r!   r>     r  r   )r   rJ   r   >   rk   rl   rm   )r
   r%   r  r.   r   rI   )r0   ru   r    r    r!   test_gen_dotted_names  s2   

	z'ScopeProviderTest.test_gen_dotted_namesc                 C   sr  t d\}}|| }tt|jd tjjd tj}t|jd }t|tj	j
s*J | |j| |j}| t|d dd |D }t|jd tj}tt|jjd tjjd tj}	| |	j| tt|jjd tjjd tj}
| |
j| t||	 j}| t|d | |
jd jdd	 |D  tt|jjd tjjd tj}| |jd
d	 |D  d S )Nz
            from a import b
            class X:
                x = b
                b = b
                y = b
            r   r7   c                 S   r8   r    r9   )r<   r   r    r    r!   r>   =  r?   z2ScopeProviderTest.test_ordering.<locals>.<setcomp>r6   r@   c                 S   s(   g | ]}|j D ]
}t|tr|jqqS r    )rZ   r[   r   r:   )r<   accrefr    r    r!   r2  N  s    z3ScopeProviderTest.test_ordering.<locals>.<listcomp>c                 S      g | ]}|j qS r    r9   r;   r    r    r!   r2  Y  r?   )r+   r   rE   r%   rF   rY   rB   r3  r[   metadatar   r.   r:   rD   rC   r   r   r  rH   rX   r   r   )r0   r1   r2   r3   r&  first_assignmentglobal_refsglobal_refs_nodes	class_defr   class_bclass_accessesr   r    r    r!   test_ordering*  sJ   	
	zScopeProviderTest.test_orderingc                 C   s  t d\}}t|jd tj}|jjd j}t|| d d }t|j}ttt|jjd tj	jd tj
jtj}ttt|jjd tj	jd tj
jtj}| |jd j|d j tt|jd tj	jd tjjd j}	t||	 d d }
t|
j}| |g  tt|jd tj	jd tjjd j}t|| d d }t|j}| t|d | |d j|jd j d S )Nzy
            def f(a):
                print(a)
                print(b)
            a = 1
            b = 1
            r   rk   r6   r7   r   )r+   r%   r   rE   rK   r   rx   rB   rD   rF   rG   rH   rI   r.   rJ   r:   r   r   r   rC   )r0   r1   r2   r   a_parama_param_assignmenta_param_refsfirst_printsecond_printa_globala_global_assignmenta_global_refsb_globalb_global_assignmentb_global_refsr    r    r!   test_ordering_between_scopes[  s`   	



z.ScopeProviderTest.test_ordering_between_scopesc                 C   sd  t d\}}t|jd tj}|jjd j}t|| d d }t|j}| 	|g  ttt|jjd tj
jd tjjtj}t||j d d }| 	t|jd | |jdd |jD  ttt|jjd tj
jd tjjtj}	t||	j d d }
| 	t|
jd t||	j d d }| 	t|jd ttt|jjd tj
jd tjjtj}t||j d }| 	t|d t||j jd }| 	|j|j | 	t|jd |jj}| | |r| |jd	d
 |jD  tt|jd tj
jd tjjd j}t|| d d }t|j}| 	|g  d S )Nz
            def f(a):
                [a for a in [] for b in a]
                [b for a in [] for b in a]
                [a for a in [] for a in []]
            a = 1
            r   rk   r7   c                 S   r  r    r9   r<   r  r    r    r!   r2    r?   zAScopeProviderTest.test_ordering_comprehension.<locals>.<listcomp>r6   r   c                 S   s   h | ]
}t |tr|jqS r    )r[   r   r:   r  r    r    r!   r>     s    z@ScopeProviderTest.test_ordering_comprehension.<locals>.<setcomp>)r+   r%   r   rE   rK   r   rx   rB   rD   r.   rF   rG   rH   r   r   rC   r  rX   r:   rZ   r   r   assertIsNotNoner   r   r   )r0   r1   r2   r   r  r  r  
first_compa_comp_assignmentsecond_compb_comp_assignmenta_second_comp_assignment
third_compa_third_comp_assignmentsa_third_comp_accessr   r  r  r  r    r    r!   test_ordering_comprehension  s   	



z-ScopeProviderTest.test_ordering_comprehensionc           	      C   s   t d\}}t|jd tj}|jjd j}t|| d d }t|j}| 	t
|d ttt|jjd tjjd tjjtj}t||j d d }| 	t|d j|jj | 	t
|jd | 	t|jd j|j d S )NzT
            def f(a):
                [a for a in a]
            a = 1
            r   rk   r6   )r+   r%   r   rE   rK   r   rx   rB   rD   r.   rC   rF   rG   rH   r   r   r:   r   r   )	r0   r1   r2   r   r  r  r  compr  r    r    r!   %test_ordering_comprehension_confusing  s(   
z7ScopeProviderTest.test_ordering_comprehension_confusingc                 C   H   t d\}}| D ]}|jD ]}| jt|jdd|j  d qq
d S )Nz
            def f():
                for x in []:
                    x
            class X:
                def f():
                    for x in []:
                        x
            r6   3Access for node has incorrect number of referents: msgr+   r6  rX   r.   rC   rZ   r:   r0   r1   r2   r-  r  r    r    r!   test_for_scope_ordering  s   
z)ScopeProviderTest.test_for_scope_orderingc                 C   r  )Nz1
            x = y
            y = 1
            r   r  r  r  r  r    r    r!   /test_no_out_of_order_references_in_global_scope  s   
zAScopeProviderTest.test_no_out_of_order_references_in_global_scopec                 C   sr   t jdk r
| d td\}}| D ]"}|jD ]}| jt|jt	|j
dd dkr,dndd|j
  d	 qqd S )
N)r@      z&This python version doesn't support :=zL
            if x := y:
                y = 1
                x
            rH   r   r6   r   r  r  )sysversion_infoskipTestr+   r6  rX   r.   rC   rZ   getattrr:   r  r    r    r!   test_walrus_accesses   s    


z&ScopeProviderTest.test_walrus_accesseszk
                    from typing import TypeVar
                    TypeVar("Name", "int")
                r	  )r   callszd
                    from typing import Dict
                    Dict["str", "int"]
                strzy
                    from typing import Dict, cast
                    cast(Dict[str, str], {})["3rr0r"]
                zb
                    from typing import cast
                    cast(str, "foo")
                zd
                    from typing import cast
                    cast("int", "foo")
                zq
                    from typing import TypeVar
                    TypeVar("Name", func("int"))
                za
                    from typing import Literal
                    Literal["G"]
                z
                    from typing import TypeVar, Optional
                    from a import G
                    TypeVar("G2", bound="Optional[\"G\"]")
                zOptional["G"]rO  z
                    from typing import TypeVar
                    class HelperClass:
                        value: TypeVar("THelperClass", bound="HelperClass")
                HelperClass)	TypeVarDictcast_no_annotationcast_second_argcast_first_argtypevar_funcliteral
nested_strclass_self_refr   r  c                C   s|   t j}td,}||_tt| tt|gt| }| 	|j
t| || W d    d S 1 s7w   Y  d S )Nzlibcst.parse_module)r%   r&   r   patchside_effectr+   r   r   rB   r.   
call_countrC   assert_has_calls)r0   r   r  parse
parse_mockr    r    r!   test_parse_string_annotations5  s   J"z/ScopeProviderTest.test_parse_string_annotationsc                 C   s  t d\}}|| }| |t | t|d d t|d d }| |t | |jt |d }| t|d t|d }| |t	 t
|jd tjj}|jd }|| }	| |	t |	d }
| t|
d t|
d }| |t	 t|j}| t|d d S )Nz\
            a = pow(1, 2)
            def foo():
                b = pow(2, 3)
            powr6   r   rk   r   r7   )r+   rA   r   r.   rC   rB   r   r-  r   r   r   rE   r%   rK   r   rD   )r0   r1   r2   rM   builtin_pow_assignmentglobal_a_assignmentsa_assignmentrR   func_statementrT   func_b_assignmentsb_assignmentbuiltin_pow_accessesr    r    r!   test_builtin_scope  s.   

z$ScopeProviderTest.test_builtin_scopec                 C   s  t d\}}|| }| |t | t|d d t|d d }| |t | |jt |d }| t|d t|d }| |t t|j	d t
jj	}|j	d }|| }	| |	t |	d }
| t|
d t|
d }| |t t|j}| t|d d S )Nz
            def pow(x, y):
                return x ** y

            a = pow(1, 2)
            def foo():
                b = pow(2, 3)
            r  r6   r   rk   r7   r   )r+   rA   r   r.   rC   rB   r   r-  r   rE   r%   rK   r   rD   )r0   r1   r2   rM   global_pow_assignmentr  r  rR   r  rT   r  r  global_pow_accessesr    r    r!   test_override_builtin_scope  s.   


z-ScopeProviderTest.test_override_builtin_scopec                 C   s   t d\}}tt|jd tjjd tj}|| }t|d d }| |t | 	t
|jd t|j}| |d j d S )Nz
                from typing import TypeVar
                class Test:
                    var: TypeVar("T", bound="Test")
            r   Testr6   )r+   r   rE   r%   rF   rY   rB   rA   r   r.   rC   rD   ry   rX  )r0   r1   r2   r\  r-  r   rD   r    r    r!   'test_annotation_access_in_typevar_bound  s   
z9ScopeProviderTest.test_annotation_access_in_typevar_boundc                 C   sV   t d\}}|| }| |tdtdtjdh | |tdt  dS )z.Verify that a name doesn't overmatch on prefixzF
                def something():
                    ...
            	somethingr*  something_elseN)	r+   r.   r  r%   r  r   r   r  r/   r  r    r    r!   test_prefix_match  s   z#ScopeProviderTest.test_prefix_matchc                 C   s   t d\}}tt|jd tjjd tj}| || t t|| d }| 	t
|d tt|jd tjjd tj}| 	t
t|d j }d | 	|d j|jj | ||j t d S )Nz?
                type A = C
                lol: A
            r   rG  r6   )r+   r   rE   r%   rF   	TypeAliasrA   r   rB   r.   rC   	AnnAssignrD   r:   r   rH   r   )r0   r1   r2   r   a_assignmentsr  a_referencesr    r    r!   test_type_alias_scope  s   z'ScopeProviderTest.test_type_alias_scopec           	      C   s   t d\}}tt|jd tjjd tj}|jsJ ||j }| tt	|d  }d | tt	|d j
 }d | |d j|j tt|jd tjjd tjjd j}t	|| d d }| dd |j
D t|jjd jtjjh d S )Nz]
                B = int
                type A[T: B] = T
                lol: T
            r6   r   TrH  c                 S   r8   r    r9   r  r    r    r!   r>     r?   z:ScopeProviderTest.test_type_alias_param.<locals>.<setcomp>)r+   r   rE   r%   rF   r  type_parametersr.   rC   rB   rD   r:   rH   r   r   r   r   paramr  rb  )	r0   r1   r2   r   param_scopet_assignmentst_refsr   r  r    r    r!   test_type_alias_param  s.   

z'ScopeProviderTest.test_type_alias_paramc                 C   s  t d\}}tt|jd tjjd tj}|jsJ ||j }| tt	|d  }d | tt	|d j
 }d | |d j|j tt|jd tjjd tj}|js\J ||j }| tt	|d  }d | tt	|d j
 }d | |d j|j d S )Nzj
            type A[*T] = T
            lol: T
            type A[**T] = T
            lol: T
            r   r  r6   r7   )r+   r   rE   r%   rF   r  r  r.   rC   rB   rD   r:   rH   )r0   r1   r2   alias_tupler  r  r  alias_paramspecr    r    r!   #test_type_alias_tuple_and_paramspec!  s&   



z5ScopeProviderTest.test_type_alias_tuple_and_paramspecc                 C   sl  t d\}}t|jd tj}||jjd  }| tt|d  }d |js*J | t|d t	j
|jjd j | tt|d j }d t|jjd tj}|jsYJ | |d j
|jj t|jjd tj}|jssJ |jsxJ | tt||j d  }	d | t|	d t	j
|jjd j | tt|	d j }
d | |
d j
|jj d S )Nzn
            class W[T]:
                def f() -> T: pass
                def g[T]() -> T: pass
            r   r  r6   )r+   r   rE   r%   r   r.   rC   rB   r  r   r:   r   r  rD   rK   r   r   )r0   r1   r2   r   	cls_scopet_assignments_in_clst_refs_in_clsr   rn   t_assignments_in_gt_refs_in_gr    r    r!   test_class_type_params<  s6   



"z(ScopeProviderTest.test_class_type_paramsc                 C   s   t d\}}t|jd tj}tt|| d d j}| t|d t|jjd tj}|j	s3J | |d j
t|j	jd jtjj d S )NzS
            class Outer:
                class Nested[T: Outer]: pass
            r   Outerr6   )r+   r   rE   r%   r   rB   rD   r.   rC   r  r:   r   r  r  rb  )r0   r1   r2   outer
outer_refsinnerr    r    r!   test_nested_class_type_params^  s   
z/ScopeProviderTest.test_nested_class_type_paramsc                 C   s  t d\}}t|jd tj}t|jjd tj}tt|jjd tjjd tj}| ||j t	 t
||j jd }| t|d | dd |d jD |h t|jjd tj}| || t |jskJ t|jjd jtj}|| }	| |	t	 t
|	jd }
| t|
d | dd |
d jD |h t|jjd	 tj}|jjd j}|sJ t
|| jd }| t|d | d
d |d jD |h d S )Na  
                class Outer:
                    class Nested:
                        pass
                    
                    type Alias = Nested

                    def meth1[T: Nested](self): pass
                    def meth2[T](self, arg: Nested): pass
            r   r6   Nestedc                 S      h | ]}t |tjqS r    r   r   r:   r  r    r    r!   r>     r   zKScopeProviderTest.test_annotation_refers_to_nested_class.<locals>.<setcomp>r7   c                 S   r  r    r  r  r    r    r!   r>     r   r@   c                 S   r  r    r  r  r    r    r!   r>     r   )r+   r   rE   r%   r   rF   r  rA   rH   r   rB   rX   r.   rC   rZ   rK   r   r  r   r  r  r   )r0   r1   r2   r  nestedr   nested_refs_within_aliasmeth1meth1_typevarmeth1_typevar_scopenested_refs_within_meth1meth2meth2_annotationnested_refs_within_meth2r    r    r!   &test_annotation_refers_to_nested_classo  sV   
z8ScopeProviderTest.test_annotation_refers_to_nested_classc           
      C   s   t d\}}t|jd tj}||jjd  }t|d d }| t|jd t|jjd tj	}|j
s7J t|j
jd jtj}| t|jd j|j t|jjd tj}|| }	| |j|	j | t|	jd jt  d S )Nzu
            class Outer:
                class Inner: pass
                def f[T: Inner](self): Inner
            r   Innerr6   )r+   r   rE   r%   r   rB   r.   rC   rD   rK   r  r   r  r  r   r:   rb  rG   r  rH   rX   rZ   r/   )
r0   r1   r2   r  outer_scopeinner_assignmentr   r  inner_in_func_bodyf_scoper    r    r!   1test_body_isnt_subject_to_special_annotation_rule  s   
zCScopeProviderTest.test_body_isnt_subject_to_special_annotation_rule)r#   N)Er   r   r   r4   rW   r_   r   r  rh   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r#  r%  r)  r.  rF  r^  rc  re  rk  rq  r}  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   _Callr  r  r  r  r  r  r  r  r  r
  r  r  r    r    r    r!   r,   3   s    

	
;

;
 


#
@

%
J

 
O

9
3


S
@

*

` 




!
4
	







1
6
M




	
G

 
#





"
;r,   ))r  textwrapr   typingr   r   r   r   rl  r   libcstr%   r   libcst.metadatar	   libcst.metadata.scope_providerr
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   libcst.testing.utilsr   r   
CSTVisitorr   r  Moduler(   r+   r,   r    r    r    r!   <module>   s    D
