diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | tests/functional/r/regression/regression_5030.py | 31 | ||||
-rw-r--r-- | tests/functional/r/regression/regression_5030.rc | 2 |
3 files changed, 38 insertions, 0 deletions
@@ -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? ============================ diff --git a/tests/functional/r/regression/regression_5030.py b/tests/functional/r/regression/regression_5030.py new file mode 100644 index 000000000..8aa22f879 --- /dev/null +++ b/tests/functional/r/regression/regression_5030.py @@ -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"]) diff --git a/tests/functional/r/regression/regression_5030.rc b/tests/functional/r/regression/regression_5030.rc new file mode 100644 index 000000000..a17bb22da --- /dev/null +++ b/tests/functional/r/regression/regression_5030.rc @@ -0,0 +1,2 @@ +[testoptions] +min_pyver=3.7 |