From 9c8d5fcaf4d3b4dfa65c8e54ba9c9fecfaba1526 Mon Sep 17 00:00:00 2001 From: Andrew Haigh Date: Tue, 11 May 2021 09:30:27 +1000 Subject: [PATCH 1/3] Fix Enum.__member__ regression tests Ref PyCQA/astroid#940. These tests failed after fixing inference of Enum.__members__ due to unexpected "not-iterable" warnings raised. These warnings were not false-positives, as the test definition would have raised TypeError at runtime: .keys and .values on dict/mappingproxy are not properties, but methods. --- tests/functional/m/member/member_checks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/functional/m/member/member_checks.py b/tests/functional/m/member/member_checks.py index 291daee125..00fb35dcf8 100644 --- a/tests/functional/m/member/member_checks.py +++ b/tests/functional/m/member/member_checks.py @@ -227,7 +227,7 @@ class Animal(Enum): # To test false positive no-member on Enum.__members__.items() for itm in Animal.__members__.items(): print(itm) -for keyy in Animal.__members__.keys: +for keyy in Animal.__members__.keys(): # pylint: disable=consider-iterating-dictionary print(keyy) -for vall in Animal.__members__.values: +for vall in Animal.__members__.values(): print(vall) From 382cd64f8326be1e9eb04fbcd9ed54105bc85250 Mon Sep 17 00:00:00 2001 From: Andrew Haigh Date: Tue, 11 May 2021 10:27:30 +1000 Subject: [PATCH 2/3] Update _emit_no_member to ignore abstract properties --- pylint/checkers/typecheck.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pylint/checkers/typecheck.py b/pylint/checkers/typecheck.py index 66bd8320f3..d538e9573c 100644 --- a/pylint/checkers/typecheck.py +++ b/pylint/checkers/typecheck.py @@ -458,7 +458,9 @@ def _emit_no_member(node, owner, owner_name, ignored_mixins=True, ignored_none=T return False if owner_name and ignored_mixins and owner_name[-5:].lower() == "mixin": return False - if isinstance(owner, astroid.FunctionDef) and owner.decorators: + if isinstance(owner, astroid.FunctionDef) and ( + owner.decorators or owner.is_abstract() + ): return False if isinstance(owner, (astroid.Instance, astroid.ClassDef)): if owner.has_dynamic_getattr(): From 60835c4b8906a361fdbae5078ef2a46400843844 Mon Sep 17 00:00:00 2001 From: Andrew Haigh Date: Tue, 11 May 2021 10:55:40 +1000 Subject: [PATCH 3/3] Update changelog and contributors --- CONTRIBUTORS.txt | 2 ++ ChangeLog | 2 ++ 2 files changed, 4 insertions(+) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index bb794e639f..fb422cf7ba 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -482,3 +482,5 @@ contributors: * das-intensity: contributor * Jiajunsu (victor): contributor + +* Andrew Haigh (nelfin): contributor diff --git a/ChangeLog b/ChangeLog index 3137cfbf64..de7a504220 100644 --- a/ChangeLog +++ b/ChangeLog @@ -31,6 +31,8 @@ Release date: TBA * Stdlib deprecated modules check is moved to stdlib checker. New deprecated modules are added. +* Fix raising false-positive ``no-member`` on abstract properties + What's New in Pylint 2.8.2? ===========================