A basic StmtAssign formatter and better dummies for expressions (#4938)

* A basic StmtAssign formatter and better dummies for expressions

The goal of this PR was formatting StmtAssign since many nodes in the black tests (and in python in general) are after an assignment. This caused unstable formatting: The spacing of power op spacing depends on the type of the two involved expressions, but each expression was formatted as dummy string and re-parsed as a ExprName, so in the second round the different rules of ExprName were applied, causing unstable formatting.

This PR does not necessarily bring us closer to black's style, but it unlocks a good porting of black's test suite and is a basis for implementing the Expr nodes.

* fmt

* Review
This commit is contained in:
konstin 2023-06-08 12:20:25 +02:00 committed by GitHub
parent 651d89794c
commit 23abad0bd5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
62 changed files with 1291 additions and 1023 deletions

View file

@ -234,22 +234,22 @@ def trailing_func():
assert_eq!(
formatted,
r#"NOT_YET_IMPLEMENTED_StmtAssign
r#"a = 0x42
NOT_YET_IMPLEMENTED_StmtAssign
three_leading_newlines = 0x42
NOT_YET_IMPLEMENTED_StmtAssign
two_leading_newlines = 0x42
NOT_YET_IMPLEMENTED_StmtAssign
NOT_YET_IMPLEMENTED_StmtAssign
one_leading_newline = 0x42
no_leading_newline = 0x42
NOT_YET_IMPLEMENTED_StmtClassDef
NOT_YET_IMPLEMENTED_StmtAssign
trailing_statement = 0x42
NOT_YET_IMPLEMENTED_StmtFunctionDef
@ -265,18 +265,18 @@ NOT_YET_IMPLEMENTED_StmtFunctionDef"#
assert_eq!(
formatted,
r#"NOT_YET_IMPLEMENTED_StmtAssign
r#"a = 0x42
NOT_YET_IMPLEMENTED_StmtAssign
three_leading_newlines = 0x42
NOT_YET_IMPLEMENTED_StmtAssign
two_leading_newlines = 0x42
NOT_YET_IMPLEMENTED_StmtAssign
NOT_YET_IMPLEMENTED_StmtAssign
one_leading_newline = 0x42
no_leading_newline = 0x42
NOT_YET_IMPLEMENTED_StmtClassDef
NOT_YET_IMPLEMENTED_StmtAssign
trailing_statement = 0x42
NOT_YET_IMPLEMENTED_StmtFunctionDef