Skip to content

Commit

Permalink
Merge pull request #844 from timmartin/issue843
Browse files Browse the repository at this point in the history
Fix incorrect MRO being calculated for scoped multiple inheritance
  • Loading branch information
hippo91 committed Dec 12, 2020
2 parents 4629777 + c9c5792 commit 6ed58db
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ Release Date: TBA

* Fixed exception-chaining error messages.

* Fix failure to infer base class type with multiple inheritance and qualified names

Fixes #843

* Reduce memory usage of astroid's module cache.

What's New in astroid 2.4.3?
Expand Down
2 changes: 1 addition & 1 deletion astroid/scoped_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2858,7 +2858,7 @@ def _inferred_bases(self, context=None):

for stmt in self.bases:
try:
baseobj = next(stmt.infer(context=context))
baseobj = next(stmt.infer(context=context.clone()))
except exceptions.InferenceError:
continue
if isinstance(baseobj, bases.Instance):
Expand Down
16 changes: 16 additions & 0 deletions tests/unittest_scoped_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1417,6 +1417,22 @@ def __init__(self):
],
)

def test_mro_with_attribute_classes(self):
cls = builder.extract_node(
"""
class A:
pass
class B:
pass
scope = object()
scope.A = A
scope.B = B
class C(scope.A, scope.B):
pass
"""
)
self.assertEqualMro(cls, ["C", "A", "B", "object"])

def test_generator_from_infer_call_result_parent(self):
func = builder.extract_node(
"""
Expand Down

0 comments on commit 6ed58db

Please sign in to comment.