Łukasz Langa
a68dd928e6
Fix docstrings of visit_stmt and normalize_invisible_parens
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
1747c388bb
Discover whether a file is Python 3.6+ also by stars in calls
...
Fixes a pathological situation where if a function signature used a trailing
comma but was later reformatted to a single line (with the trailing comma
removed), Black would change its mind whether a file is Python
3.6-compatible between runs.
2018-05-08 21:57:09 -07:00
Łukasz Langa
0967dfcbeb
Don't fail the entire right_hand_split if an optional split failed
...
Fixes splitting long import lines with only a single name.
2018-05-08 10:11:16 -07:00
Łukasz Langa
27a36671fe
Diff version
2018-05-07 11:36:51 -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
Łukasz Langa
dc0c14240e
Don't leave invalid trailing comma on imports
...
Fixes #185
2018-05-07 10:40:18 -07:00
Łukasz Langa
b1cd59f267
Formatting nits
2018-05-07 10:22:43 -07:00
snlkapil
6dbb657681
Removing empty parentheses after class name ( #180 )
2018-05-07 10:15:24 -07:00
Christian Heimes
2d9eaafa97
Output something when no files are reformatted ( #190 )
...
Just executing ``black`` without any argument does not print any message
to stdout or stderr. It's rather confusing, because the user doesn't
know what happened.
In ``len(sources) == 0`` case, black now prints ``No paths given. Nothing to
do``.
Signed-off-by: Christian Heimes <christian@python.org>
2018-05-07 10:12:47 -07:00
Christian Heimes
adf4ebd2d9
Remove unnecessary shebang lines ( #189 )
...
Since black.py is not marked as executable, the shebang in black.py serves
no purpose. black should be invoked through its entry point any way.
token.py is an internal module without a __name__ == '__main__' block or
other executable code. It contains just list of constants and small
helper functions.
Signed-off-by: Christian Heimes <christian@python.org>
2018-05-04 13:52:17 -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
0f3ecb7e50
18.4a4 hotfix: don't populate the cache on --check
...
Fixes #175
2018-04-27 14:04:46 -07:00
Łukasz Langa
b62bd4de75
Add explode_split
to documentation
2018-04-24 14:27:21 -07:00
Łukasz Langa
1445bea97e
18.4a3
2018-04-24 13:52:12 -07:00
Łukasz Langa
09f5ee3a19
Split imports like isort
...
Fixes #127
Partially addresses #152
2018-04-24 13:44:28 -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
Jonas Obrist
92957a41e3
Make cache work with non-default line lenghts ( #163 )
2018-04-24 11:56:50 -07:00
Łukasz Langa
52fda8b0e9
Support sticky standalone comments (comments preceding defs, classes, and decorators)
...
Fixes #56
Fixes #154
2018-04-24 11:50:31 -07:00
Vishwas B Sharma
29e97d1d4a
[ #154 ] Handle comments between decorators properly ( #166 )
2018-04-24 09:38:12 -07:00
Łukasz Langa
54d707e10a
Allow standalone comments to close code blocks
...
Fixes #16
Fixes #32
2018-04-23 16:17:12 -07:00
Łukasz Langa
82198030ee
Remove nonsensical grammar from blib2to3
2018-04-23 14:24:14 -07:00
Łukasz Langa
06e95b1e9b
Show full path on diffs
...
Fixes #130
2018-04-23 12:00:03 -07:00
Łukasz Langa
3ddf73337d
Refactor reformat_one
and schedule_formatting
to decrease state
2018-04-23 11:48:01 -07:00
Vishwas B Sharma
5e1e1a1820
[ #149 ] Make check and diff not mutually exclusive ( #161 )
...
Fixes #149 .
2018-04-23 11:23:11 -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
b5b658da06
Skip handling signals on event loops that don't support it ( #156 )
2018-04-21 12:16:02 -07:00
Łukasz Langa
2446941824
Remove dead code
2018-04-19 00:09:13 -07:00
Łukasz Langa
aa5629204c
Docstring for max_delimiter_priority_in_atom()
2018-04-18 18:13:36 -07:00
Łukasz Langa
15d5e36ea3
Simplify single-file vs. multi-file modes
2018-04-18 17:59:28 -07:00
Łukasz Langa
8429f3a63b
Revert format_file_in_place()
and format_stdin_to_stdout()
to return bools
...
`Changed.CACHED` is meaningless for those two functions.
2018-04-18 17:46:03 -07:00
Jonas Obrist
639b62dcd3
Added caching ( #136 )
...
Black will cache already formatted files using their file size and
modification timestamp. The cache is per-user and will always be used
unless Black is used with --diff or with code provided via standard
input.
2018-04-18 17:27:07 -07:00
Zsolt Dollenstein
661908cd02
use STARS instead of STAR | DOUBLESTAR
2018-04-17 20:35:59 +01: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
f294cc272c
18.4a2
2018-04-13 12:06:40 -07:00
Zsolt Dollenstein
2104b7cdcb
Handle unnecessarily escaped strings ( #128 )
2018-04-13 11:31:23 -07:00
Zsolt Dollenstein
8e7848c63e
Open temporary files with utf-8 encoding ( #126 )
...
This is not the default on Windows.
2018-04-12 11:19:21 -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
39a5fe7a55
18.4a1
2018-04-11 19:22:16 -07:00
Łukasz Langa
cf8e998f46
Don't omit escaping the second consecutive quote
...
This would produce invalid code for strings like `"x = ''; y = \"\""`.
2018-04-11 16:25:47 -07:00
Łukasz Langa
bc6b912fcb
Fix an embarrassing UnboundLocalError
2018-04-11 15:49:14 -07:00
Łukasz Langa
cb5aadad74
Automatic parentheses management
...
Fixes #4
2018-04-11 01:36:18 -07:00
Zsolt Dollenstein
ecdbf085a7
Add support for all valid string literals ( #115 )
2018-04-09 14:36:40 -07:00
Zsolt Dollenstein
2e0bb0fa9f
Handle arbitrary number of backslashes during string normalization ( #110 )
2018-04-05 02:28:46 -07:00
Łukasz Langa
30d921f74c
Simplify delimiter logic
2018-04-04 16:33:10 -07:00
Zsolt Dollenstein
51b3b2624d
Handle backslashes in raw strings while normalizing ( #105 )
...
In raw strings, a single backslash means a literal backslash. It is also used to escape quotes if it precedes them. This means it is impossible to change the quote type for strings that contain an unescaped version of the other quote type.
Fixes #100
2018-04-04 13:20:46 -07:00
Ivan Katanić
1d3d743dfb
Fix --check for multiple files ( #101 )
2018-04-04 09:53:34 -07:00
Łukasz Langa
21c32d80b6
Add --quiet
...
Fixes #78
2018-04-02 23:17:39 -07:00