Black, the Uncompromising (Python) Code Formatter Is Stable

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • ipython

    Official repository for IPython itself. Other repos in the IPython organization contain things like the website, documentation builds, etc.

  • “the next release will likely revert it”

    — Carreau, https://github.com/ipython/ipython/issues/13463#issuecomment...

  • black

    The uncompromising Python code formatter

  • I'm a huge fan of black, and have been using it in most of my projects for a long time.

    That being said, my biggest gripe with it is that it has at some point started reformatting docstrings [0] in addition to the code -- strictly following PEP 257 [1] -- without any way to disable that behaviour. While I understand the desire to standardise, docstrings are not executable code, and should be allowed more flexibility when it comes to formatting.

    [0] https://github.com/psf/black/issues/1779

    [1] https://www.python.org/dev/peps/pep-0257/

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • pip-audit

    Audits Python environments, requirements files and dependency trees for known security vulnerabilities, and can automatically fix them

  • Hooray!

    Loosely related - This is Python pip. Trail of Bits has a tool pip-audit that audits Python environments and dependency trees for known vulnerabilities.

    https://github.com/trailofbits/pip-audit

  • prettier

    Prettier is an opinionated code formatter.

  • google-java-format

    Reformats Java source code to comply with Google Java Style.

  • tan

    The uncompromising Python code formatter

  • Congratulations. I'm a Python developer of 17+ years and Black is truly a huge blessing in the Python ecosystem.

    That said, I'm a little sad to see it's gone stable without adding support for tabs, which would be extremely simple to add at this point (cf. https://github.com/jleclanche/tan/commit/e23c038167528bdacdd...). I have a lot of people using this tab-capable fork, that I did not advertise anywhere.

    Łukasz seems to have a personal grudge against tabs which may be why the issue for tab support was closed early on, but there's a plethora of good reasons to support it behind a flag. I don't want to rehash those arguments here on HN but you think you could re-think the approach a bit?

    I'd be happy to do a PR if it's not getting rejected right away with "no discussion allowed" like the last one was (before Black was moved to PSF maintainership).

  • squelch

  • Although the constructs are nearly structurally identical, they can be formatted very differently, which sometimes hinders understanding them.

    A different approach would be to instead normalize all words to a certain fixed width. So, "to_add" and "to_remove" would have the same virtual width.

    A related issue is that leading indentation counts towards the width limit. This causes refactorings which simply move code around (changing its indentation level) to change the code's shape, even when the code hasn't otherwise changed. This is exacerbated by that one often needs to shape code in such a way that Black formats it in an agreeable way, but this is generally not done during refactorings, so the readability of the code suffers.

    I had the opportunity to write a formatter (for SQL, also unconfigurable/opinionated); it seems to successfully avoid these problems: https://github.com/CyberShadow/squelch

  • SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
  • yapf

    A formatter for Python files

  • Have been a long time user of yapf along with isort, yapf is way less opionated and its been good till now. https://github.com/google/yapf

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • We should format code on demand

    7 projects | /r/programming | 1 Mar 2022
  • Write better Python - with some help!

    7 projects | dev.to | 3 Aug 2021
  • Thanks to Pycharms pep8 hints I've been making my code proudly and beautifully pep8 for years. Started working at a company on a very big python project a month ago and I'm stunned by how other people code. Is it normal to work to Pep8?

    2 projects | /r/Jetbrains | 8 Apr 2021
  • Let's meet Black: Python Code Formatting

    2 projects | dev.to | 7 Feb 2024
  • Auto-formater for Android (Kotlin)

    1 project | /r/androiddev | 5 Dec 2023