mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-24 12:24:17 +00:00
Add support for PEP 696 syntax (#11120)
This commit is contained in:
parent
45725d3275
commit
cd3e319538
49 changed files with 4338 additions and 669 deletions
|
@ -8,7 +8,15 @@ pub struct FormatTypeParamParamSpec;
|
|||
|
||||
impl FormatNodeRule<TypeParamParamSpec> for FormatTypeParamParamSpec {
|
||||
fn fmt_fields(&self, item: &TypeParamParamSpec, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
let TypeParamParamSpec { range: _, name } = item;
|
||||
write!(f, [token("**"), name.format()])
|
||||
let TypeParamParamSpec {
|
||||
range: _,
|
||||
name,
|
||||
default,
|
||||
} = item;
|
||||
write!(f, [token("**"), name.format()])?;
|
||||
if let Some(default) = default {
|
||||
write!(f, [space(), token("="), space(), default.format()])?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,11 +12,15 @@ impl FormatNodeRule<TypeParamTypeVar> for FormatTypeParamTypeVar {
|
|||
range: _,
|
||||
name,
|
||||
bound,
|
||||
default,
|
||||
} = item;
|
||||
name.format().fmt(f)?;
|
||||
if let Some(bound) = bound {
|
||||
write!(f, [token(":"), space(), bound.format()])?;
|
||||
}
|
||||
if let Some(default) = default {
|
||||
write!(f, [space(), token("="), space(), default.format()])?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,15 @@ pub struct FormatTypeParamTypeVarTuple;
|
|||
|
||||
impl FormatNodeRule<TypeParamTypeVarTuple> for FormatTypeParamTypeVarTuple {
|
||||
fn fmt_fields(&self, item: &TypeParamTypeVarTuple, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
let TypeParamTypeVarTuple { range: _, name } = item;
|
||||
write!(f, [token("*"), name.format()])
|
||||
let TypeParamTypeVarTuple {
|
||||
range: _,
|
||||
name,
|
||||
default,
|
||||
} = item;
|
||||
write!(f, [token("*"), name.format()])?;
|
||||
if let Some(default) = default {
|
||||
write!(f, [space(), token("="), space(), default.format()])?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue