diff --git a/README.md b/README.md index 8cccc5005f..8326a718ed 100644 --- a/README.md +++ b/README.md @@ -558,7 +558,6 @@ For more, see [Pyflakes](https://pypi.org/project/pyflakes/2.5.0/) on PyPI. | F821 | UndefinedName | Undefined name `...` | | | F822 | UndefinedExport | Undefined name `...` in `__all__` | | | F823 | UndefinedLocal | Local variable `...` referenced before assignment | | -| F831 | DuplicateArgumentName | Duplicate argument name in function definition | | | F841 | UnusedVariable | Local variable `...` is assigned to but never used | | | F842 | UnusedAnnotation | Local variable `...` is annotated but never used | | | F901 | RaiseNotImplemented | `raise NotImplemented` should be `raise NotImplementedError` | 🛠 | diff --git a/resources/test/fixtures/pyflakes/F831.py b/resources/test/fixtures/pyflakes/F831.py deleted file mode 100644 index b866b4938f..0000000000 --- a/resources/test/fixtures/pyflakes/F831.py +++ /dev/null @@ -1,10 +0,0 @@ -def foo(x: int, y: int, x: int) -> None: - pass - - -def bar(x: int, y: int, *, x: int) -> None: - pass - - -def baz(x: int, y: int, **x: int) -> None: - pass diff --git a/ruff.schema.json b/ruff.schema.json index 5fb13c8fae..78bf843ee2 100644 --- a/ruff.schema.json +++ b/ruff.schema.json @@ -652,8 +652,6 @@ "F821", "F822", "F823", - "F83", - "F831", "F84", "F841", "F842", diff --git a/src/checkers/ast.rs b/src/checkers/ast.rs index 91ddb7901c..5caf083727 100644 --- a/src/checkers/ast.rs +++ b/src/checkers/ast.rs @@ -2767,10 +2767,6 @@ where } fn visit_arguments(&mut self, arguments: &'b Arguments) { - if self.settings.enabled.contains(&CheckCode::F831) { - self.checks - .extend(pyflakes::checks::duplicate_arguments(arguments)); - } if self.settings.enabled.contains(&CheckCode::B006) { flake8_bugbear::plugins::mutable_argument_default(self, arguments); } diff --git a/src/checks.rs b/src/checks.rs index 6e3f1faef1..64bf99fe1a 100644 --- a/src/checks.rs +++ b/src/checks.rs @@ -92,7 +92,6 @@ pub enum CheckCode { F821, F822, F823, - F831, F841, F842, F901, @@ -730,7 +729,6 @@ pub enum CheckKind { BreakOutsideLoop, ContinueOutsideLoop, DefaultExceptNotLast, - DuplicateArgumentName, ExpressionsInStarAssignment, FStringMissingPlaceholders, ForwardAnnotationSyntaxError(String), @@ -1134,7 +1132,6 @@ impl CheckCode { CheckCode::F821 => CheckKind::UndefinedName("...".to_string()), CheckCode::F822 => CheckKind::UndefinedExport("...".to_string()), CheckCode::F823 => CheckKind::UndefinedLocal("...".to_string()), - CheckCode::F831 => CheckKind::DuplicateArgumentName, CheckCode::F841 => CheckKind::UnusedVariable("...".to_string()), CheckCode::F842 => CheckKind::UnusedAnnotation("...".to_string()), CheckCode::F901 => CheckKind::RaiseNotImplemented, @@ -1631,7 +1628,6 @@ impl CheckCode { CheckCode::F821 => CheckCategory::Pyflakes, CheckCode::F822 => CheckCategory::Pyflakes, CheckCode::F823 => CheckCategory::Pyflakes, - CheckCode::F831 => CheckCategory::Pyflakes, CheckCode::F841 => CheckCategory::Pyflakes, CheckCode::F842 => CheckCategory::Pyflakes, CheckCode::F901 => CheckCategory::Pyflakes, @@ -1768,7 +1764,6 @@ impl CheckKind { CheckKind::DefaultExceptNotLast => &CheckCode::F707, CheckKind::DoNotAssignLambda(..) => &CheckCode::E731, CheckKind::DoNotUseBareExcept => &CheckCode::E722, - CheckKind::DuplicateArgumentName => &CheckCode::F831, CheckKind::FStringMissingPlaceholders => &CheckCode::F541, CheckKind::ForwardAnnotationSyntaxError(..) => &CheckCode::F722, CheckKind::FutureFeatureNotDefined(..) => &CheckCode::F407, @@ -2114,9 +2109,6 @@ impl CheckKind { "Do not assign a `lambda` expression, use a `def`".to_string() } CheckKind::DoNotUseBareExcept => "Do not use bare `except`".to_string(), - CheckKind::DuplicateArgumentName => { - "Duplicate argument name in function definition".to_string() - } CheckKind::ForwardAnnotationSyntaxError(body) => { format!("Syntax error in forward annotation: `{body}`") } diff --git a/src/checks_gen.rs b/src/checks_gen.rs index 86e2d49641..87150b7bd7 100644 --- a/src/checks_gen.rs +++ b/src/checks_gen.rs @@ -283,8 +283,6 @@ pub enum CheckCodePrefix { F821, F822, F823, - F83, - F831, F84, F841, F842, @@ -647,7 +645,6 @@ impl CheckCodePrefix { CheckCode::F821, CheckCode::F822, CheckCode::F823, - CheckCode::F831, CheckCode::F841, CheckCode::F842, CheckCode::F901, @@ -1506,7 +1503,6 @@ impl CheckCodePrefix { CheckCode::F821, CheckCode::F822, CheckCode::F823, - CheckCode::F831, CheckCode::F841, CheckCode::F842, CheckCode::F901, @@ -1640,7 +1636,6 @@ impl CheckCodePrefix { CheckCode::F821, CheckCode::F822, CheckCode::F823, - CheckCode::F831, CheckCode::F841, CheckCode::F842, ], @@ -1650,8 +1645,6 @@ impl CheckCodePrefix { CheckCodePrefix::F821 => vec![CheckCode::F821], CheckCodePrefix::F822 => vec![CheckCode::F822], CheckCodePrefix::F823 => vec![CheckCode::F823], - CheckCodePrefix::F83 => vec![CheckCode::F831], - CheckCodePrefix::F831 => vec![CheckCode::F831], CheckCodePrefix::F84 => vec![CheckCode::F841, CheckCode::F842], CheckCodePrefix::F841 => vec![CheckCode::F841], CheckCodePrefix::F842 => vec![CheckCode::F842], @@ -3102,8 +3095,6 @@ impl CheckCodePrefix { CheckCodePrefix::F821 => SuffixLength::Three, CheckCodePrefix::F822 => SuffixLength::Three, CheckCodePrefix::F823 => SuffixLength::Three, - CheckCodePrefix::F83 => SuffixLength::Two, - CheckCodePrefix::F831 => SuffixLength::Three, CheckCodePrefix::F84 => SuffixLength::Two, CheckCodePrefix::F841 => SuffixLength::Three, CheckCodePrefix::F842 => SuffixLength::Three, diff --git a/src/pyflakes/checks.rs b/src/pyflakes/checks.rs index 290b27e7eb..c0f5b9481c 100644 --- a/src/pyflakes/checks.rs +++ b/src/pyflakes/checks.rs @@ -1,9 +1,8 @@ use std::string::ToString; use regex::Regex; -use rustc_hash::FxHashSet; use rustpython_parser::ast::{ - Arg, Arguments, Constant, Excepthandler, ExcepthandlerKind, Expr, ExprKind, Stmt, StmtKind, + Constant, Excepthandler, ExcepthandlerKind, Expr, ExprKind, Stmt, StmtKind, }; use crate::ast::types::{Binding, BindingKind, Range, Scope, ScopeKind}; @@ -125,40 +124,6 @@ pub fn default_except_not_last(handlers: &[Excepthandler]) -> Option { None } -/// F831 -pub fn duplicate_arguments(arguments: &Arguments) -> Vec { - let mut checks: Vec = vec![]; - - // Collect all the arguments into a single vector. - let mut all_arguments: Vec<&Arg> = arguments - .args - .iter() - .chain(arguments.posonlyargs.iter()) - .chain(arguments.kwonlyargs.iter()) - .collect(); - if let Some(arg) = &arguments.vararg { - all_arguments.push(arg); - } - if let Some(arg) = &arguments.kwarg { - all_arguments.push(arg); - } - - // Search for duplicates. - let mut idents: FxHashSet<&str> = FxHashSet::default(); - for arg in all_arguments { - let ident = &arg.node.arg; - if idents.contains(ident.as_str()) { - checks.push(Check::new( - CheckKind::DuplicateArgumentName, - Range::from_located(arg), - )); - } - idents.insert(ident); - } - - checks -} - #[derive(Debug, PartialEq)] enum DictionaryKey<'a> { Constant(&'a Constant), diff --git a/src/pyflakes/mod.rs b/src/pyflakes/mod.rs index b175d9af03..881e49f789 100644 --- a/src/pyflakes/mod.rs +++ b/src/pyflakes/mod.rs @@ -100,7 +100,6 @@ mod tests { #[test_case(CheckCode::F821, Path::new("F821_7.py"); "F821_7")] #[test_case(CheckCode::F822, Path::new("F822.py"); "F822")] #[test_case(CheckCode::F823, Path::new("F823.py"); "F823")] - #[test_case(CheckCode::F831, Path::new("F831.py"); "F831")] #[test_case(CheckCode::F841, Path::new("F841_0.py"); "F841_0")] #[test_case(CheckCode::F841, Path::new("F841_1.py"); "F841_1")] #[test_case(CheckCode::F842, Path::new("F842.py"); "F842")]