Type alias stub for formatter (#5880)

**Summary** This replaces the `todo!()` with a type alias stub in the
formatter. I added the tests from
704eb40108/parser/src/parser.rs (L901-L936)
as ruff python formatter tests.

**Test Plan** None, testing is part of the actual implementation
This commit is contained in:
konsti 2023-07-19 17:28:07 +02:00 committed by GitHub
parent a51606a10a
commit a227775f62
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 748 additions and 1 deletions

View file

@ -27,6 +27,7 @@ pub(crate) mod stmt_raise;
pub(crate) mod stmt_return;
pub(crate) mod stmt_try;
pub(crate) mod stmt_try_star;
pub(crate) mod stmt_type_alias;
pub(crate) mod stmt_while;
pub(crate) mod stmt_with;
pub(crate) mod suite;
@ -64,7 +65,7 @@ impl FormatRule<Stmt, PyFormatContext<'_>> for FormatStmt {
Stmt::Pass(x) => x.format().fmt(f),
Stmt::Break(x) => x.format().fmt(f),
Stmt::Continue(x) => x.format().fmt(f),
Stmt::TypeAlias(_) => todo!(),
Stmt::TypeAlias(x) => x.format().fmt(f),
}
}
}

View file

@ -0,0 +1,17 @@
use crate::{not_yet_implemented_custom_text, FormatNodeRule, PyFormatter};
use ruff_formatter::{write, Buffer, FormatResult};
use rustpython_parser::ast::StmtTypeAlias;
#[derive(Default)]
pub struct FormatStmtTypeAlias;
impl FormatNodeRule<StmtTypeAlias> for FormatStmtTypeAlias {
fn fmt_fields(&self, _item: &StmtTypeAlias, f: &mut PyFormatter) -> FormatResult<()> {
write!(
f,
[not_yet_implemented_custom_text(
"type NOT_YET_IMPLEMENTED_type_alias = int"
)]
)
}
}