Skip to content

Commit

Permalink
Merge branch 'main' into emptyline
Browse files Browse the repository at this point in the history
  • Loading branch information
yilei authored Oct 16, 2022
2 parents 3c71bd6 + 575220f commit 36ae752
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Multiple contributions by:
- [Alex Vandiver](mailto:[email protected])
- [Allan Simon](mailto:[email protected])
- Anders-Petter Ljungquist
- [Amethyst Reese](mailto:[email protected])
- [Andrew Thorp](mailto:[email protected])
- [Andrew Zhou](mailto:[email protected])
- [Andrey](mailto:[email protected])
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@

<!-- Changes to the parser or to version autodetection -->

- Parsing support has been added for walruses inside generator expression that are
passed as function args (for example,
`any(match := my_re.match(text) for text in texts)`) (#3327).

### Performance

<!-- Changes that improve Black's performance. -->
Expand Down
4 changes: 3 additions & 1 deletion docs/integrations/github_actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ extra. Installing the extra and including Jupyter Notebook files can be configur
`jupyter` (default is `false`).

You can also configure the arguments passed to _Black_ via `options` (defaults to
`'--check --diff'`) and `src` (default is `'.'`)
`'--check --diff'`) and `src` (default is `'.'`). Please note that the
[`--check` flag](labels/exit-code) is required so that the workflow fails if _Black_
finds files that need to be formatted.

Here's an example configuration:

Expand Down
2 changes: 2 additions & 0 deletions docs/usage_and_configuration/the_basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ _Black_ to just tell you what it _would_ do without actually rewriting the Pytho
There's two variations to this mode that are independently enabled by their respective
flags. Both variations can be enabled at once.

(labels/exit-code)=

#### Exit code

Passing `--check` will make _Black_ exit with:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ build-backend = "hatchling.build"
[project]
name = "black"
description = "The uncompromising code formatter."
license = "MIT"
license = { text = "MIT" }
requires-python = ">=3.7"
authors = [
{ name = "Łukasz Langa", email = "[email protected]" },
Expand Down
2 changes: 0 additions & 2 deletions src/black/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ def parse_single_version(
# comments separately.
return ast3.parse(src, filename, feature_version=version[1])

raise AssertionError("INTERNAL ERROR: Tried parsing unsupported Python version!")


def parse_ast(src: str) -> Union[ast.AST, ast3.AST]:
# TODO: support Python 4+ ;)
Expand Down
2 changes: 1 addition & 1 deletion src/blib2to3/Grammar.txt
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ arglist: argument (',' argument)* [',']
# multiple (test comp_for) arguments are blocked; keyword unpackings
# that precede iterable unpackings are blocked; etc.
argument: ( test [comp_for] |
test ':=' test |
test ':=' test [comp_for] |
test 'as' test |
test '=' asexpr_test |
'**' test |
Expand Down
11 changes: 11 additions & 0 deletions tests/data/py_310/pep_572_py310.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,14 @@
x[a:=0]
x[a:=0, b:=1]
x[5, b:=0]

# Walruses are allowed inside generator expressions on function calls since 3.10.
if any(match := pattern_error.match(s) for s in buffer):
if match.group(2) == data_not_available:
# Error OK to ignore.
pass

f(a := b + c for c in range(10))
f((a := b + c for c in range(10)), x)
f(y=(a := b + c for c in range(10)))
f(x, (a := b + c for c in range(10)), y=z, **q)

0 comments on commit 36ae752

Please sign in to comment.