§
ÝÈx~ëj,”ã ód — d Z ddlmZ ddlmZmZmZmZmZm Z dZ
dZ G d„ dej ¦ « Z
dS ) 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)ÚCallÚCommaÚNameÚNodeÚ BlankLineÚsymsz0(n='!=' | '==' | 'is' | n=comp_op< 'is' 'not' >)z(power< 'type' trailer< '(' x=any ')' > >c óX ‡ — e Zd ZdZde›de›de›de›d� Zˆ fd„Zd„ 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