Formatting Code with Black

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

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • ssort

    Tool for automatically sorting python statements within a module

  • Shameless plug: For people who like black, I've been working on ssort[0], a python source code sorter that will organize python statements into topological order based on their dependencies. It aims to resolve a similar source of bikeshedding and back and forth commits.

    0: https://github.com/bwhmather/ssort

  • isort

    A Python utility / library to sort imports.

  • We use isort[0] for this. It even has a "black" compatible profile that line spits along black's defaults. Additionally we use autoflake[1] to remove unused import statements in place.

    [0](https://github.com/PyCQA/isort)

    [1](https://github.com/PyCQA/autoflake)

  • 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
  • deps

    Django Enhancement Proposals

  • black

    The uncompromising Python code formatter

  • The etymology of black is "any color you like, as long as it's black" [0]. The whole point is that it's _not_ configurable.

    [0] https://github.com/psf/black#readme

  • yapf

    A formatter for Python files

  • A little shoutout to a alternative Python formating tool https://github.com/google/yapf (developed by Google).

    The built in "facebook style" formating felt by far the most natural to me.

  • ipython

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

  • Here’s a script that automates the once-per-repository local setup of this feature:

    https://github.com/ipython/ipython/pull/12091/files

    Unfortunately there isn’t support for it in GitHub or GitLab yet, but there’s at least a GitLab issue here requesting it:

  • gitlab

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • autoflake

    Removes unused imports and unused variables as reported by pyflakes

  • We use isort[0] for this. It even has a "black" compatible profile that line spits along black's defaults. Additionally we use autoflake[1] to remove unused import statements in place.

    [0](https://github.com/PyCQA/isort)

    [1](https://github.com/PyCQA/autoflake)

  • ufmt

    Safe, atomic formatting with black and µsort

  • Give µsort a try instead; it's focused on providing more safety when applying sorting to large codebases, and is designed to pair well with black out of the box:

    https://usort.readthedocs.io

    https://ufmt.omnilib.dev

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