Add support for TypedDict

This commit is contained in:
Charlie Marsh 2022-09-10 13:03:29 -04:00
parent d7f95ac6b6
commit 6a24351202
2 changed files with 25 additions and 0 deletions

View File

@ -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})]

View File

@ -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);
}