Commit Graph

790 Commits

Author SHA1 Message Date
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
jgirardet
e9d4e7b67f add gitignore support using pathspec (#878) 2019-10-21 11:44:53 +02:00
Yngve Høiseth
a6d866990e Automatic markdown and YAML formatting with Prettier (#874) 2019-10-21 11:42:46 +02:00
Alexander Huynh
ba2733dc81 Restore all cursors, instead of only the current window (#978)
If we have the same buffer open in multiple windows/tabs, we'll only
restore the current window's cursor.

Iterate through all tabs and windows, and save/restore all cursor
positions of windows that contain our buffer.

Addendum to #433.
2019-10-21 11:21:05 +02:00
Matt VanEseltine
03766f515b Do not load incompatible cache (#875) (#1034)
A black cache created in Python 3.8 throws an unhandled
ValueError in earlier versions. This is because 3.6 does
not recognize the pickle protocol used as default in 3.8.
Accordingly, this commit:

  - Fixes read_cache to return an empty cache instead.

  - Changes the pickle protocol to 4 as the highest protocol
    fully supported by black's supported Python versions.
2019-10-21 11:20:13 +02:00
Hugo van Kemenade
000147c007 Run pre-commit on Travis CI (#1081) 2019-10-21 11:18:23 +02:00
Łukasz Langa
394edc3887
Revert "restore cursor to same line of code, not same line of buffer (#989)"
This reverts commit 65c5a0d9f1.

Edge cases were discovered on the pull request post merge.
2019-10-21 11:16:34 +02:00
Jelle Zijlstra
14b28c89c2
Back out #850 (#1079)
Fixes #1042 (and probably #1044 which looks like the same thing).

The issue with the "obviously unnecessary" parentheses that #850 removed is that sometimes they're necessary to help Black fit something in one line. I didn't see an obvious solution that still removes the parens #850 was intended to remove, so let's back out this change for now in the interest of unblocking a release.

This PR also adds a test adapted from the failing example in #1042, so that if we try to reapply the #850 change we don't break the same case again.
2019-10-20 09:02:17 -07:00
Jelle Zijlstra
a73d25883a
fix CI (#1078) 2019-10-20 08:35:57 -07:00
Yurii Karabas
4b5852e44a Set correct return statement for is_type_comment function (#929) 2019-10-20 16:52:07 +02:00
Asger Hautop Drewsen
4bcae4cf83 Use better default venv dir when using neovim (#937) 2019-10-20 16:43:02 +02:00
Zsolt Dollenstein
51f1e0a873 Create new issue templates (#934)
* Create new issue templates

* style -> design

* Apply suggestions from code review

Co-Authored-By: Hugo van Kemenade <hugovk@users.noreply.github.com>
2019-10-20 16:30:44 +02:00
Andrew Thorp
893dd952a5 Update README.md (#906)
Add Kakoune integration instructions
2019-10-20 16:26:17 +02:00
Josh Bode
9027ca63ca Change how venv path is modified in vim plugin (#804)
- Check if black venv path is not already in `sys.path`
- Append (not insert) path so that black doesn't incorrectly import backports (e.g. `typing`)

Avoids this error if `typing` is present in venv:
```
Traceback (most recent call last):
  File "<string>", line 56, in <module>
  File "/home/josh/.virtualenvs/default/lib/python3.7/site-packages/black.py", line 19, in <module>
    from typing import (
  File "/home/josh/.virtualenvs/default/lib/python3.7/site-packages/typing.py", line 1356, in <module>
    class Callable(extra=collections_abc.Callable, metaclass=CallableMeta):
  File "/home/josh/.virtualenvs/default/lib/python3.7/site-packages/typing.py", line 1004, in __new__
    self._abc_registry = extra._abc_registry
AttributeError: type object 'Callable' has no attribute '_abc_registry'
```
2019-10-20 16:24:50 +02:00
Joe Antonakakis
b73ec93fa7 Add .svn to default exclusion list (#965) 2019-10-20 16:16:26 +02:00
Augie Fackler
9854d4b375 Tweak collection literals to explode with trailing comma (#826) 2019-10-20 16:08:34 +02:00
Florent Thiery
84e22b75c6 add instructions to Readme for installing vim plugin using vim native package loading, and how to map a key to run it manually (#944) 2019-10-20 16:07:07 +02:00