News for hackers. Stuff that matters.
Re:Black – Uncompromising Python code formatter by hardwaregeek on Friday May 17, 2019 @11:59AM (#19940817)
This 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 by rurban on Friday May 17, 2019 @12:26PM (#19941081)
I also switched to mandatory clang-format for a big C project of mine last month. Just the PR hooks and linter integration into github not yet. Saves away a full round of nit picking.
Re:Black – Uncompromising Python code formatter by abtinf on Friday May 17, 2019 @01:02PM (#19941454)
I think a nontrivial portion of Go’s success can be attributed to having a standard format and treating deviation as compiler errors.

It is immensely valuable to be able to look at any Go code, whether in the toolchain, the standard library, or a random stackoverflow snippet, and not have to think about formatting at all.

Re:Black – Uncompromising Python code formatter by fwip on Friday May 17, 2019 @01:07PM (#19941506)
I think you're conflating two concepts a little bit - deviation from `gofmt` isn't a compiler error, but lots of things (like unused variables or imports) are. I think they're both great.
Re:Black – Uncompromising Python code formatter by abtinf on Friday May 17, 2019 @06:47PM (#19944348)
You are corrrect. I guess I’ve learned to treat deviation from gofmt as error because of the go vim plugin. It runs goimports on save, which fixes a bunch of real errors (like unused imports).
Re:Black – Uncompromising Python code formatter by masklinn on Friday May 17, 2019 @01:10PM (#19941535)
> treating deviation as compiler errors.

That's not the case at all. The Go compiler treats an arbitrary few lint issues as compiler errors (e.g. unused imports), code which is not gofmt-formatted isn't a compiler error.

Re:Black – Uncompromising Python code formatter by lucaspottersky on Friday May 17, 2019 @02:24PM (#19942187)
thats actually a very annoying feature that has thrown me off when i tried.

you can't even comment out your code while debugging. annoying as hell.

Re:Black – Uncompromising Python code formatter by askvictor on Saturday May 18, 2019 @12:46AM (#19945703)
How do you recommend fitting an autoformatter into a programming workflow? I'm using pycharm
Re:Black – Uncompromising Python code formatter by misterdoubt on Saturday May 18, 2019 @01:52AM (#19945896)
Format on save. Failing that, format as part of your normal tox run. Failing that, pre-commit hook.
Re:Black – Uncompromising Python code formatter by IanCal on Saturday May 18, 2019 @04:11AM (#19946313)
You can also add it to your CI, for black that seems to be `black --check`
Re:Black – Uncompromising Python code formatter by Ace17 on Saturday May 18, 2019 @06:23AM (#19946657)
All my projects have a top-level 'check' script, which always does, in order:

- reformat the whole codebase

- build (if needed, e.g a C++ project)

- run all tests

The programming workflow is then:

- edit code

- run the 'check' script

- repeat.

Re:Black – Uncompromising Python code formatter by jalanb on Saturday May 18, 2019 @01:32AM (#19945847)
pycharm is a workflow now?