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
docformatterAutomatically formats Python docstrings for consistent style
SSortSorts Python statements by dependency for clearer code
reorder-python-importsReorders Python imports into a consistent, readable layout
μsortSorts import statements
eradicateRemove commented-out code from Python files

Read our verdict in the software roundup.


Best Free and Open Source Software LinuxLinks helps you discover the best free and open source software for Linux. Explore our extensive collection of recommended applications, including alternatives to popular proprietary software.

We also publish software reviews, Linux tutorials, hardware reviews, free programming books and articles covering the wider open source community. Browse our Linux resources to discover more.

Know a useful free and open source Linux application we haven't covered? Suggest a program for inclusion.

Has your software been featured on LinuxLinks? Display one of our Featured on LinuxLinks badges on your website or GitHub README.
Subscribe

Please read our Comment Policy before commenting.

Notify of
guest
0 Comments
Oldest
Newest Most Voted