mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-17 00:50:33 +00:00
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:
parent
a51606a10a
commit
a227775f62
21 changed files with 748 additions and 1 deletions
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue