Black – Uncompromising Python code formatter
21–30 of 251 posts
Re: Black – Uncompromising Python code formatter
#22I've been using it for a few months now, but I don't really like it. It does remove quabbles about formatting, but I've personally never felt that as a problem and it just replaces them with constant frustration. I think code formatting is very important for readability, and I think many (subtle) choices about how to make a piece of code more readable are very subjective. These types of tools are just incapable to ma…
Re: Black – Uncompromising Python code formatter
#23How do you enforce the use of a formatter in a project -- pre-commit hook? pre-receive hook? both? And is there a convention to put a specific dotfile at the project root to hint at your IDE/editor that it should use a certain tool for automatic formatting?
Re: Black – Uncompromising Python code formatter
#24I like the idea of auto-formatting code, like go does. Though I think I prefer autopep8
Re: Black – Uncompromising Python code formatter
#25Let me know when it's available as a Vim plugin.
https://github.com/python/black/blob/master/plugin/black.vim
Re: Black – Uncompromising Python code formatter
#26I've been using it for a few months now, but I don't really like it. It does remove quabbles about formatting, but I've personally never felt that as a problem and it just replaces them with constant frustration. I think code formatting is very important for readability, and I think many (subtle) choices about how to make a piece of code more readable are very subjective. These types of tools are just incapable to ma…
Re: Black – Uncompromising Python code formatter
#27The way you can tell that black is good is that everyone mildly dislikes a few things about it, but they're usually different things. That's usually a good clue that you've hit real middle-ground. I blackify my projects once we hit 3 contributors.
Why wait? I run black on all my new single-author projects.
Re: Black – Uncompromising Python code formatter
#28I super dislike black's formatting, and I think it's really rare to actually see it in codebases. It wraps weirdly (sometimes not at all). I'd prefer to use yapf, but last I checked it still crashes on "f-strings".
Here's a small example:
basket.add({
apple.stem
for satchel in satchels
for apple in satchel
})
Black formats this as: basket.add(
{
apple.stem
for satchel in satchels
for apple in satchel
}
)
I've never seen Python code like that.I totally believe using a formatter is good practice. Black is in a challenging position of coming into a community with a lot of existing code and customs, and I get that. But I also think that's an opportunity, rather than having to guess at what is good, there's a wealth of prior art to look at. I wish it had done this, rather than essentially codify the author's style.
Re: Black – Uncompromising Python code formatter
#29This is a case where I'm completely decided. Everybody should use an autoformatter. The minimal benefit you get from custom formatting is completely outweighed by the uniformity, the consistency and readability of autoformatted code.
Re: Black – Uncompromising Python code formatter
#30If you use Pandas you should be using method chaining and therefore also black.