diff options
author | Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> | 2021-10-07 14:31:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-07 14:31:35 +0200 |
commit | 5143e3a28b59fcf42addaabb0c93d55f911c890a (patch) | |
tree | cdc13201f717875680e7af5908dc9eeac8415344 | |
parent | c4b54416d985da0dd7292de491874fcffcd7c375 (diff) | |
download | pylint-git-5143e3a28b59fcf42addaabb0c93d55f911c890a.tar.gz |
Add tests for ClassDef inference regression (#5037)
Closes #5030
Closes #5036
-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 |