-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Format
target: annotation = value?
expressions
- Loading branch information
1 parent
9cc7c21
commit d03c0b6
Showing
28 changed files
with
315 additions
and
981 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
...rmatter/resources/test/fixtures/black/simple_cases/skip_magic_trailing_comma.options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"magic_trailing_comma": "ignore" | ||
} |
13 changes: 13 additions & 0 deletions
13
crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/annotated_assign.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
a: string | ||
|
||
b: string = "test" | ||
|
||
b: list[ | ||
string, | ||
int | ||
] = [1, 2] | ||
|
||
b: list[ | ||
string, | ||
int, | ||
] = [1, 2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 21 additions & 3 deletions
24
crates/ruff_python_formatter/src/statement/stmt_ann_assign.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,30 @@ | ||
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter}; | ||
use ruff_formatter::{write, Buffer, FormatResult}; | ||
use crate::prelude::*; | ||
use crate::FormatNodeRule; | ||
use ruff_formatter::write; | ||
use rustpython_parser::ast::StmtAnnAssign; | ||
|
||
#[derive(Default)] | ||
pub struct FormatStmtAnnAssign; | ||
|
||
impl FormatNodeRule<StmtAnnAssign> for FormatStmtAnnAssign { | ||
fn fmt_fields(&self, item: &StmtAnnAssign, f: &mut PyFormatter) -> FormatResult<()> { | ||
write!(f, [not_yet_implemented(item)]) | ||
let StmtAnnAssign { | ||
range: _, | ||
target, | ||
annotation, | ||
value, | ||
simple: _, | ||
} = item; | ||
|
||
write!( | ||
f, | ||
[target.format(), text(":"), space(), annotation.format()] | ||
)?; | ||
|
||
if let Some(value) = value { | ||
write!(f, [space(), text("="), space(), value.format()])?; | ||
} | ||
|
||
Ok(()) | ||
} | ||
} |
Oops, something went wrong.