Skip to content

Commit

Permalink
Merge branch 'main' into feat/project-root-verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
Shivansh-007 committed Jan 10, 2022
2 parents 092675a + e401b6b commit c02122a
Show file tree
Hide file tree
Showing 42 changed files with 289 additions and 2,493 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ current development version. To confirm this, you have three options:
3. Or run _Black_ on your machine:
- create a new virtualenv (make sure it's the same Python version);
- clone this repository;
- run `pip install -e .[d,python2]`;
- run `pip install -e .[d]`;
- run `pip install -r test_requirements.txt`
- make sure it's sane by running `python -m pytest`; and
- run `black` like you did last time.
Expand Down
20 changes: 18 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,34 @@

### _Black_

- **Remove Python 2 support** (#2740)
- Do not accept bare carriage return line endings in pyproject.toml (#2408)
- Improve error message for invalid regular expression (#2678)
- Improve error message when parsing fails during AST safety check by embedding the
underlying SyntaxError (#2693)
- Fix mapping cases that contain as-expressions, like `case {"key": 1 | 2 as password}`
(#2686)
- Verbose mode also now describes how a project root was discovered and which paths will
be formatted. (#2526)
- Fix cases that contain multiple top-level as-expressions, like `case 1 as a, 2 as b`
(#2716)
- Fix call patterns that contain as-expressions with keyword arguments, like
`case Foo(bar=baz as quux)` (#2749)
- No longer color diff headers white as it's unreadable in light themed terminals
(#2691)
- Tuple unpacking on `return` and `yield` constructs now implies 3.8+ (#2700)
- Unparenthesized tuples on annotated assignments (e.g
`values: Tuple[int, ...] = 1, 2, 3`) now implies 3.8+ (#2708)
- For stubs, one blank line between class attributes and methods is now kept if there's
at least one pre-existing blank line (#2736)
- Verbose mode also now describes how a project root was discovered and which paths will
be formatted. (#2526)

### Packaging

- All upper version bounds on dependencies have been removed (#2718)

### Integrations

- Update GitHub action to support containerized runs (#2748)

## 21.12b0

Expand Down
49 changes: 0 additions & 49 deletions Pipfile

This file was deleted.

1,958 changes: 0 additions & 1,958 deletions Pipfile.lock

This file was deleted.

4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ Try it out now using the [Black Playground](https://black.vercel.app). Watch the
### Installation

_Black_ can be installed by running `pip install black`. It requires Python 3.6.2+ to
run. If you want to format Python 2 code as well, install with
`pip install black[python2]`. If you want to format Jupyter Notebooks, install with
`pip install black[jupyter]`.
run. If you want to format Jupyter Notebooks, install with `pip install black[jupyter]`.

If you can't wait for the latest _hotness_ and want to install from GitHub, use:

Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ runs:
import subprocess;
from pathlib import Path;
MAIN_SCRIPT = Path(r'${{ github.action_path }}') / 'action' / 'main.py';
MAIN_SCRIPT = Path(r'${GITHUB_ACTION_PATH}') / 'action' / 'main.py';
proc = subprocess.run([sys.executable, str(MAIN_SCRIPT)]);
sys.exit(proc.returncode)
Expand Down
2 changes: 1 addition & 1 deletion action/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

run([sys.executable, "-m", "venv", str(ENV_PATH)], check=True)

req = "black[colorama,python2]"
req = "black[colorama]"
if VERSION:
req += f"=={VERSION}"
pip_proc = run(
Expand Down
36 changes: 14 additions & 22 deletions docs/contributing/the_basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,32 @@ An overview on contributing to the _Black_ project.
Development on the latest version of Python is preferred. As of this writing it's 3.9.
You can use any operating system.

Install all development dependencies using:
Install development dependencies inside a virtual environment of your choice, for
example:

```console
$ pipenv install --dev
$ pipenv shell
$ pre-commit install
```

If you haven't used `pipenv` before but are comfortable with virtualenvs, just run
`pip install pipenv` in the virtualenv you're already using and invoke the command above
from the cloned _Black_ repo. It will do the correct thing.

Non pipenv install works too:

```console
$ pip install -r test_requirements.txt
$ pip install -e .[d]
$ python3 -m venv .venv
$ source .venv/bin/activate
(.venv)$ pip install -r test_requirements.txt
(.venv)$ pip install -e .[d]
(.venv)$ pre-commit install
```

Before submitting pull requests, run lints and tests with the following commands from
the root of the black repo:

```console
# Linting
$ pre-commit run -a
(.venv)$ pre-commit run -a

# Unit tests
$ tox -e py
(.venv)$ tox -e py

# Optional Fuzz testing
$ tox -e fuzz
(.venv)$ tox -e fuzz

# Optional CI run to test your changes on many popular python projects
$ black-primer [-k -w /tmp/black_test_repos]
(.venv)$ black-primer [-k -w /tmp/black_test_repos]
```

### News / Changelog Requirement
Expand Down Expand Up @@ -70,9 +62,9 @@ formatting don't need to be mentioned separately though.
If you make changes to docs, you can test they still build locally too.

```console
$ pip install -r docs/requirements.txt
$ pip install [-e] .[d]
$ sphinx-build -a -b html -W docs/ docs/_build/
(.venv)$ pip install -r docs/requirements.txt
(.venv)$ pip install [-e] .[d]
(.venv)$ sphinx-build -a -b html -W docs/ docs/_build/
```

## black-primer
Expand Down
14 changes: 2 additions & 12 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,7 @@ disabled-by-default counterpart W504. E203 should be disabled while changes are

## Does Black support Python 2?

```{warning}
Python 2 support has been deprecated since 21.10b0.
This support will be dropped in the first stable release, expected for January 2022.
See [The Black Code Style](the_black_code_style/index.rst) for details.
```

For formatting, yes! [Install](getting_started.md#installation) with the `python2` extra
to format Python 2 files too! In terms of running _Black_ though, Python 3.6 or newer is
required.
Support for formatting Python 2 code was removed in version 22.0.

## Why does my linter or typechecker complain after I format my code?

Expand All @@ -96,8 +87,7 @@ codebase with _Black_.

## Can I run Black with PyPy?

Yes, there is support for PyPy 3.7 and higher. You cannot format Python 2 files under
PyPy, because PyPy's inbuilt ast module does not support this.
Yes, there is support for PyPy 3.7 and higher.

## Why does Black not detect syntax errors in my code?

Expand Down
4 changes: 1 addition & 3 deletions docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ Also, you can try out _Black_ online for minimal fuss on the
## Installation

_Black_ can be installed by running `pip install black`. It requires Python 3.6.2+ to
run, but can format Python 2 code too. Python 2 support needs the `typed_ast`
dependency, which be installed with `pip install black[python2]`. If you want to format
Jupyter Notebooks, install with `pip install black[jupyter]`.
run. If you want to format Jupyter Notebooks, install with `pip install black[jupyter]`.

If you can't wait for the latest _hotness_ and want to install from GitHub, use:

Expand Down
65 changes: 40 additions & 25 deletions docs/integrations/editors.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,36 +78,51 @@ Options include the following:

## Wing IDE

Wing supports black via the OS Commands tool, as explained in the Wing documentation on
[pep8 formatting](https://wingware.com/doc/edit/pep8). The detailed procedure is:
Wing IDE supports `black` via **Preference Settings** for system wide settings and
**Project Properties** for per-project or workspace specific settings, as explained in
the Wing documentation on
[Auto-Reformatting](https://wingware.com/doc/edit/auto-reformatting). The detailed
procedure is:

1. Install `black`.
### Prerequistes

```console
$ pip install black
```
- Wing IDE version 8.0+

1. Make sure it runs from the command line, e.g.
- Install `black`.

```console
$ black --help
```
```console
$ pip install black
```

- Make sure it runs from the command line, e.g.

```console
$ black --help
```

### Preference Settings

If you want Wing IDE to always reformat with `black` for every project, follow these
steps:

1. In menubar navigate to `Edit -> Preferences -> Editor -> Reformatting`.

1. Set **Auto-Reformat** from `disable` (default) to `Line after edit` or
`Whole files before save`.

1. Set **Reformatter** from `PEP8` (default) to `Black`.

### Project Properties

If you want to just reformat for a specific project and not intervene with Wing IDE
global setting, follow these steps:

1. In menubar navigate to `Project -> Project Properties -> Options`.

1. Set **Auto-Reformat** from `Use Preferences setting` (default) to `Line after edit`
or `Whole files before save`.

1. In Wing IDE, activate the **OS Commands** panel and define the command **black** to
execute black on the currently selected file:

- Use the Tools -> OS Commands menu selection
- click on **+** in **OS Commands** -> New: Command line..
- Title: black
- Command Line: black %s
- I/O Encoding: Use Default
- Key Binding: F1
- [x] Raise OS Commands when executed
- [x] Auto-save files before execution
- [x] Line mode

1. Select a file in the editor and press **F1** , or whatever key binding you selected
in step 3, to reformat the file.
1. Set **Reformatter** from `Use Preferences setting` (default) to `Black`.

## Vim

Expand Down
4 changes: 2 additions & 2 deletions docs/integrations/github_actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ environment. Great for enforcing that your code matches the _Black_ code style.
This action is known to support all GitHub-hosted runner OSes. In addition, only
published versions of _Black_ are supported (i.e. whatever is available on PyPI).

Finally, this action installs _Black_ with both the `colorama` and `python2` extras so
the `--color` flag and formatting Python 2 code are supported.
Finally, this action installs _Black_ with the `colorama` extra so the `--color` flag
should work fine.

## Usage

Expand Down
4 changes: 2 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Used by ReadTheDocs; pinned requirements for stability.

myst-parser==0.16.0
Sphinx==4.3.1
myst-parser==0.16.1
Sphinx==4.3.2
sphinxcontrib-programoutput==0.17
sphinx_copybutton==0.4.0
3 changes: 1 addition & 2 deletions docs/the_black_code_style/current_style.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,7 @@ removed.

_Black_ standardizes most numeric literals to use lowercase letters for the syntactic
parts and uppercase letters for the digits themselves: `0xAB` instead of `0XAB` and
`1e10` instead of `1E10`. Python 2 long literals are styled as `2L` instead of `2l` to
avoid confusion between `l` and `1`.
`1e10` instead of `1E10`.

### Line breaks & binary operators

Expand Down
8 changes: 4 additions & 4 deletions docs/usage_and_configuration/the_basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ python -m black {source_file_or_directory}

### Command line options

_Black_ has quite a few knobs these days, although _Black_ is opinionated so style
configuration options are deliberately limited and rarely added. You can list them by
running `black --help`.
The CLI options of _Black_ can be displayed by expanding the view below or by running
`black --help`. While _Black_ has quite a few knobs these days, it is still opinionated
so style options are deliberately limited and rarely added.

<details>

<summary>Help output</summary>
<summary>CLI reference</summary>

```{program-output} black --help
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ 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",
"no_jupyter: run when `jupyter` extra NOT installed",
]
Expand Down
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ def find_python_files(base: Path) -> List[Path]:
install_requires=[
"click>=7.1.2",
"platformdirs>=2",
"tomli>=0.2.6,<2.0.0",
"tomli>=1.1.0",
"typed-ast>=1.4.2; python_version < '3.8' and implementation_name == 'cpython'",
"pathspec>=0.9.0, <1",
"pathspec>=0.9.0",
"dataclasses>=0.6; python_version < '3.7'",
"typing_extensions>=3.10.0.0",
# 3.10.0.1 is broken on at least Python 3.10,
Expand All @@ -112,7 +112,6 @@ def find_python_files(base: Path) -> List[Path]:
extras_require={
"d": ["aiohttp>=3.7.4"],
"colorama": ["colorama>=0.4.3"],
"python2": ["typed-ast>=1.4.3"],
"uvloop": ["uvloop>=0.15.2"],
"jupyter": ["ipython>=7.8.0", "tokenize-rt>=3.2.0"],
},
Expand Down
Loading

0 comments on commit c02122a

Please sign in to comment.