mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 12:29:28 +00:00

## Summary This PR renames... - `Parameter#arg` to `Parameter#name` - `ParameterWithDefault#def` to `ParameterWithDefault#parameter` (such that `ParameterWithDefault` has a `default` and a `parameter`) ## Test Plan `cargo test`
25 lines
584 B
Rust
25 lines
584 B
Rust
use crate::prelude::*;
|
|
use crate::FormatNodeRule;
|
|
use ruff_formatter::write;
|
|
use ruff_python_ast::Parameter;
|
|
|
|
#[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, [text(":"), space(), annotation.format()])?;
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
}
|