Skip to content

Commit

Permalink
Visit TypeVar and NewType name arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed May 24, 2023
1 parent 3644695 commit f657d30
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions crates/ruff/src/checkers/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4061,12 +4061,18 @@ where
}
Some(Callable::NewType) => {
self.visit_expr(func);
if !args.is_empty() {
self.visit_non_type_definition(&args[0]);
}
for expr in args.iter().skip(1) {
self.visit_type_definition(expr);
}
}
Some(Callable::TypeVar) => {
self.visit_expr(func);
if !args.is_empty() {
self.visit_non_type_definition(&args[0]);
}
for expr in args.iter().skip(1) {
self.visit_type_definition(expr);
}
Expand All @@ -4089,6 +4095,9 @@ where
self.visit_expr(func);

// Ex) NamedTuple("a", [("a", int)])
if !args.is_empty() {
self.visit_non_type_definition(&args[0]);
}
if args.len() > 1 {
match &args[1] {
Expr::List(ast::ExprList { elts, .. })
Expand Down Expand Up @@ -4120,6 +4129,9 @@ where
self.visit_expr(func);

// Ex) TypedDict("a", {"a": int})
if !args.is_empty() {
self.visit_non_type_definition(&args[0]);
}
if args.len() > 1 {
if let Expr::Dict(ast::ExprDict {
keys,
Expand Down

0 comments on commit f657d30

Please sign in to comment.