Example #1
0
 def _self_set(self, context):
     if self.holding is not None:
         return
     iterable = context.get_pyname('iterable')
     holding = _infer_sequence_for_pyname(iterable)
     if holding is not None and holding != pyobjects.get_unknown():
         context.save_per_name(holding)
Example #2
0
 def get_returned_object(self, args):
     result = rope.base.evaluate.get_statement_result(self.scope,
                                                      self.node.body)
     if result is not None:
         return result.get_object()
     else:
         return pyobjects.get_unknown()
Example #3
0
 def _self_set(self, context):
     if self.holding is not None:
         return
     iterable = context.get_pyname('iterable')
     holding = _infer_sequence_for_pyname(iterable)
     if holding is not None and holding != pyobjects.get_unknown():
         context.save_per_name(holding)
Example #4
0
def unsure_pyname(pyname, unbound=True):
    """Return `True` if we don't know what this name references"""
    if pyname is None:
        return True
    if unbound and not isinstance(pyname, pynames.UnboundName):
        return False
    if pyname.get_object() == pyobjects.get_unknown():
        return True
Example #5
0
def unsure_pyname(pyname, unbound=True):
    """Return `True` if we don't know what this name references"""
    if pyname is None:
        return True
    if unbound and not isinstance(pyname, pynames.UnboundName):
        return False
    if pyname.get_object() == pyobjects.get_unknown():
        return True
Example #6
0
 def _Attribute(self, node):
     if not isinstance(node.ctx, ast.Store):
         scope = self.scope.get_inner_scope_for_line(node.lineno)
         pyname = evaluate.eval_node(scope, node.value)
         if pyname is not None and pyname.get_object() != pyobjects.get_unknown():
             if node.attr not in pyname.get_object():
                 self._add_error(node, "Unresolved attribute")
     ast.walk(node.value, self)
Example #7
0
 def _Attribute(self, node):
     if not isinstance(node.ctx, ast.Store):
         scope = self.scope.get_inner_scope_for_line(node.lineno)
         pyname = evaluate.eval_node(scope, node.value)
         if pyname is not None and \
            pyname.get_object() != pyobjects.get_unknown():
             if node.attr not in pyname.get_object():
                 self._add_error(node, 'Unresolved attribute')
     ast.walk(node.value, self)
Example #8
0
def _object_attributes(obj, parent):
    attributes = {}
    for name in dir(obj):
        if name == 'None':
            continue
        child = getattr(obj, name)
        pyobject = None
        if inspect.isclass(child):
            pyobject = BuiltinClass(child, {}, parent=parent)
        elif inspect.isroutine(child):
            pyobject = BuiltinFunction(builtin=child, parent=parent)
        else:
            pyobject = pyobjects.get_unknown()
        attributes[name] = BuiltinName(pyobject)
    return attributes
Example #9
0
def _object_attributes(obj, parent):
    attributes = {}
    for name in dir(obj):
        if name == 'None':
            continue
        child = getattr(obj, name)
        pyobject = None
        if inspect.isclass(child):
            pyobject = BuiltinClass(child, {}, parent=parent)
        elif inspect.isroutine(child):
            pyobject = BuiltinFunction(builtin=child, parent=parent)
        else:
            pyobject = pyobjects.get_unknown()
        attributes[name] = BuiltinName(pyobject)
    return attributes
Example #10
0
 def _set_add(self, context):
     if self.holding is not None:
         return
     holding = context.get_arguments(['self', 'value'])[1]
     if holding is not None and holding != pyobjects.get_unknown():
         context.save_per_name(holding)
Example #11
0
 def _set_add(self, context):
     if self.holding is not None:
         return
     holding = context.get_arguments(['self', 'value'])[1]
     if holding is not None and holding != pyobjects.get_unknown():
         context.save_per_name(holding)
Example #12
0
 def _dict_add(self, context):
     if self.keys is not None:
         return
     key, value = context.get_arguments(['self', 'key', 'value'])[1:]
     if key is not None and key != pyobjects.get_unknown():
         context.save_per_name(get_tuple(key, value))
Example #13
0
 def _list_add(self, context):
     if self.holding is not None:
         return
     holding = context.get_argument('value')
     if holding is not None and holding != pyobjects.get_unknown():
         context.save_per_name(holding)
Example #14
0
 def __init__(self, builtin):
     super(BuiltinUnknown, self).__init__(pyobjects.get_unknown())
     self.builtin = builtin
     self.type = pyobjects.get_unknown()
Example #15
0
 def get_returned_object(self, args):
     result = rope.base.evaluate.eval_node(self.scope, self.node.body)
     if result is not None:
         return result.get_object()
     else:
         return pyobjects.get_unknown()
Example #16
0
 def _dict_add(self, context):
     if self.keys is not None:
         return
     key, value = context.get_arguments(['self', 'key', 'value'])[1:]
     if key is not None and key != pyobjects.get_unknown():
         context.save_per_name(get_tuple(key, value))
Example #17
0
 def _list_add(self, context):
     if self.holding is not None:
         return
     holding = context.get_argument('value')
     if holding is not None and holding != pyobjects.get_unknown():
         context.save_per_name(holding)
Example #18
0
 def __init__(self, builtin):
     super(BuiltinUnknown, self).__init__(pyobjects.get_unknown())
     self.builtin = builtin
     self.type = pyobjects.get_unknown()