Handle name nodes prior to running rules (#5770)

## Summary

This is more consistent with other patterns in the Checker. Shouldn't
change behavior at all.
This commit is contained in:
Charlie Marsh 2023-07-14 22:21:55 -04:00 committed by GitHub
parent 086f8a3c12
commit bf248ede93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -2271,6 +2271,8 @@ where
Expr::Name(ast::ExprName { id, ctx, range: _ }) => { Expr::Name(ast::ExprName { id, ctx, range: _ }) => {
match ctx { match ctx {
ExprContext::Load => { ExprContext::Load => {
self.handle_node_load(expr);
if self.enabled(Rule::TypingTextStrAlias) { if self.enabled(Rule::TypingTextStrAlias) {
pyupgrade::rules::typing_text_str_alias(self, expr); pyupgrade::rules::typing_text_str_alias(self, expr);
} }
@ -2324,10 +2326,10 @@ where
} }
} }
} }
self.handle_node_load(expr);
} }
ExprContext::Store => { ExprContext::Store => {
self.handle_node_store(id, expr);
if self.enabled(Rule::AmbiguousVariableName) { if self.enabled(Rule::AmbiguousVariableName) {
if let Some(diagnostic) = if let Some(diagnostic) =
pycodestyle::rules::ambiguous_variable_name(id, expr.range()) pycodestyle::rules::ambiguous_variable_name(id, expr.range())
@ -2354,8 +2356,6 @@ where
); );
} }
} }
self.handle_node_store(id, expr);
} }
ExprContext::Del => self.handle_node_delete(expr), ExprContext::Del => self.handle_node_delete(expr),
} }