Files
ruff/crates/ruff_python_formatter/src/other/parameter.rs
2023-09-02 10:05:47 +02:00

26 lines
559 B
Rust

use ruff_formatter::write;
use ruff_python_ast::Parameter;
use crate::prelude::*;
#[derive(Default)]
pub struct FormatParameter;
impl FormatNodeRule<Parameter> for FormatParameter {
fn fmt_fields(&self, item: &Parameter, f: &mut PyFormatter) -> FormatResult<()> {
let Parameter {
range: _,
name,
annotation,
} = item;
name.format().fmt(f)?;
if let Some(annotation) = annotation {
write!(f, [token(":"), space(), annotation.format()])?;
}
Ok(())
}
}