diff --git a/resources/test/fixtures/F821.py b/resources/test/fixtures/F821.py index 722f463907..4a6b7a288c 100644 --- a/resources/test/fixtures/F821.py +++ b/resources/test/fixtures/F821.py @@ -58,3 +58,10 @@ y: int = 1 x: "Bar" = 1 [first] = ["yup"] + + +from typing import List, TypedDict + + +class Item(TypedDict): + nodes: List[TypedDict("Node", {"id": str})] diff --git a/src/check_ast.rs b/src/check_ast.rs index be4df3f4ef..1c377f1a5b 100644 --- a/src/check_ast.rs +++ b/src/check_ast.rs @@ -559,6 +559,24 @@ where } } } + } else if match_name_or_attr(func, "TypedDict") { + // TypedDict("a", {"a": int}) + if args.len() > 1 { + if let ExprKind::Dict { keys, values } = &args[1].node { + for key in keys { + self.visit_expr(key); + } + for value in values { + self.visit_annotation(value); + } + } + } + + // TypedDict("a", a=int) + for keyword in keywords { + let KeywordData { value, .. } = &keyword.node; + self.visit_annotation(value); + } } else { visitor::walk_expr(self, expr); }