diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2015-11-30 10:37:47 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2015-11-30 10:37:47 +0200 |
commit | f0e5799175980963b1dc8c2e3e068f022917c4bf (patch) | |
tree | c312f61d8084eb90cd2d2dd077bee306d2b5775c | |
parent | a56f16b7a7e5b7b40a9d613e8cbec671a052f9e3 (diff) | |
download | pylint-f0e5799175980963b1dc8c2e3e068f022917c4bf.tar.gz |
Don't emit unsubscriptable-object if the node is found inside an abstract class. Closes #685.
-rw-r--r-- | pylint/checkers/typecheck.py | 3 | ||||
-rw-r--r-- | pylint/test/functional/unsubscriptable_value.py | 25 |
2 files changed, 28 insertions, 0 deletions
diff --git a/pylint/checkers/typecheck.py b/pylint/checkers/typecheck.py index 7ec0b55..46535d2 100644 --- a/pylint/checkers/typecheck.py +++ b/pylint/checkers/typecheck.py @@ -866,6 +866,9 @@ accessed. Python regular expressions are accepted.'} node=node.value) return + if is_inside_abstract_class(node): + return + inferred = safe_infer(node.value) if inferred is None or inferred is astroid.YES: return diff --git a/pylint/test/functional/unsubscriptable_value.py b/pylint/test/functional/unsubscriptable_value.py index 7f2ceae..4f1848a 100644 --- a/pylint/test/functional/unsubscriptable_value.py +++ b/pylint/test/functional/unsubscriptable_value.py @@ -88,3 +88,28 @@ from collections import deque deq = deque(maxlen=10) deq.append(42) deq[0] + + +class AbstractClass(object): + + def __init__(self): + self.ala = {i for i in range(10)} + self.bala = [i for i in range(10)] + self.portocala = None + + def test_unsubscriptable(self): + self.bala[0] + self.portocala[0] + + +class ClassMixin(object): + + def __init__(self): + self.ala = {i for i in range(10)} + self.bala = [i for i in range(10)] + self.portocala = None + + def test_unsubscriptable(self): + self.bala[0] + self.portocala[0] +
\ No newline at end of file |