mirror of https://github.com/astral-sh/ruff
[`ruff`] Fix false positives on starred arguments (`RUF057`) (#21256)
## Summary Fixes https://github.com/astral-sh/ruff/issues/21209 ## Test Plan `cargo nextest run ruf057`
This commit is contained in:
parent
5c69e00d1c
commit
cef6600cf3
|
|
@ -81,3 +81,7 @@ round(# a comment
|
|||
round(
|
||||
17 # a comment
|
||||
)
|
||||
|
||||
# See: https://github.com/astral-sh/ruff/issues/21209
|
||||
print(round(125, **{"ndigits": -2}))
|
||||
print(round(125, *[-2]))
|
||||
|
|
@ -143,6 +143,15 @@ pub(super) fn rounded_and_ndigits<'a>(
|
|||
return None;
|
||||
}
|
||||
|
||||
// *args
|
||||
if arguments.args.iter().any(Expr::is_starred_expr) {
|
||||
return None;
|
||||
}
|
||||
// **kwargs
|
||||
if arguments.keywords.iter().any(|kw| kw.arg.is_none()) {
|
||||
return None;
|
||||
}
|
||||
|
||||
let rounded = arguments.find_argument_value("number", 0)?;
|
||||
let ndigits = arguments.find_argument_value("ndigits", 1);
|
||||
|
||||
|
|
|
|||
|
|
@ -253,6 +253,8 @@ RUF057 [*] Value being rounded is already an integer
|
|||
82 | | 17 # a comment
|
||||
83 | | )
|
||||
| |_^
|
||||
84 |
|
||||
85 | # See: https://github.com/astral-sh/ruff/issues/21209
|
||||
|
|
||||
help: Remove unnecessary `round` call
|
||||
78 | round(# a comment
|
||||
|
|
@ -262,4 +264,7 @@ help: Remove unnecessary `round` call
|
|||
- 17 # a comment
|
||||
- )
|
||||
81 + 17
|
||||
82 |
|
||||
83 | # See: https://github.com/astral-sh/ruff/issues/21209
|
||||
84 | print(round(125, **{"ndigits": -2}))
|
||||
note: This is an unsafe fix and may change runtime behavior
|
||||
|
|
|
|||
Loading…
Reference in New Issue