Commit Graph

275 Commits

Author SHA1 Message Date
Anthony Sottile
7546ed292c delete some dead code (#669)
dead code detected via [dead](https://github.com/asottile/dead)

- **`KEYWORDS`**: introduced (unreferenced) in e74117f172
- **`FLOW_CONTROL`**: last referenced in e9a940d69e

"clean" command:

```
dead --exclude '^(tests/data/|docs/conf.py|blib2to3/)' | grep -Ev '^(visit_.*|show|_stop_signal|lib2to3_unparse) '
```
2019-01-12 09:23:20 -08:00
Utsav Shah
024c9cab55 Add support for special comments in multiline functions (#642) 2019-01-05 11:20:12 -08:00
Tsuyoshi Hombashi
3b72ed0d48 Improve an error message when failed to load pyproject.toml (#653) 2018-12-31 05:03:31 -08:00
Peter Stensmyr
fe24a15b84 Fix multiprocessing support for Windows binary (#632)
* Fix multiprocessing support for Windows binary

The black and blackd binaries generated for Windows builds would fail on
reformatting multiple files due to a Windows-specific
multiprocessing issue. Fix by calling freeze_support() as
described in Python docs.
2018-12-14 15:01:50 +00:00
Jim Brännlund
55121195ce Add .eggs to default exclusions (#629) 2018-11-29 14:27:08 -08:00
hauntsaninja
e4e59f87a8 Improves performance on large commented logical lines (#606)
Fixes #509
2018-11-13 15:04:27 -08:00
hauntsaninja
5bc62a4a82 Fix two types to be Optional (#607) 2018-11-13 15:02:27 -08:00
Jelle Zijlstra
fbf59b60d7 remove unused variable (#604) 2018-11-13 21:23:56 +00:00
Chuck Wooters
5c2dd96a69 patch main to ensure click_patch() gets called (#572) 2018-10-29 11:10:32 +01:00
Felix Kohlgrüber
99c97c3d7f delete unused code (#588) 2018-10-29 11:09:06 +01:00
Łukasz Langa
61feadc0f8
v18.9b0 2018-09-26 13:05:49 -07:00
Łukasz Langa
7145fa325c
Remove whitespace at the beginning of the file
Fixes #399
2018-09-26 12:18:45 -07:00
Łukasz Langa
c6c8ef76a4
Fix mangling pweave and Spyder IDE special comments
Fixes #532.
2018-09-26 09:42:42 -07:00
Łukasz Langa
a4b5c085a3
Move should_explode handling to bracket_split_build_line 2018-09-26 08:53:56 -07:00
Łukasz Langa
1610fd6bc5
Add trailing comma for single as imports, too 2018-09-26 08:26:35 -07:00
Łukasz Langa
0c5c537431
Refactor left_hand_split and right_hand_split to deduplicate line building logic 2018-09-26 07:41:34 -07:00
Zsolt Dollenstein
25d24a10a4 Add trailing comma when a single import doesn't fit on a line. (#504)
Fixes #250.
2018-09-26 13:26:50 +01:00
Zsolt Dollenstein
5f9eb9e4f7 Add underscores to numeric literals with more than six digits (#529) 2018-09-26 12:32:11 +01:00
Tim Swast
2d99573b34 Add .nox directories to default exclude (#525)
[Nox](https://nox.readthedocs.io/) is similar to Tox. It creates a .nox directory that contains virtualenv for testing with different Python versions.
2018-09-25 16:25:58 +01:00
Zsolt Dollenstein
bbf38400ce Uppercase digits in hex literals (#530) 2018-09-25 16:01:56 +01:00
Łukasz Langa
41368138bb
Fix documentation build 2018-09-18 12:04:30 -07:00
Zsolt Dollenstein
a82f186787 blackd: a HTTP server for blackening (#460) 2018-09-17 10:02:25 -07:00
Zsolt Dollenstein
80500748a7
fix unstable formatting when unpacking big tuples (#514)
* fix unstable formatting when unpacking big tuples

* add changelog entry
2018-09-17 12:03:21 +01:00
Zsolt Dollenstein
08f1cdd00b
Make sure async for is not broken up to separate lines (#503)
Fixes #372.
2018-09-08 10:34:08 +01:00
Jelle Zijlstra
a37abdcbc5
change some numeric behavior (#469) 2018-08-23 11:55:29 -07: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
Jelle Zijlstra
8b340e2102
wrap atoms in invisible parens to split adjacent strings (#463) 2018-08-21 21:10:59 -07:00
Jelle Zijlstra
d4f0521754
fix misformatting of floats with leading zeros (#464) 2018-08-20 08:19:25 -07:00
Jelle Zijlstra
b719d85ccc
autodetect Python 3.6 on the basis of underscores (#461) 2018-08-19 21:02:06 -07:00
ceh
66b82ced50 Fix minor typos (#443) 2018-08-19 13:10:06 +01:00
Łukasz Langa
2a357b3606 Nits around numeral normalization. 2018-08-17 10:38:28 -07:00
Łukasz Langa
71bdd727a8 Put missing blank lines after return statements. 2018-08-17 10:29:19 -07:00
Łukasz Langa
ebbb98919d Make schedule_formatting logic less nested. 2018-08-17 10:17:37 -07:00
Łukasz Langa
1dbe77cd91 Simplify caching logic. 2018-08-17 10:14:10 -07:00
Jelle Zijlstra
9e15cacc67 write cache in --check mode (#453)
Fixes #448.

This diff makes us always write to the cache in normal mode, except
if the file is already in the cache, and it makes us write to the
cache in --check mode if the file is already well formatted.

I also fixed some related docstrings.

WriteBack.NO is now used only in tests.
2018-08-17 15:40:37 +01: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
e94a41f92a Look at actual parenthesis when generating ignored leafs.
Fixes #385
2018-07-22 15:30:02 +01:00
Zsolt Dollenstein
dd8bde6d2f Improve get_future_imports implementation.
Closes #389.
2018-07-02 17:49:47 +01:00
Łukasz Langa
41240e9a78 18.6b4 2018-06-21 14:25:07 -07:00
Łukasz Langa
d93e726806 Don't freeze when multiple comments directly precede # fmt: off
Fixes #371
2018-06-21 14:03:01 -07:00
Łukasz Langa
98b6c887da 18.6b3 2018-06-20 12:00:07 -07:00
Łukasz Langa
c2327c83b2 More tests for # fmt: off
Two more known limitations that I don't feel like solving now.  Probably very
low priority.
2018-06-19 23:46:58 -07: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
Łukasz Langa
8a8c58252c Support # fmt: off/on pairs within brackets
Fixes #329
2018-06-18 22:37:46 -07:00
Łukasz Langa
e4340f5c3e Cache generated comments 2018-06-18 22:37:46 -07:00
Jelle Zijlstra
9db828c3de Add blank line after constants in stub file (#360)
Fixes #340
2018-06-16 11:53:45 -07:00
Neraste
42a3fe5331 Ignore symbolic links pointing outside of the root directory (#339)
Fixes #338
2018-06-13 00:07:04 -07:00
Zsolt Dollenstein
efcd039482 Fix string normalization eating all backslashes above 3 2018-06-10 09:44:41 +01:00
Łukasz Langa
d240ca25ea Make is_complex_subscript() ignore list literals
This fixes catastrophically quadratic behavior on long lists.
2018-06-09 16:04:09 -07:00
Zsolt Dollenstein
5d0a469e8e Fix string normalization sometimes producing invalid fstrings (#327) 2018-06-09 12:30:49 -07:00
Łukasz Langa
ff2e5dd6e6 18.6b2 2018-06-08 12:07:43 -07:00
Łukasz Langa
8482d38fb4 Return early from comment placement calculation on lines without comments 2018-06-08 12:00:53 -07:00
Loren Carvalho
39e9347687 Add -h as a shortcut for --help (#316) 2018-06-07 19:43:04 -07:00
Zsolt Dollenstein
7f3678885f fix handling of empty triple quoted strings (#314) 2018-06-07 11:41:34 -07:00
Łukasz Langa
489d00ed8f Support pyproject.toml
Fixes #65
2018-06-06 17:02:10 -07:00
Łukasz Langa
92a150d9e4 Fix improper unmodified file caching when -S was used
This will also future-proof the cache to changes to FileMode.
2018-06-06 15:46:30 -07:00
Zsolt Dollenstein
c1a962b885 Don't put a space after * in g = 1, *"x" (#309)
Fixes #305.
2018-06-06 15:44:12 -07:00
Hugo
9e9ee449b4 Link to GitHub + HTTPS + typos (#303)
* Link to GitHub, update 3.6 minor version

* http -> https

* Fix typos

* The Black style for Black, the project, is italics
2018-06-06 09:50:08 -07:00
Łukasz Langa
ed50737290 18.6b1 2018-06-05 09:49:06 -07:00
Peter Bengtsson
aeaaf571ad 🍰 isn't appropriate when it fails, fixes #300 (#301) 2018-06-05 09:35:35 -07:00
Zsolt Dollenstein
61a8d401c7 Print report on stderr.\n\nFixes #299. 2018-06-05 10:38:20 +01:00
Łukasz Langa
f3ea58cbc7 18.6b0
Fixes #289
2018-06-04 21:29:09 -07:00
Łukasz Langa
d638d56e0e Fix unnecessary parentheses when a line contains multiline strings
Fixes #232
2018-06-04 21:27:51 -07:00
Łukasz Langa
23a00f0515 Fix long trivial assignments being wrapped in unnecessary parentheses
Fixes #273
2018-06-04 20:24:50 -07:00
Łukasz Langa
7fc6ce9906 Fix handling of empty files 2018-06-04 19:04:29 -07:00
Łukasz Langa
bbc09a4f01 Consider stars in testlist_star_expr unpacking (because they are)
Fixes #297
2018-06-04 18:42:16 -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
041ec995e5 Nits 2018-06-04 16:57:27 -07:00
Łukasz Langa
ee02ebe3e9 Always show summary of reformatting 2018-06-04 15:53:37 -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
Łukasz Langa
e5452a6b67 Make sure --verbose trumps --quiet
This is so that users can have a --quiet alias in their environment and only
occasionally add --verbose if they are surprised by the result.
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
75d2af2e3a Fix missing leading slash due to relative_to() resolution 2018-06-04 12:18:27 -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
e7b312fb43 [trivial] Simplify mode and write_back calculation in main() 2018-06-04 11:20:15 -07:00
Łukasz Langa
1aa14c5db0 [trivial] Simplify stdin handling 2018-06-04 11:06:38 -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
Łukasz Langa
a80e037a9a Don't over-eagerly make a path absolute if only one passed
If a directory or more than one file is passed, Black nicely shows the relative
paths in output.  Before this change, it showed an absolute path if only
a single file was passed as an argument.  This fixes the inconsistency.
2018-05-31 19:47:24 -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
Łukasz Langa
435aa7ac4a Reorder command-line options 2018-05-31 19:24:09 -07:00
Łukasz Langa
6fa60ba39d Sort default excludes, include the leading slash 2018-05-31 19:09:51 -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
b2067aabbf 18.5b1 2018-05-29 02:07:09 -07:00
Łukasz Langa
023e61a254 Refactor --pyi and --py36 into FileMode 2018-05-29 01:53:54 -07:00
Łukasz Langa
2057bf6fae Clean up PEP 257 support
I documented the new behavior, added it to the change log, greatly expanded
tests, added support for inner defs and classes, and added Luka to ACKS.

Fixes #196
2018-05-29 00:47:52 -07:00
Luka Sterbic
e818260f1a Class new line between docstrings / vars / methods (#219)
Partially addresses #144
2018-05-28 23:48:59 -07:00
Łukasz Langa
e9a940d69e Remove remains of extra empty lines for flow control statements 2018-05-24 13:32:52 -07:00
Łukasz Langa
bbed104e6d Reword --pyi and --py36 documentation 2018-05-23 11:52:41 -07:00
Carl Meyer
07b1b2f3dd Add --pyi and --py36 flags (#249)
Fixes #244.
2018-05-23 11:01:26 -07:00
Łukasz Langa
658eb7161d Fix unstable formatting on trailers omitted from line splitting with comments
Fixes #238
2018-05-22 00:38:31 -07:00
Łukasz Langa
9a6c88c7f4 Fix invalid code on stars in long from-imports being wrapped in parentheses
Fixes #234
2018-05-21 16:37:29 -07:00
Łukasz Langa
808754af18 Fix optional parentheses being removed within # fmt: off sections
Fixes #224
2018-05-21 15:21:14 -07:00
Łukasz Langa
91de9ea6e3 Fix invalid code in an omitted trailer on large expressions
Fixes #237
2018-05-21 12:29:36 -07:00
Łukasz Langa
c891c65b6b Store grammar pickle caches in CACHE_DIR
Fixes #192

Fixes #203
2018-05-19 14:06:27 -07:00
Łukasz Langa
7395f55564 18.5b0 2018-05-17 17:32:43 -07:00
Łukasz Langa
180bc06ede Don't explode a one-element collection ending with a comma. 2018-05-17 17:32:43 -07:00
Łukasz Langa
87b8df28c4 Fix overly optimistic removal of optional parentheses
The current behavior is explained with much detail in
`can_omit_invisible_parens`.
2018-05-17 17:32:43 -07:00