Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into reorganize-docs-v2
Browse files Browse the repository at this point in the history
merge conflicts suck, although these ones weren't too bad.
  • Loading branch information
ichard26 committed May 7, 2021
2 parents d354346 + 4fc1354 commit fc51b65
Show file tree
Hide file tree
Showing 29 changed files with 431 additions and 172 deletions.
4 changes: 4 additions & 0 deletions .coveragerc
Expand Up @@ -3,3 +3,7 @@ omit =
src/blib2to3/*
tests/data/*
*/site-packages/*
.tox/*

[run]
relative_files = True
3 changes: 1 addition & 2 deletions .github/workflows/lint.yml
Expand Up @@ -22,8 +22,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pre-commit
python -m pip install -e '.[d]'
- name: Lint
run: pre-commit run --all-files --show-diff-on-failure
uses: pre-commit/action@v2.0.2
33 changes: 32 additions & 1 deletion .github/workflows/test.yml
Expand Up @@ -33,4 +33,35 @@ jobs:
- name: Unit tests
run: |
tox -e py
tox -e py -- -v --color=yes
- name: Publish coverage to Coveralls
# If pushed / is a pull request against main repo AND
# we're running on Linux (this action only supports Linux)
if:
((github.event_name == 'push' && github.repository == 'psf/black') ||
github.event.pull_request.base.repo.full_name == 'psf/black') && matrix.os ==
'ubuntu-latest'

uses: AndreMiras/coveralls-python-action@v20201129
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel: true
flag-name: py${{ matrix.python-version }}-${{ matrix.os }}
debug: true

coveralls-finish:
needs: build
# If pushed / is a pull request against main repo
if:
(github.event_name == 'push' && github.repository == 'psf/black') ||
github.event.pull_request.base.repo.full_name == 'psf/black'

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Coveralls finished
uses: AndreMiras/coveralls-python-action@v20201129
with:
parallel-finished: true
debug: true
31 changes: 0 additions & 31 deletions .travis.yml

This file was deleted.

17 changes: 16 additions & 1 deletion CHANGES.md
@@ -1,5 +1,17 @@
# Change Log

## 21.5b0

### _Black_

- Set `--pyi` mode if `--stdin-filename` ends in `.pyi` (#2169)
- Stop detecting target version as Python 3.9+ with pre-PEP-614 decorators that are being
called but with no arguments (#2182)

### _Black-Primer_

- Add `--no-diff` to black-primer to suppress formatting changes (#2187)

## 21.4b2

### _Black_
Expand All @@ -12,6 +24,9 @@

### _Packaging_

- Allow `.gitignore` rules to be overridden by specifying `exclude` in `pyproject.toml` or
on the command line. (#2170)

- Install `primer.json` (used by `black-primer` by default) with black. (#2154)

## 21.4b1
Expand Down Expand Up @@ -592,4 +607,4 @@

- alpha quality

- date-versioned (see: https://calver.org/)
- date-versioned (see: <https://calver.org/>)
2 changes: 1 addition & 1 deletion Pipfile
Expand Up @@ -20,7 +20,7 @@ wheel = ">=0.31.1"
black = {editable = true, extras = ["d"], path = "."}

[packages]
aiohttp = ">=3.3.2"
aiohttp = ">=3.6.0"
aiohttp-cors = "*"
appdirs = "*"
click = ">=7.1.2"
Expand Down
1 change: 0 additions & 1 deletion README.md
Expand Up @@ -3,7 +3,6 @@
<h2 align="center">The Uncompromising Code Formatter</h2>

<p align="center">
<a href="https://travis-ci.com/psf/black"><img alt="Build Status" src="https://travis-ci.com/psf/black.svg?branch=master"></a>
<a href="https://github.com/psf/black/actions"><img alt="Actions Status" src="https://github.com/psf/black/workflows/Test/badge.svg"></a>
<a href="https://github.com/psf/black/actions"><img alt="Actions Status" src="https://github.com/psf/black/workflows/Primer/badge.svg"></a>
<a href="https://black.readthedocs.io/en/stable/?badge=stable"><img alt="Documentation Status" src="https://readthedocs.org/projects/black/badge/?version=stable"></a>
Expand Down
12 changes: 11 additions & 1 deletion action.yml
Expand Up @@ -2,8 +2,18 @@ name: "Black"
description: "The uncompromising Python code formatter."
author: "Łukasz Langa and contributors to Black"
inputs:
options:
description:
"Options passed to black. Use `black --help` to see available options. Default:
'--check'"
required: false
default: "--check --diff"
src:
description: "Source to run black. Default: '.'"
required: false
default: "."
black_args:
description: "Black input arguments."
description: "[DEPRECATED] Black input arguments."
required: false
default: ""
branding:
Expand Down
20 changes: 6 additions & 14 deletions action/entrypoint.sh
@@ -1,17 +1,9 @@
#!/bin/bash
set -e
#!/bin/bash -e

# If no arguments are given use current working directory
black_args=(".")
if [ "$#" -eq 0 ] && [ "${INPUT_BLACK_ARGS}" != "" ]; then
black_args+=(${INPUT_BLACK_ARGS})
elif [ "$#" -ne 0 ] && [ "${INPUT_BLACK_ARGS}" != "" ]; then
black_args+=($* ${INPUT_BLACK_ARGS})
elif [ "$#" -ne 0 ] && [ "${INPUT_BLACK_ARGS}" == "" ]; then
black_args+=($*)
else
# Default (if no args provided).
black_args+=("--check" "--diff")
if [ -n "$INPUT_BLACK_ARGS" ]; then
echo '::warning::Input `with.black_args` is deprecated. Use `with.options` and `with.src` instead.'
black $INPUT_BLACK_ARGS
exit $?
fi

sh -c "black . ${black_args[*]}"
black $INPUT_OPTIONS $INPUT_SRC
1 change: 0 additions & 1 deletion docs/conf.py
Expand Up @@ -120,7 +120,6 @@ def make_pypi_svg(version: str) -> None:
"show_powered_by": True,
"fixed_sidebar": True,
"logo": "logo2.png",
"travis_button": True,
}


Expand Down
50 changes: 22 additions & 28 deletions docs/guides/using_black_with_other_tools.md
Expand Up @@ -21,7 +21,24 @@ Compatible configuration files can be
_Black_ also formats imports, but in a different way from isort's defaults which leads
to conflicting changes.

#### Configuration
#### Profile

Since version 5.0.0, isort supports
[profiles](https://pycqa.github.io/isort/docs/configuration/profiles/) to allow easy
interoperability with common code styles. You can set the black profile in any of the
[config files](https://pycqa.github.io/isort/docs/configuration/config_files/) supported
by isort. Below, an example for `pyproject.toml`:

```toml
[tool.isort]
profile = "black"
```

#### Custom Configuration

If you're using an isort version that is older than 5.0.0 or you have some custom
configuration for _Black_, you can tweak your isort configuration to make it compatible
with _Black_. Below, an example for `.isort.cfg`:

```
multi_line_output = 3
Expand Down Expand Up @@ -74,9 +91,6 @@ works the same as with _Black_.

**Please note** `ensure_newline_before_comments = True` only works since isort >= 5 but
does not break older versions so you can keep it if you are running previous versions.
If only isort >= 5 is used you can add `profile = black` instead of all the options
since [profiles](https://timothycrosley.github.io/isort/docs/configuration/profiles/)
are available and do the configuring for you.

#### Formats

Expand All @@ -85,12 +99,7 @@ are available and do the configuring for you.

```cfg
[settings]
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
use_parentheses = True
ensure_newline_before_comments = True
line_length = 88
profile = black
```

</details>
Expand All @@ -100,12 +109,7 @@ line_length = 88

```cfg
[isort]
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
use_parentheses = True
ensure_newline_before_comments = True
line_length = 88
profile = black
```

</details>
Expand All @@ -115,12 +119,7 @@ line_length = 88

```toml
[tool.isort]
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
ensure_newline_before_comments = true
line_length = 88
profile = 'black'
```

</details>
Expand All @@ -130,12 +129,7 @@ line_length = 88

```ini
[*.py]
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
use_parentheses = True
ensure_newline_before_comments = True
line_length = 88
profile = black
```

</details>
Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Expand Up @@ -25,3 +25,10 @@ extend-exclude = '''
[build-system]
requires = ["setuptools>=41.0", "setuptools-scm", "wheel"]
build-backend = "setuptools.build_meta"

[tool.pytest.ini_options]
# Option below requires `tests/optional.py`
optional-tests = [
"no_python2: run when `python2` extra NOT installed",
"no_blackd: run when `d` extra NOT installed",
]
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -83,7 +83,7 @@ def get_long_description() -> str:
"mypy_extensions>=0.4.3",
],
extras_require={
"d": ["aiohttp>=3.3.2", "aiohttp-cors"],
"d": ["aiohttp>=3.6.0", "aiohttp-cors"],
"colorama": ["colorama>=0.4.3"],
"python2": ["typed-ast>=1.4.2"],
},
Expand Down

0 comments on commit fc51b65

Please sign in to comment.