Skip to content

Commit

Permalink
Avoid unused argument violations in .pyi files (#3533)
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Mar 15, 2023
1 parent 12dfd57 commit e636c5f
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions crates/ruff/src/checkers/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4685,31 +4685,37 @@ impl<'a> Checker<'a> {
while let Some((scopes, ..)) = self.deferred.assignments.pop() {
let scope_index = scopes[scopes.len() - 1];
let parent_scope_index = scopes[scopes.len() - 2];

// pyflakes
if self.settings.rules.enabled(&Rule::UnusedVariable) {
pyflakes::rules::unused_variable(self, scope_index);
}
if self.settings.rules.enabled(&Rule::UnusedAnnotation) {
pyflakes::rules::unused_annotation(self, scope_index);
}
if self.settings.rules.enabled(&Rule::UnusedFunctionArgument)
|| self.settings.rules.enabled(&Rule::UnusedMethodArgument)
|| self
.settings
.rules
.enabled(&Rule::UnusedClassMethodArgument)
|| self
.settings
.rules
.enabled(&Rule::UnusedStaticMethodArgument)
|| self.settings.rules.enabled(&Rule::UnusedLambdaArgument)
{
self.diagnostics
.extend(flake8_unused_arguments::rules::unused_arguments(
self,
&self.ctx.scopes[parent_scope_index],
&self.ctx.scopes[scope_index],
&self.ctx.bindings,
));

if !self.is_stub {
// flake8-unused-arguments
if self.settings.rules.enabled(&Rule::UnusedFunctionArgument)
|| self.settings.rules.enabled(&Rule::UnusedMethodArgument)
|| self
.settings
.rules
.enabled(&Rule::UnusedClassMethodArgument)
|| self
.settings
.rules
.enabled(&Rule::UnusedStaticMethodArgument)
|| self.settings.rules.enabled(&Rule::UnusedLambdaArgument)
{
self.diagnostics
.extend(flake8_unused_arguments::rules::unused_arguments(
self,
&self.ctx.scopes[parent_scope_index],
&self.ctx.scopes[scope_index],
&self.ctx.bindings,
));
}
}
}
}
Expand Down

0 comments on commit e636c5f

Please sign in to comment.