Closed MartinThoma closed 3 years ago
For(
target=Name(id='key', ctx=Store()),
iter=Call(
func=Attribute(
value=Name(id='dict', ctx=Load()),
attr='keys',
ctx=Load(),
),
args=[],
keywords=[],
),
body=[
If(
test=Compare(
left=Name(id='key', ctx=Load()),
ops=[In()],
comparators=[
List(
elts=[
Constant(value='a', kind=None),
Constant(value='c', kind=None),
],
ctx=Load(),
),
],
),
body=[
Delete(
targets=[
Subscript(
value=Name(id='dict', ctx=Load()),
slice=Name(id='key', ctx=Load()),
ctx=Del(),
),
],
),
],
orelse=[],
),
],
orelse=[],
type_comment=None,
)
Delete(
targets=[
Subscript(
value=Name(id='dict', ctx=Load()),
slice=Name(id='key', ctx=Load()),
ctx=Del(),
),
],
),
Desired change
Explanation
The change would actually introduce a bug
Example
This is an example where the mentioned rule(s) would currently be suboptimal: