Skip to content

Commit b3a102e

Browse files
anderskhauntsaninja
authored andcommitted
Fix RawExpressionType.accept crash with --cache-fine-grained (#17588)
Commit 1072c78 (#17148) converted all quoted types into `RawExpressionType`, which raised an `AssertionError` when `accept`ing a `TypeTriggersVisitor`. - Fixes #17574. - Fixes #17587. Signed-off-by: Anders Kaseorg <[email protected]>
1 parent aec04c7 commit b3a102e

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

mypy/types.py

+2
Original file line numberDiff line numberDiff line change
@@ -2703,6 +2703,8 @@ def simple_name(self) -> str:
27032703
return self.base_type_name.replace("builtins.", "")
27042704

27052705
def accept(self, visitor: TypeVisitor[T]) -> T:
2706+
if self.node is not None:
2707+
return self.node.accept(visitor)
27062708
assert isinstance(visitor, SyntheticTypeVisitor)
27072709
ret: T = visitor.visit_raw_expression_type(self)
27082710
return ret

test-data/unit/check-typeddict.test

+12
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,18 @@ reveal_type(x) # N: Revealed type is "TypedDict('__main__.X', {'a': TypedDict('_
14421442
reveal_type(x['a']['b']) # N: Revealed type is "builtins.int"
14431443
[builtins fixtures/dict.pyi]
14441444

1445+
[case testTypedDictForwardReferenceCacheFineGrained]
1446+
# flags: --cache-fine-grained
1447+
from mypy_extensions import TypedDict
1448+
class A(TypedDict):
1449+
b: "B"
1450+
class B(TypedDict):
1451+
c: "C"
1452+
class C(TypedDict):
1453+
d: "D"
1454+
class D:
1455+
pass
1456+
14451457
[case testSelfRecursiveTypedDictInheriting]
14461458
from mypy_extensions import TypedDict
14471459

0 commit comments

Comments
 (0)