VccsdZddlmZddlmZddlmZddlmZmZm Z m Z m Z m Z dZ GddejZd Zd Zgd fd Zd Zd S)a:Fixer for function definitions with tuple parameters. def func(((a, b), c), d): ... -> def func(x, d): ((a, b), c) = x ... It will also support lambdas: lambda (x, y): x + y -> lambda t: t[0] + t[1] # The parens are a syntax error in Python 3 lambda (x): x + y -> lambda x: x + y )pytree)token) fixer_base)AssignNameNewlineNumber Subscriptsymscsvt|tjo|jdjt jkS)N) isinstancerNodechildrentyperZSTRING)stmt 7/usr/lib64/python3.11/lib2to3/fixes/fix_tuple_params.py is_docstringrs/ dFK ( ( 1 =  EL 01cs&eZdZdZdZdZdZdZdS)FixTupleParamsiTa funcdef< 'def' any parameters< '(' args=any ')' > ['->' any] ':' suite=any+ > | lambda= lambdef< 'lambda' args=vfpdef< '(' inner=any ')' > ':' body=any > cs d|vr||Sg |d}|d}|djdjtjkr)d}|djdj}t n#d}d}tjtjd d fd }|jtj kr ||nU|jtj kr@t|jD]+\}} | jtj kr|| |dk , sdS D]} |d| _ |} |dkrd d_n2t|dj|r| d_|dz} D]} |d| _  |dj| | <t!| dz| t# zdzD]}||dj|_|ddS)NZlambdasuiteargsr rz; Fcst}|}d|_t ||}|rd|_||tjtj |gdS)Nr ) rnew_namecloneprefixrreplaceappendrr r Z simple_stmt)Z tuple_arg add_prefixnargrend new_linesselfs r handle_tuplez.FixTupleParams.transform..handle_tupleCsT]]__%%A//##CCJ#qwwyy))D    a   V[)9*. )<>> ? ? ? ? ?r)rr)F)transform_lambdar rrZINDENTvaluerrZLeafr ZtfpdefZ typedargslist enumerateZparentrrZrangeZlenZchanged)r$noderesultsrrZstartZindentr%ir!ZlineZafterr"r#s` @@r transformzFixTupleParams.transform.sZ w  8((w77 7  v 8 Q  $ 4 0E1X&q)/F))CCEF+elB//C ? ? ? ? ? ? ? ? 9 # : L     Y$, , :#DM22 : :38t{*:!L!a%9999  F # #D(DKK A: "%IaL   %(+E2 3 3 "(IaL AIE # #D(DKK)2a%+&uQwc)nn 4Q 677 1 1A*0E!H a ' ' arcs|d}|d}t|d}|jtjkr2|}d|_||dSt|}t|}| t|}t|d} || | D]} | jtjkrv| j |vrmd|| j D} tjt j| g| z} | j| _| | dS)Nrbodyinnerr)rcs6g|]}|S)rZ.0Zc r z3FixTupleParams.transform_lambda..s CCCAaggiiCCCr) simplify_argsrrNAMErrr find_params map_to_indexr tuple_namerZ post_orderr'rr r Zpower) r$r)r*rr-r.ZparamsZto_indexZtup_nameZ new_paramr Z subscriptsZnews rr&zFixTupleParams.transform_lambdansfvvgg.// : # KKMMEEL LL    FT""''==F!3!344#...  Y__&&'''""  Av# 8(; CC!'1BCCC k$*#,??#4#4"5 "BDDX  #   rN)Z__name__Z __module__Z __qualname__Z run_orderZ BM_compatibleZPATTERNr,r&r/rrrrsDIMG>>>@rrcs|jtjtjfvr|S|jtjkr9|jtjkr"|jd}|jtjk"|Std|z)NrzReceived unexpected node %s)rr Zvfplistrr4vfpdefr Z RuntimeErrorr)rrr3r3s{ yT\5:.. dk !i4;& $=#Di4;& $ 4t; < <.s, K K KqQVu{5J KKNN K K Kr)rr r8r5r rr4r'r9rrr5r5sW yDK4=+,,, ej z K KDM K K KKrNcs|i}t|D]_\}}ttt|g}t |t rt |||W||z||<`|S)N)d)r(rrZstrr listr6) param_listrr:r+objZtrailers rr6r6s J''&&3VCFF^^,,- c4  & g + + + + +g%AcFF Hrcsg}|D]O}t|tr#|t|:||Pd|S)NZ_)r r;rr7Zjoin)r<Zlr=s rr7r7sd A c4   HHZ__ % % % % HHSMMMM 88A;;r)Z__doc__rrZpgen2rrZ fixer_utilrrrrrr rZBaseFixrr3r5r6r7r/rrr>s*GGGGGGGGGGGGGGGG111gggggZ'gggX = = =LLL%'$     r