I thought the community standardized on black
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 py…
Format Python Code Using YAPF
11–20 of 67 posts
Re: Format Python Code Using YAPF
#12Earlier quoted context omitted.
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 py…
Thats a shame, especially as I've heard tabs are more accessible: https://www.reddit.com/r/javascript/comments/c8drjo/nobody_t...
Re: Format Python Code Using YAPF
#13I've used Yapf for a year, then switched to Black when it appeared. Seriously, use Black. I my experience, and to my taste, it works perfectly all the time, and the result is beautiful. It's also pep8 compliant, for the parts of pep8 that are concerned by a reformatter.
Black produces code with more lines than yapf. Sure sometimes yapf makes very weird decision (especially when using a dictionary litteral as an argument to a function) but at least it does not use 4 lines for a list with 2 items that could have fitted on one line.
Re: Format Python Code Using YAPF
#14Earlier quoted context omitted.
black is opinionated. If you disagree with black's opinions then a negotiable formatter like YAPF might be better. I personally love black though.
Black is opinionated enough that you will occasionally mumble about it, but good enough that you will keep using it anyway. That's a remarkable achievement for a formatter. For me it just took a little to get used to double-quoted strings. Rust's "cargo fmt" tool is similarly good.
Re: Format Python Code Using YAPF
#15Earlier quoted context omitted.
black is opinionated. If you disagree with black's opinions then a negotiable formatter like YAPF might be better. I personally love black though.
Black is opinionated enough that you will occasionally mumble about it, but good enough that you will keep using it anyway. That's a remarkable achievement for a formatter. For me it just took a little to get used to double-quoted strings. Rust's "cargo fmt" tool is similarly good.
Re: Format Python Code Using YAPF
#16I thought the community standardized on black
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 py…
Re: Format Python Code Using YAPF
#17I thought the community standardized on black
> Differences from Black
> - The default line length is 99 instead of 88 (configurable with --line-length).
> - Single quoted strings are preferred (configurable with --string-normalization none/single/double).
> - Empty lines between classes and defs are treated no differently from other code. The old behavior, which sometimes inserts double empty lines between them, remains available via --special-case-def-empty-lines.
> - The Vim plugin configuration variable for line length is named g:lavender_line_length instead of g:lavender_linelength, for consistency with the other configuration variable names.
Re: Format Python Code Using YAPF
#18This is one area Golang got it right with gofmt.
Re: Format Python Code Using YAPF
#19The only successful formatter are ones who don't have any knobs to tune. The reason a formatter exists is to make all codebases look consistent, not to cater to your personal style. This is one area Golang got it right with gofmt.
Re: Format Python Code Using YAPF
#20I've used Yapf for a year, then switched to Black when it appeared. Seriously, use Black. I my experience, and to my taste, it works perfectly all the time, and the result is beautiful. It's also pep8 compliant, for the parts of pep8 that are concerned by a reformatter.
From the experience in our code base, yapf produces higher-quality results, but is much slower. Black removes any additional parentheses added to enable a line split at a reasonable position (such as "and"). With those removed, black has to split at weird locations like at a function call. But switching to black just for the speed increase is reasonable.
Thus I "like" black's opinionated take.
"I see some rude code and I want to paint it black, " -- Sir Mick Jagger, probably.