mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 05:25:17 +00:00
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:
parent
651d89794c
commit
23abad0bd5
62 changed files with 1291 additions and 1023 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue