Skip to content

Commit

Permalink
Update regression tests for pylint-dev/astroid#940 (#4466)
Browse files Browse the repository at this point in the history
* Fix Enum.__member__ regression tests

Ref pylint-dev/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.

* Update _emit_no_member to ignore abstract properties
* Update changelog and contributors
  • Loading branch information
nelfin committed May 11, 2021
1 parent 817a1c6 commit 547ed55
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -482,3 +482,5 @@ contributors:
* das-intensity: contributor

* Jiajunsu (victor): contributor

* Andrew Haigh (nelfin): contributor
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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?
===========================
Expand Down
4 changes: 3 additions & 1 deletion pylint/checkers/typecheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/m/member/member_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 547ed55

Please sign in to comment.