diff --git a/ChangeLog b/ChangeLog index f94dea5cb6..35d46c40c8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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? ============================ diff --git a/astroid/nodes/scoped_nodes.py b/astroid/nodes/scoped_nodes.py index 025cd8451e..e64f736e15 100644 --- a/astroid/nodes/scoped_nodes.py +++ b/astroid/nodes/scoped_nodes.py @@ -2096,7 +2096,8 @@ def postinit( :param keywords: The keywords given to the class definition. :type keywords: list(Keyword) or None """ - self.keywords = keywords + if keywords is not None: + self.keywords = keywords self.bases = bases self.body = body self.decorators = decorators diff --git a/tests/unittest_nodes.py b/tests/unittest_nodes.py index 45fde769ef..323ae08f48 100644 --- a/tests/unittest_nodes.py +++ b/tests/unittest_nodes.py @@ -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: @@ -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())