Commit Graph

617 Commits

Author SHA1 Message Date
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
Charles Reid
65c5a0d9f1 restore cursor to same line of code, not same line of buffer (#989) 2019-10-20 16:00:48 +02:00
Michael J. Sullivan
0ff718e1e2 Blacken .py files in blib2to3 (#1011)
* Blacken .py files in blib2to3

This is in preparation for adding type annotations to blib2to3 in
order to compiling it with mypyc (#1009, which I can rebase on top of
this).

To enforce that it stays blackened, I just cargo-culted the existing
test code used for validating formatting. It feels pretty clunky now,
though, so I can abstract the common logic out into a helper if that
seems better. (But error messages might be less clear then?)

* Tidy up the tests
2019-10-20 15:55:31 +02:00
Hugo van Kemenade
3bfb66971f Test on Python 3.8 final (#1070) 2019-10-15 11:56:28 -07:00
Hugo van Kemenade
be35b1ed2d Declare support for Python 3.8 (#1069) 2019-10-15 10:08:44 -07:00
Michael J. Sullivan
7b11f04d54 Fix type: ignore line breaking when there is a destructuring assignment (#1065)
It turns out we also need to handle invisible *left* parens added at
the *start* of a line. Refactor `contains_unsplittable_type_ignore` to
handle this more cleanly.
2019-10-14 18:15:18 -07:00
Michael J. Sullivan
788f87cb58 Update Pipfile.lock (#1062) 2019-10-14 12:30:57 -07:00
Michael J. Sullivan
34aeee6879 Add .eggs to .gitignore (#1063)
I don't know what .eggs is but it keeps showing up when I work on black
so...
2019-10-14 12:30:37 -07:00
Linus Groh
73bd7038fb Add black version header to blackd responses (#1046) 2019-10-13 11:35:31 -07:00
Zsolt Dollenstein
57ab909bde
Require regex version 2019.8 2019-10-13 10:24:11 -07:00
Andrey
6aef6c9d45 #455 Fix bug with tricky unicode symbols (#1047)
* add test for special unicode symbol which usual re can not process correctly
add regex lib which supports unicode 12.1.0 standard
replace re usage in project in favor to regex

* #455 fix dependency
2019-10-13 10:21:15 -07:00
Hugo van Kemenade
faaa2c8d59 Used by: add pandas and Pillow (#1057) 2019-10-10 20:19:43 -07:00
Michael J. Sullivan
1336094634 Fix missed cases in the # type: ignore logic (#1059)
In #1040 I had convinced myself that the type ignore logic didn't
need anything like the ignored_ids from the type comment logic, but I
was wrong, and we do.

We hit these cases in practice a bunch.
2019-10-10 18:25:33 -07:00
Michael J. Sullivan
6fe800933d Fix issue with type comments on lines with trailing commas (#1058)
The code introduced in #1027 to detect whether a type comment appeared
after a regular comment in a Line would spuriously misfire when a leaf
was in the comments dict but had an empty list of comments. This can
occur as an artifact of how comments on trailing commas are handled,
it seems.

(This was discovered trying to test black out on mypy.)
2019-10-10 11:50:51 -07:00
Michael J. Sullivan
d9e71a75cc Don't break long lines when type: ignore is present (#1040)
Fixes #997.
2019-10-02 18:57:49 -07:00
Michael J. Sullivan
c5637a7085 Fix typechecking under mypy 0.730 (#1039)
mypy 0.730 fixed a bug involving nonexistent attributes accessed on
modules, which caused an error since COLONEQUAL never got added to
token.pyi. Add it.
2019-10-01 15:30:51 -07:00
Zsolt Dollenstein
0acad54c02 fix environment for readthedocs 2019-09-18 14:08:03 +01:00
Zsolt Dollenstein
47861a6a3b fix doc generation 2019-09-18 14:00:18 +01:00
Zsolt Dollenstein
1521d3d2dc Bump dependencies 2019-09-18 13:51:09 +01:00
vezeli
5938106ac4 Switch from versioneer to setuptools-scm (#1008) 2019-09-18 13:34:20 +01:00
Zsolt Dollenstein
7ae084aaa1 fix tests 2019-09-18 13:33:14 +01:00
Pablo Galindo
673327449f Support PEP 572 in while statements (#1028)
Commit d8fa8df052 added support for
parsing and formatting PEP572, but it missed the posibility to add
PEP572 syntax in while statements.
2019-09-18 12:54:40 +01:00
Michael J. Sullivan
0c44220e21 Don't allow type comments to be merged behind regular comments (#1027)
Type comments only apply if they are the first comment on the line,
which means that allowing them to be pushed behind a regular comment
when joining lines is a semantic change (and, indeed, one that black
catches and fails on).
2019-09-17 13:40:03 -07:00
Rishikesh Jha
ae5588cf07 Print a separate message when there are no inputs given (#999)
Fixes #886.
2019-09-04 12:51:32 +01:00