summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <cpopa@cloudbasesolutions.com>2015-04-24 11:33:20 +0300
committerClaudiu Popa <cpopa@cloudbasesolutions.com>2015-04-24 11:33:20 +0300
commit6ea091d1a2d2d25b8b53734909931eb793105beb (patch)
tree3a2be74f812520f8cd2537999888b0804bc9e372
parentebe75a0e80e538946926b491eaf7b6c9305ac627 (diff)
downloadpylint-6ea091d1a2d2d25b8b53734909931eb793105beb.tar.gz
Don't emit no-member for classes with unknown bases.
Since we don't know what those bases might add, we simply ignore the error in this case.
-rw-r--r--ChangeLog7
-rw-r--r--pylint/checkers/typecheck.py7
-rw-r--r--pylint/test/functional/class_members_py27.py10
-rw-r--r--pylint/test/functional/class_members_py30.py10
4 files changed, 26 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 025e922..8b356b1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -63,7 +63,12 @@ ChangeLog for Pylint
Since the __new__ comes from builtins, it will not have attached any
information regarding what parameters it expects, so the check
will be useless. Retrieving __init__ in that case will at least
- detect a couple of false negatives. Closes issue #429.
+ detect a couple of false negatives. Closes issue #429.
+
+ * Don't emit no-member for classes with unknown bases.
+
+ Since we don't know what those bases might add, we simply ignore
+ the error in this case.
2015-03-14 -- 1.4.3
diff --git a/pylint/checkers/typecheck.py b/pylint/checkers/typecheck.py
index 784ca1d..ed3c901 100644
--- a/pylint/checkers/typecheck.py
+++ b/pylint/checkers/typecheck.py
@@ -28,7 +28,7 @@ from pylint.checkers import BaseChecker
from pylint.checkers.utils import (
safe_infer, is_super,
check_messages, decorated_with_property,
- decorated_with)
+ decorated_with, has_known_bases)
MSGS = {
'E1101': ('%s %r has no %r member',
@@ -112,8 +112,9 @@ def _emit_no_member(owner, owner_name, attrname,
return False
if isinstance(owner, astroid.Function) and owner.decorators:
return False
- if isinstance(owner, Instance) and owner.has_dynamic_getattr():
- return False
+ if isinstance(owner, Instance):
+ if owner.has_dynamic_getattr() or not has_known_bases(owner):
+ return False
# explicit skipping of module member access
if owner.root().name in ignored_modules:
return False
diff --git a/pylint/test/functional/class_members_py27.py b/pylint/test/functional/class_members_py27.py
index 40423b1..5bbbb65 100644
--- a/pylint/test/functional/class_members_py27.py
+++ b/pylint/test/functional/class_members_py27.py
@@ -1,6 +1,6 @@
""" Various tests for class members access. """
-# pylint: disable=R0903,print-statement,no-absolute-import, metaclass-assignment
-
+# pylint: disable=R0903,print-statement,no-absolute-import, metaclass-assignment,import-error,no-init
+from missing import Missing
class MyClass(object):
"""class docstring"""
@@ -49,3 +49,9 @@ TestMetaclass.register(int)
UsingMetaclass.test()
TestMetaclass().register(int) # [no-member]
UsingMetaclass().test() # [no-member]
+
+
+class NoKnownBases(Missing):
+ """Don't emit no-member if we don't know the bases of a class."""
+
+NoKnownBases().lalala()
diff --git a/pylint/test/functional/class_members_py30.py b/pylint/test/functional/class_members_py30.py
index cf0e7bd..b8bc109 100644
--- a/pylint/test/functional/class_members_py30.py
+++ b/pylint/test/functional/class_members_py30.py
@@ -1,6 +1,6 @@
""" Various tests for class members access. """
-# pylint: disable=R0903
-
+# pylint: disable=R0903,import-error,no-init
+from missing import Missing
class MyClass(object):
"""class docstring"""
@@ -47,3 +47,9 @@ TestMetaclass.register(int)
UsingMetaclass.test()
TestMetaclass().register(int) # [no-member]
UsingMetaclass().test() # [no-member]
+
+
+class NoKnownBases(Missing):
+ """Don't emit no-member if we don't know the bases of a class."""
+
+NoKnownBases().lalala()