VcdZddlmZddlmZddlmZddlmZmZm 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 Subscriptsymscvt|tjo|jdjt jkS)N) isinstancerNodechildrentyperSTRING)stmts 7/usr/lib64/python3.11/lib2to3/fixes/fix_tuple_params.py is_docstringrs/ dFK ( ( 1 =  EL 01c&eZdZdZdZdZdZdZdS)FixTupleParamsTa funcdef< 'def' any parameters< '(' args=any ')' > ['->' any] ':' suite=any+ > | lambda= lambdef< 'lambda' args=vfpdef< '(' inner=any ')' > ':' body=any > c 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)Nlambdasuiteargsr rz; Fct}|}d|_t ||}|rd|_||tjtj |gdS)Nr ) rnew_namecloneprefixrreplaceappendrrr simple_stmt) tuple_arg add_prefixnargrend new_linesselfs r handle_tuplez.FixTupleParams.transform..handle_tupleCsT]]__%%A//##CCJ#qwwyy))D    a   V[)9*. )<>> ? ? ? ? ?r)r)r!)F)transform_lambdarrrINDENTvaluerrLeafr tfpdef typedargslist enumerateparentr$rrangelenchanged)r.noderesultsrrstartindentr/ir+lineafterr,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 ' ' arc|d}|d}t|d}|jtjkr2|}d|_||dSt|}t|}| t|}t|d} || | D]} | jtjkrv| j |vrmd|| j D} tjt j| g| z} | j| _| | dS)Nrbodyinnerr!)r$c6g|]}|S)r#.0cs r z3FixTupleParams.transform_lambda..s CCCAaggiiCCCr) simplify_argsrrNAMEr#r$r% find_params map_to_indexr" tuple_namer post_orderr2rrr power) r.r;r<rrDrEparamsto_indextup_name new_paramr* subscriptsnews rr0zFixTupleParams.transform_lambdansfvvgg.// : # KKMMEEL LL    FT""''==F!3!344#...  Y__&&'''""  Av# 8(; CC!'1BCCC k$*#,??#4#4"5 "BDDX  #   rN)__name__ __module__ __qualname__ run_order BM_compatiblePATTERNrBr0rGrrrrsDIMG>>>@rrc|jtjtjfvr|S|jtjkr9|jtjkr"|jd}|jtjk"|Std|z)NrzReceived unexpected node %s)rr vfplistrrMvfpdefr RuntimeErrorr;s rrLrLs{ yT\5:.. dk !i4;& $=#Di4;& $ 4t; < <.s, K K KqQVu{5J KKNN K K Kr)rr rarNrrrMr2rcs rrNrNsW yDK4=+,,, ej z K KDM K K KKrNc|i}t|D]_\}}ttt|g}t |t rt |||W||z||<`|S)N)d)r6r r strrlistrO) param_listr$rhr?objtrailers rrOrOs J''&&3VCFF^^,,- c4  & g + + + + +g%AcFF Hrcg}|D]O}t|tr#|t|:||Pd|S)N_)rrjr&rPjoin)rklrls rrPrPsd A c4   HHZ__ % % % % HHSMMMM 88A;;r)__doc__rrpgen2rr fixer_utilrrrr r r rBaseFixrrLrNrOrPrGrrrvs*GGGGGGGGGGGGGGGG111gggggZ'gggX = = =LLL%'$     r