Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2300,7 +2300,7 @@ def verify_base_classes(self, defn: ClassDef) -> bool:
cycle = True
dup = find_duplicate(info.direct_base_classes())
if dup:
self.fail(f'Duplicate base class "{dup.name}"', defn, blocker=True)
self.fail(f'Duplicate base class "{dup.name}"', defn)
return False
return not cycle

Expand Down
12 changes: 12 additions & 0 deletions test-data/unit/check-classes.test
Original file line number Diff line number Diff line change
Expand Up @@ -4131,6 +4131,18 @@ class C(str, str):
[out]
Comment thread
sobolevn marked this conversation as resolved.
Outdated
main:1: error: Duplicate base class "str"

[case testDupBaseClassesIsNotBlocking]
class A:
def method(self) -> str: ...

class B(A, A): # E: Duplicate base class "A"
...

b: B
# We use dummy type info, so no real attrs will be there:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's pretty unfortunate, can we make it inherit from Any or just skip the duplicate base instead?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeap, got it. Fixed!

b.method() # E: "B" has no attribute "method"
[out]

[case testCannotDetermineMro]
class A: pass
class B(A): pass
Expand Down