Commit Graph

1953 Commits

Author SHA1 Message Date
Richard Si
303a0b2c4d
Maintainers += Richard Si (aka ichard26) (#2149) 2021-04-26 16:59:45 -04:00
Richard Si
b55ea63ff4
Stop stripping parens in even more illegal spots (#2148)
We're only fixing them so fuzzers don't yell at us when we break "valid"
code. I mean "valid" because some of the examples aren't even accepted by
Python.
2021-04-26 22:26:43 +02:00
Łukasz Langa
a0b4e609a7
Bump pathspec to >= 0.8.1 to solve invalid .gitignore exclusion handling (#2084)
Also made the Click requirement in Pipfile consistent with setup.py and bumped mypy.
2021-04-26 21:22:25 +02:00
Łukasz Langa
eaa337f176
Add more tests for fancy whitespace (#2147) 2021-04-26 20:24:06 +02:00
Jelle Zijlstra
557b54aa60
Fix crash on docstrings ending with "\ " (#2142)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-04-26 19:42:16 +02:00
Richard Si
97c24664c5
Symlink docs/change_log.md to CHANGES.md, don't copy (#2146)
Super duper janky stopgap fix until I get my documentation reorganization
work done and merged
2021-04-26 10:26:03 -07:00
Richard Si
db30456916
Don't strip parens in assert / return with assign expr (#2143)
Black would previously strip the parenthesis away from statements like this these ones:

    assert (spam := 12 + 1)
    return (cheese := 1 - 12)

Which happens to be invalid code. Now before making the parenthesis invisible, Black
checks if the assignment expression's parent is an assert stamtment, aborting if True.

Raise, yield, and await are already handled fine.

I added a bunch of test cases from the PEP defining asssignment expressions (PEP 572).
2021-04-26 08:28:42 -07:00
Jelle Zijlstra
0a833b4b14
fix magic comma and experimental string cache flags (#2131)
* fix magic comma and experimental string cache flags

* more changelog

* Update CHANGES.md

Co-authored-by: Cooper Lees <me@cooperlees.com>

* fix tests

Co-authored-by: Cooper Lees <me@cooperlees.com>
2021-04-26 07:46:48 +02:00
Cooper Lees
65f0ea6159
Remove Lowercase Hex (PR #1692) from CHANGES.md (#2133)
- It was reverted to not cause so much diff churn on millions of lines of code
- Fix primer config for projects that should now pass
2021-04-25 20:48:04 -07:00
Cooper Lees
67d5532c33
Update CHANGES.md for release (#2129) 2021-04-25 15:12:27 -07:00
Richard Si
de7187a823
Issue 1629 has been closed, let's celebrate! (#2127) 2021-04-25 23:52:23 +02:00
Cooper Lees
eee949e286
Docker CI: Add missed Checkout step (#2128)
- Reading my error others hit it by forgetting this Checkoutstep too so trying the fix
  - e.g. https://github.com/docker/build-push-action/issues/179
- Makes sense it's needed
2021-04-25 23:51:13 +02:00
Cooper Lees
e5490e9623
Add Docker Github Action (#2086)
* Add Docker Github Action
- Build and upload arm64 + amd64 black images on push to master

This will need a `DOCKERHUB_USERNAME` and `DOCKERHUB_TOKEN` secrets set by someone with access.

* Change tag to push to pyfound/black repository. Thanks @ewdurbin
2021-04-25 11:27:35 -07:00
Łukasz Langa
8672af35f0
Work around stability errors due to optional trailing commas (#2126)
Optional trailing commas put by Black become magic trailing commas on another
pass of the tool.  Since they are influencing formatting around optional
parentheses, on rare occasions the tool changes its mind in terms of putting
parentheses or not.

Ideally this would never be the case but sadly the decision to put optional
parentheses or not (which looks at pre-existing "magic" trailing commas) is
happening around the same time as the decision to put an optional trailing
comma.  Untangling the two proved to be impractically difficult.

This shameful workaround uses the fact that the formatting instability
introduced by magic trailing commas is deterministic: if the optional trailing
comma becoming a pre-existing "magic" trailing comma changes formatting, the
second pass becomes stable since there is no variable factor anymore on pass 3,
4, and so on.

For most files, this will introduce no performance penalty since `--safe` is
already re-formatting everything twice to ensure formatting stability.  We're
using this result and if all's good, the behavior is equivalent.  If there is
a difference, we treat the second result as the binding one, and check its
sanity again.
2021-04-25 20:15:54 +02:00
Łukasz Langa
5e09fa07f5
Fix primer config 2021-04-25 19:44:06 +02:00
Łukasz Langa
ea9fefb359
Re-add .venv to .gitignore 2021-04-25 19:42:02 +02:00
Łukasz Langa
773e4a22d5
Revert "Use lowercase hex numbers fixes #1692 (#1775)"
This reverts commit 7d032fa848.
2021-04-25 19:13:23 +02:00
Felix Hildén
368f043f13
Document experimental string processing and docstring indentation (#2106) 2021-04-22 10:37:27 -07:00
CiderMan
5316bbff0e
Handle Docstrings as bytes + strip all whitespace (#2037)
(fixes #1844, fixes #1923, fixes #1851, fixes #2002, fixes #2103)
2021-04-22 08:40:51 -07:00
Mark Bell
1fc3215e8c
Make black remove leading and trailing spaces from one-line docstrings (#1740)
Fixes #1738. Fixes #1812.

Previously, Black removed leading and trailing spaces in multiline docstrings but failed to remove them from one-line docstrings.
2021-04-22 08:23:41 -07:00
Felix Hildén
7b4ca4bd90
Instructions on documenting code style modifications (#2109) 2021-04-18 14:18:39 -07:00
Laurent Tréguier
9eb29a6d47
Fix small comment typo (#2112)
We probably don't need to fall back on "polling" when setting up an asyncio loop
2021-04-16 10:41:19 -07:00
Pierre Verkest
6d0bdc2f38
Add missing instructions to make test passed (#2100) 2021-04-12 06:18:11 -07:00
Pierre Sassoulas
d960d5d238
Remove NBSP at the beginning of comments (#2092)
Closes #2091
2021-04-11 14:41:22 -07:00
Simon
ea4e714b9a
Added not formatting files in gitignore (psf#1682) (#1734) 2021-04-11 14:00:03 -07:00
Jelle Zijlstra
2116eca51f
fix typing issue around lru_cache arguments (#2098)
This was found by python/mypy#10308
2021-04-11 07:49:42 -07:00
johnthagen
e4003c2c43
Exclude venv directory by default (#1683)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-04-10 05:07:34 -07:00
Jelle Zijlstra
4d36304a2c
Fix error from upcoming typeshed change (#2096)
See python/typeshed#5190
2021-04-08 10:25:37 -07:00
Cooper Lees
8e0803e7e5
Add black Dockerfile (#1916)
* Add `black` Dockerfile
- Build a `black` container based on python3-slim
- Test: `docker build --network-host --tag black .`
```console
cooper-mbp1:black cooper$ docker image ls
REPOSITORY                                         TAG            IMAGE ID       CREATED              SIZE
black                                              latest         0c7636402ac2   4 seconds ago        332MB
```

Addresses part of #1914

* Build with colorama + d extra installs - Adds ~9mb

* Combine all build commands in 1 run
- Combine the commands all into 1 RUN to down the size
- Get to 65.98 MB image size now: https://hub.docker.com/repository/docker/cooperlees/black/tags?page=1&ordering=last_updated

* Add rm -r of /var/lib/apt/lists/* + save 10mb down to 55mb
2021-04-07 21:13:11 -07:00
dependabot[bot]
9cbf1f1622
Bump urllib3 from 1.26.3 to 1.26.4 (#2090)
Bumps [urllib3](https://github.com/urllib3/urllib3) from 1.26.3 to 1.26.4.
- [Release notes](https://github.com/urllib3/urllib3/releases)
- [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst)
- [Commits](https://github.com/urllib3/urllib3/compare/1.26.3...1.26.4)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-06 11:07:57 -07:00
Jakub Warczarek
e114ef5514
Get rid of redundant spaces in docs (#2085)
Thanks!
2021-04-04 07:21:33 -07:00
Cooper Lees
201b331e55
Run lint in latest python + update precommit (#2081)
- Lets move to latest and greatest of lints
2021-04-01 16:15:50 -07:00
Richard Si
48dfda084a
Push contributors to use Next PR Number (#2080)
This is a tool of my own making. Right now our requirement to have the
PR number in the changelog entry is pretty painful / annoying since
the contributor either has to guess or add the # retroactively after
the PR creation. This tool should make it way less painful by making
it simple to get your PR number beforehand.
2021-04-01 14:24:18 -07:00
Cooper Lees
53a6216cd5
Add CONTRBUTING info about CHANGES.md requirement (#2073)
Instruct contributors to add the change line to help save maintainer / releaser time
2021-04-01 18:54:45 +02:00
Cooper Lees
125ed5b260
Add a GitHub Action to build + Upload black to PyPI (#1848)
* Add a GitHub Action to build + Upload black to PyPI
- Build a wheel + sdist
- Upload via twine using token stored in GitHub secrets
2021-04-01 18:41:55 +02:00
Harish Rajagopal
9451c57d1c
Support for top-level user configuration (#1899)
* Added support for top-level user configuration

At the user level, a TOML config can be specified in the following locations:
* Windows: ~\.black
* Unix-like: $XDG_CONFIG_HOME/black (~/.config/black fallback)

Instead of changing env vars for the entire black-primer process, they
are now changed only for the black subprocess, using a tmpdir.
2021-04-01 18:39:18 +02:00
KotlinIsland
ed9d58b741 don't require typed-ast 2021-04-01 17:38:04 +02:00
dependabot[bot]
c702588daa
Bump pygments from 2.6.1 to 2.7.4 in /docs (#2076)
Bumps [pygments](https://github.com/pygments/pygments) from 2.6.1 to 2.7.4.
- [Release notes](https://github.com/pygments/pygments/releases)
- [Changelog](https://github.com/pygments/pygments/blob/master/CHANGES)
- [Commits](https://github.com/pygments/pygments/compare/2.6.1...2.7.4)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-03-29 18:59:57 -07:00
Mark Bell
dc8b0a4383
GREP for PR reference accepts references that are split over a line (#2072)
Fixes #2070
2021-03-28 16:01:37 -07:00
Shantanu
4218ae18c0
Add --skip-magic-trailing-comma to CHANGES.md (#2064) 2021-03-26 07:21:18 -07:00
Richard Si
580b4fe8bc
Add entry for --extend-exclude in the right place (#2061)
The PR author added the changelog entry for their `extend-exclude` addition
in `docs/change_log.md` which is understandable but incorrect as it will be
overwritten since it's autogenerated from the readme.
2021-03-24 16:38:07 -07:00
Cooper Lees
5d33f20a2a
Add a GitHub CHANGELOG/News Check (#2057)
- Run grep to see commit has a line mentioning it to CHANGES.md
- Also add a label to disable this being required for PRs that don't need a change entry
2021-03-21 13:05:24 -07:00
Richard Si
0be7f96d9c
Fix indentation in docs/editor_integration.md (#2056)
Numbered list entries' bodies need to be indented or else the list won't
render correctly.
2021-03-20 12:15:55 -07:00
Jairo Llopis
d62d677ca2
Recommend B950 + 88 char limit instead of 80 (#2050)
[The section about line length][1] was contradictory.

On one side, it said:

> Black will try to respect that [line length limit]. However, sometimes it won't be able to without breaking other rules. In those rare cases, auto-formatted code will exceed your allotted limit.

So black doesn't guarantee that your code is formatted at 88 chars, even when configured with `--line-length=88` (default). Black uses this limit as a "hint" more than a "rule".

OTOH, it also said:

> If you're using Flake8, you can bump max-line-length to 88 and forget about it. Alternatively, use Bugbear's B950 warning instead of E501 and keep the max line length at 80 which you are probably already using.

But that's not true. You can't "forget about it" because Black sometimes won't respect the limit. Both E501 at 88 and B950 at 80 behave the same: linter error at 89+ length. So, if Black happens to decide that a line of code is better at 90 characters that some other fancy style, you land on a unlucky situation where both tools will fight.

So, AFAICS, the best way to align flake8 and black is to:

1. Use flake8-bugbear
2. Enable B950
3. Disable E501
4. Set `max-line-length = 88`

This way, we also tell flake8 that 88 limit is a "hint" and not a "rule". The real rule will be 88 + 10%. If black decides that a line fits better in 97 characters than in 88 + some formatting, _that_ probably means your code has a real problem.

To avoid further confusion, I change the official recommendation here.

[1]: e82bb8d8b8 (opinionated-warnings)
2021-03-18 08:14:15 -07:00
Konstantin Alekseev
5446a92f01
Use vim autoload script (#1157) 2021-03-07 16:13:25 -08:00
Richard Si
b332cfa655
Add missing changelog entry for fmt: skip (#2025) 2021-03-06 12:02:25 -08:00
John Meow
1f7e73506c
Add ALE (#1753) 2021-03-05 20:22:19 -08:00
Hadi Alqattan
b3ceb293d9
Remove unused import statements using Pycln. (#2021)
* remove unused imports using Pycln.

* reverse comma style.
2021-03-05 11:58:00 -08:00
dependabot[bot]
12f98219bc
Bump aiohttp from 3.7.3 to 3.7.4 (#2009)
Bumps [aiohttp](https://github.com/aio-libs/aiohttp) from 3.7.3 to 3.7.4.
- [Release notes](https://github.com/aio-libs/aiohttp/releases)
- [Changelog](https://github.com/aio-libs/aiohttp/blob/master/CHANGES.rst)
- [Commits](https://github.com/aio-libs/aiohttp/compare/v3.7.3...v3.7.4)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-03-05 10:43:54 -08:00
Hugo van Kemenade
24418a5450
Black requires Python 3.6.2+ (#1668) 2021-03-04 05:59:31 -08:00