NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI · #1711 most downloaded on PyPI
A formatter for Python code
Last release 2 years ago
no release in 18 months
Release timing varies
gaps range from 2 months to 1.2 years
Nearly every release is documented
notes for 55 of the last 60 stable releases
2 versions withdrawn
withdrawn after publishing
11 years old
72 releases · first in 2015
Bump version to v0.43.0
Bump version to v0.43.0
The verification module has been removed. NOTE: this changes the public APIs by removing the "verify" parameter.
match as the match keyword.One column per quarter.
Fix for bad v0.40.0 packaging
Fix for bad v0.40.0 packaging
Add the --print-modified flag to print out file names of modified files when running in in-place mode.
--print-modified flag to print out file names of modified files when
running in in-place mode.Add a new Python parser to generate logical lines.
# fmt: on and # fmt: off pragmas.Look at the 'pyproject.toml' file to see if it contains ignore file information for YAPF.
yapf_api.FormatTree for formatting lib2to3 concrete
syntax trees.BLANK_LINE_BEFORE_NESTED_CLASS_OR_DEF knob for "pep8" style, so
method definitions inside a class are surrounded by a single blank line as
prescribed by PEP8.Renamed 'master' branch to 'main'.
# copybara: directives when checking line length.Added SPACES_AROUND_LIST_DELIMITERS, SPACES_AROUND_DICT_DELIMITERS, and SPACES_AROUND_TUPLE_DELIMITERS to add spaces after the opening- and before the
SPACES_AROUND_LIST_DELIMITERS, SPACES_AROUND_DICT_DELIMITERS,
and SPACES_AROUND_TUPLE_DELIMITERS to add spaces after the opening-
and before the closing-delimiters for lists, dicts, and tuples.FORCE_MULTILINE_DICT knob to ensure dictionaries always split,
even when shorter than the max line length.SPACE_INSIDE_BRACKETS to add spaces inside brackets, braces, and
parentheses.SPACES_AROUND_SUBSCRIPT_COLON to add spaces around the subscript /
slice operator.CONTINUATION_ALIGN_STYLE with FIXED or VALIGN-RIGHT now works with
space indentation.SPLIT_ALL_TOP_LEVEL_COMMA_SEPARATED_VALUES is set. The knob is meant for
values, not comments, which may be associated with the current line.This is intended to support a staggered migration from v0.29.0 to
This is intended to support a staggered migration from v0.29.0 to
=v0.30.
c.f. https://bugs.chromium.org/p/chromium/issues/detail?id=1306598#c8
Add the --quiet flag to suppress output. The return code is 1 if there are changes, similarly to the --diff flag.
--quiet flag to suppress output. The return code is 1 if there are
changes, similarly to the --diff flag.indent_closing_brackets option. This is the same as the
dedent_closing_brackets option except the brackets are indented the same
as the previous line.UnicodeDecodeError exceptions.New knob SPLIT_ALL_TOP_LEVEL_COMMA_SEPARATED_VALUES is a variation on SPLIT_ALL_COMMA_SEPARATED_VALUES in which, if a subexpression with a comma fits
SPLIT_ALL_TOP_LEVEL_COMMA_SEPARATED_VALUES is a variation on
SPLIT_ALL_COMMA_SEPARATED_VALUES in which, if a subexpression with a comma
fits in its starting line, then the subexpression is not split (thus avoiding
unnecessary splits).INDENT_DICTIONARY_VALUE for Google style.JOIN_MULTIPLE_LINES = False for Google style.BLANK_LINE_BEFORE_NESTED_CLASS_OR_DEF=False wasn't honored because the
number of newlines was erroneously calculated beforehand.SPLIT_BEFORE_ARITHMETIC_OPERATOR splits before an arithmetic operator when set. SPLIT_PENALTY_ARITHMETIC_OPERATOR allows you to set the split penalty
SPLIT_BEFORE_ARITHMETIC_OPERATOR splits before an arithmetic operator when
set. SPLIT_PENALTY_ARITHMETIC_OPERATOR allows you to set the split penalty
around arithmetic operators.ALLOW_SPLIT_BEFORE_DEFAULT_OR_NAMED_ASSIGNS allows us to split before default / named assignments.
ALLOW_SPLIT_BEFORE_DEFAULT_OR_NAMED_ASSIGNS allows us to split before
default / named assignments.ARITHMETIC_PRECEDENCE_INDICATION removes spacing around binary operators
if they have higher precedence than other operators in the same expression.SPACES_BEFORE_COMMENT can now be assigned to a specific value (standard
behavior) or a list of column values. When assigned to a list, trailing
comments will be horizontally aligned to the first column value within
the list that is greater than the maximum line length in the block.CONTINUATION_ALIGN_STYLE to accept quoted or underline-separated
option value for passing option with command line arguments.NO_SPACES_AROUND_SELECTED_BINARY_OPERATORS option enabled.Added INDENT_BLANK_LINES knob to select whether the blank lines are empty or indented consistently with the current block.
INDENT_BLANK_LINES knob to select whether the blank lines are empty
or indented consistently with the current block.DEDENT_CLOSING_BRACKETS enabled.Added 'SPLIT_BEFORE_DOT' knob to support "builder style" calls. The "builder style" option didn't work as advertised. Lines would split after the dots
DISABLE_ENDING_COMMA_HEURISTIC is a new knob to disable the heuristic which splits a list onto separate lines if the list is comma-terminated.
DISABLE_ENDING_COMMA_HEURISTIC is a new knob to disable the heuristic which
splits a list onto separate lines if the list is comma-terminated.The BLANK_LINE_BEFORE_MODULE_DOCSTRING knob adds a blank line before a module's docstring.
BLANK_LINE_BEFORE_MODULE_DOCSTRING knob adds a blank line before a
module's docstring.SPLIT_ALL_COMMA_SEPARATED_VALUES knob causes all lists, tuples, dicts
function defs, etc... to split on all values, instead of maximizing the
number of elements on each line, when not able to fit on a single line.Introduce a new option of formatting multiline literals. Add SPLIT_BEFORE_CLOSING_BRACKET knob to control whether closing bracket should get their own
SPLIT_BEFORE_CLOSING_BRACKET knob to control whether closing bracket should
get their own line.CONTINUATION_ALIGN_STYLE knob to choose continuation alignment style
when USE_TABS is enabled.Improve the speed at which files are excluded by ignoring them earlier.
USE_TABS is enabled.**foo. Take that into account and don't split after the
unpacking operator.Don't treat 'None' as a keyword if calling a function on it, like '__ne__()'.
dedent_closing_brackets option requires that it be able to split there.Improve splitting of comprehensions and generators. Add SPLIT_PENALTY_COMPREHENSION knob to control preference for keeping comprehensions on a single
SPLIT_PENALTY_COMPREHENSION knob to control preference for keeping
comprehensions on a single line and SPLIT_COMPLEX_COMPREHENSION to enable
splitting each clause of complex comprehensions onto its own line.Added SPLIT_BEFORE_EXPRESSION_AFTER_OPENING_PAREN that enforces a split after the opening paren of an expression that's surrounded by parens.
SPLIT_BEFORE_EXPRESSION_AFTER_OPENING_PAREN that enforces a split
after the opening paren of an expression that's surrounded by parens.Option ALLOW_SPLIT_BEFORE_DICT_VALUE allows a split before a value. If False, then it won't be split even if it goes over the column limit.
ALLOW_SPLIT_BEFORE_DICT_VALUE allows a split before a value. If
False, then it won't be split even if it goes over the column limit.Option NO_SPACES_AROUND_SELECTED_BINARY_OPERATORS prevents adding spaces around selected binary operators, in accordance with the current style guide.
NO_SPACES_AROUND_SELECTED_BINARY_OPERATORS prevents adding spaces
around selected binary operators, in accordance with the current style guide.--lines option.-vv flag to print out file names as they are processedDEDENT_CLOSING_BRACKETS and COALESCE_BRACKETS interacted.Add filename information to a ParseError exception.
Treat expansion operators ('*', '') in a similar way to function calls to avoid splitting directly after the opening parenthesis.
Improved performance of cloning the format decision state object. This improved the time in one *large* case from 273.485s to 234.652s.
The EACH_DICT_ENTRY_ON_SEPARATE_LINE knob indicates that each dictionary entry should be in separate lines if the full dictionary isn't able to fit on
EACH_DICT_ENTRY_ON_SEPARATE_LINE knob indicates that each dictionary
entry should be in separate lines if the full dictionary isn't able to fit on
a single line.SPLIT_BEFORE_DICT_SET_GENERATOR knob splits before the for part of a
dictionary/set generator.BLANK_LINE_BEFORE_CLASS_DOCSTRING knob adds a blank line before a
class's docstring.ALLOW_MULTILINE_DICTIONARY_KEYS knob allows dictionary keys to span
more than one line.Don't perform a global split when a named assign is part of a function call which itself is an argument to a function call. I.e., don't cause 'a' to s
Don't perform a global split when a named assign is part of a function call which itself is an argument to a function call. I.e., don't cause 'a' to split here:
func(a, b, c, d(x, y, z=42))
Allow splitting inside a subscript if it's a logical or bitwise operating. This should keep the subscript mostly contiguous otherwise.
Don't insert a space between a type hint and the '=' sign.
Keep type annotations intact as much as possible. Don't try to split the over multiple lines.
formatting can be run in parallel using the "-p" / "--parallel" flags.
REGRESSION: A comment may have a prefix with newlines in it. When calculating the prefix indent, we cannot take the newlines into account. Otherwise,
Correct emitting a diff that was accidentally removed.
Added support to retain the original line endings of the source code.
If style.SetGlobalStyle( ) was called and then yapf_api.FormatCode was called, the style set by the first call would be lost, because it would return
style.SetGlobalStyle(<create pre-defined style>) was called and then
yapf_api.FormatCode was called, the style set by the first call would be
lost, because it would return the style created by DEFAULT_STYLE_FACTORY,
which is set to PEP8 by default. Fix this by making the first call set which
factory we call as the "default" style.Dictionary values will be placed on the same line as the key if *all* of the elements in the dictionary can be placed on one line. Otherwise, the dict
Support formatting of typed names. Typed names are formatted a similar way to how named arguments are formatted, except that there's a space after the
Issue #228: Return exit code 0 on success, regardless of whether files were changed. (Previously, 0 meant success with no files modified, and 2 meant
The COALESCE_BRACKETS knob prevents splitting consecutive brackets when DEDENT_CLOSING_BRACKETS is set.
Add a knob, 'USE_TABS', to allow using tabs for indentation.
Added a knob (SPLIT_PENALTY_BEFORE_IF_EXPR) to adjust the split penalty before an if expression. This allows the user to place a list comprehension al
Prefer not to split after the opening of a subscript.
'SPLIT_BEFORE_LOGICAL_OPERATOR' wasn't working correctly. The penalty was being set incorrectly when it was part of a larger construct.
Add a knob, 'SPACES_AROUND_POWER_OPERATOR', to allow adding spaces around the power operator.
Don't rewrite the file if there are no changes.
Add 'ALLOW_MULTILINE_LAMBDAS' which allows lambdas to be formatted onto multiple lines.
Fix spacing of multiline comments when formatting is disabled.
Look at the 'setup.cfg' file to see if it contains style information for YAPF.
Make sure to align comments in data literals correctly. Also make sure we don't count a "#." in a string as an i18n comment.
Add knob to indent the dictionary value if there is a split before it.
Add option to exclude files/directories from formatting.
Support for dedenting closing brackets, "facebook" style.
Format closing scope bracket correctly when indentation size changes.
Return a 2 if the source changed, 1 on error, and 0 for no change.
Formatting of multiple files. It was halting after formatting the first file.
Return a non-zero exit code if the source was changed.
Nothing published for this version
Nothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →