Commits

Anonymous committed 192f259

Not giving up when the first inferred returned object was inaccurate

Comments (0)

Files changed (2)

docs/dev/issues.txt

 Unresolved Issues
 =================
 
-* objectinfer._infer_returned; should we give up when the first
-  attempt returned None or unknown, user config?
 * Review objectinfo module
 * Searching all files when extracting a global method?
 * Better tests in `patchedasttest`

rope/base/oi/objectinfer.py

     scope = pyobject.get_scope()
     if not scope._get_returned_asts():
         return
-    for returned_node in reversed(scope._get_returned_asts()):
+    maxtries = 3
+    for returned_node in reversed(scope._get_returned_asts()[-maxtries:]):
         try:
             resulting_pyname = evaluate.get_statement_result(scope,
                                                              returned_node)
             if resulting_pyname is None:
-                return
+                continue
             pyobject = resulting_pyname.get_object()
             if pyobject == rope.base.pyobjects.get_unknown():
-                return
+                continue
             if not scope._is_generator():
                 return pyobject
             else: