summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--astroid/nodes.py1
-rw-r--r--astroid/protocols.py7
-rw-r--r--astroid/tests/unittest_inference.py4
3 files changed, 8 insertions, 4 deletions
diff --git a/astroid/nodes.py b/astroid/nodes.py
index 861b0a66..2b207d02 100644
--- a/astroid/nodes.py
+++ b/astroid/nodes.py
@@ -42,6 +42,7 @@ from astroid.node_classes import (
Backquote, Discard, AssName, AssAttr, Getattr, CallFunc, From,
# Node not present in the builtin ast module.
DictUnpack,
+ Unknown,
)
from astroid.scoped_nodes import (
Module, GeneratorExp, Lambda, DictComp,
diff --git a/astroid/protocols.py b/astroid/protocols.py
index d1abdea0..605ae1ce 100644
--- a/astroid/protocols.py
+++ b/astroid/protocols.py
@@ -147,10 +147,13 @@ def _multiply_seq_by_int(self, opnode, other, context):
def _filter_uninferable_nodes(elts, context):
for elt in elts:
if elt is util.Uninferable:
- yield elt
+ yield nodes.Unknown()
else:
for inferred in elt.infer(context):
- yield inferred
+ if inferred is not util.Uninferable:
+ yield inferred
+ else:
+ yield nodes.Unknown()
@decorators.yes_if_nothing_inferred
diff --git a/astroid/tests/unittest_inference.py b/astroid/tests/unittest_inference.py
index a90803d6..9d4554db 100644
--- a/astroid/tests/unittest_inference.py
+++ b/astroid/tests/unittest_inference.py
@@ -1304,7 +1304,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
inferred = next(ast['Z'].infer())
self.assertIsInstance(inferred, nodes.List)
self.assertEqual(len(inferred.elts), 1)
- self.assertIs(inferred.elts[0], util.Uninferable)
+ self.assertIsInstance(inferred.elts[0], nodes.Unknown)
def test__new__(self):
code = '''
@@ -2479,7 +2479,7 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
self.assertIsInstance(inferred, nodes.List)
self.assertEqual(len(inferred.elts), 2)
self.assertIsInstance(inferred.elts[0], nodes.Const)
- self.assertIs(inferred.elts[1], util.Uninferable)
+ self.assertIsInstance(inferred.elts[1], nodes.Unknown)
def test_binop_same_types(self):
ast_nodes = extract_node('''