summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <cpopa@cloudbasesolutions.com>2015-06-23 12:40:29 +0300
committerClaudiu Popa <cpopa@cloudbasesolutions.com>2015-06-23 12:40:29 +0300
commit893bcc5d6e063e512e320122559703e4c1b15811 (patch)
tree6cf8664e2fd875ed143720e7acadbd5d1e4e111e
parentb258a6b92276594ace53509a43313c02b098f4be (diff)
downloadastroid-git-893bcc5d6e063e512e320122559703e4c1b15811.tar.gz
NotImplemented is detected properly now as being part of the builtins module.
Previously trying to infer the Name(NotImplemented) returned an YES object.
-rw-r--r--ChangeLog4
-rw-r--r--astroid/node_classes.py3
-rw-r--r--astroid/raw_building.py3
-rw-r--r--astroid/tests/unittest_builder.py8
4 files changed, 17 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 95b88c0c..b2bd0876 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -174,6 +174,10 @@ Change log for the astroid package (used to be astng)
* Add support for Python 3.5's MatMul operation: see PEP 465 for more
details.
+ * NotImplemented is detected properly now as being part of the
+ builtins module. Previously trying to infer the Name(NotImplemented)
+ returned an YES object.
+
2015-03-14 -- 1.3.6
diff --git a/astroid/node_classes.py b/astroid/node_classes.py
index bb2da139..c064c4ff 100644
--- a/astroid/node_classes.py
+++ b/astroid/node_classes.py
@@ -969,7 +969,8 @@ CONST_CLS = {
tuple: Tuple,
dict: Dict,
set: Set,
- type(None): Const,
+ type(None): Const,
+ type(NotImplemented): Const,
}
def _update_const_classes():
diff --git a/astroid/raw_building.py b/astroid/raw_building.py
index 73a7db4e..5edf3b49 100644
--- a/astroid/raw_building.py
+++ b/astroid/raw_building.py
@@ -369,6 +369,9 @@ def _astroid_bootstrapping(astroid_builtin=None):
if cls is type(None):
proxy = build_class('NoneType')
proxy.parent = astroid_builtin
+ elif cls is type(NotImplemented):
+ proxy = build_class('NotImplementedType')
+ proxy.parent = astroid_builtin
else:
proxy = astroid_builtin.getattr(cls.__name__)[0]
if cls in (dict, list, set, tuple):
diff --git a/astroid/tests/unittest_builder.py b/astroid/tests/unittest_builder.py
index 9f0fbaf2..9d8e7d01 100644
--- a/astroid/tests/unittest_builder.py
+++ b/astroid/tests/unittest_builder.py
@@ -576,6 +576,14 @@ class BuilderTest(unittest.TestCase):
method = test_utils.extract_node(code)
self.assertEqual('classmethod', method.type)
+ def test_not_implemented(self):
+ node = test_utils.extract_node('''
+ NotImplemented #@
+ ''')
+ inferred = next(node.infer())
+ self.assertIsInstance(inferred, nodes.Const)
+ self.assertEqual(inferred.value, NotImplemented)
+
class FileBuildTest(unittest.TestCase):
def setUp(self):