Skip to content

Fix regression on ClassDef inference #1181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
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/scoped_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
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