So, I have tried black, yapf and autopep8 because those are the options that VS Code prompts me to use when I want to format on save.
Out of the 3, I find black the most useful, because it is more similar to Prettier. However, I don't like that it enforces me to use double quotes instead of single quotes. I have read in lots of places that this is not possible. I really like black but I find this limitation a HUGE disadvantage.
Do you know a way to enforce single quotes with black or do you prefer yapf or autopep8? Which one is more "flexible"? Do you use any of these formatters along with pylint?
Thanks for your answers!
Top comments (2)
I use black and I'm fine with the double quotes. From their documentation:
from github.com/psf/black/blob/master/d...
they explain there's a way not to enforce quotes normalization using
--skip-string-normalization
but I've never tried it.You can also use it with
flake8
if you want to go further in syntax checking: black.readthedocs.io/en/stable/com...My recommendation is to surrender to the double quotes :D
I am glad to have discovered that black automatically standardizes quoting. At some point in my early learning of python I was under the impression that single quotes were preferred and consciously tried to use them. But I found myself doing so very inconsistently since double quotes come more naturally (being the required or preferred choice in most other of the dozen languages that I use regularly)
Black is self-admittedly very opinionated and there's a number of other things layout things that I just don't like either. But I finally decided to stop caring.
And that really have been very freeing. Now I just don't care about formatting how I think it looks pretty. I just let black reformat stuff in a highly consistent manner and focus on writing the code, not the presentation of the code (which I used to expend way too much mental energy and keystrokes on).