Skip to content

Commit a9fa9ab

Browse files
authored
TypeVisitor and Co now support allow_interpreted_subclasses=True (#9602)
Now these types can be extended from plugin code. More context: #9001 (comment)
1 parent 22d2e32 commit a9fa9ab

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mypy/type_visitor.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from abc import abstractmethod
1515
from mypy.ordered_dict import OrderedDict
1616
from typing import Generic, TypeVar, cast, Any, List, Callable, Iterable, Optional, Set, Sequence
17-
from mypy_extensions import trait
17+
from mypy_extensions import trait, mypyc_attr
1818

1919
T = TypeVar('T')
2020

@@ -28,6 +28,7 @@
2828

2929

3030
@trait
31+
@mypyc_attr(allow_interpreted_subclasses=True)
3132
class TypeVisitor(Generic[T]):
3233
"""Visitor class for types (Type subclasses).
3334
@@ -104,6 +105,7 @@ def visit_type_alias_type(self, t: TypeAliasType) -> T:
104105

105106

106107
@trait
108+
@mypyc_attr(allow_interpreted_subclasses=True)
107109
class SyntheticTypeVisitor(TypeVisitor[T]):
108110
"""A TypeVisitor that also knows how to visit synthetic AST constructs.
109111
@@ -134,6 +136,7 @@ def visit_placeholder_type(self, t: PlaceholderType) -> T:
134136
pass
135137

136138

139+
@mypyc_attr(allow_interpreted_subclasses=True)
137140
class TypeTranslator(TypeVisitor[Type]):
138141
"""Identity type transformation.
139142
@@ -241,6 +244,7 @@ def visit_type_alias_type(self, t: TypeAliasType) -> Type:
241244
pass
242245

243246

247+
@mypyc_attr(allow_interpreted_subclasses=True)
244248
class TypeQuery(SyntheticTypeVisitor[T]):
245249
"""Visitor for performing queries of types.
246250

0 commit comments

Comments
 (0)