Pyink is a python formatter, forked from Black with slightly different behavior.
Maintained. Last release 3 months ago, commits in 7 of the last 26 weeks. Weaker on release cadence.
pip install pyinkPyink, pronounced pī-ˈiŋk, is a Python formatter, forked from Black with a few different formatting behaviors. We intend to keep rebasing on top of Black's latest changes.
Why Pyink?
We would love to adopt Black, but adopting it overnight is too disruptive to the thousands of developers working in our monorepo. We also have other Python tooling that assumes certain formatting, it would be a too big task to update them all at once. We decided to maintain a few local patches to Black as a medium-term solution, and release them as a separate tool called Pyink.
Pyink is intended to be an adoption helper, and we wish to remove as many patches as possible in the future.
What are the main differences?
-
Support two-space indentation, using the
pyink-indentationoption. -
Support inferring preferred quote style by calculating the majority in a file, using the
pyink-use-majority-quotesoption. -
Do not wrap trailing pragma comments if the line exceeds the length only because of the pragma (see psf/black#2843). Example
# Pyink: result = some_other_module._private_function(arg="value") # pylint: disable=protected-access # Black: result = some_other_module._private_function( arg="value" ) # pylint: disable=protected-access -
Do not wrap imports in parentheses and move them to separate lines (see psf/black#3324). Example:
# Pyink: from very_long_top_level_package_name.sub_package.another_level import a_long_module # Black: from very_long_top_level_package_name.sub_package.another_level import ( a_long_module, ) -
Add an empty line between class statements without docstrings, and the first method. We expect we will simply remove this difference from Pyink at some point. Example:
# Pyink: class MyTest(unittest.TestCase): def test_magic(self): ... # Black: class MyTest(unittest.TestCase): def test_magic(self): ... -
Module docstrings are formatted same as other docstrings (see psf/black#3493).