Пример #1
0
    def visit_classdef(self, node: astroid.ClassDef) -> None:
        node.inf_type = NoType()

        # Update type_store for this class.
        # TODO: include node.instance_attrs as well?
        for attr in node.locals:
            attr_inf_type = self.type_constraints.resolve(node.type_environment.lookup_in_env(attr))
            attr_inf_type >> (
                lambda a: self.type_store.methods[attr].append((a, node.locals[attr][0].type)) if is_callable(a) else None)
            attr_inf_type >> (
                lambda a: self.type_store.classes[node.name][attr].append((a, node.locals[attr][0].type if is_callable(a) else 'attribute')))
Пример #2
0
    def visit_classdef(self, node: astroid.ClassDef) -> None:
        node.inf_type = NoType()
        self.type_constraints.unify(self.lookup_inf_type(node.parent, node.name),
                                    Type[_ForwardRef(node.name)], node)

        # Update type_store for this class.
        # TODO: include node.instance_attrs as well?
        for attr in node.locals:
            attr_inf_type = self.type_constraints.resolve(node.type_environment.lookup_in_env(attr))
            attr_inf_type >> (
                lambda a: self.type_store.methods[attr].append((a, node.locals[attr][0].type)) if isinstance(a, CallableMeta) else None)
            attr_inf_type >> (
                lambda a: self.type_store.classes[node.name][attr].append((a, node.locals[attr][0].type if isinstance(a, CallableMeta) else 'attribute')))
Пример #3
0
    def visit_classdef(self, node: astroid.ClassDef) -> None:
        node.inf_type = TypeInfo(NoType)
        self.type_constraints.unify(self.lookup_type(node.parent, node.name),
                                    _ForwardRef(node.name), node)

        # Update type_store for this class.
        # TODO: include node.instance_attrs as well?
        for attr in node.locals:
            attr_type = self.type_constraints.resolve(
                node.type_environment.lookup_in_env(attr)).getValue()
            self.type_store.classes[node.name][attr].append(attr_type)
            if isinstance(attr_type, CallableMeta):
                self.type_store.methods[attr].append(attr_type)