diff options
| author | Andrew Simmons <a.simmons@deakin.edu.au> | 2020-04-20 22:40:09 +1000 |
|---|---|---|
| committer | Claudiu Popa <pcmanticore@gmail.com> | 2020-04-22 08:26:43 +0200 |
| commit | d1484608e89c3e7e2900183e9fb9cbc183de1fb5 (patch) | |
| tree | 947568a7b728feea1df966068c26f547795921ee /tests/unittest_checker_variables.py | |
| parent | 67d05722b705c949a6bc0638f65e60c5f888c8d4 (diff) | |
| download | pylint-git-d1484608e89c3e7e2900183e9fb9cbc183de1fb5.tar.gz | |
Fix false positive for ``undefined-variable`` when using class attribute in decorator (#511)
Diffstat (limited to 'tests/unittest_checker_variables.py')
| -rw-r--r-- | tests/unittest_checker_variables.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/unittest_checker_variables.py b/tests/unittest_checker_variables.py index b594e7d18..f33dbf8af 100644 --- a/tests/unittest_checker_variables.py +++ b/tests/unittest_checker_variables.py @@ -119,6 +119,32 @@ class TestVariablesChecker(CheckerTestCase): with self.assertAddsMessages(msg): self.checker.visit_global(node) + def test_listcomp_in_decorator(self): + """ Make sure class attributes in scope for listcomp in decorator. + + https://github.com/PyCQA/pylint/issues/511 + """ + module = astroid.parse( + """ + def dec(inp): + def inner(func): + print(inp) + return func + return inner + + + class Cls: + + DATA = "foo" + + @dec([x for x in DATA]) + def fun(self): + pass + """ + ) + with self.assertNoMessages(): + self.walk(module) + class TestVariablesCheckerWithTearDown(CheckerTestCase): |
