]> git.madduck.net Git - etc/vim.git/log

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

etc/vim.git
3 years agoAdd blackd to nicely exit if missing aiohttp deps (#1761)
Cooper Lees [Tue, 13 Oct 2020 05:03:00 +0000 (22:03 -0700)]
Add blackd to nicely exit if missing aiohttp deps (#1761)

- If no aiohttp* deps exist nicely print a helpful message and exit
- There seems to be no nice way to optionally install the entry point, so lets make the entry point nicer

Test:
```
cooper-mbp1:black cooper$ /tmp/tb/bin/pip install .
cooper-mbp1:black cooper$ /tmp/tb/bin/blackd
aiohttp dependency is not installed: No module named 'aiohttp'. Please re-install black with the '[d]' extra install  to obtain aiohttp_cors: `pip install black[d]`
cooper-mbp1:black cooper$ /tmp/tb/bin/pip install .[d]
...
Successfully installed aiohttp-3.6.3 aiohttp-cors-0.7.0 black
cooper-mbp1:black cooper$ /tmp/tb/bin/blackd
blackd version 20.8b2.dev31+gdd2f86a.d20201013 listening on localhost port 45484
```

Fixes #1688

3 years agoSupport stable Python3.9. (#1748)
Hadi Alqattan [Thu, 8 Oct 2020 21:13:13 +0000 (00:13 +0300)]
Support stable Python3.9. (#1748)

* Support stable Python3.9.

* Get back to 3.9-dev

* Add py39 to black usage.

* remove 3.9 temporarily.

3 years agodocs: update `used-by` link to proper url (#1745)
Cha Gyuseok [Wed, 7 Oct 2020 14:45:06 +0000 (23:45 +0900)]
docs: update `used-by` link to proper url (#1745)

3 years agoPrimer: pyramid and sqlalchemy are now formatted with latest Black (#1736)
Hugo van Kemenade [Fri, 2 Oct 2020 11:47:57 +0000 (14:47 +0300)]
Primer: pyramid and sqlalchemy are now formatted with latest Black (#1736)

3 years agoFix unnecessary if checks (#1728)
Hakan Çelik [Mon, 28 Sep 2020 19:55:35 +0000 (22:55 +0300)]
Fix unnecessary if checks (#1728)

3 years agoHypothesis is now formatted with Black 20.8b1 (#1729)
Hugo van Kemenade [Mon, 28 Sep 2020 02:42:01 +0000 (05:42 +0300)]
Hypothesis is now formatted with Black 20.8b1 (#1729)

3 years agoRepair colorama wrapping on non-Windows platforms (#1670)
Pete Grayson [Sun, 27 Sep 2020 21:41:11 +0000 (21:41 +0000)]
Repair colorama wrapping on non-Windows platforms (#1670)

* Repair colorama wrapping on non-Windows platforms

The wrap_stream_for_windows() function calls
colorama.initialise.wrap_stream() function to apply colorama's magic to
wrapper to the output stream. Except this wrapper is only applied on
Windows platforms that need it, otherwise the original stream is
returned as-is.

The colorama wrapped stream lacks a detach() method, so a no-op lambda
was being assigned to the wrapped stream.

The problem is that the no-op lambda was being assigned unconditionally
whether or not colorama actually returns a wrapped stream, thus
replacing the original TextIOWrapper's detach() method. Replacing the
detach() method with a no-op lambda is the root cause of the problem
observed in #1664.

The solution is to only assign the no-op detach() method if the stream
lacks its own detach() method.

Repairs #1664

3 years agoEnd 'force-exclude' help message with a period (#1727)
Vipul [Sun, 27 Sep 2020 05:54:21 +0000 (05:54 +0000)]
End 'force-exclude' help message with a period (#1727)

It would be nice, if like other options help message, force-exclude's
help message also ends with a period punctuation mark.

3 years agoPEP 614 support (#1717)
QuentinSoubeyran [Sat, 19 Sep 2020 18:33:10 +0000 (20:33 +0200)]
PEP 614 support (#1717)

3 years agoFix typo in docstring (#1700)
Daniel [Sun, 13 Sep 2020 15:59:18 +0000 (17:59 +0200)]
Fix typo in docstring (#1700)

Added a missing preposition

3 years agoFix empty line handling when formatting typing stubs (#1646)
Richard Si [Thu, 10 Sep 2020 20:21:37 +0000 (16:21 -0400)]
Fix empty line handling when formatting typing stubs (#1646)

Black used to erroneously remove all empty lines between non-function
code and decorators when formatting typing stubs. Now a single empty
line is enforced.

I chose for putting empty lines around decorated classes that have empty
bodies since removing empty lines around such classes would cause a
formatting issue that seems to be impossible to fix.

For example:

```
class A: ...
@some_decorator
class B: ...
class C: ...
class D: ...

@some_other_decorator
def foo(): -> None: ...
```

It is easy to enforce no empty lines between class A, B, and C.
Just return 0, 0 for a line that is a decorator and precedes an stub
class. Fortunately before this commit, empty lines after that class
would be removed already.

Now let's look at the empty line between class D and function foo. In
this case, there should be an empty line there since it's class code next
to function code. The problem is that when deciding to add X empty lines
before a decorator, you can't tell whether it's before a class or a
function. If the decorator is before a function, then an empty line
is needed, while no empty lines are needed when the decorator is
before a class.

So even though I personally prefer no empty lines around decorated
classes, I had to go the other way surrounding decorated classes with
empty lines.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
3 years agoVirtualenv is now formatted with newest Black https://github.com/pypa/virtualenv...
Hugo van Kemenade [Thu, 10 Sep 2020 19:52:23 +0000 (22:52 +0300)]
Virtualenv is now formatted with newest Black https://github.com/pypa/virtualenv/pull/1939 (#1695)

3 years agoFix unstable subscript assignment string wrapping (#1678)
Bryan Bugyi [Thu, 10 Sep 2020 16:24:01 +0000 (12:24 -0400)]
Fix unstable subscript assignment string wrapping (#1678)

Fixes #1598

3 years agoAdd link to conda-forge integration (#1687)
Michael Wilkinson [Tue, 8 Sep 2020 16:42:57 +0000 (12:42 -0400)]
Add link to conda-forge integration (#1687)

* Add link to conda-forge integration

resolves #1686

* README: keep PyPI tags together

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
3 years agoFix crash on assert and parenthesized % format (fixes #1597, fixes #1605) (#1681)
Bryan Bugyi [Sun, 6 Sep 2020 16:15:40 +0000 (12:15 -0400)]
Fix crash on assert and parenthesized % format (fixes #1597, fixes #1605) (#1681)

3 years agoFix crash on concatenated string + comment (fixes #1596) (#1677)
Bryan Bugyi [Sun, 6 Sep 2020 15:02:57 +0000 (11:02 -0400)]
Fix crash on concatenated string + comment (fixes #1596) (#1677)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
3 years agoFix unstable formatting on string split + % formatting (#1680)
Bryan Bugyi [Sun, 6 Sep 2020 00:24:00 +0000 (20:24 -0400)]
Fix unstable formatting on string split + % formatting (#1680)

Fixes #1595

3 years agoHandle .COLOR_DIFF in the same way as .DIFF (#1673)
Tom Saunders [Sat, 5 Sep 2020 19:15:28 +0000 (20:15 +0100)]
Handle .COLOR_DIFF in the same way as .DIFF (#1673)

3 years agoTest primer on Pillow (#1679)
Hugo van Kemenade [Sat, 5 Sep 2020 16:38:43 +0000 (19:38 +0300)]
Test primer on Pillow (#1679)

3 years agoUpdate primer.json to reflect Black's adoption (#1674)
Richard Si [Fri, 4 Sep 2020 21:20:55 +0000 (17:20 -0400)]
Update primer.json to reflect Black's adoption (#1674)

- tox recently adopted Black
https://github.com/tox-dev/tox/commit/a7903508fa07068b327e15cfdbf8ea330ab78765

- attrs already adopted Black but they updated to 20.08b1 + did a format pass and removed some trailing commas
https://github.com/python-attrs/attrs/commit/f680c5b83e65413eeb684c68ece60198015058c3

3 years agoClarify current trailing comma behavior in the docs
Łukasz Langa [Tue, 1 Sep 2020 11:24:31 +0000 (13:24 +0200)]
Clarify current trailing comma behavior in the docs

3 years agoMention optional invalid W503 warning in pycodestyle
Łukasz Langa [Tue, 1 Sep 2020 11:18:46 +0000 (13:18 +0200)]
Mention optional invalid W503 warning in pycodestyle

3 years agoFix incorrect space before colon in if/while stmts (#1655)
Richard Si [Mon, 31 Aug 2020 21:20:05 +0000 (17:20 -0400)]
Fix incorrect space before colon in if/while stmts (#1655)

* Fix incorrect space before colon in if/while stmts

Previously Black would format this code

```
if (foo := True):
print(foo)
```

as

```
if (foo := True) :
print(foo)
```

adding an incorrect space after the RPAR. Buggy code in the
normalize_invisible_parens function caused the colon to be wrapped in
invisible parentheses. The LPAR of that pair was then prefixed with a
single space at the request of the whitespace function.

This commit fixes the accidental skipping of a pre-condition check
which must return True before parenthesis normalization of a specific
child Leaf or Node can happen. The pre-condition check being skipped
was why the colon was wrapped in invisible parentheses.

* Add an entry in CHANGES.md

3 years agoRemove flake8 W503 from docs as it is ignored by default (#1661)
Jon Dufresne [Mon, 31 Aug 2020 21:18:43 +0000 (14:18 -0700)]
Remove flake8 W503 from docs as it is ignored by default (#1661)

Fixes #1660

3 years agoFix typo in comment (#1650)
Tristan Seligmann [Fri, 28 Aug 2020 15:37:37 +0000 (17:37 +0200)]
Fix typo in comment (#1650)

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
3 years agofix 1631 and add test (#1641)
mbarkhau [Thu, 27 Aug 2020 11:47:59 +0000 (11:47 +0000)]
fix 1631 and add test (#1641)

3 years agoFix multiline docstring quote normalization
Richard Si [Wed, 26 Aug 2020 22:17:59 +0000 (18:17 -0400)]
Fix multiline docstring quote normalization

The quotes of multiline docstrings are now only normalized when string
normalization is off, instead of the string normalization setting being
ignored and the quotes being *always* normalized.

I had to make a new test case and data file since the current pair for
docstrings only worked when there is no formatting difference between the
formatting results with string normalization on and off. I needed to add
tests for when there *are* differences between the two. So I split
test_docstring's test code when string normalization is disabled into a
new test case along with a new data file.

3 years agoFix g:black_fast and g:black_(skip)_string_normalization opts
Rowan Rodrik van der Molen [Sat, 11 Jul 2020 19:20:31 +0000 (21:20 +0200)]
Fix g:black_fast and g:black_(skip)_string_normalization opts

3 years ago Revert contains_pragma_comment function changes
Yurii Karabas [Wed, 26 Aug 2020 10:43:00 +0000 (13:43 +0300)]
 Revert contains_pragma_comment function changes

3 years agoRevert contains_standalone_comments function changes
Yurii Karabas [Wed, 26 Aug 2020 06:35:21 +0000 (09:35 +0300)]
Revert contains_standalone_comments function changes

3 years agoSimplify black code by using generator expressions
Yurii Karabas [Tue, 23 Jun 2020 21:33:05 +0000 (00:33 +0300)]
Simplify black code by using generator expressions

3 years agoStop running Primer on macOS as it's flaky on GitHub Actions
Łukasz Langa [Wed, 26 Aug 2020 16:18:14 +0000 (18:18 +0200)]
Stop running Primer on macOS as it's flaky on GitHub Actions

3 years agov20.8b1
Łukasz Langa [Wed, 26 Aug 2020 15:50:44 +0000 (17:50 +0200)]
v20.8b1

3 years agoMake dependency on Click 7.0, regex 2020.1.8, and toml 0.10.1 explicit
Łukasz Langa [Wed, 26 Aug 2020 15:15:20 +0000 (17:15 +0200)]
Make dependency on Click 7.0, regex 2020.1.8, and toml 0.10.1 explicit

3 years agoAdd expected failure tests with the unstable formattings
Łukasz Langa [Wed, 26 Aug 2020 10:57:38 +0000 (12:57 +0200)]
Add expected failure tests with the unstable formattings

3 years agoInclude mode information for unstable formattings
Łukasz Langa [Wed, 26 Aug 2020 10:57:05 +0000 (12:57 +0200)]
Include mode information for unstable formattings

3 years agoTreat all trailing commas as pre-existing, as they effectively are
Łukasz Langa [Wed, 26 Aug 2020 10:22:56 +0000 (12:22 +0200)]
Treat all trailing commas as pre-existing, as they effectively are

On a second pass of Black on the same file, inserted trailing commas are now
pre-existing.  Doesn't make sense to differentiate between the passes then.

3 years agov20.8b0
Łukasz Langa [Wed, 26 Aug 2020 14:00:55 +0000 (16:00 +0200)]
v20.8b0

3 years agoPrimer update config - enable pytest (#1626)
Cooper Lees [Wed, 26 Aug 2020 04:55:05 +0000 (21:55 -0700)]
Primer update config - enable pytest (#1626)

Reformatted projects I have acceess to:
- aioexabgp
- bandersnatch
- flake8-bugbear

```
-- primer results 📊 --

13 / 16 succeeded (81.25%) ✅
0 / 16 FAILED (0.0%) 💩
 - 3 projects disabled by config
 - 0 projects skipped due to Python version
 - 0 skipped due to long checkout
```

* Also re-enable pytest

```
-- primer results 📊 --

14 / 16 succeeded (87.5%) ✅
0 / 16 FAILED (0.0%) 💩
 - 2 projects disabled by config
 - 0 projects skipped due to Python version
 - 0 skipped due to long checkout

real 2m26.207s
user 17m55.404s
sys 0m43.061s
```

3 years agoAdd links regarding Spotless integration for gradle/maven users (#1622)
Ned Twigg [Wed, 26 Aug 2020 01:54:05 +0000 (18:54 -0700)]
Add links regarding Spotless integration for gradle/maven users (#1622)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
3 years agoImprove docstring re-indentation handling
Łukasz Langa [Tue, 25 Aug 2020 20:26:13 +0000 (22:26 +0200)]
Improve docstring re-indentation handling

This addresses a few crashers, namely:

* producing non-equivalent code due to mangling escaped newlines,

* invalid hugging quote characters in the docstring body to the docstring outer
  triple quotes (causing a quadruple quote which is a syntax error),

* lack of handling for docstrings that start on the same line as the `def`, and

* invalid stripping of outer triple quotes when the docstring contained
  a string prefix.

As a bonus, tests now also run when string normalization is disabled.

3 years agoAddress pre-existing trailing commas when not in the rightmost bracket pair
Łukasz Langa [Mon, 24 Aug 2020 16:29:59 +0000 (18:29 +0200)]
Address pre-existing trailing commas when not in the rightmost bracket pair

This required some hackery.  Long story short, we need to reuse the ability to
omit rightmost bracket pairs (which glues them together and splits on something
else instead), for use with pre-existing trailing commas.

This form of user-controlled formatting is brittle so we have to be careful not
to cause a scenario where Black first formats code without trailing commas in
one way, and then looks at the same file with pre-existing trailing commas
(that it itself put on the previous run) and decides to format the code again.

One particular ugly edge case here is handling of optional parentheses.  In
particular, the long-standing `line_length=1` hack got in the way of
pre-existing trailing commas and had to be removed.  Instead, a more
intelligent but costly solution was put in place: a "second opinion" if the
formatting that omits optional parentheses ended up causing lines to be too
long.  Again, for efficiency purposes, Black reuses Leaf objects from blib2to3
and modifies them in place, which was invalid for having two separate
formattings.  Line cloning was used to mitigate this.

Fixes #1619

3 years agoRun trailing comma tests with TargetVersion.PY38
Łukasz Langa [Mon, 24 Aug 2020 19:33:51 +0000 (21:33 +0200)]
Run trailing comma tests with TargetVersion.PY38

3 years agoAdd more trailing comma test variants
Łukasz Langa [Mon, 24 Aug 2020 16:48:11 +0000 (18:48 +0200)]
Add more trailing comma test variants

3 years agoMake doc generation a little smarter, update doc sections
Łukasz Langa [Mon, 24 Aug 2020 12:33:16 +0000 (14:33 +0200)]
Make doc generation a little smarter, update doc sections

3 years agoUpdate the changelog
Łukasz Langa [Mon, 24 Aug 2020 12:11:18 +0000 (14:11 +0200)]
Update the changelog

3 years agoProperty-based fuzz test
Zac-HD [Fri, 21 Aug 2020 10:58:58 +0000 (20:58 +1000)]
Property-based fuzz test

3 years agoFix dealing with generated files in docs
Łukasz Langa [Fri, 21 Aug 2020 13:55:03 +0000 (15:55 +0200)]
Fix dealing with generated files in docs

3 years agoUse properly renamed function name in docs
Łukasz Langa [Fri, 21 Aug 2020 13:46:00 +0000 (15:46 +0200)]
Use properly renamed function name in docs

3 years agoRequire Sphinx 3
Łukasz Langa [Fri, 21 Aug 2020 13:42:58 +0000 (15:42 +0200)]
Require Sphinx 3

3 years agoMark Primer projects that will change formatting
Łukasz Langa [Fri, 21 Aug 2020 13:27:08 +0000 (15:27 +0200)]
Mark Primer projects that will change formatting

3 years agoOpen file explicitly with UTF-8 so it works on Windows, too
Łukasz Langa [Thu, 20 Aug 2020 17:21:40 +0000 (19:21 +0200)]
Open file explicitly with UTF-8 so it works on Windows, too

3 years agoReformat docs/conf.py according to the new style
Łukasz Langa [Thu, 20 Aug 2020 17:04:56 +0000 (19:04 +0200)]
Reformat docs/conf.py according to the new style

3 years agoRe-implement magic trailing comma handling:
Łukasz Langa [Mon, 28 Oct 2019 23:50:42 +0000 (00:50 +0100)]
Re-implement magic trailing comma handling:

- when a trailing comma is specified in any bracket pair, that signals to Black
  that this bracket pair needs to be always exploded, e.g. presented as "one
  item per line";

- this causes some changes to previously formatted code that erroneously left
  trailing commas embedded into single-line expressions;

- internally, Black needs to be able to identify trailing commas that it put
  itself compared to pre-existing trailing commas. We do this by using/abusing
  lib2to3's `was_checked` attribute.  It's True for internally generated
  trailing commas and False for pre-existing ones (in fact, for all
  pre-existing leaves and nodes).

Fixes #1288

3 years agoReset trailing comma handling
Łukasz Langa [Mon, 28 Oct 2019 23:34:46 +0000 (00:34 +0100)]
Reset trailing comma handling

3 years agoUpgrade docs to Sphinx 3+ and add doc build test (#1613)
Richard Si [Thu, 20 Aug 2020 22:06:41 +0000 (18:06 -0400)]
Upgrade docs to Sphinx 3+ and add doc build test (#1613)

* Upgrade docs to Sphinx 3+
* Fix all the warnings...

- Fixed bad docstrings
- Fixed bad fenced code blocks in documentation
- Blocklisted some sections from being generated from the README
- Added missing documentation to index.rst
- Fixed an invalid autofunction directive in reference/reference_functions.rst
- Pin another documentation dependency

* Add documentation build test

3 years agoDisable string splitting/merging by default (#1609)
Jelle Zijlstra [Thu, 20 Aug 2020 12:23:28 +0000 (05:23 -0700)]
Disable string splitting/merging by default (#1609)

* put experimental string stuff behind a flag
* update tests
* don't need an output section if it's the same as the input
* Primer: Expect no formatting changes in attrs, hypothesis and poetry with --experimental-string-processing off

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
3 years agoUpdate all dependencies to latest versions
Łukasz Langa [Tue, 18 Aug 2020 10:31:15 +0000 (12:31 +0200)]
Update all dependencies to latest versions

3 years agoFix inline code style in README (#1608)
Daanyaal Syed [Mon, 17 Aug 2020 18:55:38 +0000 (14:55 -0400)]
Fix inline code style in README (#1608)

Refer to `pyproject.toml` in HTML section of README with HTML code tags

3 years agofix unary op detection (#1600)
David Szotten [Fri, 14 Aug 2020 16:17:56 +0000 (17:17 +0100)]
fix unary op detection (#1600)

3 years agodon't strip brackets before lsqb (#1575) (#1590)
David Szotten [Fri, 14 Aug 2020 02:20:46 +0000 (03:20 +0100)]
don't strip brackets before lsqb (#1575) (#1590)

if the string contains a PERCENT, it's not safe to remove brackets that
follow and operator with the same or higher precedence than PERCENT

3 years agofix some docstring crashes (#1593)
Jelle Zijlstra [Thu, 13 Aug 2020 23:40:45 +0000 (16:40 -0700)]
fix some docstring crashes (#1593)

Allow removing some trailing whitespace

3 years agoin verbose mode, print stack trace (#1594)
Jelle Zijlstra [Thu, 13 Aug 2020 18:14:34 +0000 (11:14 -0700)]
in verbose mode, print stack trace (#1594)

Make Black failures easier to debug

3 years agoMake --exclude only apply to recursively found files (#1591)
Richard Si [Thu, 13 Aug 2020 03:07:19 +0000 (23:07 -0400)]
Make --exclude only apply to recursively found files (#1591)

Ever since --force-exclude was added, --exclude started to touch files
that were given to Black through the CLI too. This is not documented
behaviour and neither expected as --exclude and --force-exclude now
behave the same!

Before this commit, get_sources() when encountering a file that was passed
explicitly through the CLI would pass a single Path object list to
gen_python_files(). This causes bad behaviour since that function
doesn't treat the exclude and force_exclude regexes differently. Which
is fine for recursively found files, but *not* for files given through
the CLI.

Now when get_sources() iterates through srcs and encounters
a file, it checks if the force_exclude regex matches, if not, then the
file will be added to the computed sources set.

A new function had to be created since before you can do regex matching,
the path must be normalized. The full process of normalizing the path is
somewhat long as there is special error handling. I didn't want to
duplicate this logic in get_sources() and gen_python_files() so that's
why there is a new helper function.

3 years agoAdd the direnv base directory to the default excludes (#1564)
Chris Rose [Thu, 13 Aug 2020 02:28:01 +0000 (19:28 -0700)]
Add the direnv base directory to the default excludes (#1564)

Co-authored-by: Chris Rose <offline@offby1.net>
3 years agoRemove slow assertion (#1592)
Jelle Zijlstra [Thu, 13 Aug 2020 02:12:21 +0000 (19:12 -0700)]
Remove slow assertion (#1592)

Partial fix for #1581

This assertion produces behavior quadratic in the number of leaves in a line, which is making Black extremely slow on files with very long expressions. On my benchmark file this change makes Black 10x faster.

3 years agofix spelling (#1567)
Kaligule [Sat, 1 Aug 2020 21:21:55 +0000 (23:21 +0200)]
fix spelling (#1567)

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
3 years agoUpdate to accomodate isort 5 release changes. (#1559)
Maximilian Cosmo Sitter [Wed, 22 Jul 2020 00:29:38 +0000 (02:29 +0200)]
Update to accomodate isort 5 release changes. (#1559)

Isort 5 introduced profiles and ensure_newline_before_comments options. Either needs to be added to work correctly with black.

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
3 years agodocs: Improve pre-commit use (#1551)
Vinicius Gubiani Ferreira [Thu, 16 Jul 2020 04:51:39 +0000 (01:51 -0300)]
docs: Improve pre-commit use (#1551)

Stable tag wasn't available and crashed when attempting to set initial
pre-commit. Also the python version needs to be installed so it would
be better to use the generic "python3" command.

3 years agopre-commit: show diff on failure on CI (#1552)
Hugo van Kemenade [Wed, 15 Jul 2020 21:53:48 +0000 (00:53 +0300)]
pre-commit: show diff on failure on CI (#1552)

* pre-commit: --show-diff-on-failure

* pre-commit: --show-diff-on-failure

3 years agoUpdate curl command to use stable branch (#1543)
Steven Maude [Wed, 15 Jul 2020 18:36:14 +0000 (19:36 +0100)]
Update curl command to use stable branch (#1543)

3 years agoEnsure path for finding root is absolute (#1550)
dhaug-op [Wed, 15 Jul 2020 15:06:30 +0000 (17:06 +0200)]
Ensure path for finding root is absolute (#1550)

As Path.resolve() is buggy on windows (see https://bugs.python.org/issue38671)
an absolute path is ensured by prepending the Path.cwd()

3 years agoSpelling fix in CONTRIBUTING.md (#1547)
jtpavlock [Mon, 13 Jul 2020 22:27:05 +0000 (15:27 -0700)]
Spelling fix in CONTRIBUTING.md (#1547)

3 years agoISSUE 1533: Fix --config argument description (#1534)
Olexiy [Wed, 8 Jul 2020 15:51:18 +0000 (18:51 +0300)]
ISSUE 1533: Fix --config argument description (#1534)

Change --config argument description to "Read configuration from FILE."
The "--config FILE                   Read configuration from FILE path"

3 years agoadd Quora to orgs that use Black (#1532)
Jelle Zijlstra [Mon, 6 Jul 2020 19:45:13 +0000 (12:45 -0700)]
add Quora to orgs that use Black (#1532)

3 years agoMozilla uses black too (#1531)
Sylvestre Ledru [Mon, 6 Jul 2020 14:06:34 +0000 (16:06 +0200)]
Mozilla uses black too (#1531)

3 years agoAdd pip install from GitHub command to README.md (#1529)
Cooper Lees [Wed, 1 Jul 2020 15:15:24 +0000 (08:15 -0700)]
Add pip install from GitHub command to README.md (#1529)

* Add pip install from GitHub command to README.md
* Make it prettier ...

3 years agoFind project root correctly (#1518)
Lihu Ben-Ezri-Ravin [Wed, 24 Jun 2020 09:09:07 +0000 (05:09 -0400)]
Find project root correctly (#1518)

Ensure root dir is a common parent of all inputs
Fixes #1493

3 years agoFix toml hashes and make it clear that only TOML is supported (#1510)
Richard Si [Sat, 20 Jun 2020 05:29:53 +0000 (01:29 -0400)]
Fix toml hashes and make it clear that only TOML is supported (#1510)

* Fix TOML hashes

* Make it clear that only TOML is supported

3 years agoAdd missing contributors to README.md (Thank you everyone!) (#1508)
Richard Si [Thu, 18 Jun 2020 10:54:02 +0000 (06:54 -0400)]
Add missing contributors to README.md (Thank you everyone!) (#1508)

Black wouldn't be where it is without the countless outside contributions.
So thank you y'all and we will share our appreciation by listing your names
(and emails) in the README.md :D

3 years agoFix toml parsing and bump toml from 0.10.0 to 0.10.1 (#1501)
Richard Si [Tue, 16 Jun 2020 18:58:33 +0000 (14:58 -0400)]
Fix toml parsing and bump toml from 0.10.0 to 0.10.1 (#1501)

* Bump toml from 0.10.0 to 0.10.1 to fix a bug

* Add tests for TOML parsing and reading

* Fix configuration bug affecting vim plugin

The vim plugin directly calls parse_pyproject and skips the Click processing
, but parse_pyproject assumed that it would only be used before Click processing
and therefore made the config values click friendly. This moves the "make the values
click friendly processing" into read_pyproject_toml which is only called by a Click
callback.

* Please mypy and flake8

3 years agoFix grammatical typos in black_primer and blackd (#1504)
Bharat Raghunathan [Tue, 16 Jun 2020 18:57:33 +0000 (00:27 +0530)]
Fix grammatical typos in black_primer and blackd (#1504)

3 years agoIssue template: Add Python code formatting (#1485)
Hugo van Kemenade [Mon, 15 Jun 2020 16:15:11 +0000 (19:15 +0300)]
Issue template: Add Python code formatting (#1485)

Makes things a bit more readable

3 years agoFix find_pyproject_toml type hint (#1495)
Ralf Schmitt [Mon, 15 Jun 2020 15:56:16 +0000 (17:56 +0200)]
Fix find_pyproject_toml type hint (#1495)

3 years agoMove vim flag cast to outside of get (#1486)
Keith Smiley [Mon, 15 Jun 2020 15:55:42 +0000 (08:55 -0700)]
Move vim flag cast to outside of get (#1486)

With this config:

```toml
[tool.black]
line-length = 79
```

In neovim, this is loaded as a string which later causes an exception to
be thrown. This makes sure the value is always cast to an int

3 years agoexpression tests: adjust starred expression for Python 3.9 (#1441) (#1477)
Adam Williamson [Wed, 3 Jun 2020 22:15:54 +0000 (15:15 -0700)]
expression tests: adjust starred expression for Python 3.9 (#1441) (#1477)

As discussed in #1441, Python 3.9's new parser will not parse
`(*starred)` even using `compile()` with the `PyCF_ONLY_AST`
flag (as `ast.parse()` does), it raises a `SyntaxError`. This
breaks the four tests that use this file with Python 3.9.
Upstream does not consider this to be a bug - see
https://bugs.python.org/issue40848#msg370643 - so we must
adjust the expression. As suggested by @JelleZijlstra, this just
adds a comma, which makes the new parser happy with it (the old
parser is fine with this form also).

Signed-off-by: Adam Williamson <awilliam@redhat.com>
3 years agoGitHub action (#1421)
Hugo Barrera [Mon, 1 Jun 2020 18:11:49 +0000 (18:11 +0000)]
GitHub action (#1421)

* Implement a re-usable GitHub Action

Implement a GitHub action that can be reused across projects that want
to run black as part of their CI workflows.

* Fix typo in README.md

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
* Use latest Python 3

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
3 years agoConvert (most of the) configuration values from pyproject.toml to strings (#1466)
Richard Si [Mon, 1 Jun 2020 18:00:00 +0000 (14:00 -0400)]
Convert (most of the) configuration values from pyproject.toml to strings (#1466)

* Convert config values to string

We need to convert all configuration values from the pyproject.toml
file because Click already does value processing and conversion and
it only expects the exact Python type or string. Click doesn't like
the integer 1 as a boolean for example. This also means other
unsupported types like datetime.time will be rejected by Click as
a unvalid value instead of throwing an exception.

We only skip converting objects that are an instance of
collections.abc.Iterable because it's almost impossible to get back
the original iterable of a stringified iterable.

* Move where the conversion happens

Instead of converting the values in the merged 'default_map', I should
convert the values that were read from the 'pyproject.toml' file.

* Change collections.abc.Iterable to (list, dict)

I also moved where the conversion happens... again. I am rather indecisive
if you haven't noticed. It should be better as it takes place in the
parse_pyproject_toml logic where configuration modification already takes
place.

Actually when this PR was first created I had the conversion happen in that
return statement, but the target_version check was complaining about it being
a string. So I moved the conversion after that check, but then Click didn't
like the stringifed list, which led me to check whether the value was an
instance of an Iterable before turning it into a string. And... I forgot that
type checking before conversion would allow it to work before the
target_version check anyway.

3 years agoMake 'python -m black' work (#1460)
Richard Si [Wed, 27 May 2020 02:42:07 +0000 (22:42 -0400)]
Make 'python -m black' work (#1460)

3 years agoUpdate CONTRIBUTION.md with pre-commit + black-primer instructions (#1459)
Cooper Lees [Sun, 24 May 2020 19:02:52 +0000 (12:02 -0700)]
Update CONTRIBUTION.md with pre-commit + black-primer instructions (#1459)

* Update CONTRIBUTION with pre-commit + black-primer instructions
- Inform people how to run primer and alter it's config
- Link to main documentation

* Apply suggestions from code review

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
3 years agoRefactor docs / Maintenance of docs (#1456)
Richard Si [Sun, 24 May 2020 16:37:46 +0000 (12:37 -0400)]
Refactor docs / Maintenance of docs (#1456)

* Split code style and components documentation

Splits 'the_black_code_style', 'pragmatism', 'blackd',and 'black_primer'
into their own files. The exception being 'the_black_code_style' and
'pragmatism'. They have been merged into one 'the_black_code_style_and_pragmatism'
file.

These changes are being made because the README is becoming very long. And
a README isn't great if it dissuades its reader because of its length.

* Update the doc generation logic and configuration

With the moving of several sections in the README and the renaming of a
few files, 'conf.py' needs to be able to support custom sections.

This commit introduces DocSection which can be used to specify custom
sections of documentation. The information stored in DocSection will be
used by the process_sections function to read, process, and write the section
to CURRENT_DIR.

A large change has been made to the how the docs are prepared to be built.
Instead of just generating the files needed by reading the README, this
has a full chain of operations so custom sections are supported. First,
it reads the README and spits out a list of DocSection objects representing
the sections to be generated by process_sections. This is done since most
of the docs still live in README. Then along with the defined custom_sections
, the process_sections will be begin to process the DocSection objects.
It reads the information it needs to generate the section. Then fetches
the section's contents, calls processors required by the section to process
the section's contents, and finally writes the section to CURRENT_DIR.

This large change is so processing of the documentation can be done just
for the versions hosted on ReadTheDocs.org. An example processor using this
feature is a 'replace_links' processor. It will replace documentation
links that point to the docs hosted on GitHub with links that point to the
version hosted on ReadTheDocs.org. (I won't be coding that ATM)

This also means that files will be overwritten or created once the docs
have been built. It is annoying, since you have to 'git reset --hard'
and 'git clean -f -d' after each build, but there's nothing better. The old
system had the same side effects, so yeah :(

* Update filenames and delete unnecessary files

Update the filenames since 'the_black_code_style' and 'pragmatism' were
merged and 'contributing' was deleted in favor of 'contributing_to_black'.

All symlinks were deleted since their home (_build/generated) is no longer
used.

* Fix broken links and a few redirections

* Merge master into refactor_docs (manually done)

* Add my and most of @hugovk suggestions

Co-Authored-By: Hugo van Kemenade <hugovk@users.noreply.github.com>
* Add logging and improve configurability

Just some cleaning up up of the DocSection dataclass and added logging
support so you know what's going on.

* Rename a section and please the grammar gods of Black

Thanks @hugovk for the suggestion!

* Fix Markdown comments

* Add myself as an author :P

Seems like the right time.

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
3 years agoScrollable sidebar (#1457)
Richard Si [Sat, 23 May 2020 18:56:50 +0000 (14:56 -0400)]
Scrollable sidebar (#1457)

* Make the sidebar navigation scrollable

This is necessary since we have so many documentation sections that even
on a desktop screen, the navigation can sometimes be clipped. The only
annoyance is that on Firefox, the scrollbar can't be hidden :(

* allow the docs to build

3 years agoCapture CalledProcessError for any postitive returncode (#1450)
Cooper Lees [Fri, 22 May 2020 19:16:31 +0000 (12:16 -0700)]
Capture CalledProcessError for any postitive returncode (#1450)

- Leave logic to still allow for formatting changes to be ignored
- Now just capture the output of any other error that has a > 1 returncode
- Raise on anything else

Test: Add unit test to exercise this new logic

3 years agoAdd Primer badge to README.md (#1454)
Cooper Lees [Fri, 22 May 2020 19:15:41 +0000 (12:15 -0700)]
Add Primer badge to README.md (#1454)

3 years agoMove primer to own workflow (#1451)
Hugo van Kemenade [Fri, 22 May 2020 18:38:37 +0000 (21:38 +0300)]
Move primer to own workflow (#1451)

3 years agoUpdate README.md (#1453)
Gustavo Camargo [Fri, 22 May 2020 18:37:34 +0000 (13:37 -0500)]
Update README.md (#1453)

3 years agoEnable primer on CI Runs + add all README listed black projects into primer.json...
Cooper Lees [Fri, 22 May 2020 04:57:58 +0000 (21:57 -0700)]
Enable primer on CI Runs + add all README listed black projects into primer.json (#1440)

* Add all listed by projects into primer.json + Enable on CI Runs
- Change workers default to 2 as black uses system CPU count
- Increase timeout to 5 mins for subprocess black runs
- Takes about 120s for 13 (3 disabled) projects on my 2018 Macbook Pro
  - I was not removing directories tho ...

Will open an issue to investigate the failing projects and make this run cleaner.
- Once we get more stable we can expect more repos to be black formatted

Run it:
- `black-primer -k -w /tmp/primer_large_test --debug --rebase`
```
[2020-05-20 21:44:01,273] DEBUG: Starting /Users/cooper/venvs/b/bin/black-primer (cli.py:125)
[2020-05-20 21:44:01,273] DEBUG: Using selector: KqueueSelector (selector_events.py:53)
[2020-05-20 21:44:01,274] INFO: 16 projects to run Black over (lib.py:276)
[2020-05-20 21:44:01,274] DEBUG: Using 2 parallel workers to run Black (lib.py:281)
[2020-05-20 21:44:01,274] DEBUG: worker 0 workng on aioexabgp (lib.py:215)
[2020-05-20 21:44:01,276] DEBUG: worker 1 workng on attrs (lib.py:215)
[2020-05-20 21:44:02,443] INFO: Finished aioexabgp (lib.py:249)
[2020-05-20 21:44:02,443] DEBUG: worker 0 workng on bandersnatch (lib.py:215)
[2020-05-20 21:44:04,409] INFO: Finished bandersnatch (lib.py:249)
[2020-05-20 21:44:04,409] DEBUG: worker 0 workng on channels (lib.py:215)
[2020-05-20 21:44:04,702] INFO: Finished attrs (lib.py:249)
[2020-05-20 21:44:04,702] DEBUG: worker 1 workng on django (lib.py:215)
[2020-05-20 21:44:04,702] INFO: Skipping django as it's disabled via config (lib.py:222)
[2020-05-20 21:44:04,702] DEBUG: worker 1 workng on flake8-bugbear (lib.py:215)
[2020-05-20 21:44:05,813] INFO: Finished channels (lib.py:249)
[2020-05-20 21:44:05,813] DEBUG: worker 0 workng on hypothesis (lib.py:215)
[2020-05-20 21:44:06,071] INFO: Finished flake8-bugbear (lib.py:249)
[2020-05-20 21:44:06,071] DEBUG: worker 1 workng on pandas (lib.py:215)
[2020-05-20 21:44:06,071] INFO: Skipping pandas as it's disabled via config (lib.py:222)
[2020-05-20 21:44:06,071] DEBUG: worker 1 workng on poetry (lib.py:215)
[2020-05-20 21:44:16,207] INFO: Finished hypothesis (lib.py:249)
[2020-05-20 21:44:16,207] DEBUG: worker 0 workng on ptr (lib.py:215)
[2020-05-20 21:44:17,077] INFO: Finished poetry (lib.py:249)
[2020-05-20 21:44:17,077] DEBUG: worker 1 workng on pyramid (lib.py:215)
[2020-05-20 21:44:17,460] INFO: Finished ptr (lib.py:249)
[2020-05-20 21:44:17,460] DEBUG: worker 0 workng on pytest (lib.py:215)
[2020-05-20 21:44:17,460] INFO: Skipping pytest as it's disabled via config (lib.py:222)
[2020-05-20 21:44:17,460] DEBUG: worker 0 workng on sqlalchemy (lib.py:215)
[2020-05-20 21:44:33,319] INFO: Finished pyramid (lib.py:249)
[2020-05-20 21:44:33,319] DEBUG: worker 1 workng on tox (lib.py:215)
[2020-05-20 21:44:42,274] INFO: Finished tox (lib.py:249)
[2020-05-20 21:44:42,275] DEBUG: worker 1 workng on virtualenv (lib.py:215)
[2020-05-20 21:44:47,928] INFO: Finished virtualenv (lib.py:249)
[2020-05-20 21:44:47,928] DEBUG: worker 1 workng on warehouse (lib.py:215)
[2020-05-20 21:45:16,784] INFO: Finished warehouse (lib.py:249)
[2020-05-20 21:45:16,784] DEBUG: project_runner 1 exiting (lib.py:213)
[2020-05-20 21:45:45,700] INFO: Finished sqlalchemy (lib.py:249)
[2020-05-20 21:45:45,700] DEBUG: project_runner 0 exiting (lib.py:213)
[2020-05-20 21:45:45,701] INFO: Analyzing results (lib.py:292)
-- primer results 📊 --

13 / 16 succeeded (81.25%) ✅
0 / 16 FAILED (0.0%) 💩
 - 3 projects disabled by config
 - 0 projects skipped due to Python version
 - 0 skipped due to long checkout
```

* Move to partial for rmtree + specify a onerror handler for PermissionError on Windows for git

* Set default coding to utf8 for very important emoji's on Windows

* Set Python encoding to utf-8 for Windows

* Appease the white space gods of Black!

Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
3 years agoFix typos (#1442)
Kevin Kirsche [Thu, 21 May 2020 13:44:43 +0000 (09:44 -0400)]
Fix typos (#1442)

3 years agoblack-primer: handle singular and plural in output messages (#1432)
Hugo van Kemenade [Thu, 21 May 2020 04:03:51 +0000 (07:03 +0300)]
black-primer: handle singular and plural in output messages (#1432)

* Handle singular and plural in output messages

3 years agoUpdate README.md (#1439)
Gustavo Camargo [Thu, 21 May 2020 03:50:16 +0000 (22:50 -0500)]
Update README.md (#1439)