bgddlmZddlmZmZmZmZmZddl m Z m Z Gdde Z Gdde Z Gdd e Zd S) )messages)FutureImportation ImportationImportationFromStarImportationSubmoduleImportation)TestCaseskipcteZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdS)TestImportationObjectcltddd}|jdksJt|dksJdS)Nazimport arsource_statementstrselfbindings k/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/pyflakes/test/test_imports.pytest_import_basicz'TestImportationObject.test_import_basicsDc4--':55557||s""""""cltddd}|jdksJt|dksJdS)Ncrz import a as cza as crrs rtest_import_asz$TestImportationObject.test_import_assDc4--'?::::7||x''''''rcjtdd}|jdksJt|dksJdS)Na.bz import a.b)rrrrs rtest_import_submodulez+TestImportationObject.test_import_submodulesB&ud33'<77777||u$$$$$$rcltddd}|jdksJt|dksJdS)Nrrzimport a.b as ca.b as crrs rtest_import_submodule_asz.TestImportationObject.test_import_submodule_assEc4//'+<<<<<7||z))))))rcltddd}|jdksJt|dksJdS)Nrrzimport a.b as aza.b as arrs r$test_import_submodule_as_source_namez:TestImportationObject.test_import_submodule_as_source_name#sEc4//'+<<<<<7||z))))))rcntdddd}|jdksJt|dksJdS)Nr.zfrom . import az.arrrrs rtest_importfrom_relativez.TestImportationObject.test_importfrom_relative(sG!#tS#66'+<<<<<7||t######rcntdddd}|jdksJt|dksJdS)Nr..zfrom .. import a..ar%rs rtest_importfrom_relative_parentz5TestImportationObject.test_importfrom_relative_parent-sG!#tT377'+=====7||u$$$$$$rcntdddd}|jdksJt|dksJdS)Nbr)zfrom ..a import bz..a.br%rs r$test_importfrom_relative_with_modulez:TestImportationObject.test_importfrom_relative_with_module2G!#tUC88'+>>>>>7||w&&&&&&rcntdddd}|jdksJt|dksJdS)Nrr)r,zfrom ..a import b as cz ..a.b as cr%rs r'test_importfrom_relative_with_module_asz=TestImportationObject.test_importfrom_relative_with_module_as7G!#tUC88'+CCCCC7|||++++++rcntdddd}|jdksJt|dksJdS)Nr,rzfrom a import brr%rs rtest_importfrom_memberz,TestImportationObject.test_importfrom_member<sG!#tS#66'+<<<<<7||u$$$$$$rcntdddd}|jdksJt|dksJdS)Nrrzfrom a.b import cza.b.cr%rs r test_importfrom_submodule_memberz6TestImportationObject.test_importfrom_submodule_memberAr.rcntdddd}|jdksJt|dksJdS)Nrrr,zfrom a import b as crr%rs rtest_importfrom_member_asz/TestImportationObject.test_importfrom_member_asFsG!#tS#66'+AAAAA7||z))))))rcntdddd}|jdksJt|dksJdS)Ndrrzfrom a.b import c as dz a.b.c as dr%rs r#test_importfrom_submodule_member_asz9TestImportationObject.test_importfrom_submodule_member_asKr1rcjtdd}|jdksJt|dksJdS)Nrzfrom a.b import *za.b.*rrrrs rtest_importfrom_starz*TestImportationObject.test_importfrom_starPsC!%..'+>>>>>7||w&&&&&&rcjtdd}|jdksJt|dksJdS)Nz.bzfrom .b import *z.b.*r<rs rtest_importfrom_star_relativez3TestImportationObject.test_importfrom_star_relativeUsC!$--'+=====7||v%%%%%%rcltddd}|jdksJt|dksJdS)Nprint_functionz%from __future__ import print_functionz__future__.print_function)rrrrs rtest_importfrom_futurez,TestImportationObject.test_importfrom_futureZsG#$4dDAA'+RRRRR7||:::::::rcF|dtjdS)zm The magic underscore var should be reported as unused when used as an import alias. zimport fu as _Nflakesm UnusedImportrs rtest_unusedImport_underscorez2TestImportationObject.test_unusedImport_underscore_s! $an55555rN)__name__ __module__ __qualname__rrrr r"r&r*r-r0r3r5r7r:r=r?rBrIrrr r s### ((( %%% *** *** $$$ %%% ''' ,,, %%% ''' *** ,,, ''' &&& ;;; 66666rr c|eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!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.Z0d/Z1d0Z2d1Z3d2Z4d3Z5d4Z6d5Z7d6Z8d7Z9d8Z:d9Z;d:Zd=Z?d>Z@d?ZAd@ZBdAZCdBZDdCZEdDZFdEZGdFZHdGZIdHZJdIZKdJZLdKZMdLZNdMZOdNZPdOZQdPZRdQZSdRZTdSZUdTZVdUZWdVZXdWZYdXZZdYZ[dZZ\e]d[d\Z^d]Z_d^Z`d_Zad`ZbdaZcdbZddcZeddS)eTestc|dtjtj|dtjtjdS)Nzimport fu, barzfrom baz import fu, barrDrHs rtest_unusedImportzTest.test_unusedImportis> $ananEEE -q~q~NNNNNrcb|dtj|dtj|dtj|dtj|dtj|dtj|dtj|dtj|d tj|dtj}|jd }|jd ksJ|jd ksJ|dtj}|jd }|jd ksJ|jd ksJdS)Nzfrom . import fuzfrom . import fu as bazzfrom .. import fuzfrom ... import fuzfrom .. import fu as bazzfrom .bar import fuzfrom ..bar import fuzfrom ...bar import fuzfrom ...bar import fu as bazr%r imported but unusedz.fu)z .fu as baz)rErFrGrmessage message_argsrcheckererrors rtest_unusedImport_relativezTest.test_unusedImport_relativemsn &777 -q~>>> '888 (!.999 .??? )1>::: *AN;;; +Q^<<< 2ANCCC++0!.AA #} 88888!Y....++7HH #} 88888!%5555555rc|dtjtj|dtjtjdS)Nzimport fu as FU, bar as FUz#from moo import fu as FU, bar as FUrErFRedefinedWhileUnusedrGrHs rtest_aliasedImportzTest.test_aliasedImportsR 0*AN < < < 9*AN < < < < >>>>rc|dtj|dtj|dtjdS)Nzimport fu; fu = 3zimport fu; fu, bar = 3zimport fu; [fu, bar] = 3rErFr]rHs rtest_redefinedWhileUnusedzTest.test_redefinedWhileUnusedsP ')?@@@ ,a.DEEE .0FGGGGGrcF|dtjdS)ze Test that importing a module twice within an if block does raise a warning. z[ i = 2 if i==1: import os import os os.pathNrgrHs rtest_redefinedIfzTest.test_redefinedIfs1  *  , , , , ,rc0|ddS)zl Test that importing a module twice in if and else blocks does not raise a warning. zi i = 2 if i==1: import os else: import os os.pathNr`rHs rtest_redefinedIfElsezTest.test_redefinedIfElses)      rcF|dtjdS)za Test that importing a module twice in a try block does raise a warning. zj try: import os import os except: pass os.pathNrgrHs rtest_redefinedTryzTest.test_redefinedTrys1  *  , , , , ,rc0|ddS)zp Test that importing a module twice in a try and except block does not raise a warning. zY try: import os except: import os os.pathNr`rHs rtest_redefinedTryExceptzTest.test_redefinedTryExcepts)      rc0|ddS)z~ Test that importing a module twice using a nested try/except and if blocks does not issue a warning. z try: if True: if True: import os except: import os os.pathNr`rHs rtest_redefinedTryNestedzTest.test_redefinedTryNesteds)      rc0|ddS)Nz try: from aa import mixer except AttributeError: from bb import mixer except RuntimeError: from cc import mixer except: from dd import mixer mixer(123) r`rHs rtest_redefinedTryExceptMultiz!Test.test_redefinedTryExceptMultis'  rcF|dtjdS)Nz try: from aa import mixer except ImportError: pass else: from bb import mixer mixer(123) rgrHs rtest_redefinedTryElsezTest.test_redefinedTryElses/   # % % % % %rc0|ddS)Nz try: import funca except ImportError: from bb import funca from bb import funcb else: from bbb import funcb print(funca, funcb) r`rHs rtest_redefinedTryExceptElsez Test.test_redefinedTryExceptElses'  rc0|ddS)Nz try: from aa import a except ImportError: from bb import a finally: a = 42 print(a) r`rHs rtest_redefinedTryExceptFinallyz#Test.test_redefinedTryExceptFinallys'       rc0|ddS)Nz try: import b except ImportError: b = Ellipsis from bb import a else: from aa import a finally: a = 42 print(a, b) r`rHs r"test_redefinedTryExceptElseFinallyz'Test.test_redefinedTryExceptElseFinallys'  rcF|dtjdS)Nz> import fu def fu(): pass rgrHs rtest_redefinedByFunctionzTest.test_redefinedByFunction/   #  % % % % %rc\|dtjtjdS)r Test that shadowing a global name with a nested function definition generates a warning. zx import fu def bar(): def baz(): def fu(): pass Nr\rHs rtest_redefinedInNestedFunctionz#Test.test_redefinedInNestedFunction$s5   #Q^  5 5 5 5 5rc|dtjtjtjtjdS)rz import fu def bar(): import fu def baz(): def fu(): pass Nr\rHs r#test_redefinedInNestedFunctionTwicez(Test.test_redefinedInNestedFunctionTwice1s?  *A,BNAN 4 4 4 4 4rc0|ddS)z Test that a global import which is redefined locally, but used later in another scope does not generate a warning. aq import unittest, transport class GetTransportTestCase(unittest.TestCase): def test_get_transport(self): transport = 'transport' self.assertIsNotNone(transport) class TestTransportMethodArgs(unittest.TestCase): def test_send_defaults(self): transport.Transport() Nr`rHs rtest_redefinedButUsedLaterzTest.test_redefinedButUsedLaterAs)  rcF|dtjdS)Nz> import fu class fu: pass rgrHs rtest_redefinedByClasszTest.test_redefinedByClassSrrc0|ddS)z If an imported name is redefined by a class statement which also uses that name in the bases list, no warning is emitted. zM from fu import bar class bar(bar): pass Nr`rHs rtest_redefinedBySubclasszTest.test_redefinedBySubclassZ)       rc0|ddS)zi Test that shadowing a global with a class attribute does not produce a warning. zS import fu class bar: fu = 1 print(fu) Nr`rHs rtest_redefinedInClasszTest.test_redefinedInClasses)       rcp|d|dtjdS)zN Test that import within class is a locally scoped attribute. z2 class bar: import fu z> class bar: import fu fu NrErF UndefinedNamerHs rtest_importInClasszTest.test_importInClassqsM      _      rc0|ddS)NzD import fu def fun(): print(fu) r`rHs rtest_usedInFunctionzTest.test_usedInFunction'       rc|dtjtj|ddS)NzF import fu def fun(fu): print(fu) zX import fu def fun(fu): print(fu) print(fu) rErFrGr]rHs rtest_shadowedByParameterzTest.test_shadowedByParametersP  ^Q3  5 5 5       rc0|ddS)Nz fu = Noner`rHs rtest_newAssignmentzTest.test_newAssignments K     rcp|d|dtjdS)Nzimport fu; fu.bar.bazzimport fu; "bar".fu.bazrDrHs rtest_usedInGetattrzTest.test_usedInGetattrs2 +,,, -q~>>>>>rc0|ddS)Nzimport fu; print(fu.bar[1:])r`rHs rtest_usedInSlicezTest.test_usedInSlices 233333rc0|ddS)Nz6 import fu if True: print(fu) r`rHs rtest_usedInIfBodyzTest.test_usedInIfBody'       rc0|ddS)Nz/ import fu if fu: pass r`rHs rtest_usedInIfConditionalzTest.test_usedInIfConditionalrrc0|ddS)NzH import fu if False: pass elif fu: pass r`rHs rtest_usedInElifConditionalzTest.test_usedInElifConditionalrrc0|ddS)NzJ import fu if False: pass else: print(fu) r`rHs rtest_usedInElsezTest.test_usedInElserrc0|ddS)Nzimport fu; fu.bar()r`rHs rtest_usedInCallzTest.test_usedInCalls )*****rc0|ddS)NzC import fu class bar: bar = fu r`rHs rtest_usedInClasszTest.test_usedInClassrrc0|ddS)NzO import fu class bar(object, fu.baz): pass r`rHs rtest_usedInClassBasezTest.test_usedInClassBaserrc0|ddS)NzR import fu def bleh(): pass print(fu) r`rHs rtest_notUsedInNestedScopezTest.test_notUsedInNestedScope'       rc0|ddS)NzN import fu for bar in range(9): print(fu) r`rHs rtest_usedInForzTest.test_usedInForrrc0|ddS)Nzn import fu for bar in range(10): pass else: print(fu) r`rHs rtest_usedInForElsezTest.test_usedInForElse'       rcF|dtjdS)NzH import fu for fu in range(2): pass rErFImportShadowedByLoopVarrHs rtest_redefinedByForzTest.test_redefinedByFors/   &  ( ( ( ( (rcF|dtjdS)zi Test that shadowing a global name with a for loop variable generates a warning. zS import fu fu.bar() for fu in (): pass NrrHs rtest_shadowedByForzTest.test_shadowedByFors1   &  ( ( ( ( (rc|dtj|dtjdS)z Test that shadowing a global name with a for loop variable nested in a tuple unpack generates a warning. zl import fu fu.bar() for (x, y, z, (a, b, c, (fu,))) in (): pass zl import fu fu.bar() for [x, y, z, (a, b, c, (fu,))] in (): pass NrrHs rtest_shadowedByForDeepzTest.test_shadowedByForDeepsV   &  ( ( (   &  ( ( ( ( (rc0|ddS)NzD import fu def fun(): return fu r`rHs rtest_usedInReturnzTest.test_usedInReturn rrc||d|d|d|d|d|d|d|d|d |d |d |d |d |d|ddS)Nzimport fu; 3 + fu.barzimport fu; 3 % fu.barzimport fu; 3 - fu.barzimport fu; 3 * fu.barzimport fu; 3 ** fu.barzimport fu; 3 / fu.barzimport fu; 3 // fu.barzimport fu; -fu.barzimport fu; ~fu.barzimport fu; 1 == fu.barzimport fu; 1 | fu.barzimport fu; 1 & fu.barzimport fu; 1 ^ fu.barzimport fu; 1 >> fu.barzimport fu; 1 << fu.barr`rHs rtest_usedInOperatorszTest.test_usedInOperatorss% +,,, +,,, +,,, +,,, ,--- +,,, ,--- ())) ())) ,--- +,,, +,,, +,,, ,--- ,-----rc0|ddS)Nzimport fu; assert fu.barr`rHs rtest_usedInAssertzTest.test_usedInAssert!s ./////rc0|ddS)Nzimport fu; fu.bar[1]r`rHs rtest_usedInSubscriptzTest.test_usedInSubscript$s *+++++rc|d|d|ddS)Nzimport fu; fu and Falsezimport fu; fu or Falsezimport fu; not fu.barr`rHs rtest_usedInLogiczTest.test_usedInLogic'sA -... ,--- +,,,,,rc0|ddS)Nzimport fu; [fu]r`rHs rtest_usedInListzTest.test_usedInList,s %&&&&&rc0|ddS)Nzimport fu; (fu,)r`rHs rtest_usedInTuplezTest.test_usedInTuple/s &'''''rc0|ddSNz@ import fu try: fu except: pass r`rHs rtest_usedInTryzTest.test_usedInTry2rrc0|ddSrr`rHs rtest_usedInExceptzTest.test_usedInExcept9rrcztjg}|tj|jdg|RdS)NzR import fu try: pass except Exception as fu: pass )rFr]appendUnusedVariablerE)rexpecteds rtest_redefinedByExceptzTest.test_redefinedByExcept@sV*+()))          rc0|ddS)Nz0 import fu raise fu.bar r`rHs rtest_usedInRaisezTest.test_usedInRaiseJrrc0|ddS)NzC import fu def gen(): yield fu r`rHs rtest_usedInYieldzTest.test_usedInYieldPrrcZ|d|ddS)Nzimport fu; {fu:None}zimport fu; {1:fu}r`rHs rtest_usedInDictzTest.test_usedInDictWs. *+++ '(((((rc0|ddS)NzC import fu def f(bar=fu): pass r`rHs rtest_usedInParameterDefaultz Test.test_usedInParameterDefault[rrc0|ddS)Nzimport fu; fu.bar = 1r`rHs rtest_usedInAttributeAssignzTest.test_usedInAttributeAssignb +,,,,,rc0|ddS)Nzimport fu; fu.bar(stuff=fu)r`rHs rtest_usedInKeywordArgzTest.test_usedInKeywordArges 122222rcZ|d|ddS)Nzimport fu; bar=fuzimport fu; n=0; n+=fur`rHs rtest_usedInAssignmentzTest.test_usedInAssignmenths. '((( +,,,,,rcZ|d|ddS)Nz!import fu; [fu for _ in range(1)]z&import fu; [1 for _ in range(1) if fu]r`rHs rtest_usedInListCompzTest.test_usedInListCompls. 7888 <=====rcZ|d|ddS)NzA import fu try: pass finally: fu zA import fu try: fu finally: pass r`rHs rtest_usedInTryFinallyzTest.test_usedInTryFinallypsD           rcZ|d|ddS)Nz; import fu while 0: fu z2 import fu while fu: pass r`rHs rtest_usedInWhilezTest.test_usedInWhile}sD           rcF|dtjdS)zt A 'global' statement shadowing an unused import should not prevent it from being reported. z6 import fu def f(): global fu NrDrHs rtest_usedInGlobalzTest.test_usedInGlobals0  ^     rc0|ddS)zt A 'global' statement shadowing a used import should not cause it to be reported as unused. zc import foo def f(): global foo def g(): foo.is_used() Nr`rHs rtest_usedAndGlobalzTest.test_usedAndGlobalrrc0|ddS)zn Binding an import to a declared global should not cause it to be reported as unused. zX def f(): global foo; import foo def g(): foo.is_used() Nr`rHs rtest_assignedToGlobalzTest.test_assignedToGlobals)       rc:d}|d|zdS)Nzexec("print(1)", fu.bar)z import fu; %sr`)r exec_stmts rtest_usedInExeczTest.test_usedInExecs$.  Oi/00000rc0|ddS)Nzimport fu; lambda: fur`rHs rtest_usedInLambdazTest.test_usedInLambdarrc|dtjtj|ddS)Nzimport fu; lambda fu: fuzimport fu; lambda fu: fu fu()rrHs rtest_shadowedByLambdazTest.test_shadowedByLambdas> .NA$: < < < 455555rc0|ddS)Nzimport fu; "meow"[::fu]r`rHs rtest_usedInSliceObjzTest.test_usedInSliceObjs -.....rc\|dtjtjdS)Nz= def bar(): import fu fu )rErFrGrrHs rtest_unusedInNestedScopezTest.test_unusedInNestedScopes2  ^Q_  . . . . .rcF|dtjdS)Nz` class bar: import fu def fun(self): fu rrHs rtest_methodsDontUseClassScopez"Test.test_methodsDontUseClassScopes.  _      rc0|ddS)NzX def a(): def b(): fu import fu r`rHs rtest_nestedFunctionsNestScopez"Test.test_nestedFunctionsNestScoperrc0|ddS)Nz def a(): import fu class b: def c(self): print(fu) r`rHs r test_nestedClassAndFunctionScopez%Test.test_nestedClassAndFunctionScoperrc|dtjtj|dtjtj|dtjtj}|jd}|jdsJ|jdksJ|jd}|jdksJ|jdksJd S) z,Use of import * at module level is reported.zfrom fu import *zT try: from fu import * except: pass r 'from %s import *' used; unable )furS)zfu.*NrErFImportStarUsedrGrrU startswithrVrWs rtest_importStarzTest.test_importStars &(8!.III   q~  / / /++0.@@ #}''(JKKKKK!X---- #} 88888!Z//////rc|dtjtj|dtjtj|dtjtj}|jd}|jdsJ|jdksJ|jd}|jdksJ|jdksJ|d tjtj}|jd}|jdsJ|jd ksJ|jd}|jdksJ|jd ksJd S) z3Use of import * from a relative import is reported.zfrom .fu import *zU try: from .fu import * except: pass rrrTrrS)z.fu.*from .. import *r()r NrrWs rtest_importStar_relativezTest.test_importStar_relatives| ')91>JJJ   q~  / / /++1.@@ #}''(JKKKKK!Y.... #} 88888![0000++0.@@ #}''(JKKKKK!X---- #} 88888!%;;;;;;;rc|dtj|dtj|dtj}|jd}|jdksJ|jdksJdS)z)import * is only allowed at module level.z7 def a(): from fu import * z7 class a: from fu import * z7 class a: from .. import * rz/'from %s import *' only allowed at module levelr N)rErFImportStarNotPermittedrrUrVrWs rtest_localImportStarzTest.test_localImportStar s   % ' ' '   % ' ' ' ++  %'' #} QQQQQ!X------rc0|ddS)zP If a dotted name is imported and used, no warning is reported. z. import fu.bar fu.bar Nr`rHs rtest_packageImportzTest.test_packageImports)       rcF|dtjdS)zj If a dotted name is imported and not used, an unused import warning is reported. z import fu.barNrDrHs rtest_unusedPackageImportzTest.test_unusedPackageImport(s OQ^44444rc|dtj|dtjdS)z If a submodule of a package is imported twice, an unused import warning and a redefined while unused warning are reported. z6 import fu.bar, fu.bar fu.bar zD import fu.bar import fu.bar fu.bar NrgrHs rtest_duplicateSubmoduleImportz"Test.test_duplicateSubmoduleImport/sV   # % % %   #  % % % % %rcZ|d|ddS)z If two different submodules of a package are imported, no duplicate import warning is reported for the package. z> import fu.bar, fu.baz fu.bar, fu.baz zL import fu.bar import fu.baz fu.bar, fu.baz Nr`rHs rtest_differentSubmoduleImportz"Test.test_differentSubmoduleImport>sF            rcZ|d|ddS)zC Usage of package marks submodule imports as used. z> import fu import fu.bar fu.x z> import fu.bar import fu fu.x Nr`rHs r'test_used_package_with_submodule_importz,Test.test_used_package_with_submodule_importMF           rcZ|d|ddS)zL Usage of package by alias marks submodule imports as used. zU import foo as f import foo.bar f.bar.do_something() z_ import foo as f import foo.bar.blah f.bar.blah.do_something() Nr`rHs r0test_used_package_with_submodule_import_of_aliasz5Test.test_used_package_with_submodule_import_of_alias]rrc|dtj}|jd}|jdksJ|jdksJ|jr |jdksndSJdS)zR When a package and its submodule are imported, only report once. z1 import fu import fu.bar rrS)zfu.barN)rErFrGrrUrV withDoctestlinenorWs r)test_unused_package_with_submodule_importz.Test.test_unused_package_with_submodule_importms++ ^ #} 88888!\1111$($4;u|q      ;  rc|d|d|d|ddS)Nzimport fu; fu = fuzimport fu; fu, bar = fuzimport fu; [fu, bar] = fuzimport fu; fu += fur`rHs rtest_assignRHSFirstzTest.test_assignRHSFirstzsT ())) -... /000 )*****rc0|ddS)Nzp try: import fu except ImportError: import bar as fu fu r`rHs rtest_tryingMultipleImportszTest.test_tryingMultipleImportsrrc0|ddS)Nz` import fu def a(): fu = 3 return fu fu r`rHs rtest_nonGlobalDoesNotRedefinez"Test.test_nonGlobalDoesNotRedefinerrc0|ddS)Nz; def a(): fu import fu r`rHs rtest_functionsRunLaterzTest.test_functionsRunLaterrrcF|dtjdS)NzG import fu def fu(): fu fu rgrHs rtest_functionNamesAreBoundNowz"Test.test_functionNamesAreBoundNows/   #  % % % % %rc0|ddS)Nz a = 1; a = 2r`rHs r!test_ignoreNonImportRedefinitionsz&Test.test_ignoreNonImportRedefinitionss N#####rtodoc0|ddS)NzY try: import fu except ImportError: pass r`rHs rtest_importingForImportErrorz!Test.test_importingForImportError'       rc0|ddS)z0Imports in class scope can be used through self.zf class c: import i def __init__(self): self.i Nr`rHs rtest_importedInClasszTest.test_importedInClassr2rc0|ddS)zW Method named 'foo' with default args referring to module named 'foo'. z import foo class Thing(object): def foo(self, parser=foo.parse_foo): pass Nr`rHs r!test_importUsedInMethodDefinitionz&Test.test_importUsedInMethodDefinitions)       rcZ|d|ddS)z__future__ is special.zfrom __future__ import divisionze "docstring is allowed before future import" from __future__ import division Nr`rHs rtest_futureImportzTest.test_futureImports: 5666       rc|dtj|dtjdS)zD __future__ imports must come before anything else. z? x = 5 from __future__ import division zY from foo import bar from __future__ import division bar N)rErFLateFutureImportrHs rtest_futureImportFirstzTest.test_futureImportFirstsV    ! ! !     ! ! ! ! !rc0|ddS)z?__future__ is special, but names are injected in the namespace.z from __future__ import division from __future__ import print_function assert print_function is not division Nr`rHs rtest_futureImportUsedzTest.test_futureImportUsedr2rcF|dtjdS)z0Importing undefined names from __future__ fails.z8 from __future__ import print_statement NrErFFutureFeatureNotDefinedrHs rtest_futureImportUndefinedzTest.test_futureImportUndefined-   & ( ( ( ( (rcF|dtjdS)z$Importing '*' from __future__ fails.z* from __future__ import * Nr?rHs rtest_futureImportStarzTest.test_futureImportStarrBrN)frJrKrLrQrZr^rarcrerhrjrlrnrprrrtrvrxrzr|r~rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr rrrrrrrr"r$r&r(r*r,r.r r1r4r6r8r;r=rArDrMrrrOrOgsOOO666.<<< /// ))) ??? HHH , , ,    , , ,           % % %            %%% 5 5 5444    $%%%                !!!???444            +++               ((( ( ( ((((&   ..."000,,,--- '''(((            )))   ---333--->>>               111---666 ///...      000*<<<@...&   555 % % %          < < <+++          %%%$$$ T&\\  \            ! ! !   ((( (((((rrOc~eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdS)TestSpecialAllzH Tests for suppression of unused import warnings by C{__all__}. c\|dtjtjdS)zp An C{__all__} definition does not suppress unused import warnings in a function scope. zQ def foo(): import bar __all__ = ["bar"] N)rErFrGrrHs rtest_ignoredInFunctionz%TestSpecialAll.test_ignoredInFunctions5  ^Q-  / / / / /rcF|dtjdS)z_ An C{__all__} definition in a class does not suppress unused import warnings. zM import bar class foo: __all__ = ["bar"] NrDrHs rtest_ignoredInClassz"TestSpecialAll.test_ignoredInClasss0  ^      rcF|dtjdS)Nz: import bar (__all__,) = ("foo",) rDrHs r'test_ignored_when_not_directly_assignedz6TestSpecialAll.test_ignored_when_not_directly_assigneds.  ^     rcZ|d|ddS)zn If a name is imported and unused but is named in C{__all__}, no warning is reported. z6 import foo __all__ = ["foo"] z7 import foo __all__ = ("foo",) Nr`rHs rtest_warningSuppressedz%TestSpecialAll.test_warningSuppressed sF            rc\|dtjtjdS)zC The C{__all__} variable is defined incrementally. z import a import c __all__ = ['a'] __all__ += ['b'] if 1 < 3: __all__ += ['c', 'd'] NrErFUndefinedExportrHs rtest_augmentedAssignmentz'TestSpecialAll.test_augmentedAssignments6    1 3 3 3 3 3rc|dtjtjtjtjdS)zP The C{__all__} variable is defined through list concatenation. zD import sys __all__ = ['a'] + ['b'] + ['c'] NrErFrQrGrHs r"test_list_concatenation_assignmentz1TestSpecialAll.test_list_concatenation_assignment(D    113Dan V V V V Vrc|dtjtjtjtjdS)zQ The C{__all__} variable is defined through tuple concatenation. zG import sys __all__ = ('a',) + ('b',) + ('c',) NrTrHs r#test_tuple_concatenation_assignmentz2TestSpecialAll.test_tuple_concatenation_assignment1rVrc0|ddS)NzF from foo import bar __all__ = [bar.__name__] r`rHs rtest_all_with_attributesz'TestSpecialAll.test_all_with_attributes:rrc0|ddS)Nz= from foo import bar __all__ = [bar] r`rHs rtest_all_with_namesz"TestSpecialAll.test_all_with_names@s'       rc0|ddS)Nzs from foo import bar from bar import baz __all__ = [bar.__name__] + [baz.__name__] r`rHs rtest_all_with_attributes_addedz-TestSpecialAll.test_all_with_attributes_addedGrrc0|ddS)Nzi from foo import bar from foo import baz __all__ = ['bar', baz.__name__] r`rHs r%test_all_mixed_attributes_and_stringsz4TestSpecialAll.test_all_mixed_attributes_and_stringsNrrc~|dtjdD]}|d|dS)zY If C{__all__} includes a name which is not bound, a warning is emitted. z# __all__ = ["foo"] )zfoo/__init__.pyz __init__.pyz+ __all__ = ["foo"] )filenameNrP)rrbs rtest_unboundExportedz#TestSpecialAll.test_unboundExportedUsh      ; $ $H KK"  $ $ $ $ $ $rc|dtjtjtjtjdS)z6 Report undefined if import * is used zT from math import * __all__ = ['sin', 'cos'] csc(1) N)rErFrImportStarUsagerHs rtest_importStarExportedz&TestSpecialAll.test_importStarExporteddsE   q0!2CQEV  X X X X Xrc\|dtjtjdS)z8Report unused import when not needed to satisfy __all__.zL from foolib import * a = 1 __all__ = ['a'] N)rErFrrGrHs rtest_importStarNotExportedz)TestSpecialAll.test_importStarNotExportedns3   q~  / / / / /rcZ|d|ddS)zR Using a global in a generator expression results in no warnings. z!import fu; (fu for _ in range(1))z&import fu; (1 for _ in range(1) if fu)Nr`rHs rtest_usedInGenExpz TestSpecialAll.test_usedInGenExpvs0 7888 <=====rc\|dtjtjdS)z Re-using a global name as the loop variable for a generator expression results in a redefinition warning. z!import fu; (1 for fu in range(1))Nr\rHs rtest_redefinedByGenExpz%TestSpecialAll.test_redefinedByGenExp}s1 7*AN < < < < >><<<4rrFN)pyflakesrrFpyflakes.checkerrrrrrpyflakes.test.harnessr r r rOrFrMrrrvs""""""10000000X6X6X6X6X6HX6X6X6vD(D(D(D(D(8D(D(D(NIIIIIXIIIIIr