• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 # Change Log
2 # All notable changes to this project will be documented in this file.
3 # This project adheres to [Semantic Versioning](http://semver.org/).
4 
5 ## [0.23.0] UNRELEASED
6 ### Added
7 - `DISABLE_ENDING_COMMA_HEURISTIC` is a new knob to disable the heuristic which
8   splits a list onto separate lines if the list is comma-terminated.
9 ### Fixed
10 - There's no need to increase N_TOKENS. In fact, it causes other things which
11   use lib2to3 to fail if called from YAPF.
12 - Change the exception message instead of creating a new one that's just a
13   clone.
14 
15 ## [0.22.0] 2018-05-15
16 ### Added
17 - The `BLANK_LINE_BEFORE_MODULE_DOCSTRING` knob adds a blank line before a
18   module's docstring.
19 - The `SPLIT_ALL_COMMA_SEPARATED_VALUES` knob causes all lists, tuples, dicts
20   function defs, etc... to split on all values, instead of maximizing the
21   number of elements on each line, when not able to fit on a single line.
22 ### Changed
23 - Improve the heuristic we use to determine when to split at the start of a
24   function call. First check whether or not all elements can fit in the space
25   without wrapping. If not, then we split.
26 - Check all of the elements of a tuple. Similarly to how arguments are
27   analyzed. This allows tuples to be split more rationally.
28 - Adjust splitting penalties around arithmetic operators so that the code can
29   flow more freely. The code must flow!
30 - Try to meld an argument list's closing parenthesis to the last argument.
31 ### Fixed
32 - Attempt to determine if long lambdas are allowed. This can be done on a
33   case-by-case basis with a "pylint" disable comment.
34 - A comment before a decorator isn't part of the decorator's line.
35 - Only force a new wrapped line after a comment in a decorator when it's the
36   first token in the decorator.
37 
38 ## [0.21.0] 2018-03-18
39 ### Added
40 - Introduce a new option of formatting multiline literals. Add
41   `SPLIT_BEFORE_CLOSING_BRACKET` knob to control whether closing bracket should
42   get their own line.
43 - Added `CONTINUATION_ALIGN_STYLE` knob to choose continuation alignment style
44   when `USE_TABS` is enabled.
45 - Add 'BLANK_LINES_AROUND_TOP_LEVEL_DEFINITION' knob to control the number
46   of blank lines between top-level function and class definitions.
47 ### Fixed
48 - Don't split ellipses.
49 
50 ## [0.20.2] 2018-02-12
51 ### Changed
52 - Improve the speed at which files are excluded by ignoring them earlier.
53 - Allow dictionaries to stay on a single line if they only have one entry
54 ### Fixed
55 - Use tabs when constructing a continuation line when `USE_TABS` is enabled.
56 - A dictionary entry may not end in a colon, but may be an "unpacking"
57   operation: `**foo`. Take that into accound and don't split after the
58   unpacking operator.
59 
60 ## [0.20.1] 2018-01-13
61 ### Fixed
62 - Don't treat 'None' as a keyword if calling a function on it, like '__ne__()'.
63 - use_tabs=True always uses a single tab per indentation level; spaces are
64   used for aligning vertically after that.
65 - Relax the split of a paren at the end of an if statement. With
66   `dedent_closing_brackets` option requires that it be able to split there.
67 
68 ## [0.20.0] 2017-11-14
69 ### Added
70 - Improve splitting of comprehensions and generators. Add
71   `SPLIT_PENALTY_COMPREHENSION` knob to control preference for keeping
72   comprehensions on a single line and `SPLIT_COMPLEX_COMPREHENSION` to enable
73   splitting each clause of complex comprehensions onto its own line.
74 ### Changed
75 - Take into account a named function argument when determining if we should
76   split before the first argument in a function call.
77 - Split before the first argument in a function call if the arguments contain a
78   dictionary that doesn't fit on a single line.
79 - Improve splitting of elements in a tuple. We want to split if there's a
80   function call in the tuple that doesn't fit on the line.
81 ### Fixed
82 - Enforce spaces between ellipses and keywords.
83 - When calculating the split penalty for a "trailer", process the child nodes
84   afterwards because their penalties may change. For example if a list
85   comprehension is an argument.
86 - Don't enforce a split before a comment after the opening of a container if it
87   doesn't it on the current line. We try hard not to move such comments around.
88 - Use a TextIOWrapper when reading from stdin in Python3. This is necessary for
89   some encodings, like cp936, used on Windows.
90 - Remove the penalty for a split before the first argument in a function call
91   where the only argument is a generator expression.
92 
93 ## [0.19.0] 2017-10-14
94 ### Added
95 - Added `SPLIT_BEFORE_EXPRESSION_AFTER_OPENING_PAREN` that enforces a split
96   after the opening paren of an expression that's surrounded by parens.
97 ### Changed
98 - Split before the ending bracket of a comma-terminated tuple / argument list
99   if it's not a single element tuple / arg list.
100 ### Fixed
101 - Prefer to split after a comma in an argument list rather than in the middle
102   of an argument.
103 - A non-multiline string may have newlines if it contains continuation markers
104   itself. Don't add a newline after the string when retaining the vertical
105   space.
106 - Take into account the "async" keyword when determining if we must split
107   before the first argument.
108 - Increase affinity for "atom" arguments in function calls. This helps prevent
109   lists from being separated when they don't need to be.
110 - Don't place a dictionary argument on its own line if it's the last argument
111   in the function call where that function is part of a builder-style call.
112 - Append the "var arg" type to a star in a star_expr.
113 
114 ## [0.18.0] 2017-09-18
115 ### Added
116 - Option `ALLOW_SPLIT_BEFORE_DICT_VALUE` allows a split before a value. If
117   False, then it won't be split even if it goes over the column limit.
118 ### Changed
119 - Use spaces around the '=' in a typed name argument to align with 3.6 syntax.
120 ### Fixed
121 - Allow semicolons if the line is disabled.
122 - Fix issue where subsequent comments at decreasing levels of indentation
123   were improperly aligned and/or caused output with invalid syntax.
124 - Fix issue where specifying a line range removed a needed line before a
125   comment.
126 - Fix spacing between unary operators if one is 'not'.
127 - Indent the dictionary value correctly if there's a multi-line key.
128 - Don't remove needed spacing before a comment in a dict when in "chromium"
129   style.
130 - Increase indent for continuation line with same indent as next logical line
131   with 'async with' statement.
132 
133 ## [0.17.0] 2017-08-20
134 ### Added
135 - Option `NO_SPACES_AROUND_SELECTED_BINARY_OPERATORS` prevents adding spaces
136   around selected binary operators, in accordance with the current style guide.
137 ### Changed
138 - Adjust blank lines on formatting boundaries when using the `--lines` option.
139 - Return 1 if a diff changed the code. This is in line with how GNU diff acts.
140 - Add `-vv` flag to print out file names as they are processed
141 ### Fixed
142 - Corrected how `DEDENT_CLOSING_BRACKETS` and `COALESCE_BRACKETS` interacted.
143 - Fix return value to return a boolean.
144 - Correct vim plugin not to clobber edited code if yapf returns an error.
145 - Ensured comma-terminated tuples with multiple elements are split onto separate lines.
146 
147 ## [0.16.3] 2017-07-13
148 ### Changed
149 - Add filename information to a ParseError exception.
150 ### Fixed
151 - A token that ends in a continuation marker may have more than one newline in
152   it, thus changing its "lineno" value. This can happen if multiple
153   continuation markers are used with no intervening tokens. Adjust the line
154   number to account for the lines covered by those markers.
155 - Make sure to split after a comment even for "pseudo" parentheses.
156 
157 ## [0.16.2] 2017-05-19
158 ### Fixed
159 - Treat expansion operators ('*', '**') in a similar way to function calls to
160   avoid splitting directly after the opening parenthesis.
161 - Increase the penalty for splitting after the start of a tuple.
162 - Increase penalty for excess characters.
163 - Check that we have enough children before trying to access them all.
164 - Remove trailing whitespaces from comments.
165 - Split before a function call in a list if the full list isn't able to fit on
166   a single line.
167 - Trying not to split around the '=' of a named assign.
168 - Changed split before the first argument behavior to ignore compound
169   statements like if and while, but not function declarations.
170 - Changed coalesce brackets not to line split before closing bracket.
171 
172 ## [0.16.1] 2017-03-22
173 ### Changed
174 - Improved performance of cloning the format decision state object. This
175   improved the time in one *large* case from 273.485s to 234.652s.
176 - Relax the requirement that a named argument needs to be on one line. Going
177   over the column limit is more of an issue to pylint than putting named args
178   on multiple lines.
179 - Don't make splitting penalty decisions based on the original formatting. This
180   can and does lead to non-stable formatting, where yapf will reformat the same
181   code in different ways.
182 ### Fixed
183 - Ensure splitting of arguments if there's a named assign present.
184 - Prefer to coalesce opening brackets if it's not at the beginning of a
185   function call.
186 - Prefer not to squish all of the elements in a function call over to the
187   right-hand side. Split the arguments instead.
188 - We need to split a dictionary value if the first element is a comment anyway,
189   so don't force the split here. It's forced elsewhere.
190 - Ensure tabs are used for continued indentation when USE_TABS is True.
191 
192 ## [0.16.0] 2017-02-05
193 ### Added
194 - The `EACH_DICT_ENTRY_ON_SEPARATE_LINE` knob indicates that each dictionary
195   entry should be in separate lines if the full dictionary isn't able to fit on
196   a single line.
197 - The `SPLIT_BEFORE_DICT_SET_GENERATOR` knob splits before the `for` part of a
198   dictionary/set generator.
199 - The `BLANK_LINE_BEFORE_CLASS_DOCSTRING` knob adds a blank line before a
200   class's docstring.
201 - The `ALLOW_MULTILINE_DICTIONARY_KEYS` knob allows dictionary keys to span
202   more than one line.
203 ### Fixed
204 - Split before all entries in a dict/set or list maker when comma-terminated,
205   even if there's only one entry.
206 - Will now try to set O_BINARY mode on stdout under Windows and Python 2.
207 - Avoid unneeded newline transformation when writing formatted code to
208   output on (affects only Python 2)
209 
210 ## [0.15.2] 2017-01-29
211 ### Fixed
212 - Don't perform a global split when a named assign is part of a function call
213   which itself is an argument to a function call. I.e., don't cause 'a' to
214   split here:
215 
216       func(a, b, c, d(x, y, z=42))
217 - Allow splitting inside a subscript if it's a logical or bitwise operating.
218   This should keep the subscript mostly contiguous otherwise.
219 
220 ## [0.15.1] 2017-01-21
221 ### Fixed
222 - Don't insert a space between a type hint and the '=' sign.
223 - The '@' operator can be used in Python 3 for matrix multiplication. Give the
224   '@' in the decorator a DECORATOR subtype to distinguish it.
225 - Encourage the formatter to split at the beginning of an argument list instead
226   of in the middle. Especially if the middle is an empty parameter list. This
227   adjusts the affinity of binary and comparison operators. In particular, the
228   "not in" and other such operators don't want to have a split after it (or
229   before it) if at all possible.
230 
231 ## [0.15.0] 2017-01-12
232 ### Added
233 - Keep type annotations intact as much as possible. Don't try to split the over
234   multiple lines.
235 ### Fixed
236 - When determining if each element in a dictionary can fit on a single line, we
237   are skipping dictionary entries. However, we need to ignore comments in our
238   calculations and implicitly concatenated strings, which are already placed on
239   separate lines.
240 - Allow text before a "pylint" comment.
241 - Also allow text before a "yapf: (disable|enable)" comment.
242 
243 ## [0.14.0] 2016-11-21
244 ### Added
245 - formatting can be run in parallel using the "-p" / "--parallel" flags.
246 ### Fixed
247 - "not in" and "is not" should be subtyped as binary operators.
248 - A non-Node dictionary value may have a comment before it. In those cases, we
249   want to avoid encompassing only the comment in pseudo parens. So we include
250   the actual value as well.
251 - Adjust calculation so that pseudo-parentheses don't count towards the total
252   line length.
253 - Don't count a dictionary entry as not fitting on a single line in a
254   dictionary.
255 - Don't count pseudo-parentheses in the length of the line.
256 
257 ## [0.13.2] 2016-10-22
258 ### Fixed
259 - REGRESSION: A comment may have a prefix with newlines in it. When calculating
260   the prefix indent, we cannot take the newlines into account. Otherwise, the
261   comment will be misplaced causing the code to fail.
262 
263 ## [0.13.1] 2016-10-17
264 ### Fixed
265 - Correct emitting a diff that was accidentally removed.
266 
267 ## [0.13.0] 2016-10-16
268 ### Added
269 - Added support to retain the original line endings of the source code.
270 
271 ### Fixed
272 - Functions or classes with comments before them were reformatting the comments
273   even if the code was supposed to be ignored by the formatter. We now don't
274   adjust the whitespace before a function's comment if the comment is a
275   "disabled" line. We also don't count "# yapf: {disable|enable}" as a disabled
276   line, which seems logical.
277 - It's not really more readable to split before a dictionary value if it's part
278   of a dictionary comprehension.
279 - Enforce two blank lines after a function or class definition, even before a
280   comment. (But not between a decorator and a comment.) This is related to PEP8
281   error E305.
282 - Remove O(n^2) algorithm from the line disabling logic.
283 
284 ## [0.12.2] 2016-10-09
285 ### Fixed
286 - If `style.SetGlobalStyle(<create pre-defined style>)` was called and then
287   `yapf_api.FormatCode` was called, the style set by the first call would be
288   lost, because it would return the style created by `DEFAULT_STYLE_FACTORY`,
289   which is set to PEP8 by default. Fix this by making the first call set which
290   factory we call as the "default" style.
291 - Don't force a split before non-function call arguments.
292 - A dictionary being used as an argument to a function call and which can exist
293   on a single line shouldn't be split.
294 - Don't rely upon the original line break to determine if we should split
295   before the elements in a container. Especially split if there's a comment in
296   the container.
297 - Don't add spaces between star and args in a lambda expression.
298 - If a nested data structure terminates in a comma, then split before the first
299   element, but only if there's more than one element in the list.
300 
301 ## [0.12.1] 2016-10-02
302 ### Changed
303 - Dictionary values will be placed on the same line as the key if *all* of the
304   elements in the dictionary can be placed on one line. Otherwise, the
305   dictionary values will be placed on the next line.
306 
307 ### Fixed
308 - Prefer to split before a terminating r-paren in an argument list if the line
309   would otherwise go over the column limit.
310 - Split before the first key in a dictionary if the dictionary cannot fit on a
311   single line.
312 - Don't count "pylint" comments when determining if the line goes over the
313   column limit.
314 - Don't count the argument list of a lambda as a named assign in a function
315   call.
316 
317 ## [0.12.0] 2016-09-25
318 ### Added
319 - Support formatting of typed names. Typed names are formatted a similar way to
320   how named arguments are formatted, except that there's a space after the
321   colon.
322 - Add a knob, 'SPACES_AROUND_DEFAULT_OR_NAMED_ASSIGN', to allow adding spaces
323   around the assign operator on default or named assigns.
324 
325 ## Changed
326 - Turn "verification" off by default for external APIs.
327 - If a function call in an argument list won't fit on the current line but will
328   fit on a line by itself, then split before the call so that it won't be split
329   up unnecessarily.
330 
331 ## Fixed
332 - Don't add space after power operator if the next operator's a unary operator.
333 
334 ## [0.11.1] 2016-08-17
335 ### Changed
336 - Issue #228: Return exit code 0 on success, regardless of whether files were
337   changed.  (Previously, 0 meant success with no files
338   modified, and 2 meant success with at least one file modified.)
339 
340 ### Fixed
341 - Enforce splitting each element in a dictionary if comma terminated.
342 - It's okay to split in the middle of a dotted name if the whole expression is
343   going to go over the column limit.
344 - Asynchronous functions were going missing if they were preceded by a comment
345   (a what? exactly). The asynchronous function processing wasn't taking the
346   comment into account and thus skipping the whole function.
347 - The splitting of arguments when comma terminated had a conflict. The split
348   penalty of the closing bracket was set to the maximum, but it shouldn't be if
349   the closing bracket is preceded by a comma.
350 
351 ## [0.11.0] 2016-07-17
352 ### Added
353 - The COALESCE_BRACKETS knob prevents splitting consecutive brackets when
354   DEDENT_CLOSING_BRACKETS is set.
355 - Don't count "pylint" directives as exceeding the column limit.
356 
357 ### Changed
358 - We split all of the arguments to a function call if there's a named argument.
359   In this case, we want to split after the opening bracket too. This makes
360   things look a bit better.
361 
362 ### Fixed
363 - When retaining format of a multiline string with Chromium style, make sure
364   that the multiline string doesn't mess up where the following comma ends up.
365 - Correct for when 'lib2to3' smooshes comments together into the same DEDENT
366   node.
367 
368 ## [0.10.0] 2016-06-14
369 ### Added
370 - Add a knob, 'USE_TABS', to allow using tabs for indentation.
371 
372 ### Changed
373 - Performance enhancements.
374 
375 ### Fixed
376 - Don't split an import list if it's not surrounded by parentheses.
377 
378 ## [0.9.0] 2016-05-29
379 ### Added
380 - Added a knob (SPLIT_PENALTY_BEFORE_IF_EXPR) to adjust the split penalty
381   before an if expression. This allows the user to place a list comprehension
382   all on one line.
383 - Added a knob (SPLIT_BEFORE_FIRST_ARGUMENT) that encourages splitting before
384   the first element of a list of arguments or parameters if they are going to
385   be split anyway.
386 - Added a knob (SPLIT_ARGUMENTS_WHEN_COMMA_TERMINATED) splits arguments to a
387   function if the list is terminated by a comma.
388 
389 ### Fixed
390 - Don't split before a first element list argument as we would before a first
391   element function call.
392 - Don't penalize when we must split a line.
393 - Allow splitting before the single argument in a function call.
394 
395 ## [0.8.2] 2016-05-21
396 ### Fixed
397 - Prefer not to split after the opening of a subscript.
398 - Don't add space before the 'await' keyword if it's preceded by an opening
399   paren.
400 - When we're setting the split penalty for a continuous list, we don't want to
401   mistake a comment at the end of that list as part of the list.
402 - When calculating blank lines, don't assume the last seen object was a class
403   or function when we're in a class or function.
404 - Don't count the closing scope when determining if the current scope is the
405   last scope on the line.
406 
407 ## [0.8.1] 2016-05-18
408 ### Fixed
409 - 'SPLIT_BEFORE_LOGICAL_OPERATOR' wasn't working correctly. The penalty was
410   being set incorrectly when it was part of a larger construct.
411 - Don't separate a keyword, like "await", from a left paren.
412 - Don't rely upon the original tokens' line number to determine if we should
413   perform splitting in Facebook mode. The line number isn't the line number of
414   the reformatted token, but the line number where it was in the original code.
415   Instead, we need to carefully determine if the line is liabel to be split and
416   act accordingly.
417 
418 ## [0.8.0] 2016-05-10
419 ### Added
420 - Add a knob, 'SPACES_AROUND_POWER_OPERATOR', to allow adding spaces around the
421   power operator.
422 
423 ### Fixed
424 - There shouldn't be a space between a decorator and an intervening comment.
425 - If we split before a bitwise operator, then we assume that the programmer
426   knows what they're doing, more or less, and so we enforce a split before said
427   operator if one exists in the original program.
428 - Strengthen the bond between a keyword and value argument.
429 - Don't add a blank line after a multiline string.
430 - If the "for" part of a list comprehension can exist on the starting line
431   without going over the column limit, then let it remain there.
432 
433 ## [0.7.1] 2016-04-21
434 ### Fixed
435 - Don't rewrite the file if there are no changes.
436 - Ensure the proper number of blank lines before an async function.
437 - Split after a bitwise operator when in PEP 8 mode.
438 - Retain the splitting within a dictionary data literal between the key and
439   value.
440 - Try to keep short function calls all on one line even if they're part of a
441   larger series of tokens. This stops us from splitting too much.
442 
443 ## [0.7.0] 2016-04-09
444 ### Added
445 - Support for Python 3.5.
446 - Add 'ALLOW_MULTILINE_LAMBDAS' which allows lambdas to be formatted onto
447   multiple lines.
448 
449 ### Fixed
450 - Lessen penalty for splitting before a dictionary keyword.
451 - Formatting of trailing comments on disabled formatting lines.
452 - Disable / enable formatting at end of multi-line comment.
453 
454 ## [0.6.3] 2016-03-06
455 ### Changed
456 - Documentation updated.
457 
458 ### Fixed
459 - Fix spacing of multiline comments when formatting is disabled.
460 
461 ## [0.6.2] 2015-11-01
462 ### Changed
463 - Look at the 'setup.cfg' file to see if it contains style information for
464   YAPF.
465 - Look at the '~/.config/yapf/style' file to see if it contains global style
466   information for YAPF.
467 
468 ### Fixed
469 - Make lists that can fit on one line more likely to stay together.
470 - Correct formatting of '*args' and '**kwargs' when there are default values in
471   the argument list.
472 
473 ## [0.6.1] 2015-10-24
474 ### Fixed
475 - Make sure to align comments in data literals correctly. Also make sure we
476   don't count a "#." in a string as an i18n comment.
477 - Retain proper vertical spacing before comments in a data literal.
478 - Make sure that continuations from a compound statement are distinguished from
479   the succeeding line.
480 - Ignore preceding comments when calculating what is a "dictonary maker".
481 - Add a small penalty for splitting before a closing bracket.
482 - Ensure that a space is enforced after we remove a pseudo-paren that's between
483   two names, keywords, numbers, etc.
484 - Increase the penalty for splitting after a pseudo-paren. This could lead to
485   less readable code in some circumstances.
486 
487 ## [0.6.0] 2015-10-18
488 ### Added
489 - Add knob to indent the dictionary value if there is a split before it.
490 
491 ### Changed
492 - No longer check that a file is a "Python" file unless the '--recursive' flag
493   is specified.
494 - No longer allow the user to specify a directory unless the '--recursive' flag
495   is specified.
496 
497 ### Fixed
498 - When determining if we should split a dictionary's value to a new line, use
499   the longest entry instead of the total dictionary's length. This allows the
500   formatter to reformat the dictionary in a more consistent manner.
501 - Improve how list comprehensions are formatted. Make splitting dependent upon
502   whether the "comp_for" or "comp_if" goes over the column limit.
503 - Don't over indent if expression hanging indents if we expect to dedent the
504   closing bracket.
505 - Improve splitting heuristic when the first argument to a function call is
506   itself a function call with arguments. In cases like this, the remaining
507   arguments to the function call would look badly aligned, even though they are
508   techincally correct (the best kind of correct!).
509 - Improve splitting heuristic more so that if the first argument to a function
510   call is a data literal that will go over the column limit, then we want to
511   split before it.
512 - Remove spaces around '**' operator.
513 - Retain formatting of comments in the middle of an expression.
514 - Don't add a newline to an empty file.
515 - Over indent a function's parameter list if it's not distinguished from the
516   body of the function.
517 
518 ## [0.5.0] 2015-10-11
519 ### Added
520 - Add option to exclude files/directories from formatting.
521 - Add a knob to control whether import names are split after the first '('.
522 
523 ### Fixed
524 - Indent the continuation of an if-then statement when it's not distinguished
525   from the body of the if-then.
526 - Allow for sensible splitting of array indices where appropriate.
527 - Prefer to not split before the ending bracket of an atom. This produces
528   better code in most cases.
529 - Corrected how horizontal spaces were presevered in a disabled region.
530 
531 ## [0.4.0] 2015-10-07
532 ### Added
533 - Support for dedenting closing brackets, "facebook" style.
534 
535 ### Fixed
536 - Formatting of tokens after a multiline string didn't retain their horizontal
537   spacing.
538 
539 ## [0.3.1] 2015-09-30
540 ### Fixed
541 - Format closing scope bracket correctly when indentation size changes.
542 
543 ## [0.3.0] 2015-09-20
544 ### Added
545 - Return a 2 if the source changed, 1 on error, and 0 for no change.
546 
547 ### Fixed
548 - Make sure we format if the "lines" specified are in the middle of a
549   statement.
550 
551 ## [0.2.9] - 2015-09-13
552 ### Fixed
553 - Formatting of multiple files. It was halting after formatting the first file.
554 
555 ## [0.2.8] - 2015-09-12
556 ### Added
557 - Return a non-zero exit code if the source was changed.
558 - Add bitwise operator splitting penalty and prefer to split before bitwise
559   operators.
560 
561 ### Fixed
562 - Retain vertical spacing between disabled and enabled lines.
563 - Split only at start of named assign.
564 - Retain comment position when formatting is disabled.
565 - Honor splitting before or after logical ops.
566