Formatting Code with Black

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

Our great sponsors
  • InfluxDB - Collect and Analyze Billions of Data Points in Real Time
  • Onboard AI - Learn any GitHub repo in 59 seconds
  • 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

    Collect and Analyze Billions of Data Points in Real Time. Manage all types of time series data in a single, purpose-built database. Run at any scale in any environment in the cloud, on-premises, or at the edge.

  • 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

  • Onboard AI

    Learn any GitHub repo in 59 seconds. Onboard AI learns any GitHub repo in minutes and lets you chat with it to locate functionality, understand different parts, and generate new code. Use it for free at www.getonboard.dev.

  • 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