bg ^ddlZddlmZddlmZGddeZGddeZdS)N)checker)TestCasec@eZdZdZedZdZdZdZdZ dS)TypeableVisitorTestsz& Tests of L{_TypeableVisitor} c~tj|}tj}|||S)zV Run L{_TypeableVisitor} on the parsed source and return the visitor. )astparser_TypeableVisitorvisit)streevisitors k/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/pyflakes/test/test_checker.py _run_visitorz!TypeableVisitorTests._run_visitor s6 y||*,, dc|d}||jgd||jdt j||jdt j||jdt j||jdt j dS)zA Test that the typeable node types are collected zx = 1 # assignment for x in range(1): pass # for loop def f(): pass # function definition with a as b: pass # with statement )rrrrN) r assertEqualtypeable_linesassertIsInstancetypeable_nodesrAssignFor FunctionDefWithselfrs rtest_node_typesz$TypeableVisitorTests.test_node_typess##    />>> g4Q7DDD g4Q7AAA g4Q7III g4Q7BBBBBrc|d}||jddg||jdt j||jdt jdS)z Test the common pitfall of missing `generic_visit` in visitors by ensuring that nested nodes are reported zdef f(): x = 1 rrN)rrrrrrrrrs rtest_visitor_recursesz*TypeableVisitorTests.test_visitor_recurses(s ##    /!Q888 g4Q7III g4Q7DDDDDrcl|d}||jgd||jdt j||jdt j||jdt jdS)z@ Test that the PEP 492 node types are collected zoasync def f(): # async def async for x in y: pass # async for async with a as b: pass # async with )rrrrrrN) rrrrrrAsyncFunctionDefAsyncFor AsyncWithrs rtest_py35_node_typesz)TypeableVisitorTests.test_py35_node_types7s##    /;;; g4Q79MNNN g4Q7FFF g4Q7GGGGGrc|d}||jddg||jdjdjddS)n Test that when two typeable nodes are present on a line, the last typeable one wins. z x = 1; y = 1rryN)rrrrtargetsidrs rtest_last_node_winsz(TypeableVisitorTests.test_last_node_winsGsc ##N33 /!Q888 /2:1=@#FFFFFrN) __name__ __module__ __qualname____doc__ staticmethodrr!r#r(r.rrrrs\CCC$ E E EHHH G G G G GrrcjeZdZdZedZdZdZdZdZ dZ dZ d Z d Z d Zd Zd ZdS)CollectTypeCommentsTestsz, Tests of L{_collect_type_comments} ctj|}tj|}tj||}d|DS)z Run L{_collect_type_comments} on the parsed source and return the mapping from nodes to comments. The return value is converted to a set: {(node_type, tuple of comments), ...} cdh|]-\}}t|td|Df.S)c3 K|] \}}|V dS)Nr4).0_r s r z>CollectTypeCommentsTests._collect...bs&00da000000r)typetuple)r:kvs r z4CollectTypeCommentsTests._collect..bs>JJJdaa%00a000001JJJr)rr r make_tokens_collect_type_commentsitems)r r tokensrets r_collectz!CollectTypeCommentsTests._collectXsOy||$Q'',T6::JJciikkJJJJrcv|d}||tjdfhdS)z@ Test that the function works for binary source sx = 1 # type: int # type: intNrGassertSetEqualrrr rFs r test_bytesz#CollectTypeCommentsTests.test_bytesds=mm122 C3:/?"@!ABBBBBrcv|d}||tjdfhdS)z> Test that the function works for text source zx = 1 # type: intrIN)rGrrrrMs r test_textz"CollectTypeCommentsTests.test_textks=mm011  ,<=>?????rct|d}||tdS)z9 Test that a non-type comment is ignored z x = 1 # noqaNrGrLsetrMs rtest_non_type_comment_ignoredz6CollectTypeCommentsTests.test_non_type_comment_ignoredrs5mmO,, C'''''rct|d}||tdS)zP Test that a type comment before something typeable is ignored. z# type: int x = 1NrRrMs r!test_type_comment_before_typeablez:CollectTypeCommentsTests.test_type_comment_before_typeableys6mm011 C'''''rct|d}||tdS)zH Test that `# type: ignore` comments are not collected. zx = 1 # type: ignoreNrRrMs r test_type_ignore_comment_ignoredz9CollectTypeCommentsTests.test_type_ignore_comment_ignoreds6mm344 C'''''rc|d}||t|d}||tdS)zg Test that `# type: ignore` comments with more content are also not collected. zx = 1 # type: ignore # noqazx = 1 #type:ignore#noqaNrRrMs r*test_type_ignore_with_other_things_ignoredzCCollectTypeCommentsTests.test_type_ignore_with_other_things_ignoredsb mm:;; C'''mm677 C'''''rcv|d}||tjdfhdS)Nzx = 1 # type: int # noqa)z# type: int # noqarKrMs r,test_type_comment_with_extra_still_collectedzECollectTypeCommentsTests.test_type_comment_with_extra_still_collecteds;mm899 C3:/G"H!IJJJJJrcv|d}||tjdfhdS)Nzx = 1 #type:int)z #type:intrKrMs r$test_type_comment_without_whitespacez=CollectTypeCommentsTests.test_type_comment_without_whitespaces:mm-.. C3:~">!?@@@@@rct|d}||tdS)Nzx = 1 # type: ignore[T]rRrMs r)test_type_comment_starts_with_word_ignorezBCollectTypeCommentsTests.test_type_comment_starts_with_word_ignores4mm566 C'''''rcv|d}||tjdfhdS)r*zdef f(): x = 1 # type: intrINrKrMs rr.z,CollectTypeCommentsTests.test_last_node_winss= mm9:: C3:/?"@!ABBBBBrcz|d}tjdfh}|||dS)zw Test that type comments for function arguments are all attributed to the function definition. z]def f( a, # type: int b, # type: str ): # type: (...) -> None pass )rJz # type: strz# type: (...) -> NoneN)rGrrrL)r rFexpecteds r#test_function_def_assigned_commentszrgs ******IGIGIGIGIG8IGIGIGXe+e+e+e+e+xe+e+e+e+e+r