mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-26 20:09:22 +00:00
26 lines
582 B
Rust
26 lines
582 B
Rust
use crate::prelude::*;
|
|
use crate::FormatNodeRule;
|
|
use ruff_formatter::write;
|
|
use rustpython_parser::ast::Arg;
|
|
|
|
#[derive(Default)]
|
|
pub struct FormatArg;
|
|
|
|
impl FormatNodeRule<Arg> for FormatArg {
|
|
fn fmt_fields(&self, item: &Arg, f: &mut PyFormatter) -> FormatResult<()> {
|
|
let Arg {
|
|
range: _,
|
|
arg,
|
|
annotation,
|
|
type_comment: _,
|
|
} = item;
|
|
|
|
arg.format().fmt(f)?;
|
|
|
|
if let Some(annotation) = annotation {
|
|
write!(f, [text(":"), space(), annotation.format()])?;
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
}
|