5 ms·
Fuck I love Black -- makes working with other developers amazing once you stick it in a precommit. The quote from Dusty Phillips on the homepage is perfect and
by Mockapapella 5y ago
Fuck I love Black -- makes working with other developers amazing once you stick it in a precommit. The quote from Dusty Phillips on the homepage is perfect and has stuck with me for years. I don't have to debate with developers about their individual preferences over what's best because we can just use Black and be done with it.
- crlees 5y agoHere here! Same.
- mumblemumble 5y agoI love it even though I dislike quite a few of its formatting rules. Because the only thing worse than a slightly wonk formatting convention is spending any time at all implementing, arguing about, or otherwise worrying about formatting conventions.
- javajosh 5y agoWord. I got major pushback trying to fix this problem at my last company, which is (in part) why I'm not there.
- unfunco 5y agoRob Pike's proverbs about Go fmt springs to mind: "Go fmt's style is nobody's favourite, but go fmt is everybody's favourite."
- ploxiln 5y agogofmt, on the other hand, gives you a lot more flexibility to wrap lines how you deem appropriate. I like gofmt way more than black.
- Mawr 5y agoExactly, gofmt is actually almost perfect. Ironically, it makes Rob's quote less meaningful. I think gofmt's brilliance comes down to it not being overly pedantic, it doesn't have an opinion on how all code should be formatted, it only fixes what it sees as clear mistakes.
- solarmist 5y agoYup! This.
- Alex3917 5y agoThe problem I have with it is that, to me, these are super readable: x = [ 1, 2, 3 ] y = { 'a': 1, 'b': 2 } Whereas these are not: x = [1, 2, 3] y = {'a': 1, 'b': 2} To me, declaring inline lists and dicts without the leading and trailing space makes it more difficult to see what the data structure is, and what it contains. This is especially true when you have lists or dicts declared inline as arguments to functions, e.g.: my_function_call([ 1, 2, 3 ]) versus: my_function_call([1, 2, 3]) While it's generally not good style to declare data structures inside function calls, at least with the space it's still somewhat apparent what's happening, whereas without the space it just looks like three positional arguments. I love the idea of black, but in practice I'm not going to use something that changes my own code into something that's more difficult for me to read.
- spiderice 5y agoMy only response to this would be “get used to it”. I used to think 2 space tabs made code harder to read than 4. Now I used 2 spaces and I’ve gotten used to it and can read it fine. And I have no doubt you could learn to read the black formatted code just as easily. I can, since that is how I format my code anyway.
- bfung 5y agoAgreed - end of day, code formatting is not that important in the context of how end users utilize the product. Read a lot of different code and programming languages. They all look pretty much the same after awhile, formatting and syntax.
- Alex3917 5y ago> I used to think 2 space tabs made code harder to read than 4. Now I used 2 spaces and I’ve gotten used to it and can read it fine. I might be in the minority, but it's an empirically testable proposition. Given the thousands of people taking Python quizzes for toptal, triplebyte, etc., it should be possible to see which version results in a lower time to answer or a higher accuracy rate.
- solarmist 5y ago
- throwaway894345 5y agoAgreed. My only grievance with Black was that it was really slow compared to gofmt or rustfmt, but that’s a perennial problem with Python tooling.
- ambivalence 5y agoThis is now improved. Black is compiled with mypyc, should be roughly 2X faster than before.
- throwaway894345 5y agoOh, good to know!
- Hnrobert42 5y agoIs there a way to pass hooks with a repo, or do you have to give people instructions about how to install them and hope they do it?
- goerz 5y agoNot directly, unfortunately. Sometimes you can hook it into the tooling, like the Makefile or the test runner. Other than that, enforce it in CI: patches that don’t match the code style can’t be merged
- globular-toast 5y agoBefore I introduced Black in my workplace, all code reviews were peppered with stuff like "should be indented", "use single quotes" etc. Made it impossible to talk about the stuff that actually matters. When introducing it there was some resistance. There's always that one guy who tried it once and it reformatted that perfectly hand-formatted function. My answer to them was suck it up. In a tiny fraction of cases Black might make a suboptimal choice, but the rest of your code is so shit it outweighs this negative by 100x.