Jelle Zijlstra
36d3c516d3
Add --target-version
option to allow users to choose targeted Python versions ( #618 )
2019-02-06 18:43:50 -08:00
Samuel Cormier-Iijima
66aa676278
Fix indent calculation with tabs when computing prefixes ( #595 )
...
Closes #262
2019-02-04 18:55:01 -08:00
Jan Hnátek
f6643c4f0c
Fix location of expression.diff in the change notification message ( #670 )
2019-02-04 18:42:42 -08:00
Utsav Shah
024c9cab55
Add support for special comments in multiline functions ( #642 )
2019-01-05 11:20:12 -08:00
Jim Brännlund
4809e365d4
Silence expected stderr ( #621 )
...
* Silence expected stderr output during test
* Change based on PR comment
2018-11-29 21:43:22 +00:00
Jelle Zijlstra
8d58827376
Refactor Travis ( #614 )
...
Fixes #305
- Run separate jobs for mypy, self-formatting, flake8, and test runs.
- Don't run flake8 in 3.8 because it is broken (and we can't really expect flake8 to always keep up with 3.8 development).
- Fix unused variable in test
2018-11-20 08:42:43 -08:00
Zsolt Dollenstein
5f9eb9e4f7
Add underscores to numeric literals with more than six digits ( #529 )
2018-09-26 12:32:11 +01:00
Zsolt Dollenstein
a82f186787
blackd: a HTTP server for blackening ( #460 )
2018-09-17 10:02:25 -07:00
Zsolt Dollenstein
66a6be642c
fix lint errors
2018-08-26 21:27:33 +01:00
Zsolt Dollenstein
401836d02e
add test case for preserving newlines from stdin
2018-08-26 21:19:22 +01:00
Jelle Zijlstra
b53cb94743
fix bracket match bug ( #470 )
...
* fix bracket match bug
* add missing test file
2018-08-23 12:52:07 +01:00
Zsolt Dollenstein
883689366c
Support parsing of async generators in non-async functions ( #165 )
...
This is a new syntax added in python3.7, so black can't verify that reformatting will not change the ast unless black itself is run with 3.7. We'll need to change the error message black gives in this case. @ambv any ideas?
Fixes #125 .
2018-08-20 14:47:58 +01:00
Jelle Zijlstra
b719d85ccc
autodetect Python 3.6 on the basis of underscores ( #461 )
2018-08-19 21:02:06 -07:00
Jelle Zijlstra
cc48bc56ca
normalize numeric literals ( #454 )
...
Fixes #452
I ended up making a couple of other normalizations to numeric literals
too (lowercase everything, don't allow leading or trailing . in floats,
remove redundant + sign in exponent). I don't care too much about those,
so I'm happy to change the behavior there.
For reference, here is Python's grammar for numeric literals:
https://docs.python.org/3/reference/lexical_analysis.html#numeric-literals
2018-08-17 15:03:58 +01:00
Zsolt Dollenstein
df965b0558
update to mypy 0.620 and make tests pass again
...
Fixes #408
2018-07-18 22:10:52 +01:00
Zsolt Dollenstein
dd8bde6d2f
Improve get_future_imports implementation.
...
Closes #389 .
2018-07-02 17:49:47 +01:00
Łukasz Langa
048efa7476
Trivial nits
2018-06-19 23:08:10 -07:00
Łukasz Langa
2dfa69bb7f
Stop Click from crashing Black on invalid environments
...
Fixes #277
2018-06-19 22:55:57 -07:00
Łukasz Langa
df2ae3bbe6
Use the separate pass for # fmt: off
on all code
...
This removes the hacky exception-based handling that didn't work across
statement boundaries.
Fixes #335
2018-06-19 17:32:41 -07:00
Neraste
42a3fe5331
Ignore symbolic links pointing outside of the root directory ( #339 )
...
Fixes #338
2018-06-13 00:07:04 -07:00
Łukasz Langa
ec31ee967d
Make test_black.py work in profilers
2018-06-09 18:49:39 -07:00
Łukasz Langa
489d00ed8f
Support pyproject.toml
...
Fixes #65
2018-06-06 17:02:10 -07:00
Łukasz Langa
f71db23824
Move test data to data
2018-06-06 15:48:38 -07:00
Zsolt Dollenstein
33baccd88e
Change tests with stdin/out to exercise black.main ( #307 )
2018-06-06 15:42:50 -07:00
Łukasz Langa
7fc6ce9906
Fix handling of empty files
2018-06-04 19:04:29 -07:00
Łukasz Langa
728e5a2f1e
Properly format unified diff
...
Previously we weren't using timestamps.
2018-06-04 18:07:03 -07:00
Łukasz Langa
ed91dd4de6
Make source handling use sets instead of lists
...
Also, sort cached file output to be (more) deterministic.
2018-06-04 15:53:37 -07:00
Zsolt Dollenstein
00a302560b
Preserve line endings when formatting a file in place ( #288 )
2018-06-04 15:52:06 -07:00
Łukasz Langa
4c352ad4be
Add --verbose
and report excluded paths in it, too
...
Fixes #283
2018-06-04 12:09:18 -07:00
Łukasz Langa
36bed855e1
Introduce "project root" as a concept
...
This is required for regular expressions in `--include=` and `--exclude=` not
to catch false positives from directories outside of the project.
2018-06-04 11:03:18 -07:00
Zsolt Dollenstein
ef903ecd46
Skip symlink test if can't create one ( #287 )
2018-06-01 14:47:07 -07:00
Łukasz Langa
8a82e0bf9a
Make empty --include mean "anything goes", simplify gen_python_files_in_dir
2018-05-31 19:40:07 -07:00
Mika⠙
51756a405c
Added --include and --exclude cli options ( #281 )
...
These 2 options allow you to pass in regular expressions that determine
whether files/directories are included or excluded in the recursive file
search.
Fixes #270
2018-05-31 17:51:15 -07:00
Łukasz Langa
8ebbd26888
Add --skip-string-normalization
...
Fixes #118
2018-05-30 12:56:16 -07:00
Łukasz Langa
023e61a254
Refactor --pyi and --py36 into FileMode
2018-05-29 01:53:54 -07:00
Luka Sterbic
e818260f1a
Class new line between docstrings / vars / methods ( #219 )
...
Partially addresses #144
2018-05-28 23:48:59 -07:00
Carl Meyer
07b1b2f3dd
Add --pyi and --py36 flags ( #249 )
...
Fixes #244 .
2018-05-23 11:01:26 -07:00
Jelle Zijlstra
14ba1bf8b6
Add support for pyi files ( #210 )
...
Fixes #207
2018-05-15 15:09:35 -04:00
Miguel Gaiowski
c667b85a7f
Check for broken symlinks before checking file data ( #202 )
2018-05-15 01:13:48 -04:00
Jelle Zijlstra
21c8dc85f5
Remove u prefix if unicode_literals is present ( #199 )
2018-05-09 18:26:41 -04: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
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
Zsolt Dollenstein
9f096d5536
Format subscriptions in a PEP-8 compliant way ( #178 )
...
Fixes #157
2018-04-30 22:49:30 -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
06e95b1e9b
Show full path on diffs
...
Fixes #130
2018-04-23 12:00:03 -07:00
Zsolt Dollenstein
c012c70176
Fix tests on windows ( #159 )
2018-04-23 11:23:36 -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
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
Ł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