Skip to content

Commit

Permalink
Update to 20.8b1 (#2)
Browse files Browse the repository at this point in the history
* Find project root correctly (psf#1518)

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

* Add pip install from GitHub command to README.md (psf#1529)

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

* Mozilla uses black too (psf#1531)

* add Quora to orgs that use Black (psf#1532)

* ISSUE 1533: Fix --config argument description (psf#1534)

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

* Spelling fix in CONTRIBUTING.md (psf#1547)

* Ensure path for finding root is absolute (psf#1550)

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

* Update curl command to use stable branch (psf#1543)

* pre-commit: show diff on failure on CI (psf#1552)

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

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

* docs: Improve pre-commit use (psf#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.

* Update to accomodate isort 5 release changes. (psf#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>

* fix spelling (psf#1567)

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>

* Remove slow assertion (psf#1592)

Partial fix for psf#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.

* Add the direnv base directory to the default excludes (psf#1564)

Co-authored-by: Chris Rose <offline@offby1.net>

* Make --exclude only apply to recursively found files (psf#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.

* in verbose mode, print stack trace (psf#1594)

Make Black failures easier to debug

* fix some docstring crashes (psf#1593)

Allow removing some trailing whitespace

* don't strip brackets before lsqb (psf#1575) (psf#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

* fix unary op detection (psf#1600)

* Fix inline code style in README (psf#1608)

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

* Update all dependencies to latest versions

* Disable string splitting/merging by default (psf#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>

* Upgrade docs to Sphinx 3+ and add doc build test (psf#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

* Reset trailing comma handling

* 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 psf#1288

* Reformat docs/conf.py according to the new style

* Open file explicitly with UTF-8 so it works on Windows, too

* Mark Primer projects that will change formatting

* Require Sphinx 3

* Use properly renamed function name in docs

* Fix dealing with generated files in docs

* Property-based fuzz test

* Update the changelog

* Make doc generation a little smarter, update doc sections

* Add more trailing comma test variants

* Run trailing comma tests with TargetVersion.PY38

* 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 psf#1619

* 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.

* Add links regarding Spotless integration for gradle/maven users (psf#1622)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>

* Primer update config - enable pytest (psf#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
```

* v20.8b0

* 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.

* Include mode information for unstable formattings

* Add expected failure tests with the unstable formattings

* Make dependency on Click 7.0, regex 2020.1.8, and toml 0.10.1 explicit

* v20.8b1

Co-authored-by: Lihu Ben-Ezri-Ravin <lbenezriravin@starry.com>
Co-authored-by: Cooper Lees <me@cooperlees.com>
Co-authored-by: Sylvestre Ledru <sledru@mozilla.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Olexiy <alosha969@gmail.com>
Co-authored-by: jtpavlock <jtpavlock@gmail.com>
Co-authored-by: dhaug-op <56020126+dhaug-op@users.noreply.github.com>
Co-authored-by: Steven Maude <StevenMaude@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-authored-by: Vinicius Gubiani Ferreira <vini.g.fer@gmail.com>
Co-authored-by: Maximilian Cosmo Sitter <48606431+mcsitter@users.noreply.github.com>
Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
Co-authored-by: Kaligule <Code@schauderbasis.de>
Co-authored-by: Chris Rose <offby1@offby1.net>
Co-authored-by: Chris Rose <offline@offby1.net>
Co-authored-by: David Szotten <davidszotten@gmail.com>
Co-authored-by: Daanyaal Syed <daanyaalasyed@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Zac-HD <zac.hatfield.dodds@gmail.com>
Co-authored-by: Ned Twigg <ned.twigg@diffplug.com>
  • Loading branch information
21 people committed Aug 31, 2020
1 parent d9ff43c commit 23a7e4e
Show file tree
Hide file tree
Showing 54 changed files with 3,573 additions and 828 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/doc.yml
@@ -0,0 +1,36 @@
name: Documentation Build

on:
push:
paths:
- "docs/**"
- "README.md"
- "CHANGES.md"
- "CONTRIBUTING.md"
pull_request:
paths:
- "docs/**"
- "README.md"
- "CHANGES.md"
- "CONTRIBUTING.md"

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install -e "."
python -m pip install -r "docs/requirements.txt"
- name: Build documentation
run: sphinx-build -a -b html -W docs/ docs/_build/
31 changes: 31 additions & 0 deletions .github/workflows/fuzz.yml
@@ -0,0 +1,31 @@
name: Fuzz

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade coverage
python -m pip install --upgrade hypothesmith
python -m pip install -e ".[d]"
- name: Run fuzz tests
run: |
coverage run fuzz.py
coverage report
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Expand Up @@ -24,4 +24,4 @@ jobs:
python -m pip install -e '.[d]'
- name: Lint
run: pre-commit run --all-files
run: pre-commit run --all-files --show-diff-on-failure
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -14,3 +14,4 @@ src/_black_version.py
.eggs
.dmypy.json
*.swp
.hypothesis/
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -20,7 +20,7 @@ matrix:
- name: "lint"
python: 3.7
env:
- TEST_CMD="pre-commit run --all-files"
- TEST_CMD="pre-commit run --all-files --show-diff-on-failure"
- name: "3.6"
python: 3.6
- name: "3.7"
Expand Down
51 changes: 45 additions & 6 deletions CHANGES.md
@@ -1,18 +1,57 @@
## Change Log

### Unreleased
### 20.8b1

#### _Packaging_

- explicitly depend on Click 7.1.2 or newer as `Black` no longer works with versions
older than 7.0

### 20.8b0

#### _Black_

- reindent docstrings when reindenting code around it (#1053)
- re-implemented support for explicit trailing commas: now it works consistently within
any bracket pair, including nested structures (#1288 and duplicates)

- `Black` now reindents docstrings when reindenting code around it (#1053)

- `Black` now shows colored diffs (#1266)

- `Black` is now packaged using 'py3' tagged wheels (#1388)

- `Black` now supports Python 3.8 code, e.g. star expressions in return statements
(#1121)

- `Black` no longer normalizes capital R-string prefixes as those have a
community-accepted meaning (#1244)

- `Black` now uses exit code 2 when specified configuration file doesn't exit (#1361)

- `Black` now works on AWS Lambda (#1141)

- added `--force-exclude` argument (#1032)

- removed deprecated `--py36` option (#1236)

- fixed `--diff` output when EOF is encountered (#526)

- fixed `# fmt: off` handling around decorators (#560)

- fixed unstable formatting with some `# type: ignore` comments (#1113)

- show colored diffs (#1266)
- fixed invalid removal on organizing brackets followed by indexing (#1575)

- move to 'py3' tagged wheels (#1388)
- introduced `black-primer`, a CI tool that allows us to run regression tests against
existing open source users of Black (#1402)

- remove deprecated `--py36` option (#1236)
- introduced property-based fuzzing to our test suite based on Hypothesis and
Hypothersmith (#1566)

- add `--force-exclude` argument (#1032)
- implemented experimental and disabled by default long string rewrapping (#1132),
hidden under a `--experimental-string-processing` flag while it's being worked on;
this is an undocumented and unsupported feature, you lose Internet points for
depending on it (#1609)

#### Vim plugin

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Expand Up @@ -45,7 +45,7 @@ $ black-primer [-k -w /tmp/black_test_repos]
## black-primer

`black-primer` is used by CI to pull down well-known _Black_ formatted projects and see
if we get soure code changes. It will error on formatting changes or errors. Please run
if we get source code changes. It will error on formatting changes or errors. Please run
before pushing your PR to see if you get the actions you would expect from _Black_ with
your PR. You may need to change
[primer.json](https://github.com/psf/black/blob/master/src/black_primer/primer.json)
Expand Down
10 changes: 5 additions & 5 deletions Pipfile
Expand Up @@ -4,30 +4,30 @@ url = "https://pypi.python.org/simple"
verify_ssl = true

[dev-packages]
Sphinx = "*"
Sphinx = ">=3.1.2"
coverage = "*"
docutils = "==0.15" # not a direct dependency, see https://github.com/pypa/pipenv/issues/3865
flake8 = "*"
flake8-bugbear = "*"
flake8-mypy = "*"
mypy = ">=0.740"
mypy = ">=0.782"
pre-commit = "*"
readme_renderer = "*"
recommonmark = "*"
setuptools = ">=39.2.0"
setuptools-scm = "*"
twine = ">=1.11.0"
wheel = ">=0.31.1"
black = {editable = true,extras = ["d"],path = "."}
black = {editable = true, extras = ["d"], path = "."}

[packages]
aiohttp = ">=3.3.2"
aiohttp-cors = "*"
appdirs = "*"
click = ">=6.5"
click = ">=7.0"
mypy_extensions = ">=0.4.3"
pathspec = ">=0.6"
regex = ">=2019.8"
regex = ">=2020.1.8"
toml = ">=0.10.1"
typed-ast = "==1.4.0"
typing_extensions = ">=3.7.4"
Expand Down

0 comments on commit 23a7e4e

Please sign in to comment.