コード例 #1
0
    def attr___defaults__(self):
        func = self._instance
        if not func.args.defaults:
            return node_classes.Const(value=None, parent=func)

        defaults_obj = node_classes.Tuple(parent=func)
        defaults_obj.postinit(func.args.defaults)
        return defaults_obj
コード例 #2
0
    def attr___mro__(self):
        if not self._instance.newstyle:
            raise AttributeInferenceError(target=self._instance, attribute="__mro__")

        mro = self._instance.mro()
        obj = node_classes.Tuple(parent=self._instance)
        obj.postinit(mro)
        return obj
コード例 #3
0
    def attr_items(self):
        elems = []
        obj = node_classes.List(parent=self._instance)
        for key, value in self._instance.items:
            elem = node_classes.Tuple(parent=obj)
            elem.postinit((key, value))
            elems.append(elem)
        obj.postinit(elts=elems)

        obj = objects.DictItems(obj)
        return self._generic_dict_attribute(obj, "items")
コード例 #4
0
 def attr___bases__(self):
     obj = node_classes.Tuple()
     context = InferenceContext()
     elts = list(self._instance._inferred_bases(context))
     obj.postinit(elts=elts)
     return obj
コード例 #5
0
 def attr_args(self):
     message = node_classes.Const("")
     args = node_classes.Tuple(parent=self._instance)
     args.postinit((message, ))
     return args