Skip to content

Commit a9b58e1

Browse files
committed
[pyupgrade] remove unecessary Expr::Attribute match
Remove the `Expr::Attribute` matching for the second parameter in `super`. The UP008 does not care when it's an Attribute, the only cases are: - super(MyClass, self) - super(OuterClass.InnerClass, self) Which is always an `Expr::Name`
1 parent ff11db4 commit a9b58e1

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

crates/ruff_linter/src/rules/pyupgrade/rules/super_call_with_parameters.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,18 @@ pub(crate) fn super_call_with_parameters(checker: &Checker, call: &ast::ExprCall
128128
};
129129

130130
let first_arg_id = match first_arg {
131+
// Simple case: super(MyClass, self)
131132
Expr::Name(ast::ExprName { id, .. }) => id,
133+
// Nested class case: super(OuterClass.InnerClass, self)
132134
Expr::Attribute(ast::ExprAttribute { attr, .. }) => &attr.id,
133135
_ => return,
134136
};
135137

136-
let second_arg_id = match second_arg {
137-
Expr::Name(ast::ExprName { id, .. }) => id,
138-
Expr::Attribute(ast::ExprAttribute { attr, .. }) => &attr.id,
139-
_ => return,
138+
let Expr::Name(ast::ExprName {
139+
id: second_arg_id, ..
140+
}) = second_arg
141+
else {
142+
return;
140143
};
141144

142145
// The `super(__class__, self)` and `super(ParentClass, self)` patterns are redundant in Python 3

0 commit comments

Comments
 (0)