Ł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
Łukasz Langa
65c52a655f
18.4a0
2018-04-01 00:30:45 -07:00
Łukasz Langa
2f260514f6
Ignore # fmt: off
as inline comment
...
Black cannot currently support this form due to its generator-based nature.
This is mostly a problem for existing `# yapf: disable` usage as trailing
comment.
Fixes #95
2018-04-01 00:08:09 -07:00
Łukasz Langa
4787294622
Don't insert trailing commas after standalone comments
2018-03-31 23:32:11 -07:00
Łukasz Langa
a20a3eeb0f
Support --diff for both files and stdin
...
Fixes #87
2018-03-31 15:46:09 -07:00
Zsolt Dollenstein
a42aef7806
Describe how string literals are handled ( #96 )
2018-03-31 14:42:48 -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
ba61bfe386
Graceful shutdown in case of cancellation
2018-03-30 19:38:08 -07:00
Łukasz Langa
c55d08d0b9
Remove standalone comment hacks
...
Now Black properly splits standalone comments within bracketed expressions.
They are treated as another type of split instead of being bolted on with
whitespace prefixes.
A related fix: now multiple comments might appear after a given leaf.
Fixes #22
2018-03-29 21:10:00 -07:00
Josh Holland
3ee9ebb091
Fix --check with multiple files ( #88 )
...
Passing multiple files to --check would previously result in the report
being printed as if the files had been written to.
2018-03-29 15:21:18 -07:00
Łukasz Langa
44a2351731
Use imperative language in all docstrings
2018-03-28 19:31:53 -07:00
Łukasz Langa
7f7b31058a
More minor documentation-related changes
2018-03-28 19:03:16 -07:00
Łukasz Langa
d01460d939
Auto-generated documentation-related fixes
2018-03-28 17:43:18 -07:00
Łukasz Langa
e5f8251704
Allow up to two empty lines on module level and single empty lines otherwise
...
Fixes #74
2018-03-26 22:55:56 -07:00
Łukasz Langa
c5fd578279
18.3a4
2018-03-26 00:57:02 -07:00
Łukasz Langa
0677a53937
Implement # fmt: off
and # fmt: on
...
Fixes #5
2018-03-23 17:16:08 -07:00
Łukasz Langa
7e1c5b2ba6
Introduce DebugVisitor.show() + tests
2018-03-23 16:08:05 -07:00
Łukasz Langa
475179a53a
Omit extra space in Sphinx auto-attribute comments
...
This feature of Sphinx is described in:
http://www.sphinx-doc.org/en/stable/ext/autodoc.html#directive-autoattribute
Fixes #68
2018-03-23 08:56:55 -07:00
Łukasz Langa
cf6f577928
Properle space complex expressions in default values of typed arguments
...
Fixes #60
2018-03-22 23:52:21 -07:00
Łukasz Langa
7bd6f3cb2f
Ignore typing error around Node/Leaf
2018-03-22 23:22:46 -07:00
Łukasz Langa
6316e293ac
Automatic detection of deprecated Python 2 forms of print and exec
...
Note: if those are handled, you can't use --safe because this check is using
Python 3.6+ builtin AST.
Fixes #49
2018-03-22 23:19:23 -07:00
Łukasz Langa
8de552eb4f
Only return exit code 1 when --check is used
...
Also, output less confusing messages in --check.
Fixes #50
2018-03-22 17:33:44 -07:00
Łukasz Langa
7914a5b0a2
Mention delimiter_split() in CannotSplit docstring
2018-03-22 17:15:28 -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
1b696555e1
18.3a3
2018-03-20 19:05:51 -07:00
Łukasz Langa
b1a7600b0a
Treat comments less magically
2018-03-20 18:55:19 -07:00
Łukasz Langa
d1e0d79e38
Don't write back stdin to stdout when --check is passed
2018-03-20 18:54:55 -07:00
Łukasz Langa
5bc40707af
Fix numpy-style array indexing for real
...
Fixes #33
2018-03-20 18:54:33 -07:00
Łukasz Langa
e911c79809
Don't remove single empty lines outside of bracketed expressions
...
Fixes #19
2018-03-20 18:54:19 -07:00
Łukasz Langa
d9c6b99073
Restore ability to format code with legacy usage of async
as a name
...
Fixes #20
Fixes #42
2018-03-20 18:54:01 -07:00
treuherz
10d8976a79
Add piping from stdin to stdout with a - ( #25 )
...
Being able to format code by piping it through the formatter makes it much easier to integrate with tools like google/vim-codefmt or Chiel92/vim-autoformat.
2018-03-19 11:07:10 -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
Łukasz Langa
6c3ce53b60
Consolidate empty line handling in EmptyLineTracker
...
Previously, extra newlines left on imports were handled sort of by accident.
Now it's all handled uniformly in one place.
2018-03-17 00:40:21 -07:00
Łukasz Langa
b9c06a0d23
Don't put four empty lines between top-level functions split by a comment
2018-03-16 22:14:43 -07:00
Mika⠙
497de7fa08
Line breaks before logical operators ( #36 )
...
Fixes #21
2018-03-16 21:45:51 -07:00
Łukasz Langa
28d1442d57
Use implicit defaults for auto_attribs
...
It reads much nicer.
2018-03-16 17:43:14 -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
6ba615092e
Ignore empty bracket pairs while splitting
...
Fixes #35
2018-03-16 17:09:23 -07:00
Łukasz Langa
0de0851a47
Add flake8 to CI, too
2018-03-16 00:47:01 -07:00
Łukasz Langa
1ec7544ab7
Bump version, update README with current fixes
2018-03-16 00:01:22 -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
907dc6c35e
Clean up typing ignores, fix build
2018-03-15 23:26:56 -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
4c480bcac2
Add --check
...
Fixes #9
2018-03-15 16:02:57 -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
da3c2f3582
Fix spurious extra spaces after opening parentheses and in default arguments
...
Fixes #14
Fixes #17
2018-03-15 12:53:23 -07:00
Łukasz Langa
174fc47b78
Fix spurious space in parenthesized set expressions
...
Fixes #7
2018-03-15 11:28:59 -07:00
Łukasz Langa
e1e89091d1
Fix invalid spacing of dots in relative imports
...
Fixes #6
Fixes #13
2018-03-15 11:21:53 -07:00
Łukasz Langa
e74117f172
Initial commit
2018-03-14 12:55:32 -07:00