Hacker News new | ask | show | jobs
by viccis 28 days ago
One Python one I hate is that it adds crazy amounts of newlines for no real readability gains.

Instead of this:

  def add_three_ints(x: int, y: int, z: int) -> int:  
      return x + y + z
it will write:

  def add_three_ints(  
      x: int,  
      y: int,  
      x: int,  
  ):  
      return x + y + z
While it's always preferable to do this when you get either long or complex function signatures, Opus 4.7 and GPT 5.5 do this everywhere. When you combine it with their penchant for writing helper functions for everything, you get a ton of vertical padding that messes up the readability imo because Python really relies on your eye seeing indents for scope.
3 comments

That's for diffing gains later.

If you have to add arguments, when they're on one line like that, the diff is cleaner, so the reviewer has an easier time kf understanding what's going on. That is, if you still have a human reviewing code, that is.

The second way produces more billable output tokens. Worse, when you feed that code back into the LLM service, the extra whitespace counts as input tokens.
an LF is 1 character, just like a space. Its just looks bigger to our puny human brains.
It isn't a 1:1 substitution. Indenting each parameter like in the second example adds additional space characters: in this case, 4 extra spaces per parameter.
A code formatter like Black can handle that. It's there to enforce a single code style no matter what the contributors use, whether they are human or AI.
Black's default, which I like, has it keep any vertical spacing of comma separated things like function arguments or list contents if they end with a trailing comma. I'm not sure there's an easy way to make a "don't break up short function signatures" rule, but would love to hear if anyone's done anything like that.
Not sure if you can still read my late reply, but Black has a `--skip-magic-trailing-comma` flag:

> By default, Black uses existing trailing commas as an indication that short lines should be left separate, as described in the style documentation. If this option is given, the magic trailing comma is ignored.

https://black.readthedocs.io/en/stable/usage_and_configurati...

It should then keep the lines intact, unless they exceed the line length. I have mine set to 120.