How to setup Black and pre-commit in python for auto text-formatting on commit

This page summarizes the projects mentioned and recommended in the original post on dev.to

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

    A framework for managing and maintaining multi-language pre-commit hooks.

  • Today we are going to look at how to setup Black (a python code formatter) and pre-commit (a package for handling git hooks in python) to automatically format you code on commit.

  • black-pre-commit-example-setup

    Example repo for article showing how to setup Black and pre-commit for text-formatting in python

  • All the Code used in this article can be found on this GitHub repo here

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

    The uncompromising Python code formatter

  • $ git commit -m "add pre-commit configuration" [INFO] Initializing environment for https://github.com/psf/black. [INFO] Installing environment for https://github.com/psf/black. [INFO] Once installed this environment will be reused. [INFO] This may take a few minutes... black................................................(no files to check)Skipped [main 6e21eab] add pre-commit configuration 1 file changed, 7 insertions(+)

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