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

@ -361,6 +361,46 @@ impl<'ast> IntoFormat<PyFormatContext<'ast>> for ast::StmtDelete {
}
}
impl FormatRule<ast::StmtTypeAlias, PyFormatContext<'_>>
for crate::statement::stmt_type_alias::FormatStmtTypeAlias
{
#[inline]
fn fmt(
&self,
node: &ast::StmtTypeAlias,
f: &mut Formatter<PyFormatContext<'_>>,
) -> FormatResult<()> {
FormatNodeRule::<ast::StmtTypeAlias>::fmt(self, node, f)
}
}
impl<'ast> AsFormat<PyFormatContext<'ast>> for ast::StmtTypeAlias {
type Format<'a> = FormatRefWithRule<
'a,
ast::StmtTypeAlias,
crate::statement::stmt_type_alias::FormatStmtTypeAlias,
PyFormatContext<'ast>,
>;
fn format(&self) -> Self::Format<'_> {
FormatRefWithRule::new(
self,
crate::statement::stmt_type_alias::FormatStmtTypeAlias::default(),
)
}
}
impl<'ast> IntoFormat<PyFormatContext<'ast>> for ast::StmtTypeAlias {
type Format = FormatOwnedWithRule<
ast::StmtTypeAlias,
crate::statement::stmt_type_alias::FormatStmtTypeAlias,
PyFormatContext<'ast>,
>;
fn into_format(self) -> Self::Format {
FormatOwnedWithRule::new(
self,
crate::statement::stmt_type_alias::FormatStmtTypeAlias::default(),
)
}
}
impl FormatRule<ast::StmtAssign, PyFormatContext<'_>>
for crate::statement::stmt_assign::FormatStmtAssign
{