Format Function definitions (#4951)

This commit is contained in:
Micha Reiser 2023-06-08 18:07:33 +02:00 committed by GitHub
parent 07cc4bcb0f
commit 68969240c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
79 changed files with 2601 additions and 1223 deletions

View file

@ -188,7 +188,7 @@ mod tests {
use crate::comments::Comments;
use crate::prelude::*;
use crate::statement::suite::SuiteLevel;
use ruff_formatter::{format, SimpleFormatOptions};
use ruff_formatter::{format, IndentStyle, SimpleFormatOptions};
use rustpython_parser::ast::Suite;
use rustpython_parser::Parse;
@ -216,8 +216,14 @@ def trailing_func():
let statements = Suite::parse(source, "test.py").unwrap();
let context =
PyFormatContext::new(SimpleFormatOptions::default(), source, Comments::default());
let context = PyFormatContext::new(
SimpleFormatOptions {
indent_style: IndentStyle::Space(4),
..SimpleFormatOptions::default()
},
source,
Comments::default(),
);
let test_formatter =
format_with(|f: &mut PyFormatter| statements.format().with_options(level).fmt(f));
@ -252,10 +258,13 @@ NOT_YET_IMPLEMENTED_StmtClassDef
trailing_statement = 1
NOT_YET_IMPLEMENTED_StmtFunctionDef
def func():
pass
NOT_YET_IMPLEMENTED_StmtFunctionDef"#
def trailing_func():
pass
"#
);
}
@ -278,9 +287,12 @@ NOT_YET_IMPLEMENTED_StmtClassDef
trailing_statement = 1
NOT_YET_IMPLEMENTED_StmtFunctionDef
def func():
pass
NOT_YET_IMPLEMENTED_StmtFunctionDef"#
def trailing_func():
pass
"#
);
}
}