diff --git a/mypy/erasetype.py b/mypy/erasetype.py index 6533d0c4e0f9..fbbb4f80b578 100644 --- a/mypy/erasetype.py +++ b/mypy/erasetype.py @@ -71,7 +71,7 @@ def visit_erased_type(self, t: ErasedType) -> ProperType: def visit_partial_type(self, t: PartialType) -> ProperType: # Should not get here. - raise RuntimeError() + raise RuntimeError("Cannot erase partial types") def visit_deleted_type(self, t: DeletedType) -> ProperType: return t diff --git a/mypy/nodes.py b/mypy/nodes.py index 2d763fc482d3..ebd222f4f253 100644 --- a/mypy/nodes.py +++ b/mypy/nodes.py @@ -203,7 +203,7 @@ def str_with_options(self, options: Options) -> str: return ans def accept(self, visitor: NodeVisitor[T]) -> T: - raise RuntimeError("Not implemented") + raise RuntimeError("Not implemented", type(self)) @trait @@ -213,7 +213,7 @@ class Statement(Node): __slots__ = () def accept(self, visitor: StatementVisitor[T]) -> T: - raise RuntimeError("Not implemented") + raise RuntimeError("Not implemented", type(self)) @trait @@ -223,7 +223,7 @@ class Expression(Node): __slots__ = () def accept(self, visitor: ExpressionVisitor[T]) -> T: - raise RuntimeError("Not implemented") + raise RuntimeError("Not implemented", type(self)) class FakeExpression(Expression): diff --git a/mypy/patterns.py b/mypy/patterns.py index 32c27d2a5b3c..839864ef5879 100644 --- a/mypy/patterns.py +++ b/mypy/patterns.py @@ -19,7 +19,7 @@ class Pattern(Node): __slots__ = () def accept(self, visitor: PatternVisitor[T]) -> T: - raise RuntimeError("Not implemented") + raise RuntimeError("Not implemented", type(self)) class AsPattern(Pattern): diff --git a/mypy/server/astmerge.py b/mypy/server/astmerge.py index 5e3759227c7b..f58a4eedabc8 100644 --- a/mypy/server/astmerge.py +++ b/mypy/server/astmerge.py @@ -467,13 +467,13 @@ def visit_overloaded(self, t: Overloaded) -> None: def visit_erased_type(self, t: ErasedType) -> None: # This type should exist only temporarily during type inference - raise RuntimeError + raise RuntimeError("Cannot handle erased type") def visit_deleted_type(self, typ: DeletedType) -> None: pass def visit_partial_type(self, typ: PartialType) -> None: - raise RuntimeError + raise RuntimeError("Cannot handle partial type") def visit_tuple_type(self, typ: TupleType) -> None: for item in typ.items: diff --git a/mypy/types.py b/mypy/types.py index ba629a3553cf..9eeaa2cc4c3f 100644 --- a/mypy/types.py +++ b/mypy/types.py @@ -260,7 +260,7 @@ def can_be_false_default(self) -> bool: return True def accept(self, visitor: TypeVisitor[T]) -> T: - raise RuntimeError("Not implemented") + raise RuntimeError("Not implemented", type(self)) def __repr__(self) -> str: return self.accept(TypeStrVisitor(options=Options()))