Skip to content

Commit

Permalink
HashSet
Browse files Browse the repository at this point in the history
  • Loading branch information
Tester authored and Tester committed Nov 3, 2023
1 parent 4425b78 commit 54387be
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::collections::HashSet;

use itertools::Itertools;
use ruff_diagnostics::{AlwaysFixableViolation, Diagnostic, Edit, Fix};
use ruff_python_ast::{self as ast, Expr, Keyword};
Expand Down Expand Up @@ -53,12 +55,12 @@ impl AlwaysFixableViolation for UnnecessaryDictKwargs {

/// PIE804
pub(crate) fn unnecessary_dict_kwargs(checker: &mut Checker, expr: &Expr, kwargs: &[Keyword]) {
let mut all_kwargs = Vec::new();
let mut all_kwargs = HashSet::new();

for kw in kwargs {
// keyword is a spread operator (indicated by None)
if let Some(name) = &kw.arg {
all_kwargs.push(name.as_str());
all_kwargs.insert(name.as_str());
continue;
}

Expand Down Expand Up @@ -88,7 +90,7 @@ pub(crate) fn unnecessary_dict_kwargs(checker: &mut Checker, expr: &Expr, kwargs
if all_kwargs.contains(name) {
false
} else {
all_kwargs.push(name);
all_kwargs.insert(name);
true
}
})
Expand Down

0 comments on commit 54387be

Please sign in to comment.