4 ms·
Black is just slightly too opinionated. It gives you configuration options for benign things such as numeric separators, but it flat out refuses to allow tab in
by scrollaway 7y ago
Black is just slightly too opinionated. It gives you configuration options for benign things such as numeric separators, but it flat out refuses to allow tab indent, which a fairly significant part of the python community uses.
I tried to PR a --use-tabs flag but the PR was rejected without comments. Had to fork Black to be able to use it. Tan is a drop-in replacement that allows --use-tabs (and use-tabs = true in pyproject.toml).
https://github.com/jleclanche/tan https://github.com/jleclanche/tan
- jakear 7y agoThats a shame, especially as I've heard tabs are more accessible: https://www.reddit.com/r/javascript/comments/c8drjo/nobody_talks_about_the_real_reason_to_use_tabs/?utm_source=BD&utm_medium=Search&utm_name=Bing&utm_content=PSR1 https://www.reddit.com/r/javascript/comments/c8drjo/nobody_t...
- scrollaway 7y agoPrecisely why I use them and why I'm uncomfortable with Black refusing to add the option (https://github.com/psf/black/pull/513 https://github.com/psf/black/pull/513).
- patrec 7y agoThis argument sounds quite bizarre to me. Why would a visually impaired programer not manage to set their editor up to show indenting spaces the way they want, or failing that, collaborate with others to do so? It's not like they can be effective at their job either without the ability to read 3rd party code, which overwhelmingly will be space indented.
- j88439h84 7y agoHow to set an editor to use big visual indents for spaces?
- patrec 7y agoDepends on the editor, of course, but e.g. https://www.emacswiki.org/emacs/redshift-indent.el https://www.emacswiki.org/emacs/redshift-indent.el (Haven't tried the above, but I've done fairly extensive display hacks with emacs in the distant past, so I have a fair amount of confidence that it's not hard).
- stubish 7y agoThe reason Black is fast becoming standard is precisely because it is so opinionated. Like the other code formatters that have successfully become 'normal', such as gofmt. An option means that there isn't a standard, but several standards. And the people pushing Black in their projects see the benefit of a global standard, even though it is rarely 100% their personal preferences. It is a consensus.
- scrollaway 7y agoPrettier is more widespread than black, is very opinionated, and still has an option for tab indent. This is a strawman.
- weberc2 7y agoHow is this argument a strawman?
- stubish 7y agoPrettier's opinion then is that tabs are irrelevant to the formatting. Which is probably fine for the all the languages Prettier seems to support. Unlike Python, where tabs vs spaces matter. Mixing tabs and spaces is a problem, and a formatter cannot automatically support both or risks changing the meaning of code.
- scrollaway 7y agoI don't know how you arrive to this conclusion… prettier never mixes tabs and spaces, it would be a bug if it did. And there's no meaningful difference between tabs and spaces in Python either. Python has significant indent stops, that's all. Furthermore, prettier has a python plugin which does support tabs.
- zelly 7y agoWhile I prefer tabs whenever I can, I can see why it doesn't support it. If you have to share code, you're going to use spaces. For some reason everyone including Guido insists on spaces. I would rather not have to waste time thinking about formatting or much less which formatting style to use. New languages like Go and Rust solved this problem.