-
-
Notifications
You must be signed in to change notification settings - Fork 308
Open
Description
Originally reported by: BitBucket: ceridwenv, GitHub: @ceridwen
I've already tweaked builtin_lookup() to accommodate cases where ast_from_object() is creating an AssignName node because of an alias to the same object in the builtins module. However, there's another issue that's less clear how to solve: in some cases, the builtins module has objects that actually belong to another module. The proximate test failure caused by this case is that on Python3, open() is imported from io:
FAIL: test_builtin_open (unittest_inference.InferenceTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "~/code/astroid/.tox/py34/lib/python3.4/site-packages/astroid/tests/unittest_inference.py", line 811, in test_builtin_open
self.assertIsInstance(inferred[0], nodes.FunctionDef)
AssertionError: Uninferable is not an instance of <class 'astroid.tree.scoped_nodes.FunctionDef'>However, there are other cases. ast_from_object() tries to create an AST that's as close as possible to the AST that would create the object if it were compiled. I think this should probably be solved in builtin_lookup(), but what's the best way to do it?