Skip to content

Commit

Permalink
Raise error on unimplemented abstract method call
Browse files Browse the repository at this point in the history
This helps to point out the offending unimplemented abstract methods in
subtypes. Part of python#730.
  • Loading branch information
JamesGuthrie committed Aug 24, 2015
1 parent 1f83def commit 9225437
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions mypy/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,10 +491,12 @@ def visit_unbound_type(self, t: UnboundType) -> T:
pass

def visit_type_list(self, t: TypeList) -> T:
pass
raise NotImplementedError("Method visit_type_list not implemented in '{}'\n".format(type(self).__name__)
+ "This is a known bug, track development in 'https://github.com/JukkaL/mypy/issues/730'")

def visit_error_type(self, t: ErrorType) -> T:
pass
raise NotImplementedError("Method visit_error_type not implemented in '{}'\n".format(type(self).__name__)
+ "This is a known bug, track development in 'https://github.com/JukkaL/mypy/issues/730'")

@abstractmethod
def visit_any(self, t: AnyType) -> T:
Expand All @@ -509,7 +511,8 @@ def visit_none_type(self, t: NoneTyp) -> T:
pass

def visit_erased_type(self, t: ErasedType) -> T:
pass
raise NotImplementedError("Method visit_erased_type not implemented in '{}'\n".format(type(self).__name__)
+ "This is a known bug, track development in 'https://github.com/JukkaL/mypy/issues/730'")

@abstractmethod
def visit_type_var(self, t: TypeVarType) -> T:
Expand All @@ -524,21 +527,24 @@ def visit_callable_type(self, t: CallableType) -> T:
pass

def visit_overloaded(self, t: Overloaded) -> T:
pass
raise NotImplementedError("Method visit_overloaded not implemented in '{}'\n".format(type(self).__name__)
+ "This is a known bug, track development in 'https://github.com/JukkaL/mypy/issues/730'")

@abstractmethod
def visit_tuple_type(self, t: TupleType) -> T:
pass

def visit_star_type(self, t: StarType) -> T:
pass
raise NotImplementedError("Method visit_star_type not implemented in '{}'\n".format(type(self).__name__)
+ "This is a known bug, track development in 'https://github.com/JukkaL/mypy/issues/730'")

@abstractmethod
def visit_union_type(self, t: UnionType) -> T:
pass

def visit_ellipsis_type(self, t: EllipsisType) -> T:
pass
raise NotImplementedError("Method visit_ellipsis_type not implemented in '{}'\n".format(type(self).__name__)
+ "This is a known bug, track development in 'https://github.com/JukkaL/mypy/issues/730'")


class TypeTranslator(TypeVisitor[Type]):
Expand Down

0 comments on commit 9225437

Please sign in to comment.