But does it have an #ignoreformatter directive?
Black – Uncompromising Python code formatter
141–150 of 251 posts
Re: Black – Uncompromising Python code formatter
#142Re: Black – Uncompromising Python code formatter
#143I often dislike autoformatter output too, but then I remember that while no-one likes what the autoformatter does to their code, everyone likes what the autoformatter does to their coworkers' code, and then I chill out about it. Having a standard is more important than the standard being excellent.
Re: Black – Uncompromising Python code formatter
#144The ford logo is a nice touch.
Re: Black – Uncompromising Python code formatter
#145Re: Black – Uncompromising Python code formatter
#146Earlier quoted context omitted.
No, we can't. My (and, by the sound of it, CrLf's) favorite format relies on information that your pre-commit hook has artificially removed from the code. Eg: munge(gidget, thing1,thing2,thing3); cmplt(dtypeA,valueA, dtypeB,valueB); (Most cases are more subtle (and thus less amenable to "oh, you just need to build a complete static type checker into the formatter") than this, but I wanted an obvious example.)
It seems like the signature of the functions should be different, especially the second example. I would have written the cmplt function to take tuple pairs: cmplt( (type_a, value_a), (type_b, value_b), ) That's much more clear about the relationship between each pair of values either way, and would get formatted nicely by Black.
0: which doesn't have tuples anyway; you could use structs, but it doesn't really work well in context/practice.
1: I don't use python frecently enough to have ready examples of autoformatter stupidity on hand for it.
Re: Black – Uncompromising Python code formatter
#147 x = y[1]['a'] + z[2]['b']
can be broken like this in Black (if it's over the line length limit): x = y[1][
'a'] + z[2]['b']
But it needs brackets inserted so that it can be formatted something like this: x = (
y[1]['a']
+ z[2]['b']
)
You can argue the formatting I've chosen e.g. whether the binary operator should go on the previous line (the above line is what PEP 8 suggests). But surely it's clear that breaking in the indexing bracket is atrocious.Re: Black – Uncompromising Python code formatter
#148Earlier quoted context omitted.
> Having a standard is more important... Let me take a shot at why it's important. We spend years peering at code hunting for tiny, miniscule mistakes. Thus we're training ourselves, quite rigorously, to spot minor deviations. We're also irrational in the moment: our aesthetic sense is bothered by certain patterns, and our social sense wants to assign blame for this "wrongness" to individuals. An auto-formatter remov…
Agree 100%, except for a minor quibble at the end. I've tried a few small projects with pipenv and black recently, and though I love black, I'm still struggling to accept pipenv as good. It's so slow so often, and I can't understand why.
Re: Black – Uncompromising Python code formatter
#149Auto formatters are great but the problem with Black is that Python is fundamentally incompatible with them, at least if you're only willing to insert whitespace. For example a line of code like this: x = y[1]['a'] + z[2]['b'] can be broken like this in Black (if it's over the line length limit): x = y[1][ 'a'] + z[2]['b'] But it needs brackets inserted so that it can be formatted something like this: x = ( y[1]['a']…
Re: Black – Uncompromising Python code formatter
#150Against my better judgment I'll bite. I 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…