WccsdZddlmZddlmZddlmZddlmZmZm 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 Subscriptsymscst|tjo.|jdjt j kS)N) isinstancerNodechildrentyperZSTRING)stmt 7/usr/lib64/python3.12/lib2to3/fixes/fix_tuple_params.py is_docstringrs5 dFKK ( 1 ==  ELL 01cs&eZdZdZdZdZdZdZdS)FixTupleParamsiTa funcdef< 'def' any parameters< '(' args=any ')' > ['->' any] ':' suite=any+ > | lambda= lambdef< 'lambda' args=vfpdef< '(' inner=any ')' > ':' body=any > cs d|vrj||Sg |d}|d}|djdjtjkr1d}|djdj }t n+d}d}tjtjd d fd }|jtjkr ||nl|jtjkrMt|jD]4\}} | jtjks&|| |dk 6 sdS D]} |d| _ |} |dkrd d_n5t|dj|r| d_|dz} D]} |d| _  |dj| | t!| dz| t# zdzD]}||dj|_!|dj%dS)NZlambdasuiteargsr rz; Fcsptj}|j}d|_t ||j}|rd|_|j |j tjtj|jgdS)Nr ) rnew_namecloneprefixrreplaceappendrr r Z simple_stmt)Z tuple_arg add_prefixnargrend new_linesselfs r handle_tuplez.FixTupleParams.transform..handle_tupleCsT]]_%A//#CCJ#qwwy)Dz   a   V[[)9)9*. )<> ? ? ? ?r)rr)F)transform_lambdar rrZINDENTvaluerrZLeafr ZtfpdefZ typedargslist enumerateZparentrrZrangeZlenZchanged)r$noderesultsrrZstartZindentr%ir!ZlineZafterr"r#s` @@r transformzFixTupleParams.transform.sW w  ((w7 7  v 8  Q  $ $ 4 4E1X&&q)//F)CCEF++ellB/C ? ? ? ? ? ? ? ? 99 # # L    YY$,, , ,#DMM2 : :388t{{**!L!a%9999y F # #D(DKK A::"%IaL   %(++E2 3 3"(IaL AIE # #D(DKK)2a%&uQwc)n 4Q 67 1 1A*0E!H  a ' ' arcs&|d}|d}t|d}|jtjkr,|j }d|_|j |dSt|}t|}|jt|}t|d} |j | j |jD]} | jtjks#| j|vs2d|| jD} tjt j"| j g| z} | j | _| j | dS)Nrbodyinnerr)rcs2g|]}|jS)rZ.0Zc r z3FixTupleParams.transform_lambda..sCCCAaggiiiCr) 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_lambdansGvvgg./ :: # #KKMEEL LL   FT"'==F!34#..  Y__&''"  Avv##8(;(;CC!''1BCC kk$**#,??#4"5 "BDXX  #   rN)Z__name__Z __module__Z __qualname__Z run_orderZ BM_compatibleZPATTERNr,r&r/rrrrsDIMG>>>@rrcsf|jtjtjfvr|S|jtj krS|jtj kr2|j d}|jtj kr2|Std|z)NrzReceived unexpected node %s)rr Zvfplistrr4vfpdefr Z RuntimeErrorr)rrr3r3s yyT\\5::... dkk ! !ii4;;&&==#Dii4;;&& 4t; <.s- K K KqQVVu{{5J5JKNNN Kr)rr r8r5r rr4r'r9rrr5r5s[ yyDKK4==+,, ejj zz K KDMM K KKrNcs|i}t|D]U\}}ttt|g}t |t rt |||N||z||<W|S)N)d)r(rrZstrr listr6) param_listrr:r+objZtrailers rr6r6spy J'&&3VCF^,- c4 g + + + +g%AcFF Hrcsg}|D]E}t|tr|jt|4|j|Gdj |S)NZ_)r r;rr7Zjoin)r<Zlr=s rr7r7sV A c4 HHZ_ % % % HHSMMM 88A;r)Z__doc__rrZpgen2rrZ fixer_utilrrrrrr rZBaseFixrr3r5r6r7r/rrr>s*GGGGGGGGGGGGGGGG111gggggZ''ggX = = =LLL%'$     r