
    g                         d Z ddlmZ ddlmZ ddlmZmZm	Z	  G d de      Z
 G d de      Z G d	 d
e      Z G d de      Z G d de      Zy)z&
Tests for various Pyflakes behavior.
    )version_info)messages)TestCaseskipskipIfc                   `   e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d  Z"d! Z#d" Z$d# Z%d$ Z&d% Z'd& Z(d' Z) e*d(      d)        Z+d* Z,d+ Z-d, Z.d- Z/d. Z0d/ Z1d0 Z2d1 Z3d2 Z4d3 Z5d4 Z6d5 Z7d6 Z8y7)8Testc                 D    | j                  dt        j                         y )Nzdef fu(bar, bar): pass)flakesmDuplicateArgumentselfs    [/var/www/html/brdwt/brdwt/brdwtenv/lib/python3.12/site-packages/pyflakes/test/test_other.pytest_duplicateArgszTest.test_duplicateArgs   s    ,a.A.AB    c                 b    | j                  dt        j                  t        j                         y )NzG
        a = 1
        def f():
            a; a=1
        f()
        )r   r   UndefinedLocalUnusedVariabler   s    r   $test_localReferencedBeforeAssignmentz)Test.test_localReferencedBeforeAssignment   s&     
 q//	1r   c                     | j                  d       | j                  d       | j                  dt        j                         | j                  d       | j                  d       y)z_
        Test that reusing a variable in a generator does not raise
        a warning.
        z8
        a = 1
        (1 for a, b in [(1, 2)])
        zU
        class A:
            a = 1
            list(1 for a, b in [(1, 2)])
        zQ
        def f():
            a = 1
            (1 for a, b in [(1, 2)])
        zK
        (1 for a, b in [(1, 2)])
        (1 for a, b in [(1, 2)])
        zY
        for a, b in [(1, 2)]:
            pass
        (1 for a, b in [(1, 2)])
        Nr   r   r   r   s    r   test_redefinedInGeneratorzTest.test_redefinedInGenerator   l    
 	  	 	  	
 	  		
 	  	 	  	r   c                     | j                  d       | j                  d       | j                  dt        j                         | j                  d       | j                  d       y)zg
        Test that reusing a variable in a set comprehension does not raise
        a warning.
        z8
        a = 1
        {1 for a, b in [(1, 2)]}
        zQ
        class A:
            a = 1
            {1 for a, b in [(1, 2)]}
        zQ
        def f():
            a = 1
            {1 for a, b in [(1, 2)]}
        zK
        {1 for a, b in [(1, 2)]}
        {1 for a, b in [(1, 2)]}
        zY
        for a, b in [(1, 2)]:
            pass
        {1 for a, b in [(1, 2)]}
        Nr   r   s    r    test_redefinedInSetComprehensionz%Test.test_redefinedInSetComprehension5   r   r   c                     | j                  d       | j                  d       | j                  dt        j                         | j                  d       | j                  d       y)zh
        Test that reusing a variable in a dict comprehension does not raise
        a warning.
        z<
        a = 1
        {1: 42 for a, b in [(1, 2)]}
        zU
        class A:
            a = 1
            {1: 42 for a, b in [(1, 2)]}
        zU
        def f():
            a = 1
            {1: 42 for a, b in [(1, 2)]}
        zS
        {1: 42 for a, b in [(1, 2)]}
        {1: 42 for a, b in [(1, 2)]}
        z]
        for a, b in [(1, 2)]:
            pass
        {1: 42 for a, b in [(1, 2)]}
        Nr   r   s    r   !test_redefinedInDictComprehensionz&Test.test_redefinedInDictComprehensionR   r   r   c                 D    | j                  dt        j                         y)zf
        Test that shadowing a function definition with another one raises a
        warning.
        z5
        def a(): pass
        def a(): pass
        Nr   r   RedefinedWhileUnusedr   s    r   test_redefinedFunctionzTest.test_redefinedFunctiono   s     
 	  ##	%r   c                 D    | j                  dt        j                         y )Nz-
        x = 1
        def x(): pass
        r    r   s    r   (test_redefined_function_shadows_variablez-Test.test_redefined_function_shadows_variabley   s      ##	%r   c                 &    | j                  d       y)zq
        Test that shadowing a function definition named with underscore doesn't
        raise anything.
        z5
        def _(): pass
        def _(): pass
        Nr   r   s    r    test_redefinedUnderscoreFunctionz%Test.test_redefinedUnderscoreFunction       
 	  	r   c                 D    | j                  dt        j                         y)zQ
        Test that shadowing an underscore importation raises a warning.
        z;
        from .i18n import _
        def _(): pass
        Nr    r   s    r   #test_redefinedUnderscoreImportationz(Test.test_redefinedUnderscoreImportation         	  ##	%r   c                 D    | j                  dt        j                         y)zw
        Test that shadowing a function definition in a class suite with another
        one raises a warning.
        zN
        class A:
            def a(): pass
            def a(): pass
        Nr    r   s    r   test_redefinedClassFunctionz Test.test_redefinedClassFunction        
 	  ##		%r   c                 &    | j                  d       y)z{
        Test that shadowing a function definition twice in an if
        and else block does not raise a warning.
        z\
        if True:
            def a(): pass
        else:
            def a(): pass
        Nr&   r   s    r   test_redefinedIfElseFunctionz!Test.test_redefinedIfElseFunction       
 	  	r   c                 D    | j                  dt        j                         y)zh
        Test that shadowing a function definition within an if block
        raises a warning.
        zN
        if True:
            def a(): pass
            def a(): pass
        Nr    r   s    r   test_redefinedIfFunctionzTest.test_redefinedIfFunction   r.   r   c                 &    | j                  d       y)z{
        Test that shadowing a function definition twice in try
        and except block does not raise a warning.
        zZ
        try:
            def a(): pass
        except:
            def a(): pass
        Nr&   r   s    r   test_redefinedTryExceptFunctionz$Test.test_redefinedTryExceptFunction   r1   r   c                 D    | j                  dt        j                         y)zh
        Test that shadowing a function definition within a try block
        raises a warning.
        zk
        try:
            def a(): pass
            def a(): pass
        except:
            pass
        Nr    r   s    r   test_redefinedTryFunctionzTest.test_redefinedTryFunction   s     
 	  ##	%r   c                 &    | j                  d       y)z
        Test that shadowing a variable in a list comprehension in
        an if and else block does not raise a warning.
        zY
        if False:
            a = 1
        else:
            [a for a in '12']
        Nr&   r   s    r   test_redefinedIfElseInListCompz#Test.test_redefinedIfElseInListComp   r1   r   c                 &    | j                  d       y)z
        Test that shadowing a function definition with a decorated version of
        that function does not raise a warning.
        zi
        from somewhere import somedecorator

        def a(): pass
        a = somedecorator(a)
        Nr&   r   s    r   test_functionDecoratorzTest.test_functionDecorator   r1   r   c                 &    | j                  d       y)z
        Test that shadowing a function definition in a class suite with a
        decorated version of that function does not raise a warning.
        zS
        class A:
            def a(): pass
            a = classmethod(a)
        Nr&   r   s    r   test_classFunctionDecoratorz Test.test_classFunctionDecorator       
 	  	r   c                 &    | j                  d       y )Nz
        class A:
            @property
            def t(self):
                pass
            @t.setter
            def t(self, value):
                pass
            @t.deleter
            def t(self):
                pass
        r&   r   s    r   test_modernPropertyzTest.test_modernProperty   s      	r   c                 &    | j                  d       y)zDon't die on unary +.z+1Nr&   r   s    r   test_unaryPluszTest.test_unaryPlus   s    Dr   c                 D    | j                  dt        j                         y)zn
        If a name in the base list of a class definition is undefined, a
        warning is emitted.
        z2
        class foo(foo):
            pass
        Nr   r   UndefinedNamer   s    r   test_undefinedBaseClasszTest.test_undefinedBaseClass      
 	  __	r   c                 D    | j                  dt        j                         y)z
        If a class name is used in the body of that class's definition and
        the name is not already defined, a warning is emitted.
        z,
        class foo:
            foo
        NrD   r   s    r   "test_classNameUndefinedInClassBodyz'Test.test_classNameUndefinedInClassBody  rG   r   c                 &    | j                  d       y)z
        If a class name is used in the body of that class's definition and
        the name was previously defined in some other way, no warning is
        emitted.
        z?
        foo = None
        class foo:
            foo
        Nr&   r   s    r   test_classNameDefinedPreviouslyz$Test.test_classNameDefinedPreviously  s     	  	r   c                 D    | j                  dt        j                         y)zW
        If a class is defined twice in the same module, a warning is emitted.
        zQ
        class Foo:
            pass
        class Foo:
            pass
        Nr    r   s    r   test_classRedefinitionzTest.test_classRedefinition"        	 
 ##	%r   c                 D    | j                  dt        j                         y)zN
        If a function is redefined as a class, a warning is emitted.
        zQ
        def Foo():
            pass
        class Foo:
            pass
        Nr    r   s    r   test_functionRedefinedAsClassz"Test.test_functionRedefinedAsClass-  rN   r   c                 D    | j                  dt        j                         y)zN
        If a class is redefined as a function, a warning is emitted.
        zQ
        class Foo:
            pass
        def Foo():
            pass
        Nr    r   s    r   test_classRedefinedAsFunctionz"Test.test_classRedefinedAsFunction8  rN   r   c                 D    | j                  dt        j                         y)zK
        If a return is used inside a class, a warning is emitted.
        z7
        class Foo(object):
            return
        Nr   r   ReturnOutsideFunctionr   s    r   test_classWithReturnzTest.test_classWithReturnC  s      	  $$	&r   c                 D    | j                  dt        j                         y)zP
        If a return is used at the module level, a warning is emitted.
        z
        return
        NrT   r   s    r   test_moduleWithReturnzTest.test_moduleWithReturnL  s     	 $$	&r   c                 D    | j                  dt        j                         y)zJ
        If a yield is used inside a class, a warning is emitted.
        z6
        class Foo(object):
            yield
        Nr   r   YieldOutsideFunctionr   s    r   test_classWithYieldzTest.test_classWithYieldT  r+   r   c                 D    | j                  dt        j                         y)zO
        If a yield is used at the module level, a warning is emitted.
        z
        yield
        NrZ   r   s    r   test_moduleWithYieldzTest.test_moduleWithYield]       	 ##	%r   c                 D    | j                  dt        j                         y)zO
        If a yield from is used inside a class, a warning is emitted.
        zE
        class Foo(object):
            yield from range(10)
        NrZ   r   s    r   test_classWithYieldFromzTest.test_classWithYieldFrome  r+   r   c                 D    | j                  dt        j                         y)zT
        If a yield from is used at the module level, a warning is emitted.
        z&
        yield from range(10)
        NrZ   r   s    r   test_moduleWithYieldFromzTest.test_moduleWithYieldFromn  r_   r   c                    | j                  dt        j                         | j                  dt        j                         | j                  dt        j                         | j                  dt        j                         | j                  dt        j                         | j                  dt        j                         y )Nz
        continue
        z/
        def f():
            continue
        zQ
        while True:
            pass
        else:
            continue
        z
        while True:
            pass
        else:
            if 1:
                if 2:
                    continue
        zK
        while True:
            def f():
                continue
        zK
        while True:
            class A:
                continue
        )r   r   ContinueOutsideLoopr   s    r   test_continueOutsideLoopzTest.test_continueOutsideLoopv  s     ""	$ 	  ""	$
 	 
 ""	$ 	  ""	$ 	  ""		$ 	  ""		$r   c                     | j                  d       | j                  d       | j                  d       | j                  d       | j                  d       | j                  d       y )Nz2
        while True:
            continue
        z:
        for i in range(10):
            continue
        zH
        while True:
            if 1:
                continue
        zP
        for i in range(10):
            if 1:
                continue
        z
        while True:
            while True:
                pass
            else:
                continue
        else:
            pass
        z
        while True:
            try:
                pass
            finally:
                while True:
                    continue
        r&   r   s    r   test_continueInsideLoopzTest.test_continueInsideLoop  sr      	
 	  	
 	  	 	  	 	  	 	  	r   c                    | j                  dt        j                         | j                  dt        j                         | j                  dt        j                         | j                  dt        j                         | j                  dt        j                         | j                  dt        j                         | j                  dt        j                         y )Nz
        break
        z,
        def f():
            break
        zN
        while True:
            pass
        else:
            break
        z~
        while True:
            pass
        else:
            if 1:
                if 2:
                    break
        zH
        while True:
            def f():
                break
        zH
        while True:
            class A:
                break
        zJ
        try:
            pass
        finally:
            break
        )r   r   BreakOutsideLoopr   s    r   test_breakOutsideLoopzTest.test_breakOutsideLoop  s     	! 	  	!
 	 
 	! 	  	! 	  		! 	  		! 	 
 	!r   c                    | j                  d       | j                  d       | j                  d       | j                  d       | j                  d       | j                  d       | j                  d       | j                  d       y )	Nz/
        while True:
            break
        z7
        for i in range(10):
            break
        zE
        while True:
            if 1:
                break
        zM
        for i in range(10):
            if 1:
                break
        z
        while True:
            while True:
                pass
            else:
                break
        else:
            pass
        z
        while True:
            try:
                pass
            finally:
                while True:
                    break
        zn
        while True:
            try:
                pass
            finally:
                break
        z
        while True:
            try:
                pass
            finally:
                if 1:
                    if 2:
                        break
        r&   r   s    r   test_breakInsideLoopzTest.test_breakInsideLoop  s      	
 	  	
 	  	 	  	 	  	 	  	 	  	 	  	r   c                     | j                  d       | j                  d       | j                  d       | j                  d       | j                  d       | j                  d       y)a#  
        A default except block should be last.

        YES:

        try:
            ...
        except Exception:
            ...
        except:
            ...

        NO:

        try:
            ...
        except:
            ...
        except Exception:
            ...
        zS
        try:
            pass
        except ValueError:
            pass
        zt
        try:
            pass
        except ValueError:
            pass
        except:
            pass
        zH
        try:
            pass
        except:
            pass
        zr
        try:
            pass
        except ValueError:
            pass
        else:
            pass
        zg
        try:
            pass
        except:
            pass
        else:
            pass
        z
        try:
            pass
        except ValueError:
            pass
        except:
            pass
        else:
            pass
        Nr&   r   s    r   test_defaultExceptLastzTest.test_defaultExceptLast/  st    , 	  	 	  	 	  	 	  	 	  	 	 	 		r   c                 |   | j                  dt        j                         | j                  dt        j                         | j                  dt        j                         | j                  dt        j                  t        j                         | j                  dt        j                         | j                  dt        j                         | j                  dt        j                         | j                  dt        j                  t        j                         | j                  d	t        j                         | j                  d
t        j                         | j                  dt        j                         | j                  dt        j                  t        j                         | j                  dt        j                         | j                  dt        j                         | j                  dt        j                         | j                  dt        j                  t        j                         y )Nzt
        try:
            pass
        except:
            pass
        except ValueError:
            pass
        zi
        try:
            pass
        except:
            pass
        except:
            pass
        z
        try:
            pass
        except:
            pass
        except ValueError:
            pass
        except:
            pass
        z
        try:
            pass
        except:
            pass
        except ValueError:
            pass
        except:
            pass
        except ValueError:
            pass
        z
        try:
            pass
        except:
            pass
        except ValueError:
            pass
        else:
            pass
        z
        try:
            pass
        except:
            pass
        except:
            pass
        else:
            pass
        z
        try:
            pass
        except:
            pass
        except ValueError:
            pass
        except:
            pass
        else:
            pass
        z
        try:
            pass
        except:
            pass
        except ValueError:
            pass
        except:
            pass
        except ValueError:
            pass
        else:
            pass
        z
        try:
            pass
        except:
            pass
        except ValueError:
            pass
        finally:
            pass
        z
        try:
            pass
        except:
            pass
        except:
            pass
        finally:
            pass
        z
        try:
            pass
        except:
            pass
        except ValueError:
            pass
        except:
            pass
        finally:
            pass
        z
        try:
            pass
        except:
            pass
        except ValueError:
            pass
        except:
            pass
        except ValueError:
            pass
        finally:
            pass
        z
        try:
            pass
        except:
            pass
        except ValueError:
            pass
        else:
            pass
        finally:
            pass
        z
        try:
            pass
        except:
            pass
        except:
            pass
        else:
            pass
        finally:
            pass
        z
        try:
            pass
        except:
            pass
        except ValueError:
            pass
        except:
            pass
        else:
            pass
        finally:
            pass
        a  
        try:
            pass
        except:
            pass
        except ValueError:
            pass
        except:
            pass
        except ValueError:
            pass
        else:
            pass
        finally:
            pass
        )r   r   DefaultExceptNotLastr   s    r   test_defaultExceptNotLastzTest.test_defaultExceptNotLasty  s      ##	% 	  ##	% 	 	 ##		% 	  ##Q%;%;	= 	 	 ##		% 	 	 ##		% 	  ##	% 	  ##Q%;%;	= 	 	 ##		% 	 	 ##		% 	  ##	% 	  ##Q%;%;	= 	  ##	% 	  ##	% 	  ##	% 	  ##Q%;%;	=r   c                    | j                  d       | j                  d       | j                  d       | j                  d       | j                  d       | j                  d       | j                  d       | j                  d       | j                  d	       d
j                  d t        d      D              dz   }| j                  |       dd
j                  d t        d      D              z   dz   }| j                  |       dd
j                  d t        d      D              z   dz   }| j                  |       y)z6
        Python 3 extended iterable unpacking
        z#
        a, *b = range(10)
        z#
        *a, b = range(10)
        z&
        a, *b, c = range(10)
        z%
        (a, *b) = range(10)
        z%
        (*a, b) = range(10)
        z(
        (a, *b, c) = range(10)
        z%
        [a, *b] = range(10)
        z%
        [*a, b] = range(10)
        z(
        [a, *b, c] = range(10)
        , c              3   &   K   | ]	  }d |z    ywza%dN .0is     r   	<genexpr>z5Test.test_starredAssignmentNoError.<locals>.<genexpr>k       ;Aeai;      z, *rest = range(1<<8)(c              3   &   K   | ]	  }d |z    ywrv   rw   rx   s     r   r{   z5Test.test_starredAssignmentNoError.<locals>.<genexpr>o       A!EAIAr}   z, *rest) = range(1<<8)[c              3   &   K   | ]	  }d |z    ywrv   rw   rx   s     r   r{   z5Test.test_starredAssignmentNoError.<locals>.<genexpr>s  r   r}   z, *rest] = range(1<<8)N)r   joinranger   ss     r   test_starredAssignmentNoErrorz"Test.test_starredAssignmentNoErrorB  s=    	  	 	  	 	  	 	  	 	  	 	  	 	  	 	  	 	  	
 II;z):;;#$A$))AuZ/@AAA$%A$))AuZ/@AAA$%Ar   c                    dj                  d t        d      D              dz   }| j                  |t        j                         ddj                  d t        d      D              z   dz   }| j                  |t        j                         ddj                  d	 t        d      D              z   d
z   }| j                  |t        j                         dj                  d t        d      D              dz   }| j                  |t        j                         ddj                  d t        d      D              z   dz   }| j                  |t        j                         ddj                  d t        d      D              z   dz   }| j                  |t        j                         | j                  dt        j
                         | j                  dt        j
                         | j                  dt        j
                         | j                  dt        j
                         | j                  dt        j
                         | j                  dt        j
                         | j                  dt        j
                         | j                  dt        j
                         | j                  dt        j
                         y)zp
        SyntaxErrors (not encoded in the ast) surrounding Python 3 extended
        iterable unpacking
        rt   c              3   &   K   | ]	  }d |z    ywrv   rw   rx   s     r   r{   z4Test.test_starredAssignmentErrors.<locals>.<genexpr>}  s     7Aeai7r}      z, *rest = range(1<<8 + 1)r   c              3   &   K   | ]	  }d |z    ywrv   rw   rx   s     r   r{   z4Test.test_starredAssignmentErrors.<locals>.<genexpr>       =!EAI=r}   z, *rest) = range(1<<8 + 1)r   c              3   &   K   | ]	  }d |z    ywrv   rw   rx   s     r   r{   z4Test.test_starredAssignmentErrors.<locals>.<genexpr>  r   r}   z, *rest] = range(1<<8 + 1)c              3   &   K   | ]	  }d |z    ywrv   rw   rx   s     r   r{   z4Test.test_starredAssignmentErrors.<locals>.<genexpr>  r|   r}   i   z, *rest = range(1<<8 + 2)c              3   &   K   | ]	  }d |z    ywrv   rw   rx   s     r   r{   z4Test.test_starredAssignmentErrors.<locals>.<genexpr>  r   r}   z, *rest) = range(1<<8 + 2)c              3   &   K   | ]	  }d |z    ywrv   rw   rx   s     r   r{   z4Test.test_starredAssignmentErrors.<locals>.<genexpr>  r   r}   z, *rest] = range(1<<8 + 2)z'
        a, *b, *c = range(10)
        z*
        a, *b, c, *d = range(10)
        z(
        *a, *b, *c = range(10)
        z)
        (a, *b, *c) = range(10)
        z,
        (a, *b, c, *d) = range(10)
        z*
        (*a, *b, *c) = range(10)
        z)
        [a, *b, *c] = range(10)
        z,
        [a, *b, c, *d] = range(10)
        z*
        [*a, *b, *c] = range(10)
        N)r   r   r   r   %TooManyExpressionsInStarredAssignmentTwoStarredExpressionsr   s     r   test_starredAssignmentErrorsz!Test.test_starredAssignmentErrorsw  sO    II7v77'(Aq>>?$))=uV}===()Aq>>?$))=uV}===()Aq>>?II;z):;;'(Aq>>?$))AuZ/@AAA()Aq>>?$))AuZ/@AAA()Aq>>? 	 $$	& 	 $$	& 	 $$	& 	 $$	& 	 $$	& 	 $$	& 	 $$	& 	 $$	& 	 $$	&r   z<todo: Too hard to make this warn but other cases stay silentc                 D    | j                  dt        j                         y)zd
        If a variable is re-assigned to without being used, no warning is
        emitted.
        z'
        x = 10
        x = 20
        Nr    r   s    r   test_doubleAssignmentzTest.test_doubleAssignment  s      	  ##	%r   c                 &    | j                  d       y)zc
        If a variable is re-assigned within a conditional, no warning is
        emitted.
        z<
        x = 10
        if True:
            x = 20
        Nr&   r   s    r   "test_doubleAssignmentConditionallyz'Test.test_doubleAssignmentConditionally  r>   r   c                 &    | j                  d       y)zb
        If a variable is re-assigned to after being used, no warning is
        emitted.
        z9
        x = 10
        y = x * 2
        x = 20
        Nr&   r   s    r   test_doubleAssignmentWithUsez!Test.test_doubleAssignmentWithUse  r>   r   c                 &    | j                  d       y)z
        If a defined name is used on either side of any of the six comparison
        operators, no warning is emitted.
        z
        x = 10
        y = 20
        x < y
        x <= y
        x == y
        x != y
        x >= y
        x > y
        Nr&   r   s    r   test_comparisonzTest.test_comparison  s    
 	 	 		r   c                 &    | j                  d       y)zn
        If a defined name is used on either side of an identity test, no
        warning is emitted.
        zI
        x = 10
        y = 20
        x is y
        x is not y
        Nr&   r   s    r   test_identityzTest.test_identity  r1   r   c                 &    | j                  d       y)zp
        If a defined name is used on either side of a containment test, no
        warning is emitted.
        zI
        x = 10
        y = 20
        x in y
        x not in y
        Nr&   r   s    r   test_containmentzTest.test_containment  r1   r   c                 H    | j                  d       | j                  d       y)z>
        break and continue statements are supported.
        z4
        for x in [1, 2]:
            break
        z7
        for x in [1, 2]:
            continue
        Nr&   r   s    r   test_loopControlzTest.test_loopControl  s(     	  	 	  	r   c                 &    | j                  d       y)z3
        Ellipsis in a slice is supported.
        z
        [1, 2][...]
        Nr&   r   s    r   test_ellipsiszTest.test_ellipsis       	  	r   c                 &    | j                  d       y)z0
        Extended slices are supported.
        z+
        x = 3
        [1, 2][x,:]
        Nr&   r   s    r   test_extendedSlicezTest.test_extendedSlice       	  	r   c                 &    | j                  d       y)zh
        Augmented assignment of a variable is supported.
        We don't care about var refs.
        z*
        foo = 0
        foo += 1
        Nr&   r   s    r   test_varAugmentedAssignmentz Test.test_varAugmentedAssignment%  r(   r   c                 &    | j                  d       y)zi
        Augmented assignment of attributes is supported.
        We don't care about attr refs.
        z7
        foo = None
        foo.bar += foo.baz
        Nr&   r   s    r   test_attrAugmentedAssignmentz!Test.test_attrAugmentedAssignment/  r(   r   c                 &    | j                  d       y)zP
        A 'global' can be declared in one scope and reused in another.
        zV
        def f(): global foo
        def g(): foo = 'anything'; foo.is_used()
        Nr&   r   s    r   #test_globalDeclaredInDifferentScopez(Test.test_globalDeclaredInDifferentScope9  r   r   c                     | j                  d       | j                  d       | j                  d       | j                  d       y)z;
        Test to traverse ARG and ARGUMENT handler
        z1
        def foo(a, b):
            pass
        z6
        def foo(a, b, c=0):
            pass
        z=
        def foo(a, b, c=0, *args):
            pass
        zG
        def foo(a, b, c=0, *args, **kwargs):
            pass
        Nr&   r   s    r   test_function_argumentszTest.test_function_argumentsB  sN     	  	
 	  	
 	  	
 	  	r   c                 &    | j                  d       y )NzL
        def foo(a, b, c=0, *args, d=0, **kwargs):
            pass
        r&   r   s    r   test_function_arguments_python3z$Test.test_function_arguments_python3Z        	r   N)9__name__
__module____qualname__r   r   r   r   r   r"   r$   r'   r*   r-   r0   r3   r5   r7   r9   r;   r=   r@   rB   rF   rI   rK   rM   rP   rR   rV   rX   r\   r^   ra   rc   rf   rh   rk   rm   ro   rr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rw   r   r   r	   r	      s-   C1:::%%%	%
	%
%

	
	%	%	%&&%%%%$$L(T+!Z:xHTG=R3jE&N 

HI% J%		 

0r   r	   c                      e Zd ZdZd Zd Zd Zd Z ed      d        Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d  Z"d! Z#d" Z$d# Z%d$ Z&d% Z'd& Z(d' Z)d( Z*d) Z+ e,e-d*k  d+      d,        Z.d- Z/d. Z0d/ Z1d0 Z2d1 Z3d2 Z4d3 Z5d4 Z6d5 Z7d6 Z8d7 Z9d8 Z:d9 Z;d: Z<y;)<TestUnusedAssignmentz5
    Tests for warning about unused assignments.
    c                 D    | j                  dt        j                         y)zc
        Warn when a variable in a function is assigned a value that's never
        used.
        z,
        def a():
            b = 1
        Nr   r   s    r   test_unusedVariablez(TestUnusedAssignment.test_unusedVariablef  s     
 	  	r   c                 &    | j                  d       y)zh
        Don't warn when the magic "_" (underscore) variable is unused.
        See issue #202.
        zC
        def a(unused_param):
            _ = unused_param
        Nr&   r   s    r   test_unusedUnderscoreVariablez2TestUnusedAssignment.test_unusedUnderscoreVariablep  r(   r   c                 &    | j                  d       y)zO
        Using locals() it is perfectly valid to have unused variables
        zH
        def a():
            b = 1
            return locals()
        Nr&   r   s    r   test_unusedVariableAsLocalsz0TestUnusedAssignment.test_unusedVariableAsLocalsz       	  	r   c                 D    | j                  dt        j                         y)zA
        Using locals() in wrong scope should not matter
        zq
        def a():
            locals()
            def a():
                b = 1
                return
        Nr   r   s    r   test_unusedVariableNoLocalsz0TestUnusedAssignment.test_unusedVariableNoLocals  s      	  	r   zAtodo: Difficult because it doesn't apply in the context of a loopc                 D    | j                  dt        j                         y)zV
        Shadowing a used variable can still raise an UnusedVariable warning.
        zR
        def a():
            b = 1
            b.foo()
            b = 2
        Nr   r   s    r   test_unusedReassignedVariablez2TestUnusedAssignment.test_unusedReassignedVariable  s     
 	 
 	r   c                 &    | j                  d       y)zt
        Shadowing a used variable cannot raise an UnusedVariable warning in the
        context of a loop.
        z^
        def a():
            b = True
            while b:
                b = False
        Nr&   r   s    r   test_variableUsedInLoopz,TestUnusedAssignment.test_variableUsedInLoop  r1   r   c                 &    | j                  d       y)z
        Assigning to a global and then not using that global is perfectly
        acceptable. Do not mistake it for an unused local variable.
        zO
        b = 0
        def a():
            global b
            b = 1
        Nr&   r   s    r   test_assignToGlobalz(TestUnusedAssignment.test_assignToGlobal  r1   r   c                 &    | j                  d       y)z
        Assigning to a nonlocal and then not using that binding is perfectly
        acceptable. Do not mistake it for an unused local variable.
        zW
        b = b'0'
        def a():
            nonlocal b
            b = b'1'
        Nr&   r   s    r   test_assignToNonlocalz*TestUnusedAssignment.test_assignToNonlocal  r1   r   c                 &    | j                  d       y)z
        Assigning to a member of another object and then not using that member
        variable is perfectly acceptable. Do not mistake it for an unused
        local variable.
        zR
        class b:
            pass
        def a():
            b.foo = 1
        Nr&   r   s    r   test_assignToMemberz(TestUnusedAssignment.test_assignToMember       	  	r   c                 &    | j                  d       y)zW
        Don't warn when a variable in a for loop is assigned to but not used.
        zO
        def f():
            for i in range(10):
                pass
        Nr&   r   s    r   test_assignInForLoopz)TestUnusedAssignment.test_assignInForLoop  r   r   c                 &    | j                  d       y)zi
        Don't warn when a variable in a list comprehension is
        assigned to but not used.
        z@
        def f():
            [None for i in range(10)]
        Nr&   r   s    r   test_assignInListComprehensionz3TestUnusedAssignment.test_assignInListComprehension  r(   r   c                 &    | j                  d       y)zk
        Don't warn when a variable in a generator expression is
        assigned to but not used.
        z@
        def f():
            (None for i in range(10))
        Nr&   r   s    r   test_generatorExpressionz-TestUnusedAssignment.test_generatorExpression  r(   r   c                 &    | j                  d       y)zW
        Don't warn when a variable assignment occurs lexically after its use.
        z
        def f():
            x = None
            for i in range(10):
                if i > 2:
                    return x
                x = i * 2
        Nr&   r   s    r   test_assignmentInsideLoopz.TestUnusedAssignment.test_assignmentInsideLoop  s     	  	r   c                 &   | j                  d       | j                  dt        j                  t        j                         | j                  d       | j                  dt        j                         | j                  dt        j                         y)z
        Don't warn when a variable included in tuple unpacking is unused. It's
        very common for variables in a tuple unpacking assignment to be unused
        in good Python code, so warning will only create false positives.
        z6
        def f(tup):
            (x, y) = tup
        z4
        def f():
            (x, y) = 1, 2
        zq
        def f():
            (x, y) = coords = 1, 2
            if x > 1:
                print(coords)
        z=
        def f():
            (x, y) = coords = 1, 2
        z=
        def f():
            coords = (x, y) = 1, 2
        Nr   r   s    r   test_tupleUnpackingz(TestUnusedAssignment.test_tupleUnpacking  s     	  	 	  q//	1 	  	 	  	 	  	r   c                     | j                  d       | j                  dt        j                  t        j                         y)zR
        Don't warn when a variable included in list unpacking is unused.
        z6
        def f(tup):
            [x, y] = tup
        z6
        def f():
            [x, y] = [1, 2]
        Nr   r   s    r   test_listUnpackingz'TestUnusedAssignment.test_listUnpacking  s;     	  	 	  q//	1r   c                 &    | j                  d       y)zN
        Don't warn when the assignment is used in an inner function.
        z~
        def barMaker():
            foo = 5
            def bar():
                return foo
            return bar
        Nr&   r   s    r   test_closedOverz$TestUnusedAssignment.test_closedOver$  s     	  	r   c                 &    | j                  d       y)z
        Don't warn when the assignment is used in an inner function, even if
        that inner function itself is in an inner function.
        z
        def barMaker():
            foo = 5
            def bar():
                def baz():
                    return foo
            return bar
        Nr&   r   s    r   test_doubleClosedOverz*TestUnusedAssignment.test_doubleClosedOver0  s    
 	  	r   c                 &    | j                  d       y)z}
        Do not warn about unused local variable __tracebackhide__, which is
        a special variable for py.test.
        zL
            def helper():
                __tracebackhide__ = True
        Nr&   r   s    r   !test_tracebackhideSpecialVariablez6TestUnusedAssignment.test_tracebackhideSpecialVariable>  r(   r   c                     | j                  d       | j                  dt        j                         | j                  dt        j                         y)z9
        Test C{foo if bar else baz} statements.
        za = 'moo' if True else 'oink'za = foo if True else 'oink'za = 'moo' if True else barNrD   r   s    r   
test_ifexpzTestUnusedAssignment.test_ifexpH  s7     	3411??C0!//Br   c                     | j                  d       | j                  d       | j                  dt        j                         | j                  dt        j                         y)z/
        Test C{if (foo,)} conditions.
        zif (): passzC
        if (
            True
        ):
            pass
        zD
        if (
            True,
        ):
            pass
        z?
        x = 1 if (
            True,
        ) else 2
        N)r   r   IfTupler   s    r   test_if_tuplez"TestUnusedAssignment.test_if_tupleP  sZ     	%&  	 	 
 YY	 	  YY		r   c                 &    | j                  d       y)z
        No warnings are emitted for using inside or after a nameless C{with}
        statement a name defined beforehand.
        zR
        bar = None
        with open("foo"):
            bar
        bar
        Nr&   r   s    r   test_withStatementNoNamesz.TestUnusedAssignment.test_withStatementNoNamesg  r1   r   c                 &    | j                  d       y)z
        No warnings are emitted for using a name defined by a C{with} statement
        within the suite or afterwards.
        zF
        with open('foo') as bar:
            bar
        bar
        Nr&   r   s    r   test_withStatementSingleNamez1TestUnusedAssignment.test_withStatementSingleNames  r>   r   c                 &    | j                  d       y)zn
        No warnings are emitted for using an attribute as the target of a
        C{with} statement.
        zR
        import foo
        with open('foo') as foo.bar:
            pass
        Nr&   r   s    r   test_withStatementAttributeNamez4TestUnusedAssignment.test_withStatementAttributeName~  r>   r   c                 &    | j                  d       y)zm
        No warnings are emitted for using a subscript as the target of a
        C{with} statement.
        zQ
        import foo
        with open('foo') as foo[0]:
            pass
        Nr&   r   s    r   test_withStatementSubscriptz0TestUnusedAssignment.test_withStatementSubscript  r>   r   c                 D    | j                  dt        j                         y)z
        An undefined name warning is emitted if the subscript used as the
        target of a C{with} statement is not defined.
        zS
        import foo
        with open('foo') as foo[bar]:
            pass
        NrD   r   s    r   $test_withStatementSubscriptUndefinedz9TestUnusedAssignment.test_withStatementSubscriptUndefined      
 	  __		r   c                 &    | j                  d       y)z
        No warnings are emitted for using any of the tuple of names defined by
        a C{with} statement within the suite or afterwards.
        zW
        with open('foo') as (bar, baz):
            bar, baz
        bar, baz
        Nr&   r   s    r   test_withStatementTupleNamesz1TestUnusedAssignment.test_withStatementTupleNames  r>   r   c                 &    | j                  d       y)z
        No warnings are emitted for using any of the list of names defined by a
        C{with} statement within the suite or afterwards.
        zW
        with open('foo') as [bar, baz]:
            bar, baz
        bar, baz
        Nr&   r   s    r   test_withStatementListNamesz0TestUnusedAssignment.test_withStatementListNames  r>   r   c                 &    | j                  d       y)aq  
        If the target of a C{with} statement uses any or all of the valid forms
        for that part of the grammar (See
        U{http://docs.python.org/reference/compound_stmts.html#the-with-statement}),
        the names involved are checked both for definedness and any bindings
        created are respected in the suite of the statement and afterwards.
        z
        c = d = e = g = h = i = None
        with open('foo') as [(a, b), c[d], e.f, g[h:i]]:
            a, b, c, d, e, g, h, i
        a, b, c, d, e, g, h, i
        Nr&   r   s    r   #test_withStatementComplicatedTargetz8TestUnusedAssignment.test_withStatementComplicatedTarget  r   r   c                 D    | j                  dt        j                         y)z
        An undefined name warning is emitted if the name first defined by a
        C{with} statement is used before the C{with} statement.
        zG
        bar
        with open('foo') as bar:
            pass
        NrD   r   s    r   %test_withStatementSingleNameUndefinedz:TestUnusedAssignment.test_withStatementSingleNameUndefined  r   r   c                 D    | j                  dt        j                         y)z
        An undefined name warning is emitted if a name first defined by the
        tuple-unpacking form of the C{with} statement is used before the
        C{with} statement.
        zN
        baz
        with open('foo') as (bar, baz):
            pass
        NrD   r   s    r   %test_withStatementTupleNamesUndefinedz:TestUnusedAssignment.test_withStatementTupleNamesUndefined  s     	  __		r   c                 D    | j                  dt        j                         y)z
        A redefined name warning is emitted if a name bound by an import is
        rebound by the name defined by a C{with} statement.
        zN
        import bar
        with open('foo') as bar:
            pass
        Nr    r   s    r   %test_withStatementSingleNameRedefinedz:TestUnusedAssignment.test_withStatementSingleNameRedefined  r.   r   c                 D    | j                  dt        j                         y)z
        A redefined name warning is emitted if a name bound by an import is
        rebound by one of the names defined by the tuple-unpacking form of a
        C{with} statement.
        zU
        import bar
        with open('foo') as (bar, baz):
            pass
        Nr    r   s    r   %test_withStatementTupleNamesRedefinedz:TestUnusedAssignment.test_withStatementTupleNamesRedefined  s      	  ##		%r   c                 D    | j                  dt        j                         y)z
        An undefined name warning is emitted if a name is used inside the
        body of a C{with} statement without first being bound.
        z:
        with open('foo') as bar:
            baz
        NrD   r   s    r   !test_withStatementUndefinedInsidez6TestUnusedAssignment.test_withStatementUndefinedInside  rG   r   c                 &    | j                  d       y)z|
        A name defined in the body of a C{with} statement can be used after
        the body ends without warning.
        zK
        with open('foo') as bar:
            baz = 10
        baz
        Nr&   r   s    r   #test_withStatementNameDefinedInBodyz8TestUnusedAssignment.test_withStatementNameDefinedInBody  r>   r   c                     | j                  dt        j                         | j                  dt        j                         y)z
        An undefined name warning is emitted if a name in the I{test}
        expression of a C{with} statement is undefined.
        z3
        with bar as baz:
            pass
        z3
        with bar as bar:
            pass
        NrD   r   s    r   'test_withStatementUndefinedInExpressionz<TestUnusedAssignment.test_withStatementUndefinedInExpression  s:    
 	  __	
 	  __	r   c                 &    | j                  d       y)z;
        Dict comprehensions are properly handled.
        z/
        a = {1: x for x in range(10)}
        Nr&   r   s    r   test_dictComprehensionz+TestUnusedAssignment.test_dictComprehension  r   r   c                 &    | j                  d       y)z:
        Set comprehensions are properly handled.
        zB
        a = {1, 2, 3}
        b = {x for x in range(10)}
        Nr&   r   s    r   test_setComprehensionAndLiteralz4TestUnusedAssignment.test_setComprehensionAndLiteral  r   r   c                 H    | j                  d       | j                  d       y )Nz<
        try: pass
        except Exception as e: e
        zc
        def download_review():
            try: pass
            except Exception as e: e
        r&   r   s    r   test_exceptionUsedInExceptz/TestUnusedAssignment.test_exceptionUsedInExcept'  s&      	
 	  	r   c                 D    | j                  dt        j                         y )Nz?
        try: pass
        except Exception as e: pass
        r   r   s    r   test_exceptionUnusedInExceptz1TestUnusedAssignment.test_exceptionUnusedInExcept3  s      	r   )      znew in Python 3.11c                 D    | j                  dt        j                         y )Nzf
            try:
                pass
            except* OSError as e:
                pass
        r   r   s    r   $test_exception_unused_in_except_starz9TestUnusedAssignment.test_exception_unused_in_except_star9  s     
 	r   c                 D    | j                  dt        j                         y )Nzf
        def download_review():
            try: pass
            except Exception as e: pass
        r   r   s    r   &test_exceptionUnusedInExceptInFunctionz;TestUnusedAssignment.test_exceptionUnusedInExceptInFunctionB  s      		r   c                 &    | j                  d       y)z
        Don't issue false warning when an unnamed exception is used.
        Previously, there would be a false warning, but only when the
        try..except was in a function
        zw
        import tokenize
        def foo():
            try: pass
            except tokenize.TokenError: pass
        Nr&   r   s    r    test_exceptWithoutNameInFunctionz5TestUnusedAssignment.test_exceptWithoutNameInFunctionI  s     	  	r   c                 &    | j                  d       y)z
        Don't issue false warning when an unnamed exception is used.
        This example catches a tuple of exception types.
        z
        import tokenize
        def foo():
            try: pass
            except (tokenize.TokenError, IndentationError): pass
        Nr&   r   s    r   %test_exceptWithoutNameInFunctionTuplez:TestUnusedAssignment.test_exceptWithoutNameInFunctionTupleV  r1   r   c                 &    | j                  d       y)zt
        Consider a function that is called on the right part of an
        augassign operation to be used.
        zJ
        from foo import bar
        baz = 0
        baz += bar()
        Nr&   r   s    r   ,test_augmentedAssignmentImportedFunctionCallzATestUnusedAssignment.test_augmentedAssignmentImportedFunctionCallb  r>   r   c                 &    | j                  d       y)z,An assert without a message is not an error.z(
        a = 1
        assert a
        Nr&   r   s    r   test_assert_without_messagez0TestUnusedAssignment.test_assert_without_messagem        	r   c                 &    | j                  d       y)z)An assert with a message is not an error.z-
        a = 1
        assert a, 'x'
        Nr&   r   s    r   test_assert_with_messagez-TestUnusedAssignment.test_assert_with_messaget  r  r   c                 b    | j                  dt        j                  t        j                         y)z.An assert of a non-empty tuple is always True.z>
        assert (False, 'x')
        assert (False, )
        N)r   r   AssertTupler   s    r   test_assert_tuplez&TestUnusedAssignment.test_assert_tuple{  s"      ]]AMM	+r   c                 &    | j                  d       y)z,An assert of an empty tuple is always False.z
        assert ()
        Nr&   r   s    r   test_assert_tuple_emptyz,TestUnusedAssignment.test_assert_tuple_empty  s      	r   c                 &    | j                  d       y)z,An assert of a static value is not an error.z.
        assert True
        assert 1
        Nr&   r   s    r   test_assert_staticz'TestUnusedAssignment.test_assert_static  r  r   c                 D    | j                  dt        j                         y)z.
        Test C{yield from} statement
        z9
        def bar():
            yield from foo()
        NrD   r   s    r   test_yieldFromUndefinedz,TestUnusedAssignment.test_yieldFromUndefined  s     	  __	r   c                 &    | j                  d       y)z.Test PEP 498 f-strings are treated as a usage.z3
        baz = 0
        print(f'{4*baz}')
        Nr&   r   s    r   test_f_stringz"TestUnusedAssignment.test_f_string  r  r   c                 &    | j                  d       y)zATest PEP 572 assignment expressions are treated as usage / write.zJ
        from foo import y
        print(x := y)
        print(x)
        Nr&   r   s    r   test_assign_exprz%TestUnusedAssignment.test_assign_expr        	r   c                 &    | j                  d       y)z5Test assignment expressions in generator expressions.zO
        if (any((y := x[0]) for x in [[True]])):
            print(y)
        Nr&   r   s    r    test_assign_expr_generator_scopez5TestUnusedAssignment.test_assign_expr_generator_scope  r  r   c                 &    | j                  d       y)z2Test assignment expressions in nested expressions.zz
        if ([(y:=x) for x in range(4) if [(z:=q) for q in range(4)]]):
            print(y)
            print(z)
        Nr&   r   s    r   test_assign_expr_nestedz,TestUnusedAssignment.test_assign_expr_nested  r)  r   N)=r   r   r   __doc__r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r
  r   r   r  r  r  r  r  r  r  r  r   r"  r$  r&  r(  r+  r-  rw   r   r   r   r   a  sH   
 

MN	 O	


:1
C.
							
	%
%	
 L7"$89 :
	+r   r   c                   $    e Zd Zd Zd Zd Zd Zy)TestStringFormattingc                 j   | j                  dt        j                         | j                  dt        j                         | j                  dt        j                         | j                  dt        j                         | j                  d       | j                  d       | j                  d       y )Nzf'foo'z=
            f"""foo
            bar
            """
        zX
            print(
                f'foo'
                f'bar'
            )
        zf'{{}}'z5
            x = 5
            print(f'{x}')
        z?
            x = 'a' * 90
            print(f'{x:.8}')
        zC
            x = y = 5
            print(f'{x:>2} {y:>2}')
        )r   r   FStringMissingPlaceholdersr   s    r   "test_f_string_without_placeholdersz7TestStringFormatting.test_f_string_without_placeholders  s    Ha::;  ))		+
 	 
 ))	+ 	Iq;;<  	
 	  	
 	  	r   c                 2   | j                  dt        j                         | j                  dt        j                         | j                  dt        j                         | j                  dt        j                         | j                  dt        j
                         | j                  dt        j                         | j                  dt        j                         | j                  dt        j                         | j                  d	t        j                         | j                  d
       | j                  d       | j                  d       | j                  d       | j                  d       | j                  d       | j                  d       y )Nz#
            '{'.format(1)
        z+
            '{} {1}'.format(1, 2)
        z+
            '{0} {}'.format(1, 2)
        z'
            '{}'.format(1, 2)
        z+
            '{}'.format(1, bar=2)
        z'
            '{} {}'.format(1)
        z$
            '{2}'.format()
        z&
            '{bar}'.format()
        z0
            '{:{:{}}}'.format(1, 2, 3)
        z'{.__class__}'.format('')z('{foo[bar]}'.format(foo={'bar': 'barv'})z8
            print('{:{}} {}'.format(1, 15, 2))
        z-
            print('{:2}'.format(1))
        z1
            '{foo}-{}'.format(1, foo=2)
        z8
            a = ()
            "{}".format(*a)
        z<
            k = {}
            "{foo}".format(**k)
        )r   r   StringDotFormatInvalidFormatStringDotFormatMixingAutomatic'StringDotFormatExtraPositionalArguments"StringDotFormatExtraNamedArgumentsStringDotFormatMissingArgumentr   s    r   test_invalid_dot_format_callsz2TestStringFormatting.test_invalid_dot_format_calls  su    ++	- 	 --	/ 	 --	/ 	 66	8 	 11	3 	 --	/ 	 --	/ 	 --	/ 	 ++	- 	/0>?  	 	  	 	  	 	  	 	  	r   c                 L   | j                  dt        j                         | j                  dt        j                         | j                  dt        j                         | j                  dt        j                         | j                  dt        j
                         | j                  dt        j
                         | j                  dt        j                         | j                  dt        j                         | j                  d	t        j                         | j                  d
t        j                         | j                  dt        j                         | j                  d       | j                  d       | j                  d       | j                  d       y )Nz/
            '%(foo)' % {'foo': 'bar'}
        z3
            '%s %(foo)s' % {'foo': 'bar'}
        z3
            '%(foo)s %s' % {'foo': 'bar'}
        z!
            '%j' % (1,)
        z$
            '%s %s' % (1,)
        z)
            '%s %s' % (1, 2, 3)
        z$
            '%(bar)s' % {}
        z6
            '%(bar)s' % {'bar': 1, 'baz': 2}
        z+
            '%(bar)s' % (1, 2, 3)
        z*
            '%s %s' % {'k': 'v'}
        z1
            '%(bar)*s' % {'bar': 'baz'}
        z:
            '%s' % {'foo': 'bar', 'baz': 'womp'}
        z+
            "%1000000000000f" % 1
        z,
            '%% %s %% %s' % (1, 2)
        zO
            '%.*f' % (2, 1.1234)
            '%*.*f' % (5, 2, 3.1234)
        )r   r   PercentFormatInvalidFormat$PercentFormatMixedPositionalAndNamed'PercentFormatUnsupportedFormatCharacter$PercentFormatPositionalCountMismatchPercentFormatMissingArgument PercentFormatExtraNamedArgumentsPercentFormatExpectedMappingPercentFormatExpectedSequence!PercentFormatStarRequiresSequencer   s    r   !test_invalid_percent_format_callsz6TestStringFormatting.test_invalid_percent_format_calls  s    ))	+ 	 33	5 	 33	5 	 66	8 	 33	5 	 33	5 	 ++	. 	 //	1 	 ++	- 	 ,,	. 	 00	2 	  	 	  	 	  	 	  	r   c                 H    | j                  d       | j                  d       y )NzS
            a = []
            '%s %s' % [*a]
            '%s %s' % (*a,)
        z8
            k = {}
            '%(k)s' % {**k}
        r&   r   s    r   5test_ok_percent_format_cannot_determine_element_countzJTestStringFormatting.test_ok_percent_format_cannot_determine_element_countB  s&      	
 	  	r   N)r   r   r   r3  r:  rE  rG  rw   r   r   r0  r0    s    >4l2h	r   r0  c                   T    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zy)TestAsyncStatementsc                 &    | j                  d       y )Nz8
        async def bar():
            return 42
        r&   r   s    r   test_asyncDefz!TestAsyncStatements.test_asyncDefP  r   r   c                 &    | j                  d       y )NzS
        async def read_data(db):
            await db.fetch('SELECT ...')
        r&   r   s    r   test_asyncDefAwaitz&TestAsyncStatements.test_asyncDefAwaitV  r   r   c                 D    | j                  dt        j                         y )Nz;
        async def bar():
            return foo()
        rD   r   s    r   test_asyncDefUndefinedz*TestAsyncStatements.test_asyncDefUndefined\  s      __	r   c                 &    | j                  d       y )Nz
        async def read_data(db):
            output = []
            async for row in db.cursor():
                output.append(row)
            return output
        r&   r   s    r   test_asyncForz!TestAsyncStatements.test_asyncForb        	r   c                 &    | j                  d       y )NzY
        async def coro(it):
            async for _ in it:
                pass
        r&   r   s    r   test_asyncForUnderscoreLoopVarz2TestAsyncStatements.test_asyncForUnderscoreLoopVark        	r   c                 H    | j                  d       | j                  d       y )Nz
        async def read_data(db):
            output = []
            async for row in db.cursor():
                if row[0] == 'skip':
                    continue
                output.append(row)
            return output
        z
        async def read_data(db):
            output = []
            async for row in db.cursor():
                if row[0] == 'stop':
                    break
                output.append(row)
            return output
        r&   r   s    r   test_loopControlInAsyncForz.TestAsyncStatements.test_loopControlInAsyncForr  s&      	 	  	r   c                     | j                  dt        j                         | j                  dt        j                         y )Nz
        async def read_data(db):
            output = []
            async for row in db.cursor():
                output.append(row)
            else:
                continue
            return output
        z
        async def read_data(db):
            output = []
            async for row in db.cursor():
                output.append(row)
            else:
                break
            return output
        )r   r   re   rj   r   s    r   test_loopControlInAsyncForElsez2TestAsyncStatements.test_loopControlInAsyncForElse  s<      ""	$ 	  	!r   c                 &    | j                  d       y )Nz
        async def commit(session, data):
            async with session.transaction():
                await session.update(data)
        r&   r   s    r   test_asyncWithz"TestAsyncStatements.test_asyncWith  rU  r   c                 &    | j                  d       y )Nz
        async def commit(session, data):
            async with session.transaction() as trans:
                await trans.begin()
                ...
                await trans.end()
        r&   r   s    r   test_asyncWithItemz&TestAsyncStatements.test_asyncWithItem  rR  r   c                 &    | j                  d       y )Nz9
        def foo(a, b):
            return a @ b
        r&   r   s    r   test_matmulzTestAsyncStatements.test_matmul  r   r   c                 &    | j                  d       y )NzE
        hi = 'hi'
        mom = 'mom'
        f'{hi} {mom}'
        r&   r   s    r   test_formatstringz%TestAsyncStatements.test_formatstring  rU  r   c                     | j                  d       | j                  d       | j                  dt        j                         | j                  dt        j                         y )Nz;
        raise NotImplementedError("This is fine")
        z+
        raise NotImplementedError
        z?
        raise NotImplemented("This isn't gonna work")
        z&
        raise NotImplemented
        )r   r   RaiseNotImplementedr   s    r   test_raise_notimplementedz-TestAsyncStatements.test_raise_notimplemented  s^      	 	  	 	 ""	$ 	 ""	$r   N)r   r   r   rK  rM  rO  rQ  rT  rW  rY  r[  r]  r_  ra  rd  rw   r   r   rI  rI  N  s>    *!*$r   rI  c                   :    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
y	)
TestIncompatiblePrintOperatorz@
    Tests for warning about invalid use of print function.
    c                 &    | j                  d       y )Nz 
        print("Hello")
        r&   r   s    r   test_valid_printz.TestIncompatiblePrintOperator.test_valid_print  s      	r   c                     | j                  dt        j                        j                  d   }| j	                  |j
                  d       | j	                  |j                  d       y )Nzn
        from __future__ import print_function
        import sys
        print >>sys.stderr, "Hello"
        r      )r   r   InvalidPrintSyntaxr   assertEquallinenocol)r   excs     r   ,test_invalid_print_when_imported_from_futurezJTestIncompatiblePrintOperator.test_invalid_print_when_imported_from_future  sX    kk  !!	# $,8A	/ 	Q'!$r   c                 &    | j                  d       y )Nz
print += 1r&   r   s    r   test_print_augmented_assignz9TestIncompatiblePrintOperator.test_print_augmented_assign  s    L!r   c                 &    | j                  d       y)zJ
        A valid assignment, tested for catching false positives.
        z`
        from __future__ import print_function
        log = print
        log("Hello")
        Nr&   r   s    r   test_print_function_assignmentz<TestIncompatiblePrintOperator.test_print_function_assignment  r   r   c                 &    | j                  d       y )NzQ
        from __future__ import print_function
        a = lambda: print
        r&   r   s    r   test_print_in_lambdaz2TestIncompatiblePrintOperator.test_print_in_lambda  r   r   c                 &    | j                  d       y )Nza
        from __future__ import print_function
        def a():
            return print
        r&   r   s    r   test_print_returned_in_functionz=TestIncompatiblePrintOperator.test_print_returned_in_function  rU  r   c                 &    | j                  d       y )NzN
        from __future__ import print_function
        if print: pass
        r&   r   s    r   test_print_as_condition_testz:TestIncompatiblePrintOperator.test_print_as_condition_test  r   r   N)r   r   r   r.  rh  rp  rr  rt  rv  rx  rz  rw   r   r   rf  rf    s*    
%"r   rf  N)r.  sysr   pyflakesr   r   pyflakes.test.harnessr   r   r   r	   r   r0  rI  rf  rw   r   r   <module>r~     s`     " 8 8S8 Sl"S	8 S	lT8 Tnz$( z$z3H 3r   