Skip to content
Permalink
Browse files

Automatic parentheses management

Fixes #4
  • Loading branch information...
ambv committed Apr 5, 2018
1 parent e8ba352 commit cb5aadad74c0a1c9c514a633c632c99b668c70ed
Showing with 336 additions and 71 deletions.
  1. +18 −0 README.md
  2. +208 −43 black.py
  3. +10 −0 docs/reference/reference_functions.rst
  4. +13 −0 tests/composition.py
  5. +30 −21 tests/empty_lines.py
  6. +20 −2 tests/expression.diff
  7. +18 −1 tests/expression.py
  8. +2 −2 tests/function.py
  9. +9 −1 tests/import_spacing.py
  10. +8 −1 tests/test_black.py
@@ -300,6 +300,22 @@ This behaviour may raise ``W503 line break before binary operator`` warnings in
style guide enforcement tools like Flake8. Since ``W503`` is not PEP 8 compliant,
you should tell Flake8 to ignore these warnings.
### Parentheses
Some parentheses are optional in the Python grammar. Any expression can
be wrapped in a pair of parentheses to form an atom. There are a few
interesting cases:
- `if (...):`
- `while (...):`
- `for (...) in (...):`
- `assert (...), (...)`
- `from X import (...)`
In those cases, parentheses are removed when the entire statement fits
in one line, or if the inner expression doesn't have any delimiters to
further split on. Otherwise, the parentheses are always added.
## Editor integration
@@ -479,6 +495,8 @@ More details can be found in [CONTRIBUTING](CONTRIBUTING.md).
* added `--quiet` (#78)
* added automatic parentheses management (#4)
* added [pre-commit](https://pre-commit.com) integration (#103, #104)
* fixed reporting on `--check` with multiple files (#101, #102)

0 comments on commit cb5aada

Please sign in to comment.
You can’t perform that action at this time.