Commit Graph

272 Commits

Author SHA1 Message Date
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
Łukasz Langa
a764f1bb3b Generalize star expression handling
Fixes #132
2018-04-16 01:34:15 -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
cb5aadad74 Automatic parentheses management
Fixes #4
2018-04-11 01:36:18 -07:00
Łukasz Langa
1d45f6e6a1 Improve test coverage a bit 2018-03-31 15:46:09 -07:00
Łukasz Langa
a20a3eeb0f Support --diff for both files and stdin
Fixes #87
2018-03-31 15:46:09 -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
17b22642f5 More comments tests 2018-03-29 21:19:20 -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
Łukasz Langa
fc869039eb Don't crash and burn on empty lines with trailing whitespace
Fixes #80
2018-03-26 18:41:25 -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
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
591bedc2be Support skipping AST printing on test failure 2018-03-20 18:55:04 -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
e911c79809 Don't remove single empty lines outside of bracketed expressions
Fixes #19
2018-03-20 18:54:19 -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
9fea478022 Also run mypy on test_black.py 2018-03-15 23:55:22 -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
c85cb48ec2 Fix tests after introducing --check 2018-03-15 17:05:59 -07:00
Łukasz Langa
e74117f172 Initial commit 2018-03-14 12:55:32 -07:00