Skip to content

TypeVisitor and Co now support allow_interpreted_subclasses=True #9602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 18, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion mypy/type_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from abc import abstractmethod
from mypy.ordered_dict import OrderedDict
from typing import Generic, TypeVar, cast, Any, List, Callable, Iterable, Optional, Set, Sequence
from mypy_extensions import trait
from mypy_extensions import trait, mypyc_attr

T = TypeVar('T')

Expand All @@ -28,6 +28,7 @@


@trait
@mypyc_attr(allow_interpreted_subclasses=True)
class TypeVisitor(Generic[T]):
"""Visitor class for types (Type subclasses).

Expand Down Expand Up @@ -104,6 +105,7 @@ def visit_type_alias_type(self, t: TypeAliasType) -> T:


@trait
@mypyc_attr(allow_interpreted_subclasses=True)
class SyntheticTypeVisitor(TypeVisitor[T]):
"""A TypeVisitor that also knows how to visit synthetic AST constructs.

Expand Down Expand Up @@ -134,6 +136,7 @@ def visit_placeholder_type(self, t: PlaceholderType) -> T:
pass


@mypyc_attr(allow_interpreted_subclasses=True)
class TypeTranslator(TypeVisitor[Type]):
"""Identity type transformation.

Expand Down Expand Up @@ -241,6 +244,7 @@ def visit_type_alias_type(self, t: TypeAliasType) -> Type:
pass


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

Expand Down