Commit Graph

32 Commits

Author SHA1 Message Date
Łukasz Langa
3eea3aad86 Don't explode trailers that fit in a single line 2018-05-15 01:05:39 -07:00
Łukasz Langa
90e14e8b61 Don't make parentheses invisible around yield expressions 2018-05-08 23:31:41 -07:00
Łukasz Langa
c9b73b99ac Support nested lambdas in BracketTracker 2018-05-08 21:57:09 -07:00
Łukasz Langa
793450aeb0 Automatic management of parentheses in assignments
Fixes #140

Note: this is an evolution but the end result needs to be different.  See
cantfit.py for some good examples on bad formatting caused by this change.
2018-05-08 21:57:09 -07:00
Łukasz Langa
7811f957f3 Delimit multiline expressions according to math operator priority
Fixes #148
2018-05-08 21:57:09 -07:00
Łukasz Langa
cfb003f51c Make parentheses invisible recursively in atoms
This fixes non-deterministic formatting when multiple pairs of removable
parentheses are used.

Fixes #183
2018-05-07 11:13:55 -07:00
Zsolt Dollenstein
9f096d5536 Format subscriptions in a PEP-8 compliant way (#178)
Fixes #157
2018-04-30 22:49:30 -07:00
Łukasz Langa
b250aed47b Do not enforce empty lines after control flow statements
Fixes #90
2018-04-24 12:42:46 -07:00
Łukasz Langa
9d671bdbe1 Split ternary expressions
Fixes #141
2018-04-24 12:21:56 -07:00
Łukasz Langa
d73166c42b Move delimiter token skipping to BracketTracker
Also, added lambda argument delimiter skipping.

Fixes #133
2018-04-21 15:08:36 -07:00
Zsolt Dollenstein
5192ed484b Parse complex expressions in parameters after * and ** 2018-04-17 20:34:02 +01:00
Łukasz Langa
a764f1bb3b Generalize star expression handling
Fixes #132
2018-04-16 01:34:15 -07:00
Łukasz Langa
19d69b34e5 Fix placement of dictionary unpacking inside dict literals
Fixes #111
2018-04-11 23:22:22 -07:00
Łukasz Langa
cb5aadad74 Automatic parentheses management
Fixes #4
2018-04-11 01:36:18 -07:00
Łukasz Langa
e36b8c71bb [blib2to3] Support non-ASCII identifiers
This support isn't *exactly* right per PEP 3131 as the regex engine is a bit
too limited for that and I didn't want to spend time on Other_ID_Start and
Other_ID_Continue unless they're actually needed.

Hopefully this doesn't slow it down too much.
2018-04-05 02:29:01 -07:00
Mika⠙
3455389e48 Lines now break before all delimiters (#94)
The default behaviour is that now all lines break *before* delimiters,
instead of afterwards. The special cases for this are commas and
behaviour around args.

Resolves #73
2018-03-31 11:52:11 -07:00
Zsolt Dollenstein
80bd2b3134 Normalize string quotes (#75)
* Normalize string quotes

Convert single-quoted strings to double-quoted. Convert triple single-quoted strings to triple double-quoted. Do not touch any strings where conversion would increase the number of backslashes.

Fixes #51.

* reformat Black itself
2018-03-31 11:21:25 -07:00
Łukasz Langa
a970a205bc Don't remove the single trailing comma from square bracket indexing
Fixes #59
2018-03-22 16:33:50 -07:00
Łukasz Langa
df7aacb43e Omit extra space in kwarg unpacking if it's an argument
Fixes #46
2018-03-21 18:35:25 -07:00
Łukasz Langa
92b377556e Don't omit whitespace when the factor is not a math operator
Fixes #55
2018-03-21 18:34:16 -07:00
Łukasz Langa
5bc40707af Fix numpy-style array indexing for real
Fixes #33
2018-03-20 18:54:33 -07:00
Łukasz Langa
2fa31ff314 More support for numpy tuple indexing 2018-03-17 02:39:53 -07:00
Łukasz Langa
68c71b621f Don't fold postscriptum standalone comment into last statement
This happened when the last statement was a simple statement.

Fixes #18
Fixes #28
2018-03-17 00:59:28 -07:00
Mika⠙
497de7fa08 Line breaks before logical operators (#36)
Fixes #21
2018-03-16 21:45:51 -07:00
Łukasz Langa
9c9f6eb6d5 Remove the trailing comma if there is only one argument to a call
This makes it consistent with removing the trailing comma when multiple
arguments to a call fit in a single line. It also makes it a tiny bit more
likely that an expression will fit a line that didn't use to.
2018-03-16 17:32:55 -07:00
Łukasz Langa
22ce1e1fc3 Fix spurious space after star-based unary expression
This happened when the operand was a complex expression.

Fixes #31
2018-03-15 23:56:30 -07:00
Łukasz Langa
fb84d8b2ee Fix numpy-style array indexing
Fixes #33
2018-03-15 23:39:45 -07:00
Łukasz Langa
5fb5cc8c2b Only use trailing commas in function signatures when it's safe
Trailing commas after * or ** in a function signature are only safe for Python 3.6
code.  So now Black checks whether the file was already Python 3.6 to begin
with.  If so, trailing commas are used in such cases.  Otherwise, they're not.

When * and ** don't appear in a function signature, the trailing comma is
always safe.

Fixes #8
2018-03-15 19:44:09 -07:00
Łukasz Langa
c26daa4fd5 Don't split on for-loop variable unpacks
Fixes #23
2018-03-15 19:23:19 -07:00
Łukasz Langa
5370714c96 Fix spurious space after unary expression
This happened when the operand was a complex expression.

Fixes #15
2018-03-15 14:54:37 -07:00
Łukasz Langa
174fc47b78 Fix spurious space in parenthesized set expressions
Fixes #7
2018-03-15 11:28:59 -07:00
Łukasz Langa
e74117f172 Initial commit 2018-03-14 12:55:32 -07:00