Commit Graph

1056 Commits

Author SHA1 Message Date
Tal Amuyal
8fef74cf52
Teach the Vim plugin to respect pyproject.toml (issue 414) (#1273)
Creates two separate functions:

1) abspath_pyproject_toml: find the absolute path to pyproject.toml
2) parse_pyproject_toml: finds black-specific toml config

Co-authored-by: Samuel Roeca <samuel.roeca@gmail.com>
2020-03-03 12:23:28 +01:00
Yurii Karabas
ce14fa8b49
Simplify Line.contains_multiline_strings method (#1267) 2020-02-09 21:21:46 +00:00
Shinya Fujino
383857273c Update README.md to include appropriate command to install Vim with Python 3 on macOS (#1247)
* Update README.md to include appropriate command to install Vim with Python 3 on macOS

* Run pre-commit hooks
2020-01-26 13:31:49 +00:00
Matthew Clapp
d33337b4d5 Change error message to specify its origin. (#1240) 2020-01-23 08:18:57 -08:00
Vlad Emelianov
be49ac72a0 Support py38-style starred expressions in return statement (#1121) 2020-01-18 07:21:46 -08:00
Jon Dufresne
7f5d0e9754 Remove unused variables tokenprog, Token and PlainToken (#1137) 2020-01-18 07:21:19 -08:00
Yazdan
915ebfcf7c change pyproject.toml relative path to absolute path in README.md (#1152)
because in the readthedocs hosted version this pyproject.toml will route to readthedocs does not exist page
2020-01-18 07:19:54 -08:00
Michael Aquilina
70af20eb50 Add comment to flake8 configuration explaining line-length mismatch (#1206) 2020-01-18 07:17:06 -08:00
kyle hausmann
a02829bea1 Use conditional case for diff reports (#1226)
When --diff flag is used, black will now use the
conditional case in the Report output: eg "would
be reformatted"
2020-01-18 07:13:15 -08:00
Mr. Outis
9ef8e6c9b0 bump regex version, providing wheels (#1232)
Close #1112
2020-01-18 07:12:24 -08:00
hauntsaninja
1ab87a3f67 find_project_root: allow .git to be a file (#1217)
Fixes #1213
2020-01-02 14:33:30 -08:00
Hugo van Kemenade
7af619b8c1 Skip the broken version of regex (#1209) 2019-12-16 13:46:43 -08:00
Hugo van Kemenade
1a5b55cf2d This MANIFEST.in not needed with setuptools_scm (#1200) 2019-12-11 02:23:26 -08:00
Francisco
ac10ca8e60 Add Thonny-black-code-format plugin (#1195) 2019-12-08 10:13:50 -08:00
Cooper Lees
b69bce860c Add GitHub Actions badge to README.md (#1134) 2019-12-04 00:33:25 -08:00
Zsolt Dollenstein
b7624cedb9
Fix list literal example in README
The literal as written is going to be exploded because of the trailing comma.
2019-11-30 11:16:33 +00:00
springstan
5e9244ea0d Add Home Assistant to 'Used by' section (#1182)
See the following post: https://developers.home-assistant.io/blog/2019/07/31/black.html
2019-11-29 06:19:36 -08:00
Michael J. Sullivan
4b449e7471 Fix unstable formatting with some # type: ignores (#1113)
`type: ignore` shouldn't block collapsing a line, since it will still
apply fine to the merged line. This prevents an issue where a reformat
causes it to shift lines and then be merged on a subsequent pass.

There is a downside to this, which is that it can cause a `type:
ignore` to apply to more code than was originally intended. There
might be a way to apply this in a more limited situation, but I'm not
sure what it is.

Fixes #1061.
2019-11-25 14:16:00 -08:00
Denis Laxalde
fb1ac69812 Simple docs cleanup (#1168)
* Remove reference to format_int_string in docs

The function got dropped in 250ba7f04b.

* Remove reference to is_python36 in docs

The function got removed in 36d3c516d3.
2019-11-22 20:38:46 -08:00
Hugo van Kemenade
c53853f571 CI: Add Python 3.8 and lint to GitHub Actions (#1173)
* CI: Test Python 3.8 on GitHub Actions

* pre-commit autoupdate

* CI: Lint on GitHub Actions
2019-11-22 08:14:57 +00:00
Anthony Sottile
fa1163545f Suggest extend-ignore over ignore for flake8 (#1165)
this option was introduced in flake8 3.7.x and is generally preferred over `ignore` (which unsets all default ignores)
2019-11-22 08:13:23 +00:00
Tim Gates
de6f4b1f6b Fix simple typo: intput -> input (#1146)
Fixes #1147
2019-11-07 12:57:39 -08:00
Richard Fearn
9b484d1bcc Remove duplicate paragraph about blackd headers (#1124) 2019-10-30 17:20:27 -07:00
Michael J. Sullivan
3e60f6d454 Support compilation with mypyc (#1009)
* Make most of blib2to3 directly typed and mypyc-compatible

This used a combination of retype and pytype's merge-pyi to do the
initial merges of the stubs, which then required manual tweaking to
make actually typecheck and work with mypyc.

Co-authored-by: Sanjit Kalapatapu <sanjitkal@gmail.com>
Co-authored-by: Michael J. Sullivan <sully@msully.net>

* Make black able to compile and run with mypyc

The changes made fall into a couple categories:
 * Fixing actual type mistakes that slip through the cracks
 * Working around a couple mypy bugs (the most annoying of which being
   that we need to add type annotations in a number of places where
   variables are initialized to None)

Co-authored-by: Sanjit Kalapatapu <sanjitkal@gmail.com>
Co-authored-by: Michael J. Sullivan <sully@msully.net>
2019-10-30 07:29:29 -07:00
Thomas Grainger
12826f3c1e replace broken rtfd pypi badge (#1120) 2019-10-30 07:27:20 -07:00
Michael J. Sullivan
31f4105731 Switch from attrs to dataclasses (#1116)
The main motivation here is that mypyc is going to have custom support
for dataclasses but probably not attrs.
2019-10-29 21:06:34 -07:00
Łukasz Langa
6bedb5c58a
Remove Poetry metadata 2019-10-28 23:02:39 +01:00
Hugo van Kemenade
6140f04fe1 Test Windows, macOS and Linux on GitHub Actions (#1085) 2019-10-28 21:00:43 +01:00
Łukasz Langa
f2203a77c5
acks += llchan 2019-10-28 20:58:06 +01:00
Lawrence Chan
23fec8b0f7 Fix fmt on/off when multiple exist in leaf prefix (#1086)
The old behavior would detect the existence of a `# fmt: on` in a leaf
node's comment prefix and immediately mark the node as formatting-on,
even if a subsequent `# fmt: off` in the same comment prefix would turn
it back off. This change modifies that logic to track the state through
the entire prefix and take the final state.

Note that this does not fully solve on/off behavior, since any _comment_
lines between the off/on are still formatted. We may need to add
virtual leaf nodes to truly solve that. I will leave that for a separate
commit/PR.

Fixes #1005
2019-10-28 20:51:45 +01:00
Łukasz Langa
f99fad1b78
Always move the prefix out when wrapping with parentheses (#1103)
Fixes #1097
2019-10-28 20:34:37 +01:00
Łukasz Langa
32009775e5
Restore simple form of if statement 2019-10-28 19:39:48 +01:00
Łukasz Langa
c1fe3aa4f8
Simplify some code flow
Put empty lines after control flow changes.
2019-10-28 17:44:30 +01:00
Łukasz Langa
0cf0d68cf2
Explicitly close .gitignore during processing 2019-10-28 17:42:46 +01:00
Łukasz Langa
adce126949
Remove unnecessary casts after pinning Mypy to >= 0.740 2019-10-28 17:39:52 +01:00
Łukasz Langa
95fd5cb648
Use early returns in get_grammars() to save an indentation level 2019-10-28 17:09:25 +01:00
Łukasz Langa
8adf5f0830
Reword comment 2019-10-28 15:31:37 +01:00
Jelle Zijlstra
e027fc9e75 line_length=1 to reduce churn (#1092) 2019-10-28 15:25:42 +01:00
Łukasz Langa
6dca5278a3
Fix regression: unexpected parentheses around non-mathematical powers
This was caused by an overly liberal application of parentheses in #909 that
fixed #646.

Fixes #1041
2019-10-28 14:55:24 +01:00
Joe Antonakakis
df6e1a41f7 Add diff support to blackd (#969) 2019-10-28 14:25:26 +01:00
Łukasz Langa
b65af236cf
Upgrade typed-ast to 1.4.0 2019-10-28 14:09:57 +01:00
Łukasz Langa
4b8669f502
Put missing contributors in the list (THANKS!) 2019-10-28 13:34:52 +01:00
Łukasz Langa
6864f111fc
Let readers know E203 and W503 are explained later 2019-10-28 13:21:30 +01:00
Łukasz Langa
c336b08bff
Put missing features and fixes in the change log 2019-10-28 13:12:58 +01:00
Łukasz Langa
58fd7885cd
Docstring nit 2019-10-28 13:00:31 +01:00
Jelle Zijlstra
53808e3902 fix crash with long type annotations (#1093) 2019-10-27 11:31:10 +00:00
Jelle Zijlstra
d10b56e6f7 coverage: omit tests/data (#1095)
Noticed that when it complains about falling coverage, it's sometimes because code in tests/data isn't executed.
2019-10-27 11:29:08 +00:00
Tzu-ping Chung
4c4a51cb6b Do not crash when failing to read an entry (#1090) 2019-10-24 14:19:13 -07:00
Michael McClimon
8ea13474a6 setup.py: rename _version.py to _black_version.py (#1089)
In #1082, _version.py was renamed to _black_version.py, but the
py_modules line in setup.py wasn't changed, which meant that when
installed from source, running it failed with something like:

```
Traceback (most recent call last):
  File "~/.pyenv/versions/3.6.5/bin/black", line 5, in <module>
    from black import patched_main
  File "~/.pyenv/versions/3.6.5/lib/python3.6/site-packages/black.py", line 55, in <module>
    from _black_version import version as __version__
ModuleNotFoundError: No module named '_black_version'
```
2019-10-23 21:15:12 -07:00
Łukasz Langa
a701659da2
s/_version.py/_black_version.py/ (#1082)
Some users are installing Black as a dependency in their project. Having
a _version.py in site-packages is asking for a conflict sooner or later.

Ideally we shouldn't require a separate version file at all, that's an
additional import we need to make. But I'll leave that bikeshedding for
a different time.
2019-10-21 15:03:01 +02:00