Skip to content

Commit 5143e3a

Browse files
authored
Add tests for ClassDef inference regression (#5037)
Closes #5030 Closes #5036
1 parent c4b5441 commit 5143e3a

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ Release date: TBA
7575
* Add ``is_sys_guard`` and ``is_typing_guard`` helper functions from astroid
7676
to ``pylint.checkers.utils``.
7777

78+
* Fix regression on ClassDef inference
79+
80+
Closes #5030
81+
Closes #5036
82+
7883

7984
What's New in Pylint 2.11.1?
8085
============================
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""Regression in astroid on ClassDef inference with two test cases.
2+
Fixed in https://github.com/PyCQA/astroid/pull/1181"""
3+
4+
from typing import Tuple, Type
5+
from typing import Dict, List, Any
6+
from dataclasses import dataclass, field
7+
8+
# https://github.com/PyCQA/pylint/issues/5030
9+
def is_type_list(f_type: Type) -> bool:
10+
"""just here to show the issue"""
11+
return f_type == list
12+
13+
assert not is_type_list(Tuple)
14+
15+
16+
# https://github.com/PyCQA/pylint/issues/5036
17+
@dataclass
18+
class SomeData:
19+
"""A dataclass."""
20+
a_dict: Dict[str, List[str]] = field(default_factory=dict)
21+
22+
23+
@dataclass
24+
class SubSomeData(SomeData):
25+
"""A subclass of a dataclass."""
26+
27+
def __init__(self, **kwargs: Dict[str, Any]) -> None:
28+
"""Subclass init func."""
29+
super().__init__(**kwargs)
30+
if "test" in self.a_dict:
31+
print(self.a_dict["test"])
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[testoptions]
2+
min_pyver=3.7

0 commit comments

Comments
 (0)