Comment

Comment by eesmith

When I write argparse or click, I use one parameter per line, like:

  parser.add_argument(
      "--stdout",
      choices = ("true", "false"),
      default = "true",
      help = "log data to stdout"
  )
Black turns it into:

  parser.add_argument(
    "--stdout", choices=("true", "false"), default="true", help="log data to stdout"
  )
I find the one-line-per-term easier to understand, and even though it fits on a single line, I would rather have all add_argument()/@click.option() calls follow the same layout, to make it easier to discern the structure across dozens of similar calls.

I also like to have spaces around the "=" in my keyword=arguments, except for very short and simple calls.

PEP 8 says "Don’t use spaces around the = sign when used to indicate a keyword argument" so black is following that recommendation.

However, everywhere else in the PEP (assignment like 'x = 5', and annotations like 'class Spam: foo: int = 4' or 'def spam(foo: int = 4)', there are spaces on either side of the equals sign.

That irritates me every time I have to use black.

parent eesmith 1 year ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton