Skip to content

Raise RuntimeError with better error messages #15778

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
Jul 29, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion mypy/erasetype.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions mypy/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion mypy/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions mypy/server/astmerge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion mypy/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down