Commit Graph

793 Commits

Author SHA1 Message Date
utsav-dbx
4041c560ec
Add Dropbox as a user of Black (#1335) 2020-05-08 15:23:22 +02:00
williamfzc
92c611cfdf
add bracket check in split_line (#1315) 2020-05-08 06:16:57 -07:00
David Lukes
68a3c75eb2
Make sure sys._base_executable is sane in Vim plugin (#1380)
The `venv` module relies on `sys._base_executable` to determine the
Python executable to run, but with recent versions of Vim, this is set
to the `vim` executable. A possible workaround is to just override it,
since the `black` plugin already overrides `sys.executable` (possibly
for similar reasons?) anyway.
2020-05-08 06:13:54 -07:00
Zsolt Dollenstein
1d3fb871be add change log entry for #1053 2020-05-08 14:09:15 +01:00
Alex Vandiver
a4c11a75e1
Re-indent the contents of docstrings (#1053)
* Re-indent the contents of docstrings when indentation changes

Keeping the contents of docstrings completely unchanged when
re-indenting (from 2-space intents to 4, for example) can cause
incorrect docstring indentation:

```
class MyClass:
  """Multiline
  class docstring
  """

  def method(self):
    """Multiline
    method docstring
    """
    pass
```
...becomes:
```
class MyClass:
    """Multiline
  class docstring
  """

    def method(self):
        """Multiline
    method docstring
    """
        pass
```

This uses the PEP 257 algorithm for determining docstring indentation,
and adjusts the contents of docstrings to match their new indentation
after `black` is applied.

A small normalization is necessary to `assert_equivalent` because the
trees are technically no longer precisely equivalent -- some constant
strings have changed.  When comparing two ASTs, whitespace after
newlines within constant strings is thus folded into a single space.

Co-authored-by: Luka Zakrajšek <luka@bancek.net>

* Extract the inner `_v` method to decrease complexity

This reduces the cyclomatic complexity to a level that makes flake8 happy.

* Blacken blib2to3's docstring which had an over-indent

Co-authored-by: Luka Zakrajšek <luka@bancek.net>
Co-authored-by: Zsolt Dollenstein <zsol.zsol@gmail.com>
2020-05-08 14:08:15 +01:00
Andrew Zhou
9938c92fd7
Add error on non-list target-version in config file (#1284) 2020-05-08 06:01:42 -07:00
Bryan Bugyi
544ea9c217
Improve String Handling (#1132)
This pull request's main intention is to wraps long strings (as requested by #182); however, it also provides better string handling in general and, in doing so, closes the following issues:

Closes #26
Closes #182
Closes #933
Closes #1183
Closes #1243
2020-05-08 14:56:21 +02:00
Cooper Lees
07c046b7cd
Move to 'py3' tagged wheels (#1388)
- This makes black wheels to be tagged as py3 default
- `python_requires=">=3.6"` ensures we are >= 3.6

Test:
```
python3 -m venv /tmp/build_black
/tmp/build_black/bin/pip install --upgrade pip setuptools wheel
/tmp/build_black/bin/python setup.py bdist_wheel
...
black-19.10b1.dev53+g81bf9bb.d20200508-py3-none-any.whl
```

Addresses #1385
2020-05-08 05:49:51 -07:00
otstrel
892eddacd2
Fix for "# fmt: on" with decorators (#1325) 2020-05-08 14:37:17 +02:00
Vlad Emelianov
c8ca6b2b9f
Issue 1144: Fix type annotations for --config option (#1166) 2020-05-08 05:10:04 -07:00
dependabot[bot]
81bf9bb961
Bump bleach from 3.1.2 to 3.1.4 (#1326)
Bumps [bleach](https://github.com/mozilla/bleach) from 3.1.2 to 3.1.4.
- [Release notes](https://github.com/mozilla/bleach/releases)
- [Changelog](https://github.com/mozilla/bleach/blob/master/CHANGES)
- [Commits](https://github.com/mozilla/bleach/compare/v3.1.2...v3.1.4)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-05-08 04:31:46 -07:00
Toby Fleming
7a14a37981
Change exit code to 2 when config file doesn't exist (#1361)
Fixes #1360, where an invalid config file causes a return/exit code of 1. This
change means this case is caught earlier, treated like any other bad
parameters, and results in an exit code of 2.

Co-authored-by: Toby Fleming <tobywf@users.noreply.github.com>
2020-04-30 08:47:52 +01:00
shaoran
8126b4f6a9
Fixing the documentation of how to install the vim plugin (#1318)
* fix: Fixing the documentation of how to install the vim plugin

Solves the installation problem that currently exist because
the current master branch is not stable. See psf/black#1304 for
more information.

* fix: fixing incorrect path
2020-04-23 19:32:40 -07:00
Charles
8654e8d7ae
Update heredoc marker case to conform with vim patch 8.1.1723 (#1348) 2020-04-16 19:26:09 -07:00
MomIsBestFriend
af7105f9ab
Small nitpicks (#1340)
Co-authored-by: MomIsBestFriend <>
2020-04-11 20:30:24 -07:00
Rémi Verschelde
959848c176
Fix --diff output when encountering EOF (#1328)
`split("\n")` includes a final empty element `""` if the final line
ends with `\n` (as it should for POSIX-compliant text files), which
then became an extra `"\n"`.

`splitlines()` solves that, but there's a caveat, as it will split
on other types of line breaks too (like `\r`), which may not be
desired.

Fixes #526.
2020-04-04 22:02:57 -07:00
Zsolt Dollenstein
9ed2542e93
Omit commit hash and date stamp from doc version (#1322)
This also removes the dependency on setuptools-scm while building the
docs.

Fixes #1104.
2020-03-28 19:06:00 -07:00
Quentin Pradet
7e4c6bf71f
Add missing separator in README (#1320) 2020-03-27 10:28:10 -07:00
Zsolt Dollenstein
a33823e859
Fix readthedocs build (#1321)
* migrate to new rtd config format and pip

* no type field anymore

* use builtin re for docs
2020-03-27 11:43:41 +01:00
dependabot[bot]
453ad9500b
Bump bleach from 3.1.1 to 3.1.2 (#1313)
Bumps [bleach](https://github.com/mozilla/bleach) from 3.1.1 to 3.1.2.
- [Release notes](https://github.com/mozilla/bleach/releases)
- [Changelog](https://github.com/mozilla/bleach/blob/master/CHANGES)
- [Commits](https://github.com/mozilla/bleach/compare/v3.1.1...v3.1.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-03-27 08:24:51 +00:00
Łukasz Langa
991f19031c
Don't suggest using sudo with Docker
Thanks for the tip, @imomaliev.
2020-03-17 11:35:41 +01:00
Łukasz Langa
e44e0a6598
Compress RUN statements into one to avoid layer proliferation
Thanks for the suggestion, @imomaliev.
2020-03-17 11:33:57 +01:00
Łukasz Langa
fc804d5f59
Update dependencies 2020-03-17 11:33:02 +01:00
Max Smolens
729f2d8caf
Fix typo in README (#1306) 2020-03-12 19:42:17 +00:00
Hugo van Kemenade
3ac97a3084
Update wording and formatting (#1302) 2020-03-09 15:32:27 +00:00
Batuhan Taşkaya
9a50ba261c
Implement Black Version Gallery (#1294)
Closes #1290.
2020-03-09 14:42:26 +01:00
Abdur-Rahmaan Janhangeer
5fc9f2baab
[README.md] Updated Mail Address - Abdur-Rahmaan Janhangeer (#1301) 2020-03-09 14:38:54 +01:00
Łukasz Langa
5b552fab9d
Update the name of Mode in the reference docs, too 2020-03-04 23:19:21 +01:00
Łukasz Langa
06f2790b5c
Rename FileMode into just Mode
The mode was never just about files to begin with.  There are no other modes in
Black, this can be the default one.
2020-03-04 23:16:55 +01:00
Łukasz Langa
0626c89a5a
Document how to use format_str()
Closes #1064
2020-03-04 23:08:57 +01:00
Łukasz Langa
e253f1260d
Introduce a section of docs about exceptions 2020-03-04 22:26:45 +01:00
Łukasz Langa
4eb822f20c
Run prettier and fix whitespace on CHANGES.md (#1296) 2020-03-04 19:10:17 +01:00
Łukasz Langa
c3589afa3d
Add @cooperlees to maintainers
Fixes #1295
2020-03-04 16:57:24 +01:00
Łukasz Langa
5b6f61e765
Tell people where Change Log went 2020-03-04 16:46:20 +01:00
Cooper Lees
d29303c988
Split out Change Log (#1117)
* Split out Change Log
- Move to CHANGES.md to allow bots to see changes
- MANIFEST.in already includes *.md so CHANGES.md will be included
- THis maintains format but the change log will now be after acknowledgements
- This also ensure this gets added to pypi.org via setup.py function
2020-03-04 16:40:48 +01:00
Shantanu
6d8b90167b
string prefixes: don't normalise capital R-strings (#1271)
Resolves #1244

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2020-03-03 14:55:14 +01:00
Paul Ganssle
bbe5ae70c1
Notify users of missing Python lazily (#1210)
Currently this message shows up with no context prior to the start of
Vim. By changing this to a lazy message, the user will only be notified
of a problem with the Black plugin when they are attempting to use the
Black plugin.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2020-03-03 13:00:52 +01:00
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