Skip to content

Commit

Permalink
Revert pylint-dev#893: Avoid setting a Call as a base for metaclasses…
Browse files Browse the repository at this point in the history
… from six.with_metaclass()
  • Loading branch information
jacobtylerwalls committed Jun 15, 2022
1 parent 6280a75 commit 01dbfcc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Release date: TBA

* ``astroid`` now requires Python 3.7.2 to run.

* Avoid setting a Call as a base for classes created using ``six.with_metaclass()``.

Refs PyCQA/pylint#5935

* Fix detection of builtins on ``PyPy`` 3.9.

* Fix ``re`` brain on Python ``3.11``. The flags now come from ``re._compile``.
Expand Down
1 change: 1 addition & 0 deletions astroid/brain/brain_six.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ def transform_six_with_metaclass(node):
"""
call = node.bases[0]
node._metaclass = call.args[0]
node.bases = call.args[1:]
return node


Expand Down
3 changes: 2 additions & 1 deletion tests/unittest_brain.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,8 @@ class B(six.with_metaclass(A, C)):
inferred = next(ast_node.infer())
self.assertIsInstance(inferred, nodes.ClassDef)
self.assertEqual(inferred.name, "B")
self.assertIsInstance(inferred.bases[0], nodes.Call)
self.assertIsInstance(inferred.bases[0], nodes.Name)
self.assertEqual(inferred.bases[0].name, "C")
ancestors = tuple(inferred.ancestors())
self.assertIsInstance(ancestors[0], nodes.ClassDef)
self.assertEqual(ancestors[0].name, "C")
Expand Down

0 comments on commit 01dbfcc

Please sign in to comment.