prettier / plugin-python

Prettier Python Plugin
MIT License
517 stars 41 forks source link

Open-ended slice notation gets removed #77

Closed IamJeffG closed 6 years ago

IamJeffG commented 6 years ago

If my code is slicing a list and not specifying start or end, prettier will remove the open-ended side, i.e. the hanging colon. This results in code that executes differently (or sometimes a syntax error).

$ echo "print(test[1:])" > bug_demo.py 
$ prettier bug_demo.py 
print(test[1])

$ echo "print(test[:])" > bug_demo.py 
$ prettier bug_demo.py 
print(test[])

The bug doesn't happen when both start and end are given for the slice range.

$ echo "print(test[1:3])" > bug_demo.py 
$ prettier bug_demo.py 
print(test[1:3])
FuegoFro commented 6 years ago

Hm, this doesn't repro for me on master, and I'm pretty sure it was fixed by https://github.com/prettier/plugin-python/pull/37. I'm gonna go ahead and close this out, but feel free to re-open if I'm mistaken and it still looks like an issue!