K iddlmZddlmZddlmZmZmZm Z m Z ddl m Z m Z mZGdde ZGdde ZGd d e Zy ) ) version_info)messages)FutureImportation ImportationImportationFromStarImportationSubmoduleImportation)TestCaseskipskipIfcreZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZy)TestImportationObjectc`tddd}|jdk(sJt|dk(sJy)Nazimport arsource_statementstrselfbindings `/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/pyflakes/test/test_imports.pytest_import_basicz'TestImportationObject.test_import_basics6c4-'':5557|s"""c`tddd}|jdk(sJt|dk(sJy)Ncrz import a as cza as crrs rtest_import_asz$TestImportationObject.test_import_ass6c4-''?:::7|x'''rc^tdd}|jdk(sJt|dk(sJy)Na.bz import a.b)r rrrs rtest_import_submodulez+TestImportationObject.test_import_submodules4&ud3''<7777|u$$$rc`tddd}|jdk(sJt|dk(sJy)Nrrzimport a.b as ca.b as crrs rtest_import_submodule_asz.TestImportationObject.test_import_submodule_ass7c4/''+<<<<7|z)))rc`tddd}|jdk(sJt|dk(sJy)Nrrzimport a.b as aza.b as arrs r$test_import_submodule_as_source_namez:TestImportationObject.test_import_submodule_as_source_name%s7c4/''+<<<<7|z)))rcbtdddd}|jdk(sJt|dk(sJy)Nr.zfrom . import az.arrrrs rtest_importfrom_relativez.TestImportationObject.test_importfrom_relative*s9!#tS#6''+<<<<7|t###rcbtdddd}|jdk(sJt|dk(sJy)Nr..zfrom .. import a..ar'rs rtest_importfrom_relative_parentz5TestImportationObject.test_importfrom_relative_parent/s9!#tT37''+====7|u$$$rcbtdddd}|jdk(sJt|dk(sJy)Nbr+zfrom ..a import bz..a.br'rs r$test_importfrom_relative_with_modulez:TestImportationObject.test_importfrom_relative_with_module49!#tUC8''+>>>>7|w&&&rcbtdddd}|jdk(sJt|dk(sJy)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_as99!#tUC8''+CCCC7||+++rcbtdddd}|jdk(sJt|dk(sJy)Nr.rzfrom a import brr'rs rtest_importfrom_memberz,TestImportationObject.test_importfrom_member>s9!#tS#6''+<<<<7|u$$$rcbtdddd}|jdk(sJt|dk(sJy)Nrrzfrom a.b import cza.b.cr'rs r test_importfrom_submodule_memberz6TestImportationObject.test_importfrom_submodule_memberCr0rcbtdddd}|jdk(sJt|dk(sJy)Nrrr.zfrom a import b as cr!r'rs rtest_importfrom_member_asz/TestImportationObject.test_importfrom_member_asHs9!#tS#6''+AAAA7|z)))rcbtdddd}|jdk(sJt|dk(sJy)Ndrrzfrom a.b import c as dz a.b.c as dr'rs r#test_importfrom_submodule_member_asz9TestImportationObject.test_importfrom_submodule_member_asMr3rc^tdd}|jdk(sJt|dk(sJy)Nrzfrom a.b import *za.b.*rrrrs rtest_importfrom_starz*TestImportationObject.test_importfrom_starRs5!%.''+>>>>7|w&&&rc^tdd}|jdk(sJt|dk(sJy)Nz.bzfrom .b import *z.b.*r>rs rtest_importfrom_star_relativez3TestImportationObject.test_importfrom_star_relativeWs5!$-''+====7|v%%%rc`tddd}|jdk(sJt|dk(sJy)Nprint_functionz%from __future__ import print_functionz__future__.print_function)rrrrs rtest_importfrom_futurez,TestImportationObject.test_importfrom_future\s9#$4dDA''+RRRR7|::::rcD|jdtjy)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_underscoreas $ann5rN)__name__ __module__ __qualname__rrrr"r$r(r,r/r2r5r7r9r<r?rArDrKrrrrsW# ( % * * $ % ' , % ' * , ' & ; 6rrceZdZdZdZdZdZdZdZdZ 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`ZbdaZcedeedbk\dcddZfedeedbk\dcdeZgyf)gTestc|jdtjtj|jdtjtjy)Nzimport fu, barzfrom baz import fu, barrFrJs rtest_unusedImportzTest.test_unusedImportks4 $annannE -q~~q~~Nrc|jdtj|jdtj|jdtj|jdtj|jdtj|jdtj|jdtj|jdtj|jd tj|jdtj}|jd }|jd k(sJ|j d k(sJ|jdtj}|jd }|jd k(sJ|j d k(sJy)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)rGrHrIrmessage message_argsrcheckererrors rtest_unusedImport_relativezTest.test_unusedImport_relativeosF &7 -q~~> '8 (!..9 .? )1>>: *ANN; +Q^^< 2ANNC++0!..A  #}} 8888!!Y...++7H  #}} 8888!!%5555rc|jdtjtj|jdtjtjy)Nzimport fu as FU, bar as FUz#from moo import fu as FU, bar as FUrGrHRedefinedWhileUnusedrIrJs rtest_aliasedImportzTest.test_aliasedImports> 0**ANN < 9**ANN rc|jdtj|jdtj|jdtjy)Nzimport fu; fu = 3zimport fu; fu, bar = 3zimport fu; [fu, bar] = 3rGrHr_rJs rtest_redefinedWhileUnusedzTest.test_redefinedWhileUnusedsA ')?)?@ ,a.D.DE .0F0FGrcD|jdtjy)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.pathNrirJs rtest_redefinedIfzTest.test_redefinedIfs  **  ,rc&|jdy)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.pathNrbrJs rtest_redefinedIfElsezTest.test_redefinedIfElses  rcD|jdtjy)za Test that importing a module twice in a try block does raise a warning. zj try: import os import os except: pass os.pathNrirJs rtest_redefinedTryzTest.test_redefinedTrys  **  ,rc&|jdy)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.pathNrbrJs rtest_redefinedTryExceptzTest.test_redefinedTryExcepts  rc&|jdy)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.pathNrbrJs rtest_redefinedTryNestedzTest.test_redefinedTryNesteds  rc&|jdy)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) rbrJs rtest_redefinedTryExceptMultiz!Test.test_redefinedTryExceptMultis  rcD|jdtjy)Nz try: from aa import mixer except ImportError: pass else: from bb import mixer mixer(123) rirJs rtest_redefinedTryElsezTest.test_redefinedTryElses   # # %rc&|jdy)Nz try: import funca except ImportError: from bb import funca from bb import funcb else: from bbb import funcb print(funca, funcb) rbrJs rtest_redefinedTryExceptElsez Test.test_redefinedTryExceptElses  rc&|jdy)Nz try: from aa import a except ImportError: from bb import a finally: a = 42 print(a) rbrJs rtest_redefinedTryExceptFinallyz#Test.test_redefinedTryExceptFinallys   rc&|jdy)Nz try: import b except ImportError: b = Ellipsis from bb import a else: from aa import a finally: a = 42 print(a, b) rbrJs r"test_redefinedTryExceptElseFinallyz'Test.test_redefinedTryExceptElseFinallys  rcD|jdtjy)Nz> import fu def fu(): pass rirJs rtest_redefinedByFunctionzTest.test_redefinedByFunction   # #  %rcb|jdtjtjy)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^rJs rtest_redefinedInNestedFunctionz#Test.test_redefinedInNestedFunction&s&   # #Q^^  5rc|jdtjtjtjtjy)rz import fu def bar(): import fu def baz(): def fu(): pass Nr^rJs r#test_redefinedInNestedFunctionTwicez(Test.test_redefinedInNestedFunctionTwice3s5  **A,B,BNNANN 4rc&|jdy)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() NrbrJs rtest_redefinedButUsedLaterzTest.test_redefinedButUsedLaterCs  rcD|jdtjy)Nz> import fu class fu: pass rirJs rtest_redefinedByClasszTest.test_redefinedByClassUrrc&|jdy)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 NrbrJs rtest_redefinedBySubclasszTest.test_redefinedBySubclass\s   rc&|jdy)zi Test that shadowing a global with a class attribute does not produce a warning. zS import fu class bar: fu = 1 print(fu) NrbrJs rtest_redefinedInClasszTest.test_redefinedInClassgs   rcf|jd|jdtjy)zN Test that import within class is a locally scoped attribute. z2 class bar: import fu z> class bar: import fu fu NrGrH UndefinedNamerJs rtest_importInClasszTest.test_importInClassss1    __  rc&|jdy)NzD import fu def fun(): print(fu) rbrJs rtest_usedInFunctionzTest.test_usedInFunction   rc|jdtjtj|jdy)NzF import fu def fun(fu): print(fu) zX import fu def fun(fu): print(fu) print(fu) rGrHrIr_rJs rtest_shadowedByParameterzTest.test_shadowedByParameters7  ^^Q33  5   rc&|jdy)Nz fu = NonerbrJs rtest_newAssignmentzTest.test_newAssignments K rcf|jd|jdtjy)Nzimport fu; fu.bar.bazzimport fu; "bar".fu.bazrFrJs rtest_usedInGetattrzTest.test_usedInGetattrs" +, -q~~>rc&|jdy)Nzimport fu; print(fu.bar[1:])rbrJs rtest_usedInSlicezTest.test_usedInSlices 23rc&|jdy)Nz6 import fu if True: print(fu) rbrJs rtest_usedInIfBodyzTest.test_usedInIfBody   rc&|jdy)Nz/ import fu if fu: pass rbrJs rtest_usedInIfConditionalzTest.test_usedInIfConditionalrrc&|jdy)NzH import fu if False: pass elif fu: pass rbrJs rtest_usedInElifConditionalzTest.test_usedInElifConditionalrrc&|jdy)NzJ import fu if False: pass else: print(fu) rbrJs rtest_usedInElsezTest.test_usedInElserrc&|jdy)Nzimport fu; fu.bar()rbrJs rtest_usedInCallzTest.test_usedInCalls )*rc&|jdy)NzC import fu class bar: bar = fu rbrJs rtest_usedInClasszTest.test_usedInClassrrc&|jdy)NzO import fu class bar(object, fu.baz): pass rbrJs rtest_usedInClassBasezTest.test_usedInClassBaserrc&|jdy)NzR import fu def bleh(): pass print(fu) rbrJs rtest_notUsedInNestedScopezTest.test_notUsedInNestedScope   rc&|jdy)NzN import fu for bar in range(9): print(fu) rbrJs rtest_usedInForzTest.test_usedInForrrc&|jdy)Nzn import fu for bar in range(10): pass else: print(fu) rbrJs rtest_usedInForElsezTest.test_usedInForElse   rcD|jdtjy)NzH import fu for fu in range(2): pass rGrHImportShadowedByLoopVarrJs rtest_redefinedByForzTest.test_redefinedByFors   & &  (rcD|jdtjy)zi Test that shadowing a global name with a for loop variable generates a warning. zS import fu fu.bar() for fu in (): pass NrrJs rtest_shadowedByForzTest.test_shadowedByFors   & &  (rc|jdtj|jdtjy)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 NrrJs rtest_shadowedByForDeepzTest.test_shadowedByForDeeps>   & &  (   & &  (rc&|jdy)NzD import fu def fun(): return fu rbrJs rtest_usedInReturnzTest.test_usedInReturn rrc|jd|jd|jd|jd|jd|jd|jd|jd|jd |jd |jd |jd |jd |jd|jdy)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.barrbrJs rtest_usedInOperatorszTest.test_usedInOperatorss +, +, +, +, ,- +, ,- () () ,- +, +, +, ,- ,-rc&|jdy)Nzimport fu; assert fu.barrbrJs rtest_usedInAssertzTest.test_usedInAssert#s ./rc&|jdy)Nzimport fu; fu.bar[1]rbrJs rtest_usedInSubscriptzTest.test_usedInSubscript&s *+rcj|jd|jd|jdy)Nzimport fu; fu and Falsezimport fu; fu or Falsezimport fu; not fu.barrbrJs rtest_usedInLogiczTest.test_usedInLogic)s) -. ,- +,rc&|jdy)Nzimport fu; [fu]rbrJs rtest_usedInListzTest.test_usedInList.s %&rc&|jdy)Nzimport fu; (fu,)rbrJs rtest_usedInTuplezTest.test_usedInTuple1s &'rc&|jdyNz@ import fu try: fu except: pass rbrJs rtest_usedInTryzTest.test_usedInTry4rrc&|jdyrrbrJs rtest_usedInExceptzTest.test_usedInExcept;rrctjg}|jtj|jdg|y)NzR import fu try: pass except Exception as fu: pass )rHr_appendUnusedVariablerG)rexpecteds rtest_redefinedByExceptzTest.test_redefinedByExceptBs?**+(()     rc&|jdy)Nz0 import fu raise fu.bar rbrJs rtest_usedInRaisezTest.test_usedInRaiseLrrc&|jdy)NzC import fu def gen(): yield fu rbrJs rtest_usedInYieldzTest.test_usedInYieldRrrcH|jd|jdy)Nzimport fu; {fu:None}zimport fu; {1:fu}rbrJs rtest_usedInDictzTest.test_usedInDictYs *+ '(rc&|jdy)NzC import fu def f(bar=fu): pass rbrJs rtest_usedInParameterDefaultz Test.test_usedInParameterDefault]rrc&|jdy)Nzimport fu; fu.bar = 1rbrJs rtest_usedInAttributeAssignzTest.test_usedInAttributeAssignd +,rc&|jdy)Nzimport fu; fu.bar(stuff=fu)rbrJs rtest_usedInKeywordArgzTest.test_usedInKeywordArggs 12rcH|jd|jdy)Nzimport fu; bar=fuzimport fu; n=0; n+=furbrJs rtest_usedInAssignmentzTest.test_usedInAssignmentjs '( +,rcH|jd|jdy)Nz!import fu; [fu for _ in range(1)]z&import fu; [1 for _ in range(1) if fu]rbrJs rtest_usedInListCompzTest.test_usedInListCompns 78 <=rcH|jd|jdy)NzA import fu try: pass finally: fu zA import fu try: fu finally: pass rbrJs rtest_usedInTryFinallyzTest.test_usedInTryFinallyrs&     rcH|jd|jdy)Nz; import fu while 0: fu z2 import fu while fu: pass rbrJs rtest_usedInWhilezTest.test_usedInWhiles&     rcb|jdtjtjy)zt A 'global' statement shadowing an unused import should not prevent it from being reported. z6 import fu def f(): global fu N)rGrHrIUnusedIndirectAssignmentrJs rtest_usedInGlobalzTest.test_usedInGlobals&  ^^Q77 9rcD|jdtjy)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() N)rGrHrrJs rtest_usedAndGlobalzTest.test_usedAndGlobals   ' '  )rc&|jdy)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() NrbrJs rtest_assignedToGlobalzTest.test_assignedToGlobals   rc0d}|jd|zy)Nzexec("print(1)", fu.bar)z import fu; %srb)r exec_stmts rtest_usedInExeczTest.test_usedInExecs.  Oi/0rc&|jdy)Nzimport fu; lambda: furbrJs rtest_usedInLambdazTest.test_usedInLambdarrc|jdtjtj|jdy)Nzimport fu; lambda fu: fuzimport fu; lambda fu: fu fu()rrJs rtest_shadowedByLambdazTest.test_shadowedByLambdas- .NNA$:$: < 45rc&|jdy)Nzimport fu; "meow"[::fu]rbrJs rtest_usedInSliceObjzTest.test_usedInSliceObjs -.rcb|jdtjtjy)Nz= def bar(): import fu fu )rGrHrIrrJs rtest_unusedInNestedScopezTest.test_unusedInNestedScopes"  ^^Q__  .rcD|jdtjy)Nz` class bar: import fu def fun(self): fu rrJs rtest_methodsDontUseClassScopez"Test.test_methodsDontUseClassScopes  __  rc&|jdy)NzX def a(): def b(): fu import fu rbrJs rtest_nestedFunctionsNestScopez"Test.test_nestedFunctionsNestScoperrc&|jdy)Nz def a(): import fu class b: def c(self): print(fu) rbrJs r test_nestedClassAndFunctionScopez%Test.test_nestedClassAndFunctionScoperrc|jdtjtj|jdtjtj|jdtjtj}|jd}|j j dsJ|jdk(sJ|jd}|j dk(sJ|jdk(sJy ) 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 )furU)zfu.*NrGrHImportStarUsedrIrrW startswithrXrYs rtest_importStarzTest.test_importStars &(8(8!..I    q~~  /++0..@  #}}''(JKKK!!X---  #}} 8888!!Z///rc4|jdtjtj|jdtjtj|jdtjtj}|jd}|j j dsJ|jdk(sJ|jd}|j dk(sJ|jdk(sJ|jd tjtj}|jd}|j j dsJ|jd k(sJ|jd}|j dk(sJ|jd k(sJy ) z3Use of import * from a relative import is reported.zfrom .fu import *zU try: from .fu import * except: pass rrrVrrU)z.fu.*from .. import *r*)r NrrYs rtest_importStar_relativezTest.test_importStar_relativesp ')9)91>>J    q~~  /++1..@  #}}''(JKKK!!Y...  #}} 8888!![000++0..@  #}}''(JKKK!!X---  #}} 8888!!%;;;;rc&|jdtj|jdtj|jdtj}|jd}|jdk(sJ|j dk(sJy)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)rGrHImportStarNotPermittedrrWrXrYs rtest_localImportStarzTest.test_localImportStars   % % '   % % ' ++  % %'  #}} QQQQ!!X---rc&|jdy)zP If a dotted name is imported and used, no warning is reported. z. import fu.bar fu.bar NrbrJs rtest_packageImportzTest.test_packageImport!s   rcD|jdtjy)zj If a dotted name is imported and not used, an unused import warning is reported. z import fu.barNrFrJs rtest_unusedPackageImportzTest.test_unusedPackageImport*s OQ^^4rc|jdtj|jdtjy)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 NrirJs rtest_duplicateSubmoduleImportz"Test.test_duplicateSubmoduleImport1s>   # # %   # #  %rcH|jd|jdy)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 NrbrJs rtest_differentSubmoduleImportz"Test.test_differentSubmoduleImport@s(      rcH|jd|jdy)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 NrbrJs r'test_used_package_with_submodule_importz,Test.test_used_package_with_submodule_importO(     rcH|jd|jdy)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() NrbrJs r0test_used_package_with_submodule_import_of_aliasz5Test.test_used_package_with_submodule_import_of_alias_rrc|jdtj}|jd}|jdk(sJ|j dk(sJ|j r|jdk(sJyy)zR When a package and its submodule are imported, only report once. z1 import fu import fu.bar rrU)zfu.barN)rGrHrIrrWrX withDoctestlinenorYs r)test_unused_package_with_submodule_importz.Test.test_unused_package_with_submodule_importosx++ ^^  #}} 8888!!\111$($4$4u||q ;;! rc|jd|jd|jd|jdy)Nzimport fu; fu = fuzimport fu; fu, bar = fuzimport fu; [fu, bar] = fuzimport fu; fu += furbrJs rtest_assignRHSFirstzTest.test_assignRHSFirst|s6 () -. /0 )*rc&|jdy)Nzp try: import fu except ImportError: import bar as fu fu rbrJs rtest_tryingMultipleImportszTest.test_tryingMultipleImportsrrc&|jdy)Nz` import fu def a(): fu = 3 return fu fu rbrJs rtest_nonGlobalDoesNotRedefinez"Test.test_nonGlobalDoesNotRedefinerrc&|jdy)Nz; def a(): fu import fu rbrJs rtest_functionsRunLaterzTest.test_functionsRunLaterrrcD|jdtjy)NzG import fu def fu(): fu fu rirJs rtest_functionNamesAreBoundNowz"Test.test_functionNamesAreBoundNows   # #  %rc&|jdy)Nz a = 1; a = 2rbrJs r!test_ignoreNonImportRedefinitionsz&Test.test_ignoreNonImportRedefinitionss N#rtodoc&|jdy)NzY try: import fu except ImportError: pass rbrJs rtest_importingForImportErrorz!Test.test_importingForImportError   rc&|jdy)z0Imports in class scope can be used through self.zf class c: import i def __init__(self): self.i NrbrJs rtest_importedInClasszTest.test_importedInClassr3rc&|jdy)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 NrbrJs r!test_importUsedInMethodDefinitionz&Test.test_importUsedInMethodDefinitions   rcH|jd|jdy)z__future__ is special.zfrom __future__ import divisionze "docstring is allowed before future import" from __future__ import division NrbrJs rtest_futureImportzTest.test_futureImports  56   rc|jdtj|jdtjy)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)rGrHLateFutureImportrJs rtest_futureImportFirstzTest.test_futureImportFirsts>     !      !rc&|jdy)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 NrbrJs rtest_futureImportUsedzTest.test_futureImportUsedr3r)zin 3.14+ this is a SyntaxErrorcD|jdtjy)z0Importing undefined names from __future__ fails.z8 from __future__ import print_statement NrGrHFutureFeatureNotDefinedrJs rtest_futureImportUndefinedzTest.test_futureImportUndefined   & & (rcD|jdtjy)z$Importing '*' from __future__ fails.z* from __future__ import * NrBrJs rtest_futureImportStarzTest.test_futureImportStarrErN)hrLrMrNrSr\r`rcrergrjrlrnrprrrtrvrxrzr|r~rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr rrrrrrrrr#r%r'r)r+r-r/r r2r5r7r9r<r>r rrDrGrOrrrQrQis<O6.< / ) ? H ,  ,     %      % 54  $%        !?4    +     ( ((& ."0,- '(    ) -3->    9 ) 1-6 /.  0*<@.& 5 %    <+    %$ &\       !  LG #%EF(G(  LG #%EF(G(rrQc|eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZy)TestSpecialAllzH Tests for suppression of unused import warnings by C{__all__}. cb|jdtjtjy)zp An C{__all__} definition does not suppress unused import warnings in a function scope. zQ def foo(): import bar __all__ = ["bar"] N)rGrHrIrrJs rtest_ignoredInFunctionz%TestSpecialAll.test_ignoredInFunctions&  ^^Q--  /rcD|jdtjy)z_ An C{__all__} definition in a class does not suppress unused import warnings. zM import bar class foo: __all__ = ["bar"] NrFrJs rtest_ignoredInClassz"TestSpecialAll.test_ignoredInClasss  ^^  rcD|jdtjy)Nz: import bar (__all__,) = ("foo",) rFrJs r'test_ignored_when_not_directly_assignedz6TestSpecialAll.test_ignored_when_not_directly_assigned s  ^^ rcH|jd|jdy)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",) NrbrJs rtest_warningSuppressedz%TestSpecialAll.test_warningSuppresseds(      rcb|jdtjtjy)zC The C{__all__} variable is defined incrementally. z import a import c __all__ = ['a'] __all__ += ['b'] if 1 < 3: __all__ += ['c', 'd'] NrGrHUndefinedExportrJs rtest_augmentedAssignmentz'TestSpecialAll.test_augmentedAssignments(     1 1 3rc|jdtjtjtjtjy)zP The C{__all__} variable is defined through list concatenation. zD import sys __all__ = ['a'] + ['b'] + ['c'] NrGrHrTrIrJs r"test_list_concatenation_assignmentz1TestSpecialAll.test_list_concatenation_assignment,7     1 113D3Dann Vrc|jdtjtjtjtjy)zQ The C{__all__} variable is defined through tuple concatenation. zG import sys __all__ = ('a',) + ('b',) + ('c',) NrWrJs r#test_tuple_concatenation_assignmentz2TestSpecialAll.test_tuple_concatenation_assignment5rYrc&|jdy)NzF from foo import bar __all__ = [bar.__name__] rbrJs rtest_all_with_attributesz'TestSpecialAll.test_all_with_attributes>rrc&|jdy)Nz= from foo import bar __all__ = [bar] rbrJs rtest_all_with_namesz"TestSpecialAll.test_all_with_namesDs   rc&|jdy)Nzs from foo import bar from bar import baz __all__ = [bar.__name__] + [baz.__name__] rbrJs rtest_all_with_attributes_addedz-TestSpecialAll.test_all_with_attributes_addedKrrc&|jdy)Nzi from foo import bar from foo import baz __all__ = ['bar', baz.__name__] rbrJs r%test_all_mixed_attributes_and_stringsz4TestSpecialAll.test_all_mixed_attributes_and_stringsRrrcx|jdtjdD]}|jd|y)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"] )filenameNrS)rres rtest_unboundExportedz#TestSpecialAll.test_unboundExportedYsH     ; $H KK"  $ $rc|jdtjtjtjtjy)z6 Report undefined if import * is used zT from math import * __all__ = ['sin', 'cos'] csc(1) N)rGrHrImportStarUsagerJs rtest_importStarExportedz&TestSpecialAll.test_importStarExportedhs9    q00!2C2CQEVEV  Xrcb|jdtjtjy)z8Report unused import when not needed to satisfy __all__.zL from foolib import * a = 1 __all__ = ['a'] N)rGrHrrIrJs rtest_importStarNotExportedz)TestSpecialAll.test_importStarNotExportedrs$    q~~  /rcH|jd|jdy)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)NrbrJs rtest_usedInGenExpz TestSpecialAll.test_usedInGenExpzs 78 <=rcb|jdtjtjy)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^rJs rtest_redefinedByGenExpz%TestSpecialAll.test_redefinedByGenExps" 7**ANN <4rrIN)sysrpyflakesrrHpyflakes.checkerrrrrr pyflakes.test.harnessr r r rrQrIrOrrrzsI"98X6HX6vF(8F(RIXIr