Pyink – Python code formatter

Pyink is a Python code formatter developed as a fork of Black. It introduces a small collection of formatting differences designed to make automated code formatting easier to adopt in projects with established stylistic conventions.

The project originated from Google’s need to introduce consistent formatting without disrupting existing development workflows. Although Black provides a largely fixed style, Pyink makes selected formatting behaviours configurable while retaining much of Black’s underlying functionality.

Pyink is intended as an adoption aid rather than a completely independent formatting system. It follows Black’s development and incorporates compatible improvements while retaining selected differences where they are useful for existing codebases.

This is free and open source software.

Key Features

  • Automatically formats Python source code using a Black-derived formatting engine.
  • Supports two-space or four-space indentation through the pyink-indentation option.
  • Can infer the preferred quotation style by examining the majority of string literals in a file.
  • Preserves trailing pragma comments without unnecessarily wrapping statements.
  • Avoids certain import statement transformations performed by Black.
  • Supports additional blank-line separation between class declarations and their first methods.
  • Applies consistent formatting rules to module docstrings.
  • Preserves selected parentheses around implicitly concatenated strings.
  • Can disable Pyink-specific formatting behaviour to produce Black-compatible output.
  • Supports Black’s command-line formatting options.
  • Reads project configuration from the [tool.pyink] section of pyproject.toml.
  • Provides check and diff modes for validating formatting changes.
  • Supports formatting selected line ranges through inherited Black functionality.
  • Integrates with pre-commit and editor workflows.
  • Incorporates upstream Black improvements while maintaining selected formatting differences.

Website: github.com/google/pyink
Support:
Developer: Google
License: MIT License

Pyink is written in Python. Learn Python with our recommended free books and free tutorials.


Related Software

Python Code Formatters
RuffExtremely fast Python linter and code formatter
YAPFPython formatter based on clang-format
BlackUncompromising Python code formatter
isortPython utility and library to sort imports
autopep8Formats Python code to conform to the PEP 8 style guide
DarkerApply black reformatting to Python files
PyinkPython code formatter
blueSomewhat less uncompromising code formatter than black
μsortSorts import statements
eradicateRemove commented-out code from Python files

Read our verdict in the software roundup.


Best Free and Open Source Software Explore our carefully curated directory of recommended free and open source software, covering every major software category.

The directory forms part of our extensive collection of articles for Linux enthusiasts. It includes hundreds of detailed reviews, together with free and open source alternatives to proprietary software from companies such as Google, Microsoft, Apple, Adobe, IBM, Cisco, Oracle, and Autodesk.

LinuxLinks also covers interesting projects worth exploring, Linux-compatible hardware, free programming books and tutorials, and much more.

Know a useful free and open source Linux application that we haven’t covered? Tell us about it using our submission form.
Subscribe

Please read our Comment Policy before commenting.

Notify of
guest
0 Comments
Oldest
Newest Most Voted