mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-02 14:51:25 +00:00
[flake8-bandit
] Fix truthiness: dict-only **
displays not truthy for shell
(S602
, S604
, S609
) (#20177)
## Summary Fixes #19927
This commit is contained in:
parent
cde5e4e343
commit
4c64ba4ee1
7 changed files with 42 additions and 16 deletions
|
@ -1294,15 +1294,14 @@ impl Truthiness {
|
|||
return Self::Falsey;
|
||||
}
|
||||
|
||||
if dict.items.iter().all(|item| {
|
||||
matches!(
|
||||
item,
|
||||
DictItem {
|
||||
key: None,
|
||||
value: Expr::Name(..)
|
||||
}
|
||||
)
|
||||
}) {
|
||||
// If the dict consists only of double-starred items (e.g., {**x, **y}),
|
||||
// consider its truthiness unknown. This matches lists/sets/tuples containing
|
||||
// only starred elements, which are also Unknown.
|
||||
if dict
|
||||
.items
|
||||
.iter()
|
||||
.all(|item| matches!(item, DictItem { key: None, .. }))
|
||||
{
|
||||
// {**foo} / {**foo, **bar}
|
||||
Self::Unknown
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue