Skip to content

Commit

Permalink
Add false assertion, and diamond-inheritance test case, to test comment
Browse files Browse the repository at this point in the history
  • Loading branch information
gnprice committed Dec 11, 2015
1 parent 7c9b2a6 commit a858765
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mypy/maptype.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def class_derivation_paths(typ: TypeInfo,
"""
# FIX: Currently we might only ever have a single path, so this could be
# simplified
# (But see assert below! It can fail.)
result = [] # type: List[List[TypeInfo]]

for base in typ.bases:
Expand All @@ -84,6 +85,8 @@ def class_derivation_paths(typ: TypeInfo,
for path in class_derivation_paths(base.type, supertype):
result.append([base.type] + path)

assert len(result) == 1, str(result)

return result


Expand Down
17 changes: 17 additions & 0 deletions mypy/test/data/check-multiple-inheritance.test
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,23 @@ main: note: In class "D":
main:8: error: Definition of "clear" in base class "A" is incompatible with definition in base class "B"


-- Diamond inheritance hierarchies
-- -------------------------------


[case testDiamond]
from typing import TypeVar, Generic
T = TypeVar('T')
class A(Generic[T]): pass
class B(Generic[T], A[T]): pass
class C(Generic[T], A[T]): pass
class D(Generic[T], B[T], C[T]): pass

a = None # type: A[int]
d = None # type: D[int]
a = d


-- Special cases
-- -------------

Expand Down

0 comments on commit a858765

Please sign in to comment.