WcdZddlmZddlmZddlmZddlmZmZm 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 Subscriptsymsct|tjo.|jdjt j kS)N) isinstancerNodechildrentyperSTRING)stmts 7/usr/lib64/python3.12/lib2to3/fixes/fix_tuple_params.py is_docstringrs5 dFKK ( 1 ==  ELL 01c&eZdZdZdZdZdZdZdS)FixTupleParamsTa funcdef< 'def' any parameters< '(' args=any ')' > ['->' any] ':' suite=any+ > | lambda= lambdef< 'lambda' args=vfpdef< '(' inner=any ')' > ':' body=any > c 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)Nlambdasuiteargsr rz; Fcptj}|j}d|_t ||j}|rd|_|j |j tjtj|jgdS)Nr ) rnew_namecloneprefixrreplaceappendrrr simple_stmt) tuple_arg add_prefixnargrend new_linesselfs r handle_tuplez.FixTupleParams.transform..handle_tupleCsT]]_%A//#CCJ#qwwy)Dz   a   V[[)9)9*. )<> ? ? ? ?r)r)r!)F)transform_lambdarrrINDENTvaluerrLeafr tfpdef typedargslist enumerateparentr$rrangelenchanged)r.noderesultsrrstartindentr/ir+lineafterr,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 ' ' arc&|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!)r$c2g|]}|jS)r#.0cs r z3FixTupleParams.transform_lambda..sCCCAaggiiiCr) 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_lambdansGvvgg./ :: # #KKMEEL LL   FT"'==F!34#..  Y__&''"  Avv##8(;(;CC!''1BCC kk$**#,??#4"5 "BDXX  #   rN)__name__ __module__ __qualname__ run_order BM_compatiblePATTERNrBr0rGrrrrsDIMG>>>@rrcf|jtjtjfvr|S|jtj krS|jtj kr2|j d}|jtj kr2|Std|z)NrzReceived unexpected node %s)rr vfplistrrMvfpdefr RuntimeErrorr;s rrLrLs yyT\\5::... dkk ! !ii4;;&&==#Dii4;;&& 4t; <.s- K K KqQVVu{{5J5JKNNN Kr)rr rarNrrrMr2rcs rrNrNs[ yyDKK4==+,, ejj zz K KDMM K KKrNc|i}t|D]U\}}ttt|g}t |t rt |||N||z||<W|S)N)d)r6r r strrlistrO) param_listr$rhr?objtrailers rrOrOspy J'&&3VCF^,- c4 g + + + +g%AcFF Hrcg}|D]E}t|tr|jt|4|j|Gdj |S)N_)rrjr&rPjoin)rklrls rrPrPsV A c4 HHZ_ % % % HHSMMM 88A;r)__doc__rrpgen2rr fixer_utilrrrr r r rBaseFixrrLrNrOrPrGrrrvs*GGGGGGGGGGGGGGGG111gggggZ''ggX = = =LLL%'$     r