
    j                         S r SSKJr  SSKJr  SSKJrJrJ	r	   " S S\5      r
 " S S\5      r " S	 S
\5      r " S S\5      r " S S\5      rg)z&
Tests for various Pyflakes behavior.
    )version_info)messages)TestCaseskipskipIfc                      \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r S r!S  r"S! r#S" r$S# r%S$ r&S% r'S& r(S' r)S( r*\+" S)5      S* 5       r,S+ r-S, r.S- r/S. r0S/ r1S0 r2S1 r3S2 r4S3 r5S4 r6S5 r7S6 r8S7 r9S8 r:S9 r;S: r<S; r=S< r>S= r?S>r@g?)@Test   c                 D    U R                  S[        R                  5        g )Nzdef fu(bar, bar): pass)flakesmDuplicateArgumentselfs    P/var/www/html/KUNJ/venv/lib/python3.13/site-packages/pyflakes/test/test_other.pytest_duplicateArgsTest.test_duplicateArgs   s    ,a.A.AB    c                 b    U R                  S[        R                  [        R                  5        g )NzG
        a = 1
        def f():
            a; a=1
        f()
        )r   r   UndefinedLocalUnusedVariabler   s    r   $test_localReferencedBeforeAssignment)Test.test_localReferencedBeforeAssignment   s&     
 q//	1r   c                     U R                  S5        U R                  S5        U R                  S[        R                  5        U R                  S5        U R                  S5        g)zG
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_redefinedInGeneratorTest.test_redefinedInGenerator   l    
 	  	 	  	
 	  		
 	  	 	  	r   c                     U R                  S5        U R                  S5        U R                  S[        R                  5        U R                  S5        U R                  S5        g)zO
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_redefinedInSetComprehension%Test.test_redefinedInSetComprehension5   r   r   c                     U R                  S5        U R                  S5        U R                  S[        R                  5        U R                  S5        U R                  S5        g)zP
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_redefinedInDictComprehension&Test.test_redefinedInDictComprehensionR   r   r   c                 D    U R                  S[        R                  5        g)zN
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_redefinedFunctionTest.test_redefinedFunctiono   s     
 	  ##	%r   c                 D    U R                  S[        R                  5        g )Nz-
        x = 1
        def x(): pass
        r&   r   s    r   (test_redefined_function_shadows_variable-Test.test_redefined_function_shadows_variabley   s      ##	%r   c                 &    U R                  S5        g)zY
Test that shadowing a function definition named with underscore doesn't
raise anything.
z5
        def _(): pass
        def _(): pass
        Nr   r   s    r    test_redefinedUnderscoreFunction%Test.test_redefinedUnderscoreFunction       
 	  	r   c                 D    U R                  S[        R                  5        g)zA
Test that shadowing an underscore importation raises a warning.
z;
        from .i18n import _
        def _(): pass
        Nr&   r   s    r   #test_redefinedUnderscoreImportation(Test.test_redefinedUnderscoreImportation         	  ##	%r   c                 D    U R                  S[        R                  5        g)z_
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_redefinedClassFunction Test.test_redefinedClassFunction        
 	  ##		%r   c                 &    U R                  S5        g)zc
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_redefinedIfElseFunction!Test.test_redefinedIfElseFunction       
 	  	r   c                 D    U R                  S[        R                  5        g)zP
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_redefinedIfFunctionTest.test_redefinedIfFunction   r9   r   c                 &    U R                  S5        g)zc
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_redefinedTryExceptFunction$Test.test_redefinedTryExceptFunction   r=   r   c                 D    U R                  S[        R                  5        g)zP
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_redefinedTryFunctionTest.test_redefinedTryFunction   s     
 	  ##	%r   c                 &    U R                  S5        g)zj
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_redefinedIfElseInListComp#Test.test_redefinedIfElseInListComp   r=   r   c                 &    U R                  S5        g)zo
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_functionDecoratorTest.test_functionDecorator   r=   r   c                 &    U R                  S5        g)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_classFunctionDecorator Test.test_classFunctionDecorator       
 	  	r   c                 &    U R                  S5        g )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_modernPropertyTest.test_modernProperty   s      	r   c                 &    U R                  S5        g)zDon't die on unary +.z+1Nr.   r   s    r   test_unaryPlusTest.test_unaryPlus   s    Dr   c                 D    U R                  S[        R                  5        g)zV
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_undefinedBaseClassTest.test_undefinedBaseClass      
 	  __	r   c                 D    U R                  S[        R                  5        g)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
        NrX   r   s    r   "test_classNameUndefinedInClassBody'Test.test_classNameUndefinedInClassBody  r\   r   c                 &    U R                  S5        g)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_classNameDefinedPreviously$Test.test_classNameDefinedPreviously  s     	  	r   c                 D    U R                  S[        R                  5        g)zG
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_classRedefinitionTest.test_classRedefinition"        	 
 ##	%r   c                 D    U R                  S[        R                  5        g)z>
If a function is redefined as a class, a warning is emitted.
zQ
        def Foo():
            pass
        class Foo:
            pass
        Nr&   r   s    r   test_functionRedefinedAsClass"Test.test_functionRedefinedAsClass-  rf   r   c                 D    U R                  S[        R                  5        g)z>
If a class is redefined as a function, a warning is emitted.
zQ
        class Foo:
            pass
        def Foo():
            pass
        Nr&   r   s    r   test_classRedefinedAsFunction"Test.test_classRedefinedAsFunction8  rf   r   c                 D    U R                  S[        R                  5        g)z;
If a return is used inside a class, a warning is emitted.
z7
        class Foo(object):
            return
        Nr   r   ReturnOutsideFunctionr   s    r   test_classWithReturnTest.test_classWithReturnC  s      	  $$	&r   c                 D    U R                  S[        R                  5        g)z@
If a return is used at the module level, a warning is emitted.
z
        return
        Nrn   r   s    r   test_moduleWithReturnTest.test_moduleWithReturnL  s     	 $$	&r   c                 D    U R                  S[        R                  5        g)z:
If a yield is used inside a class, a warning is emitted.
z6
        class Foo(object):
            yield
        Nr   r   YieldOutsideFunctionr   s    r   test_classWithYieldTest.test_classWithYieldT  r5   r   c                 D    U R                  S[        R                  5        g)z?
If a yield is used at the module level, a warning is emitted.
z
        yield
        Nrv   r   s    r   test_moduleWithYieldTest.test_moduleWithYield]       	 ##	%r   c                 D    U R                  S[        R                  5        g)z?
If a yield from is used inside a class, a warning is emitted.
zE
        class Foo(object):
            yield from range(10)
        Nrv   r   s    r   test_classWithYieldFromTest.test_classWithYieldFrome  r5   r   c                 D    U R                  S[        R                  5        g)zD
If a yield from is used at the module level, a warning is emitted.
z&
        yield from range(10)
        Nrv   r   s    r   test_moduleWithYieldFromTest.test_moduleWithYieldFromn  r}   r   c                    U R                  S[        R                  5        U R                  S[        R                  5        U R                  S[        R                  5        U R                  S[        R                  5        U R                  S[        R                  5        U R                  S[        R                  5        g )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_continueOutsideLoopTest.test_continueOutsideLoopv  s     ""	$ 	  ""	$
 	 
 ""	$ 	  ""	$ 	  ""		$ 	  ""		$r   c                     U R                  S5        U R                  S5        U R                  S5        U R                  S5        U R                  S5        U R                  S5        g )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_continueInsideLoopTest.test_continueInsideLoop  sr      	
 	  	
 	  	 	  	 	  	 	  	r   c                    U R                  S[        R                  5        U R                  S[        R                  5        U R                  S[        R                  5        U R                  S[        R                  5        U R                  S[        R                  5        U R                  S[        R                  5        U R                  S[        R                  5        g )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_breakOutsideLoopTest.test_breakOutsideLoop  s     	! 	  	!
 	 
 	! 	  	! 	  		! 	  		! 	 
 	!r   c                    U R                  S5        U R                  S5        U R                  S5        U R                  S5        U R                  S5        U R                  S5        U R                  S5        U R                  S5        g )	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_breakInsideLoopTest.test_breakInsideLoop  s      	
 	  	
 	  	 	  	 	  	 	  	 	  	 	  	r   c                     U R                  S5        U R                  S5        U R                  S5        U R                  S5        U R                  S5        U R                  S5        g)z
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_defaultExceptLastTest.test_defaultExceptLast/  st    , 	  	 	  	 	  	 	  	 	  	 	 	 		r   c                 |   U R                  S[        R                  5        U R                  S[        R                  5        U R                  S[        R                  5        U R                  S[        R                  [        R                  5        U R                  S[        R                  5        U R                  S[        R                  5        U R                  S[        R                  5        U R                  S[        R                  [        R                  5        U R                  S	[        R                  5        U R                  S
[        R                  5        U R                  S[        R                  5        U R                  S[        R                  [        R                  5        U R                  S[        R                  5        U R                  S[        R                  5        U R                  S[        R                  5        U R                  S[        R                  [        R                  5        g )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_defaultExceptNotLastTest.test_defaultExceptNotLasty  s      ##	% 	  ##	% 	 	 ##		% 	  ##Q%;%;	= 	 	 ##		% 	 	 ##		% 	  ##	% 	  ##Q%;%;	= 	 	 ##		% 	 	 ##		% 	  ##	% 	  ##Q%;%;	= 	  ##	% 	  ##	% 	  ##	% 	  ##Q%;%;	=r   c                    U R                  S5        U R                  S5        U R                  S5        U R                  S5        U R                  S5        U R                  S5        U R                  S5        U R                  S5        U R                  S	5        S
R                  S [        S5       5       5      S-   nU R                  U5        SS
R                  S [        S5       5       5      -   S-   nU R                  U5        SS
R                  S [        S5       5       5      -   S-   nU R                  U5        g)z&
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   ,   #    U  H
  nS U-  v   M     g7fza%dN .0is     r   	<genexpr>5Test.test_starredAssignmentNoError.<locals>.<genexpr>k       ;):Aeai):      z, *rest = range(1<<8)(c              3   ,   #    U  H
  nS U-  v   M     g7fr   r   r   s     r   r   r   o       A/@!EAI/@r   z, *rest) = range(1<<8)[c              3   ,   #    U  H
  nS U-  v   M     g7fr   r   r   s     r   r   r   s  r   r   z, *rest] = range(1<<8)N)r   joinranger   ss     r   test_starredAssignmentNoError"Test.test_starredAssignmentNoErrorB  s=    	  	 	  	 	  	 	  	 	  	 	  	 	  	 	  	 	  	
 II;z):;;#$A$))AuZ/@AAA$%A$))AuZ/@AAA$%Ar   c                    SR                  S [        S5       5       5      S-   nU R                  U[        R                  5        SSR                  S [        S5       5       5      -   S-   nU R                  U[        R                  5        SSR                  S	 [        S5       5       5      -   S
-   nU R                  U[        R                  5        SR                  S [        S5       5       5      S-   nU R                  U[        R                  5        SSR                  S [        S5       5       5      -   S-   nU R                  U[        R                  5        SSR                  S [        S5       5       5      -   S-   nU R                  U[        R                  5        U R                  S[        R
                  5        U R                  S[        R
                  5        U R                  S[        R
                  5        U R                  S[        R
                  5        U R                  S[        R
                  5        U R                  S[        R
                  5        U R                  S[        R
                  5        U R                  S[        R
                  5        U R                  S[        R
                  5        g)zX
SyntaxErrors (not encoded in the ast) surrounding Python 3 extended
iterable unpacking
r   c              3   ,   #    U  H
  nS U-  v   M     g7fr   r   r   s     r   r   4Test.test_starredAssignmentErrors.<locals>.<genexpr>}  s     7Aeair      z, *rest = range(1<<8 + 1)r   c              3   ,   #    U  H
  nS U-  v   M     g7fr   r   r   s     r   r   r          =}!EAI}r   z, *rest) = range(1<<8 + 1)r   c              3   ,   #    U  H
  nS U-  v   M     g7fr   r   r   s     r   r   r     r   r   z, *rest] = range(1<<8 + 1)c              3   ,   #    U  H
  nS U-  v   M     g7fr   r   r   s     r   r   r     r   r   i   z, *rest = range(1<<8 + 2)c              3   ,   #    U  H
  nS U-  v   M     g7fr   r   r   s     r   r   r     r   r   z, *rest) = range(1<<8 + 2)c              3   ,   #    U  H
  nS U-  v   M     g7fr   r   r   s     r   r   r     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_starredAssignmentErrors!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    U R                  S[        R                  5        g)zL
If a variable is re-assigned to without being used, no warning is
emitted.
z'
        x = 10
        x = 20
        Nr&   r   s    r   test_doubleAssignmentTest.test_doubleAssignment  s      	  ##	%r   c                 &    U R                  S5        g)zK
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_doubleAssignmentConditionally'Test.test_doubleAssignmentConditionally  rP   r   c                 &    U R                  S5        g)zJ
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_doubleAssignmentWithUse!Test.test_doubleAssignmentWithUse  rP   r   c                 &    U R                  S5        g)zi
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_comparisonTest.test_comparison  s    
 	 	 		r   c                 &    U R                  S5        g)zV
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_identityTest.test_identity  r=   r   c                 &    U R                  S5        g)zX
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_containmentTest.test_containment  r=   r   c                 H    U R                  S5        U R                  S5        g)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_loopControlTest.test_loopControl  s(     	  	 	  	r   c                 &    U R                  S5        g)z#
Ellipsis in a slice is supported.
z
        [1, 2][...]
        Nr.   r   s    r   test_ellipsisTest.test_ellipsis       	  	r   c                 &    U R                  S5        g)z 
Extended slices are supported.
z+
        x = 3
        [1, 2][x,:]
        Nr.   r   s    r   test_extendedSliceTest.test_extendedSlice       	  	r   c                 &    U R                  S5        g)zP
Augmented assignment of a variable is supported.
We don't care about var refs.
z*
        foo = 0
        foo += 1
        Nr.   r   s    r   test_varAugmentedAssignment Test.test_varAugmentedAssignment%  r1   r   c                 &    U R                  S5        g)zQ
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_attrAugmentedAssignment!Test.test_attrAugmentedAssignment/  r1   r   c                 D    U R                  S[        R                  5        g)z@
A 'global' can be declared in one scope and reused in another.
zV
        def f(): global foo
        def g(): foo = 'anything'; foo.is_used()
        Nr   r   UnusedIndirectAssignmentr   s    r   #test_globalDeclaredInDifferentScope(Test.test_globalDeclaredInDifferentScope9  s      	  ''	)r   c                 D    U R                  S[        R                  5        g )Nz
        g = 0
        def f1():
            global g
            g = 1
        def f2():
            global g  # this is unused!
            return g
        r   r   s    r   test_unused_global_statement!Test.test_unused_global_statementB  s      ''	)r   c                 D    U R                  S[        R                  5        g )Nz
        def f():
            x = 1
            def set_x():
                nonlocal x
                x = 2
            def get_x():
                nonlocal x
                return x
            set_x()
            return get_x()
        r   r   s    r   test_unused_nonlocal_statement#Test.test_unused_nonlocal_statementM  s      ''	)r   c                 b    U R                  S[        R                  [        R                  5        g )Nzi
        g = 0
        def f():
            global g
            def f2():
                g = 2
        )r   r   r   r   r   s    r   ?test_unused_global_statement_not_marked_as_used_by_nested_scopeDTest.test_unused_global_statement_not_marked_as_used_by_nested_scope[  s&      '')9)9	;r   c                 &    U R                  S5        g )Nz
        g = 0
        class C:
            global g
            g = 1
        def f():
            nl = 0
            class C:
                nonlocal nl
                nl = 1
        r.   r   s    r   $test_global_nonlocal_in_class_bodies)Test.test_global_nonlocal_in_class_bodiesd  s     
 
	r   c                 D    U R                  S[        R                  5        g )NzO
        g = 0
        class C:
            global g
            u = g
        r   r   s    r   test_unused_global_in_class Test.test_unused_global_in_classq  s     
 ''	)r   c                 D    U R                  S[        R                  5        g )Nzu
        def f():
            nl = 1
            class C:
                nonlocal nl
                u = nl
        r   r   s    r   test_unused_nonlocal_in_clas!Test.test_unused_nonlocal_in_clasy  s      ''	)r   c                     U R                  S5        U R                  S5        U R                  S5        U R                  S5        g)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_argumentsTest.test_function_arguments  sN     	  	
 	  	
 	  	
 	  	r   c                 &    U R                  S5        g )NzL
        def foo(a, b, c=0, *args, d=0, **kwargs):
            pass
        r.   r   s    r   test_function_arguments_python3$Test.test_function_arguments_python3        	r   r   N)A__name__
__module____qualname____firstlineno__r   r   r   r    r#   r(   r+   r/   r3   r7   r;   r?   rB   rE   rH   rK   rN   rR   rU   rZ   r^   ra   rd   rh   rk   rp   rs   rx   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   __static_attributes__r   r   r   r	   r	      sK   C1:::%%%	%
	%
%

	
	%	%	%&&%%%%$$L(T+!Z:xHTG=R3jE&N 

HI% J%		 

)	));))0r   r	   c                      \ rS rSrSrS rS rS rS r\	" S5      S 5       r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r S r!S  r"S! r#S" r$S# r%S$ r&S% r'S& r(S' r)S( r*S) r+S* r,S+ r-\." \/S,:  S-5      S. 5       r0S/ r1S0 r2S1 r3S2 r4S3 r5S4 r6S5 r7S6 r8S7 r9S8 r:S9 r;\." \/S::  S;5      S< 5       r<S= r=S> r>S? r?S@ r@SA rASBrBgC)DTestUnusedAssignmenti  z-
Tests for warning about unused assignments.
c                 D    U R                  S[        R                  5        g)zK
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_unusedVariable(TestUnusedAssignment.test_unusedVariable  s     
 	  	r   c                 &    U R                  S5        g)zP
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_unusedUnderscoreVariable2TestUnusedAssignment.test_unusedUnderscoreVariable  r1   r   c                 &    U R                  S5        g)z?
Using locals() it is perfectly valid to have unused variables
zH
        def a():
            b = 1
            return locals()
        Nr.   r   s    r   test_unusedVariableAsLocals0TestUnusedAssignment.test_unusedVariableAsLocals       	  	r   c                 D    U R                  S[        R                  5        g)z1
Using locals() in wrong scope should not matter
zq
        def a():
            locals()
            def a():
                b = 1
                return
        Nr   r   s    r   test_unusedVariableNoLocals0TestUnusedAssignment.test_unusedVariableNoLocals  s      	  	r   zAtodo: Difficult because it doesn't apply in the context of a loopc                 D    U R                  S[        R                  5        g)zF
Shadowing a used variable can still raise an UnusedVariable warning.
zR
        def a():
            b = 1
            b.foo()
            b = 2
        Nr   r   s    r   test_unusedReassignedVariable2TestUnusedAssignment.test_unusedReassignedVariable  s     
 	 
 	r   c                 &    U R                  S5        g)z\
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_variableUsedInLoop,TestUnusedAssignment.test_variableUsedInLoop  r=   r   c                 &    U R                  S5        g)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_assignToGlobal(TestUnusedAssignment.test_assignToGlobal  r=   r   c                 &    U R                  S5        g)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_assignToNonlocal*TestUnusedAssignment.test_assignToNonlocal  r=   r   c                 &    U R                  S5        g)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_assignToMember(TestUnusedAssignment.test_assignToMember        	  	r   c                 &    U R                  S5        g)zG
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_assignInForLoop)TestUnusedAssignment.test_assignInForLoop  r  r   c                 &    U R                  S5        g)zQ
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_assignInListComprehension3TestUnusedAssignment.test_assignInListComprehension  r1   r   c                 &    U R                  S5        g)zS
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_generatorExpression-TestUnusedAssignment.test_generatorExpression#  r1   r   c                 &    U R                  S5        g)zG
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_assignmentInsideLoop.TestUnusedAssignment.test_assignmentInsideLoop-  s     	  	r   c                 &   U R                  S5        U R                  S[        R                  [        R                  5        U R                  S5        U R                  S[        R                  5        U R                  S[        R                  5        g)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_tupleUnpacking(TestUnusedAssignment.test_tupleUnpacking:  s     	  	 	  q//	1 	  	 	  	 	  	r   c                     U R                  S5        U R                  S[        R                  [        R                  5        g)zB
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_listUnpacking'TestUnusedAssignment.test_listUnpackingW  s;     	  	 	  q//	1r   c                 &    U R                  S5        g)z>
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_closedOver$TestUnusedAssignment.test_closedOverd  s     	  	r   c                 &    U R                  S5        g)zz
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_doubleClosedOver*TestUnusedAssignment.test_doubleClosedOverp  s    
 	  	r   c                 &    U R                  S5        g)ze
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_tracebackhideSpecialVariable6TestUnusedAssignment.test_tracebackhideSpecialVariable~  r1   r   c                 &    U R                  S5        g)zd
Do not warn about unused local variable __debuggerskip__, which is
a special variable for IPython.
zK
            def helper():
                __debuggerskip__ = True
        Nr.   r   s    r    test_debuggerskipSpecialVariable5TestUnusedAssignment.test_debuggerskipSpecialVariable  r1   r   c                     U R                  S5        U R                  S[        R                  5        U R                  S[        R                  5        g)z)
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 barNrX   r   s    r   
test_ifexpTestUnusedAssignment.test_ifexp  s7     	3411??C0!//Br   c                     U R                  S5        U R                  S5        U R                  S[        R                  5        U R                  S[        R                  5        g)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_tuple"TestUnusedAssignment.test_if_tuple  sZ     	%&  	 	 
 YY	 	  YY		r   c                 &    U R                  S5        g)zk
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_withStatementNoNames.TestUnusedAssignment.test_withStatementNoNames  r=   r   c                 &    U R                  S5        g)zi
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_withStatementSingleName1TestUnusedAssignment.test_withStatementSingleName  rP   r   c                 &    U R                  S5        g)zV
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_withStatementAttributeName4TestUnusedAssignment.test_withStatementAttributeName  rP   r   c                 &    U R                  S5        g)zU
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_withStatementSubscript0TestUnusedAssignment.test_withStatementSubscript  rP   r   c                 D    U R                  S[        R                  5        g)zq
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
        NrX   r   s    r   $test_withStatementSubscriptUndefined9TestUnusedAssignment.test_withStatementSubscriptUndefined      
 	  __		r   c                 &    U R                  S5        g)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_withStatementTupleNames1TestUnusedAssignment.test_withStatementTupleNames  rP   r   c                 &    U R                  S5        g)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_withStatementListNames0TestUnusedAssignment.test_withStatementListNames  rP   r   c                 &    U R                  S5        g)aA  
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_withStatementComplicatedTarget8TestUnusedAssignment.test_withStatementComplicatedTarget  r#  r   c                 D    U R                  S[        R                  5        g)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
        NrX   r   s    r   %test_withStatementSingleNameUndefined:TestUnusedAssignment.test_withStatementSingleNameUndefined  rX  r   c                 D    U R                  S[        R                  5        g)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
        NrX   r   s    r   %test_withStatementTupleNamesUndefined:TestUnusedAssignment.test_withStatementTupleNamesUndefined  s     	  __		r   c                 D    U R                  S[        R                  5        g)zy
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_withStatementSingleNameRedefined:TestUnusedAssignment.test_withStatementSingleNameRedefined%  r9   r   c                 D    U R                  S[        R                  5        g)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_withStatementTupleNamesRedefined:TestUnusedAssignment.test_withStatementTupleNamesRedefined0  s      	  ##		%r   c                 D    U R                  S[        R                  5        g)zz
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
        NrX   r   s    r   !test_withStatementUndefinedInside6TestUnusedAssignment.test_withStatementUndefinedInside<  r\   r   c                 &    U R                  S5        g)zd
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_withStatementNameDefinedInBody8TestUnusedAssignment.test_withStatementNameDefinedInBodyF  rP   r   c                     U R                  S[        R                  5        U R                  S[        R                  5        g)zo
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
        NrX   r   s    r   'test_withStatementUndefinedInExpression<TestUnusedAssignment.test_withStatementUndefinedInExpressionQ  s:    
 	  __	
 	  __	r   c                 &    U R                  S5        g)z+
Dict comprehensions are properly handled.
z/
        a = {1: x for x in range(10)}
        Nr.   r   s    r   test_dictComprehension+TestUnusedAssignment.test_dictComprehension`  r   r   c                 &    U R                  S5        g)z*
Set comprehensions are properly handled.
zB
        a = {1, 2, 3}
        b = {x for x in range(10)}
        Nr.   r   s    r   test_setComprehensionAndLiteral4TestUnusedAssignment.test_setComprehensionAndLiteralh  r   r   c                 H    U R                  S5        U R                  S5        g )Nz<
        try: pass
        except Exception as e: e
        zc
        def download_review():
            try: pass
            except Exception as e: e
        r.   r   s    r   test_exceptionUsedInExcept/TestUnusedAssignment.test_exceptionUsedInExceptq  s&      	
 	  	r   c                 D    U R                  S[        R                  5        g )Nz?
        try: pass
        except Exception as e: pass
        r   r   s    r   test_exceptionUnusedInExcept1TestUnusedAssignment.test_exceptionUnusedInExcept}  s      	r   )   r
   znew in Python 3.11c                 D    U R                  S[        R                  5        g )Nzf
            try:
                pass
            except* OSError as e:
                pass
        r   r   s    r   $test_exception_unused_in_except_star9TestUnusedAssignment.test_exception_unused_in_except_star  s     
 	r   c                 D    U R                  S[        R                  5        g )Nzf
        def download_review():
            try: pass
            except Exception as e: pass
        r   r   s    r   &test_exceptionUnusedInExceptInFunction;TestUnusedAssignment.test_exceptionUnusedInExceptInFunction  s      		r   c                 &    U R                  S5        g)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_exceptWithoutNameInFunction5TestUnusedAssignment.test_exceptWithoutNameInFunction  s     	  	r   c                 &    U R                  S5        g)zo
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_exceptWithoutNameInFunctionTuple:TestUnusedAssignment.test_exceptWithoutNameInFunctionTuple  r=   r   c                 &    U R                  S5        g)z\
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_augmentedAssignmentImportedFunctionCallATestUnusedAssignment.test_augmentedAssignmentImportedFunctionCall  rP   r   c                 &    U R                  S5        g)z,An assert without a message is not an error.z(
        a = 1
        assert a
        Nr.   r   s    r   test_assert_without_message0TestUnusedAssignment.test_assert_without_message        	r   c                 &    U R                  S5        g)z)An assert with a message is not an error.z-
        a = 1
        assert a, 'x'
        Nr.   r   s    r   test_assert_with_message-TestUnusedAssignment.test_assert_with_message  r  r   c                 b    U R                  S[        R                  [        R                  5        g)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_tuple&TestUnusedAssignment.test_assert_tuple  s"      ]]AMM	+r   c                 &    U R                  S5        g)z,An assert of an empty tuple is always False.z
        assert ()
        Nr.   r   s    r   test_assert_tuple_empty,TestUnusedAssignment.test_assert_tuple_empty  s      	r   c                 &    U R                  S5        g)z,An assert of a static value is not an error.z.
        assert True
        assert 1
        Nr.   r   s    r   test_assert_static'TestUnusedAssignment.test_assert_static  r  r   c                 D    U R                  S[        R                  5        g)z
Test C{yield from} statement
z9
        def bar():
            yield from foo()
        NrX   r   s    r   test_yieldFromUndefined,TestUnusedAssignment.test_yieldFromUndefined  s     	  __	r   c                 &    U R                  S5        g)z.Test PEP 498 f-strings are treated as a usage.z3
        baz = 0
        print(f'{4*baz}')
        Nr.   r   s    r   test_f_string"TestUnusedAssignment.test_f_string  r  r   r     new in Python 3.14c                 &    U R                  S5        g )Nz?
            baz = 0
            tmpl = t'hello {baz}'
        r.   r   s    r   test_t_string"TestUnusedAssignment.test_t_string  r  r   c                 &    U R                  S5        g)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_expr%TestUnusedAssignment.test_assign_expr        	r   c                 &    U R                  S5        g )Nz?
        a: int
        print(a := 3)
        print(a)
        r.   r   s    r   !test_assign_expr_after_annotation6TestUnusedAssignment.test_assign_expr_after_annotation        	r   c                 &    U R                  S5        g)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_scope5TestUnusedAssignment.test_assign_expr_generator_scope  r  r   c                 &    U R                  S5        g )Nz
        def foo(x):
            fns = [lambda x: x + 1, lambda x: x + 2, lambda x: x + 3]
            return [(x := fn(x)) for fn in fns]
        r.   r   s    r   4test_assign_expr_generator_scope_reassigns_parameterITestUnusedAssignment.test_assign_expr_generator_scope_reassigns_parameter  r  r   c                 &    U R                  S5        g)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_nested,TestUnusedAssignment.test_assign_expr_nested  r  r   r   N)Cr   r  r  r  __doc__r  r  r  r  r   r  r  r  r  r!  r%  r(  r+  r.  r1  r4  r7  r:  r=  r@  rC  rG  rJ  rM  rP  rS  rV  rZ  r]  r`  rc  rf  ri  rl  ro  rr  ru  rx  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    sx   
 

MN	 O	


:1
C.
							
	%
%	
 L7"$89 :
	+ L7"$89 :r   r  c                   P    \ rS rSrS r\" \S:  S5      S 5       rS rS r	S r
S	rg
)TestStringFormattingi  c                 j   U R                  S[        R                  5        U R                  S[        R                  5        U R                  S[        R                  5        U R                  S[        R                  5        U R                  S5        U R                  S5        U R                  S5        g )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_placeholders7TestStringFormatting.test_f_string_without_placeholders  s    Ha::;  ))		+
 	 
 ))	+ 	Iq;;<  	
 	  	
 	  	r   r  r  c                 f    U R                  S[        R                  5        U R                  S5        g )Nzt'foo'z>
            x = y = 5
            tmpl = t'{x:0{y}}'
        )r   r   TStringMissingPlaceholdersr   s    r   "test_t_string_missing_placeholders7TestStringFormatting.test_t_string_missing_placeholders7  s'    Ha::;  	r   c                 2   U R                  S[        R                  5        U R                  S[        R                  5        U R                  S[        R                  5        U R                  S[        R                  5        U R                  S[        R
                  5        U R                  S[        R                  5        U R                  S[        R                  5        U R                  S[        R                  5        U R                  S	[        R                  5        U R                  S
5        U R                  S5        U R                  S5        U R                  S5        U R                  S5        U R                  S5        U R                  S5        g )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_calls2TestStringFormatting.test_invalid_dot_format_calls@  su    ++	- 	 --	/ 	 --	/ 	 66	8 	 11	3 	 --	/ 	 --	/ 	 --	/ 	 ++	- 	/0>?  	 	  	 	  	 	  	 	  	r   c                 L   U R                  S[        R                  5        U R                  S[        R                  5        U R                  S[        R                  5        U R                  S[        R                  5        U R                  S[        R
                  5        U R                  S[        R
                  5        U R                  S[        R                  5        U R                  S[        R                  5        U R                  S	[        R                  5        U R                  S
[        R                  5        U R                  S[        R                  5        U R                  S5        U R                  S5        U R                  S5        U R                  S5        g )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_calls6TestStringFormatting.test_invalid_percent_format_callsv  s    ))	+ 	 33	5 	 33	5 	 66	8 	 33	5 	 33	5 	 ++	. 	 //	1 	 ++	- 	 ,,	. 	 00	2 	  	 	  	 	  	 	  	r   c                 H    U R                  S5        U R                  S5        g )NzS
            a = []
            '%s %s' % [*a]
            '%s %s' % (*a,)
        z8
            k = {}
            '%(k)s' % {**k}
        r.   r   s    r   5test_ok_percent_format_cannot_determine_element_countJTestStringFormatting.test_ok_percent_format_cannot_determine_element_count  s&      	
 	  	r   r   N)r   r  r  r  r  r   r   r  r  r  r  r  r   r   r   r  r    s9    > L7"$89 :4l2h	r   r  c                   \    \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rS rS rS rSrg)TestAsyncStatementsi  c                 &    U R                  S5        g )Nz8
        async def bar():
            return 42
        r.   r   s    r   test_asyncDef!TestAsyncStatements.test_asyncDef  r   r   c                 &    U R                  S5        g )NzS
        async def read_data(db):
            await db.fetch('SELECT ...')
        r.   r   s    r   test_asyncDefAwait&TestAsyncStatements.test_asyncDefAwait  r   r   c                 D    U R                  S[        R                  5        g )Nz;
        async def bar():
            return foo()
        rX   r   s    r   test_asyncDefUndefined*TestAsyncStatements.test_asyncDefUndefined  s      __	r   c                 &    U R                  S5        g )Nz
        async def read_data(db):
            output = []
            async for row in db.cursor():
                output.append(row)
            return output
        r.   r   s    r   test_asyncFor!TestAsyncStatements.test_asyncFor        	r   c                 &    U R                  S5        g )NzY
        async def coro(it):
            async for _ in it:
                pass
        r.   r   s    r   test_asyncForUnderscoreLoopVar2TestAsyncStatements.test_asyncForUnderscoreLoopVar  r  r   c                 H    U R                  S5        U R                  S5        g )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_loopControlInAsyncFor.TestAsyncStatements.test_loopControlInAsyncFor  s&      	 	  	r   c                     U R                  S[        R                  5        U R                  S[        R                  5        g )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   r   r   r   s    r   test_loopControlInAsyncForElse2TestAsyncStatements.test_loopControlInAsyncForElse  s<      ""	$ 	  	!r   c                 &    U R                  S5        g )Nz
        async def commit(session, data):
            async with session.transaction():
                await session.update(data)
        r.   r   s    r   test_asyncWith"TestAsyncStatements.test_asyncWith  r  r   c                 &    U R                  S5        g )Nz
        async def commit(session, data):
            async with session.transaction() as trans:
                await trans.begin()
                ...
                await trans.end()
        r.   r   s    r   test_asyncWithItem&TestAsyncStatements.test_asyncWithItem  r  r   c                 &    U R                  S5        g )Nz9
        def foo(a, b):
            return a @ b
        r.   r   s    r   test_matmulTestAsyncStatements.test_matmul  r   r   c                 &    U R                  S5        g )NzE
        hi = 'hi'
        mom = 'mom'
        f'{hi} {mom}'
        r.   r   s    r   test_formatstring%TestAsyncStatements.test_formatstring  r  r   c                     U R                  S5        U R                  S5        U R                  S[        R                  5        U R                  S[        R                  5        g )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_notimplemented-TestAsyncStatements.test_raise_notimplemented!  s^      	 	  	 	 ""	$ 	 ""	$r   r   N)r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r	  r  r   r   r   r  r    s>    *!*$r   r  c                   B    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
rg)TestIncompatiblePrintOperatori3  z8
Tests for warning about invalid use of print function.
c                 &    U R                  S5        g )Nz 
        print("Hello")
        r.   r   s    r   test_valid_print.TestIncompatiblePrintOperator.test_valid_print8  s      	r   c                     U R                  S[        R                  5      R                  S   nU R	                  UR
                  S5        U R	                  UR                  S5        g )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_futureJTestIncompatiblePrintOperator.test_invalid_print_when_imported_from_future=  sX    kk  !!	# $,8A	/ 	Q'!$r   c                 &    U R                  S5        g )Nz
print += 1r.   r   s    r   test_print_augmented_assign9TestIncompatiblePrintOperator.test_print_augmented_assignG  s    L!r   c                 &    U R                  S5        g)z:
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_assignment<TestIncompatiblePrintOperator.test_print_function_assignmentK  r  r   c                 &    U R                  S5        g )NzQ
        from __future__ import print_function
        a = lambda: print
        r.   r   s    r   test_print_in_lambda2TestIncompatiblePrintOperator.test_print_in_lambdaU  r   r   c                 &    U R                  S5        g )Nza
        from __future__ import print_function
        def a():
            return print
        r.   r   s    r   test_print_returned_in_function=TestIncompatiblePrintOperator.test_print_returned_in_function[  r  r   c                 &    U R                  S5        g )NzN
        from __future__ import print_function
        if print: pass
        r.   r   s    r   test_print_as_condition_test:TestIncompatiblePrintOperator.test_print_as_condition_testb  r   r   r   N)r   r  r  r  r  r  r  r  r  r   r#  r&  r  r   r   r   r  r  3  s*    
%"r   r  N)r  sysr   pyflakesr   r   pyflakes.test.harnessr   r   r   r	   r  r  r  r  r   r   r   <module>r+     s`     " 8 8S8 Sl$r	8 r	j]8 ]@z$( z$z3H 3r   