ML i 6dZddlmZddlmZddlmZmZddlm Z ddl m Z m Z m Z mZmZmZmZddlmZmZddlmZdd lmZmZmZmZGd d eZ dd Z dd ZGddeZGddeZ y)z/Test cases for type inference helper functions.) annotations)map_actuals_to_formals) DisjointDictgroup_comparison_operands)Key) ARG_NAMEDARG_OPTARG_POSARG_STAR ARG_STAR2ArgKindNameExpr)Suite assert_equal) TypeFixture)AnyType TupleTypeType TypeOfAnyceZdZdZddZddZddZddZddZddZ ddZ dd Z dd Z dd Z dd Zdd ZddZddZddZddZ ddZ ddZy)MapActualsToFormalsSuitez-Test cases for argmap.map_actuals_to_formals.c*|jgggyN) assert_mapselfs Y/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/mypy/test/testinfer.py test_basicz#MapActualsToFormalsSuite.test_basics B#c|jtgtgdgg|jttgttgdgdggyNrrr rs rtest_positional_onlyz-MapActualsToFormalsSuite.test_positional_onlys<  G9se4 '*Wg,>!qc Krc|jgtggg|jtgtgdgg|jtgttgdgggyNr)rr r rs r test_optionalz&MapActualsToFormalsSuite.test_optionalsK WIt,  G9se4  GW#5RyArc|jgtggg|jtgtgdgg|jttgtgddggyr!)rr r rs rtest_callee_starz)MapActualsToFormalsSuite.test_callee_starsK XJ-  H:u5 '*XJ!QArc$|jtgtgdgg|jttgtgddgg|jtgttgdgdgg|jtgttgdgdggyr!)rr r r rs rtest_caller_starz)MapActualsToFormalsSuite.test_caller_star"su  XJ!6 (+hZ1a&B  Wh$71#sD  Wh$71#sDrc|jtggg|jtggg|jtgtgdggyr&)rr r rs rtest_too_many_caller_argsz2MapActualsToFormalsSuite.test_too_many_caller_args(s>  2r*  B+  WIu5rc |ttj}|jtgt gdgg|j ||jtgt t gdgdgg|j |||jtgt ttgdgdggg|j ||yr&)rr special_formassert_vararg_mapr r make_tupler )rany_types rtest_tuple_starz(MapActualsToFormalsSuite.test_tuple_star-s9112 zG9seT__X=VW  J'*aS1#JRZ8[   J gw 'S1#rN OOHh /  rcPtt|tjSr)rlistr std_tuple)rargss rr1z#MapActualsToFormalsSuite.make_tuple:sd[]%<%<==rc|jdgtdfgdgg|jddgtdftdfgdgdggy)Nxryr"r#rs rtest_named_argsz(MapActualsToFormalsSuite.test_named_args=sH #/1#7 c gs^gs^$DsQCjQrc^|jdgtdftdftdfggdgggy)Nr:r9zrrr rs rtest_some_named_argsz-MapActualsToFormalsSuite.test_some_named_argsAs4 ###ORTWXVY[]Q^_rc<|jdgtdfgggy)Nr:r9r>rs rtest_missing_named_argz/MapActualsToFormalsSuite.test_missing_named_argDs #/"6rcB|jddgtdfgddggyNr9rr"r>rs rtest_duplicate_named_argz1MapActualsToFormalsSuite.test_duplicate_named_argGs# c gs^$41vh?rc|jtgttdfgdggg|jtdgttdfgdgdggyrC)rr rrs rtest_varargs_and_bare_asteriskz7MapActualsToFormalsSuite.test_varargs_and_bare_asteriskJsJ  X 3/?$@A3)L 3(Y4D)EaSzRrc(|jdgtgdgg|jdtgtgddgg|jdtgtdftgdgdgg|jttgtdftgdgdggyrC)rr r rs rtest_keyword_varargsz-MapActualsToFormalsSuite.test_keyword_varargsNs  {aSE2 i(9+Ax@ i(GS>9*EaSzR ),~y.IQCRSQT:Vrcf|jttgtdftdfgddgddggy)Nr9r:rr"rr r r rs rtest_both_kinds_of_varargsz3MapActualsToFormalsSuite.test_both_kinds_of_varargsTs7 9-##/OSTVWRX[\^_Z`Qabrc2|jtgttgdggg|jttgttgdgdgg|jtgtdftgdgdgg|jtgtgdggy)Nrr"r9rJrs rtest_special_casesz+MapActualsToFormalsSuite.test_special_casesWs|  Xy$9QC9E 9-)/DsQCjQ  wni%@A3*M  i[A3%8rctt|\}}t|\}}t||||d}t||y)Nc4ttjSr)rrr/)is rz5MapActualsToFormalsSuite.assert_map..jsgi445r)expand_caller_kindsexpand_callee_kindsrr) r caller_kinds_ callee_kinds_expected caller_kinds caller_names callee_kinds callee_namesresults rrz#MapActualsToFormalsSuite.assert_map]sG &9%G" l%8%G" l'     5   VX&rcBt|g|gfd}t||y)NcSr)rP vararg_types rrQz.usVar)rr)rrWrYrVr_r[s ` rr0z*MapActualsToFormalsSuite.assert_vararg_mapns"( b,LabVX&rNreturnNone)r7rrar)rTlist[ArgKind | str]rU#list[ArgKind | tuple[ArgKind, str]]rVlist[list[int]]rarb) rW list[ArgKind]rYrfrVrer_rrarb)__name__ __module__ __qualname____doc__rr$r'r)r+r-r3r1r;r?rArDrFrHrKrMrr0r^rrrrs7$LB B E 6  >R`7@SW c9 '*';'" '  '"'#'$'" '  '  'rrcg}g}|D][}t|tr'|jt|j|:|j||jd]||fSr) isinstancestrappendr)kinds_or_nameskindsnamesks rrRrRysa E E  a  LL # LLO LLO LL   %<rcg}g}|D]]}t|tr)|j|d|j|d<|j||jd_||fSr!)rltuplern)kinds_and_namesrprqvs rrSrSsj E E  a  LL1  LL1  LLO LL   %<rc8eZdZdZddZd dZd dZd dZd dZy) OperandDisjointDictSuitezTTest cases for checker.DisjointDict, which is used for type inference with operands.ctSr)rrs rnewzOperandDisjointDictSuite.news ~rc|j}|jddhdh|jhddh|jhddh|j|jddhdhfhddhfhddhfgy)Nrr"group1group2>group3rz add_mapping assertEqualitemsrds rtest_independent_mapsz.OperandDisjointDictSuite.test_independent_mapss| HHJ q!fxj) i(, i(,  GGI!Q(,y8*.E T\S]G^_ rc||j}|jddhdh|jddhdh|jddhdh|jd dhd h|jd d hd h|jdd hdh|j|jhdhdfhdddhfgy)Nrr"r|r~rrrrrgroup4rgroup5rgroup6>rr"r~rr>r|rrr>rrrrrs rtest_partial_mergingz-OperandDisjointDictSuite.test_partial_mergings HHJ q!fxj) q!fxj) q!fxj) q!fxj) q!fxj) q!fxj)  GGI "JKXx01  rcn|j}|jhddh|jhddh|jhddh|jhddh|jhd d h|jd d hd h|j|jhdhdfgy)Nrr"r~ar}b> c> r>rrerrf> rr"r~rrrrrrrrr>rrrrrrrrs rtest_full_mergingz*OperandDisjointDictSuite.test_full_mergings HHJ i#' i#' lSE* lSE* lSE* q"gu%  GGI9;Y Z [ rcD|j}|jhddh|jhddh|jhddh|jhddh|jhdd h|j|jhd hd fgy) Nrr>rrrr>r"r~rrr>r"r~rrrrr>rr"r~rrrr>rrrrrrrs r!test_merge_with_multiple_overlapsz:OperandDisjointDictSuite.test_merge_with_multiple_overlapss} HHJ i#' i#' lSE* ou- ou- &;=V%W$XYrN)razDisjointDict[int, str]r`) rgrhrirjrzrrrrr^rrrxrxs^  "  ZrrxcHeZdZdZd dZd dZd dZd dZd dZd dZ d dZ y ) OperandComparisonGroupingSuitez1Test cases for checker.group_comparison_operands.c\i}|jD]\}}d|jf||<|S)NFakeExpr)rname)rassignable_operandsoutputindexexprs rliteral_keymapz-OperandComparisonGroupingSuite.literal_keymaps:!#.446 4KE4'3F5M 4 rc td}td}td}td}td}d||fd||fd||fd||fg}|ji}|j|||||d}||fD]} |jt|| t dd d gfdd d gfdd d gfdd d gfg|jt|| dhdgdfdd d gfdd d gfg|jt|| dhdd d gfdd d gfdd d gfdd d gfg|jt|| ddhdgdfdd d gfdd d gfgy)Nx0x1x2x3x4==<rr"r~rrrr"r~rrrr"r~)rrrrset) rrrrrr basic_inputnone_assignableall_assignable assignables rtest_basic_casesz/OperandComparisonGroupingSuite.test_basic_casessd^ d^ d^ d^ d^b"~b"~R}tRQSnU --b1,,rbR-PQ*N; J   )+z35IA$A#1v1vO    )+zD6J "S1a&MD1a&>B    )+zC5IA$A#1v1vO    )+zD#;O "S1a&MD1a&>B  rc td}td}td}td}td}td}|jtd||fd||fd||fd||fg|jiddhdgd fdgd fg|jtd||fd||fd||fd||fg|jiddhdgd fg|jtd||fd||fd||fd||fg|jiddhdd d gfdgdfg|jtd||fd||fd||fd||fd||fg|jiddhdgd fdddgfdgdfgy)Nrrrrrx5risrr~rrrrr"r"r~rrrr~rrrrrrrr)rrrrrrrs rtest_multiple_groupsz3OperandComparisonGroupingSuite.test_multiple_groupss d^ d^ d^ d^ d^ d^  %B$B$B$BP##B't   I y 1 2    %B$B$B$BP##B't   O $ %    %B$B$B$BP##B't   QF^dL1 2    %B$B#r2r2QUWY[]P^_##B't   I q!f i/@ A  rcptd}td}td}td}td}dgdfdd d gfdgd fg}dgd fdd d gfg}d||fd||fd||fd||fd||fg}|jt||j||||||d dh|d |jt||j||||ddh|d|jt||j||||ddh|d|jt||j||ddh|dy)Nrrrrrrrrr~rr)rr"r~rrrz/All vars are assignable, everything is combinedrz#x0 is unassignable, so no combining)rr"rrz3Some vars are unassignable but x0 is, so we combine)rrz2All vars are unassignable but x0 is, so we combiner) rrrrrrnothing_combinedeverything_combined two_groupss rtest_multiple_groups_coalescingz>OperandComparisonGroupingSuite.test_multiple_groups_coalescing#s d^ d^ d^ d^ d^!9-aV}tY>OP $&89C!Q=I2rN 2rN "bM 2rN 2rN    %D//B2"PRWY0Z[^b]c  =    %D//B2"0LMPTv   1    %D//B2"0LMPTv  A    %j$2E2E"QSn2UX\W] ^  @ rctd}td}td}td}d||fd||fd||fd||fg}|j|||||d}|jt||ddhdgdfdgd fgd y) Nrrrrrrrrrz)Different operators can never be combined)rrrr)rrrrrgroupskeymaps r(test_multiple_groups_different_operatorszGOperandComparisonGroupingSuite.test_multiple_groups_different_operatorsPs d^ d^ d^ d^R.4R.4R.4R.Q$$rbR%HI  %fftTl CI y 1 2 7 rc td}td}d||fg}dddgfg}id|id|i||dg}tdhdhg}|D]7}|D]0}|j|} |jt || ||29y)Nrrrrr")rr"r)rrrrr) rrrsingle_comparisonexpected_outputassignable_combinations to_group_bycombo operatorsrs rtest_single_pairz/OperandComparisonGroupingSuite.test_single_pair^s d^ d^"B^, 1a&>*>@1b'Ar7XZ_aTb=c'*utftf&= , E(  ,,U3  -.?S#  rc|jtgitg|jtgidhgy)Nr)rrrrs rtest_empty_pair_listz3OperandComparisonGroupingSuite.test_empty_pair_listps< 22r35A2F 22rD6BBGrN)rzdict[int, NameExpr]razdict[int, Key]r`) rgrhrirjrrrrrrrr^rrrrs,; @' R+ Z  $HrrN)rorcra&tuple[list[ArgKind], list[str | None]])rurdrar)!rj __future__r mypy.argmapr mypy.checkerrr mypy.literalsr mypy.nodesrr r r r r rmypy.test.helpersrrmypy.test.typefixturer mypy.typesrrrrrrRrSrxrr^rrrs5".@ZZZ1-::h'uh'V ' +  8 + 7Zu7ZtdHUdHr