Skip to content

Commit 5d9752c

Browse files
committed
[ty] Clarify recursive TypedDict identity comment
1 parent 5e990b5 commit 5d9752c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎crates/ty_python_semantic/src/types/cyclic.rs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ impl<'db> Type<'db> {
8080
Type::TypedDict(TypedDictType::Class(a)),
8181
Type::TypedDict(TypedDictType::Class(b)),
8282
) => {
83-
// Only a static class can have a GrowingTypedDict identity. Its body scope
84-
// identifies the definition even if decorators changed the class metadata.
83+
// Different specializations of the same recursive TypedDict can form a cycle.
84+
// Each class statement has a unique body scope, so comparing scopes tells us
85+
// whether the types came from the same class, even after decorators.
86+
// Other TypedDicts can only match by exact equality, which we checked above.
8587
matches!(
8688
(a.class_literal(db).as_static(), b.class_literal(db).as_static()),
8789
(Some(a), Some(b)) if a.body_scope(db) == b.body_scope(db)

0 commit comments

Comments
 (0)