Closed rpdelaney closed 2 years ago
Thank you for the idea! This will be called SIM909
for the trial period. Once it's through the trial period, it will be called SIM124
.
Example 1: foo = foo
$ python -m astpretty --no-show-offsets /dev/stdin <<< `cat example.py`
Module(
body=[
Assign(
targets=[Name(id='foo', ctx=Store())],
value=Name(id='foo', ctx=Load()),
type_comment=None,
),
],
type_ignores=[],
)
Example 2: foo = foo = 42
$ python -m astpretty --no-show-offsets /dev/stdin <<< `cat example.py`
Module(
body=[
Assign(
targets=[
Name(id='foo', ctx=Store()),
Name(id='foo', ctx=Store()),
],
value=Constant(value=42, kind=None),
type_comment=None,
),
],
type_ignores=[],
)
Explanation
Assigning a name to itself is a no-op and should be eliminated.
Example