Skip to content

Commit 547ed55

Browse files
authored
Update regression tests for pylint-dev/astroid#940 (#4466)
* 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
1 parent 817a1c6 commit 547ed55

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

CONTRIBUTORS.txt

+2
Original file line numberDiff line numberDiff line change
@@ -482,3 +482,5 @@ contributors:
482482
* das-intensity: contributor
483483

484484
* Jiajunsu (victor): contributor
485+
486+
* Andrew Haigh (nelfin): contributor

ChangeLog

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ Release date: TBA
3131
* Stdlib deprecated modules check is moved to stdlib checker. New deprecated
3232
modules are added.
3333

34+
* Fix raising false-positive ``no-member`` on abstract properties
35+
3436

3537
What's New in Pylint 2.8.2?
3638
===========================

pylint/checkers/typecheck.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,9 @@ def _emit_no_member(node, owner, owner_name, ignored_mixins=True, ignored_none=T
458458
return False
459459
if owner_name and ignored_mixins and owner_name[-5:].lower() == "mixin":
460460
return False
461-
if isinstance(owner, astroid.FunctionDef) and owner.decorators:
461+
if isinstance(owner, astroid.FunctionDef) and (
462+
owner.decorators or owner.is_abstract()
463+
):
462464
return False
463465
if isinstance(owner, (astroid.Instance, astroid.ClassDef)):
464466
if owner.has_dynamic_getattr():

tests/functional/m/member/member_checks.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ class Animal(Enum):
227227
# To test false positive no-member on Enum.__members__.items()
228228
for itm in Animal.__members__.items():
229229
print(itm)
230-
for keyy in Animal.__members__.keys:
230+
for keyy in Animal.__members__.keys(): # pylint: disable=consider-iterating-dictionary
231231
print(keyy)
232-
for vall in Animal.__members__.values:
232+
for vall in Animal.__members__.values():
233233
print(vall)

0 commit comments

Comments
 (0)