python (3.12.0)
̑e f d Z ddlmZ ddlmZmZmZmZmZm Z dZ
dZ G d dej Z
y) a Adjust some old Python 2 idioms to their modern counterparts.
* Change some type comparisons to isinstance() calls:
type(x) == T -> isinstance(x, T)
type(x) is T -> isinstance(x, T)
type(x) != T -> not isinstance(x, T)
type(x) is not T -> not isinstance(x, T)
* Change "while 1:" into "while True:".
* Change both
v = list(EXPR)
v.sort()
foo(v)
and the more general
v = EXPR
v.sort()
foo(v)
into
v = sorted(EXPR)
foo(v)
)
fixer_base)CallCommaNameNode BlankLinesymsz0(n='!=' | '==' | 'is' | n=comp_op< 'is' 'not' >)z(power< 'type' trailer< '(' x=any ')' > >c X e Zd ZdZdedededed Z fdZd Zd Z d Z
d
Z xZS ) FixIdiomsTz
isinstance=comparison< z8 T=any >
|
isinstance=comparison< T=any aX >
|
while_stmt< 'while' while='1' ':' any+ >
|
sorted=any<
any*
simple_stmt<
expr_stmt< id1=any '='
power< list='list' trailer< '(' (not arglist<any+>) any ')' > >
>
'\n'
>
sort=
simple_stmt<
power< id2=any
trailer< '.' 'sort' > trailer< '(' ')' >
>
'\n'
>
next=any*
>
|
sorted=any<
any*
simple_stmt< expr_stmt< id1=any '=' expr=any > '\n' >
sort=
simple_stmt<
power< id2=any
trailer< '.' 'sort' > trailer< '(' ')' >
>
'\n'
>
next=any*
>
c V t t | | }|rd|v r|d |d k( r|S y |S )Nsortedid1id2)superr match)selfnoder __class__s L/BuggyBox/python/3.12.0/bootstrap/lib/python3.12/lib2to3/fixes/fix_idioms.pyr zFixIdioms.matchO s<