Skip to content

Add tests for ClassDef inference regression #5037

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 5 commits into from
Oct 7, 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 @@ -75,6 +75,11 @@ Release date: TBA
* Add ``is_sys_guard`` and ``is_typing_guard`` helper functions from astroid
to ``pylint.checkers.utils``.

* Fix regression on ClassDef inference

Closes #5030
Closes #5036


What's New in Pylint 2.11.1?
============================
Expand Down
31 changes: 31 additions & 0 deletions tests/functional/r/regression/regression_5030.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""Regression in astroid on ClassDef inference with two test cases.
Fixed in https://github.com/PyCQA/astroid/pull/1181"""

from typing import Tuple, Type
from typing import Dict, List, Any
from dataclasses import dataclass, field

# https://github.com/PyCQA/pylint/issues/5030
def is_type_list(f_type: Type) -> bool:
"""just here to show the issue"""
return f_type == list

assert not is_type_list(Tuple)


# https://github.com/PyCQA/pylint/issues/5036
@dataclass
class SomeData:
"""A dataclass."""
a_dict: Dict[str, List[str]] = field(default_factory=dict)


@dataclass
class SubSomeData(SomeData):
"""A subclass of a dataclass."""

def __init__(self, **kwargs: Dict[str, Any]) -> None:
"""Subclass init func."""
super().__init__(**kwargs)
if "test" in self.a_dict:
print(self.a_dict["test"])
2 changes: 2 additions & 0 deletions tests/functional/r/regression/regression_5030.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[testoptions]
min_pyver=3.7