Your IP : 3.135.209.231
�
�Q�f � �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)�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<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 )N�sorted�id1�id2)�superr �match)�self�node�r� __class__s ��?/opt/alt/python312/lib64/python3.12/lib2to3/fixes/fix_idioms.pyr zFixIdioms.matchO s<