Skip to content

Commit

Permalink
Fix regression on ClassDef inference
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielNoord committed Sep 17, 2021
1 parent 28411ee commit 23666ce
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ Release date: TBA

Closes PyCQA/pylint#4899

* Fix regression on ClassDef inference

Closes PyCQA/pylint#5030
Closes PyCQA/pylint#5036


What's New in astroid 2.8.0?
============================
Expand Down
3 changes: 2 additions & 1 deletion astroid/nodes/as_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ def visit_classdef(self, node):
args = [n.accept(self) for n in node.bases]
if node._metaclass and not node.has_metaclass_hack():
args.append("metaclass=" + node._metaclass.accept(self))
args += [n.accept(self) for n in node.keywords]
if node.keywords:
args += [n.accept(self) for n in node.keywords]
args = f"({', '.join(args)})" if args else ""
docs = self._docs_dedent(node.doc) if node.doc else ""
return "\n\n{}class {}{}:{}\n{}\n".format(
Expand Down
5 changes: 5 additions & 0 deletions tests/unittest_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ def check_as_string_ast_equality(code: str) -> None:
def test_class_def(self) -> None:
code = """
import abc
from typing import Tuple
class A:
Expand All @@ -275,6 +276,10 @@ class C(B):
class D(metaclass=abc.ABCMeta):
pass
def func(param: Tuple):
pass
"""
ast = abuilder.string_build(code)
self.assertEqual(ast.as_string().strip(), code.strip())
Expand Down

0 comments on commit 23666ce

Please sign in to comment.