Fix StmtAnnAssign formatting by mirroring StmtAssign (#5732)

## Summary

`StmtAnnAssign` would not insert parentheses when breaking the same way
`StmtAssign` does, causing unstable formatting and likely some syntax
errors.

## Test Plan

I added a regression test.
This commit is contained in:
konsti 2023-07-13 12:51:25 +02:00 committed by GitHub
parent b1781abffb
commit 549173b395
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 69 additions and 15 deletions

View file

@ -1,5 +1,7 @@
tree_depth += 1
# Regression test: Don't forget the parentheses in the value when breaking
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: int = a + 1 * a
greeting += "This is very long, formal greeting for whomever is name here. Dear %s, it will break the line" % len(
name
)
# Regression test: Don't forget the parentheses in the annotation when breaking
class DefaultRunner:
task_runner_cls: TaskRunnerProtocol | typing.Callable[[], typing.Any] = DefaultTaskRunner

View file

@ -0,0 +1,5 @@
tree_depth += 1
greeting += "This is very long, formal greeting for whomever is name here. Dear %s, it will break the line" % len(
name
)