mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-23 21:15:19 +00:00
Fix a number of formatter errors from the cpython repository (#5089)
## Summary This fixes a number of problems in the formatter that showed up with various files in the [cpython](https://github.com/python/cpython) repository. These problems surfaced as unstable formatting and invalid code. This is not the entirety of problems discovered through cpython, but a big enough chunk to separate it. Individual fixes are generally individual commits. They were discovered with #5055, which i update as i work through the output ## Test Plan I added regression tests with links to cpython for each entry, except for the two stubs that also got comment stubs since they'll be implemented properly later.
This commit is contained in:
parent
097823b56d
commit
66089e1a2e
25 changed files with 234 additions and 23 deletions
|
@ -58,6 +58,9 @@ impl FormatNodeRule<Arguments> for FormatArguments {
|
|||
last_node = Some(default.map_or_else(|| argument.into(), AnyNodeRef::from));
|
||||
}
|
||||
|
||||
// kw only args need either a `*args` ahead of them capturing all var args or a `*`
|
||||
// pseudo-argument capturing all fields. We can also have `*args` without any kwargs
|
||||
// afterwards.
|
||||
if let Some(vararg) = vararg {
|
||||
joiner.entry(&format_args![
|
||||
leading_node_comments(vararg.as_ref()),
|
||||
|
@ -65,6 +68,8 @@ impl FormatNodeRule<Arguments> for FormatArguments {
|
|||
vararg.format()
|
||||
]);
|
||||
last_node = Some(vararg.as_any_node_ref());
|
||||
} else if !kwonlyargs.is_empty() {
|
||||
joiner.entry(&text("*"));
|
||||
}
|
||||
|
||||
debug_assert!(defaults.next().is_none());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue