# Buggy code
def decorate(self, node, cls):
    """Processes the attrib members of a class."""
    # Collect classvars to convert them to attrs.
    if self.args[cls]["auto_attribs"]:
        ordering = classgen.Ordering.FIRST_ANNOTATE
    else:
        ordering = classgen.Ordering.LAST_ASSIGN
    ordered_locals = self.get_class_locals(cls, allow_methods=False, ordering=ordering)
    own_attrs = []
    late_annotation = False  # True if we find a bare late annotation
    for name, (value, orig) in ordered_locals.items():
        if is_attrib(orig):
            if not is_attrib(value) and orig.data[0].has_type:
                # We cannot have both a type annotation and a type argument.
                self.type_clash_error(value)
                attr = Attribute(
                    name=name,
                    typ=self.vm.new_unsolvable(node),
                    init=orig.data[0].init,
                    default=orig.data[0].default,
                )
            else:
                if classgen.is_late_annotation(value):
                    attr = Attribute(
                        name=name,
                        typ=value,
                        init=orig.data[0].init,
                        default=orig.data[0].default,
                    )
                    cls.members[name] = orig.data[0].typ
                elif is_attrib(value):
                    # Replace the attrib in the class dict with its type.
                    attr = Attribute(
                        name=name,
                        typ=value.data[0].typ,
                        init=value.data[0].init,
                        default=value.data[0].default,
                    )
                    if classgen.is_late_annotation(attr.typ):
                        cls.members[name] = self.vm.new_unsolvable(node)
                        cls.late_annotations[name] = attr.typ
                        late_annotation = True
                    else:
                        cls.members[name] = attr.typ
                else:
                    # cls.members[name] has already been set via a typecomment
                    attr = Attribute(
                        name=name,
                        typ=value,
                        init=orig.data[0].init,
                        default=orig.data[0].default,
                    )
            own_attrs.append(attr)
        elif self.args[cls]["auto_attribs"]:
            # TODO(b/72678203): typing.ClassVar is the only way to filter a variable
            # out from auto_attribs, but we don't even support importing it.
            attr = Attribute(name=name, typ=value, init=True, default=orig)
            if self.add_member(node, cls, name, value, orig):
                late_annotation = True
            own_attrs.append(attr)

    # See if we need to resolve any late annotations
    if late_annotation:
        self.vm.classes_with_late_annotations.append(cls)

    base_attrs = self.get_base_class_attrs(cls, own_attrs, _ATTRS_METADATA_KEY)
    attrs = base_attrs + own_attrs
    # Stash attributes in class metadata for subclasses.
    cls.metadata[_ATTRS_METADATA_KEY] = attrs

    # Add an __init__ method
    if self.args[cls]["init"]:
        init_method = self.make_init(node, cls, attrs)
        cls.members["__init__"] = init_method


# Traceback (AttributeError)
from typing import Any
def __getattr__(name: Any) -> Any: ...
# Caught error in pytype: 'LateAnnotation' object has no attribute 'Bindings'
# Traceback (most recent call last):
#   File "/Users/name/.pyenv/versions/3.7.3/envs/venv/lib/python3.7/site-packages/pytype/io.py", line 131, in check_or_generate_pyi
#     input_filename=options.input, options=options, loader=loader)
#   File "/Users/name/.pyenv/versions/3.7.3/envs/venv/lib/python3.7/site-packages/pytype/io.py", line 89, in generate_pyi
#     analyze.infer_types, input_filename, options, loader)
#   File "/Users/name/.pyenv/versions/3.7.3/envs/venv/lib/python3.7/site-packages/pytype/io.py", line 62, in _call
#     deep=deep)
#   File "/Users/name/.pyenv/versions/3.7.3/envs/venv/lib/python3.7/site-packages/pytype/analyze.py", line 668, in infer_types
#     tracer.exitpoint = tracer.analyze(loc, defs, maximum_depth)
#   File "/Users/name/.pyenv/versions/3.7.3/envs/venv/lib/python3.7/site-packages/pytype/analyze.py", line 407, in analyze
#     return self.analyze_toplevel(node, defs)
#   File "/Users/name/.pyenv/versions/3.7.3/envs/venv/lib/python3.7/site-packages/pytype/analyze.py", line 370, in analyze_toplevel
#     new_node = self.analyze_class(node, value)
#   File "/Users/name/.pyenv/versions/3.7.3/envs/venv/lib/python3.7/site-packages/pytype/analyze.py", line 352, in analyze_class
#     node = self.analyze_method_var(node, name, b)
#   File "/Users/name/.pyenv/versions/3.7.3/envs/venv/lib/python3.7/site-packages/pytype/analyze.py", line 202, in analyze_method_var
#     node2 = self.maybe_analyze_method(node1, val)
#   File "/Users/name/.pyenv/versions/3.7.3/envs/venv/lib/python3.7/site-packages/pytype/analyze.py", line 157, in maybe_analyze_method
#     node, _ = self.call_function_with_args(node, val, args)
#   File "/Users/name/.pyenv/versions/3.7.3/envs/venv/lib/python3.7/site-packages/pytype/analyze.py", line 121, in call_function_with_args
#     new_node, ret = self.call_function_in_frame(node, fvar, *args)
#   File "/Users/name/.pyenv/versions/3.7.3/envs/venv/lib/python3.7/site-packages/pytype/analyze.py", line 132, in call_function_in_frame
#     state, var, args, kwargs, starargs, starstarargs)
#   File "/Users/name/.pyenv/versions/3.7.3/envs/venv/lib/python3.7/site-packages/pytype/vm.py", line 917, in call_function_with_state
#     starstarargs=starstarargs), fallback_to_unsolvable, allow_noreturn=True)
#   File "/Users/name/.pyenv/versions/3.7.3/envs/venv/lib/python3.7/site-packages/pytype/vm.py", line 953, in call_function
#     new_node, one_result = func.call(node, funcv, args)
#   File "/Users/name/.pyenv/versions/3.7.3/envs/venv/lib/python3.7/site-packages/pytype/abstract.py", line 3247, in call
#     alias_map=self.alias_map)
#   File "/Users/name/.pyenv/versions/3.7.3/envs/venv/lib/python3.7/site-packages/pytype/abstract.py", line 3051, in call
#     node2, ret = self.vm.run_frame(frame, node)
#   File "/Users/name/.pyenv/versions/3.7.3/envs/venv/lib/python3.7/site-packages/pytype/vm.py", line 292, in run_frame
#     state = self.run_instruction(op, state)
#   File "/Users/name/.pyenv/versions/3.7.3/envs/venv/lib/python3.7/site-packages/pytype/vm.py", line 253, in run_instruction
#     state = bytecode_fn(state, op)
#   File "/Users/name/.pyenv/versions/3.7.3/envs/venv/lib/python3.7/site-packages/pytype/vm.py", line 1980, in byte_LOAD_ATTR
#     state, val = self.load_attr(state, obj, name)
#   File "/Users/name/.pyenv/versions/3.7.3/envs/venv/lib/python3.7/site-packages/pytype/vm.py", line 1224, in load_attr
#     node, result, errors = self._retrieve_attr(state.node, obj, attr)
#   File "/Users/name/.pyenv/versions/3.7.3/envs/venv/lib/python3.7/site-packages/pytype/vm.py", line 1195, in _retrieve_attr
#     node, val.data, attr, val)
#   File "/Users/name/.pyenv/versions/3.7.3/envs/venv/lib/python3.7/site-packages/pytype/attribute.py", line 65, in get_attribute
#     return self._get_instance_attribute(node, obj, name, valself)
#   File "/Users/name/.pyenv/versions/3.7.3/envs/venv/lib/python3.7/site-packages/pytype/attribute.py", line 234, in _get_instance_attribute
#     return self._get_attribute(node, obj, obj.cls, name, valself)
#   File "/Users/name/.pyenv/versions/3.7.3/envs/venv/lib/python3.7/site-packages/pytype/attribute.py", line 270, in _get_attribute
#     node, attr = self.get_attribute(node, cls, name, valself)
#   File "/Users/name/.pyenv/versions/3.7.3/envs/venv/lib/python3.7/site-packages/pytype/attribute.py", line 58, in get_attribute
#     return self._get_class_attribute(node, obj, name, valself)
#   File "/Users/name/.pyenv/versions/3.7.3/envs/venv/lib/python3.7/site-packages/pytype/attribute.py", line 229, in _get_class_attribute
#     return self._get_attribute(node, cls, meta, name, valself)
#   File "/Users/name/.pyenv/versions/3.7.3/envs/venv/lib/python3.7/site-packages/pytype/attribute.py", line 284, in _get_attribute
#     attr = self._filter_var(node, attr)
#   File "/Users/name/.pyenv/versions/3.7.3/envs/venv/lib/python3.7/site-packages/pytype/attribute.py", line 426, in _filter_var
#     bindings = var.Bindings(node, strict=False)
# AttributeError: 'LateAnnotation' object has no attribute 'Bindings'

# Fixed code
def decorate(self, node, cls):
    """Processes the attrib members of a class."""
    # Collect classvars to convert them to attrs.
    if self.args[cls]["auto_attribs"]:
        ordering = classgen.Ordering.FIRST_ANNOTATE
    else:
        ordering = classgen.Ordering.LAST_ASSIGN
    ordered_locals = self.get_class_locals(cls, allow_methods=False, ordering=ordering)
    own_attrs = []
    for name, (value, orig) in ordered_locals.items():
        if is_attrib(orig):
            if not is_attrib(value) and orig.data[0].has_type:
                # We cannot have both a type annotation and a type argument.
                self.vm.errorlog.invalid_annotation(self.vm.frames, value.data[0].cls)
                attr = Attribute(
                    name=name,
                    typ=self.vm.new_unsolvable(node),
                    init=orig.data[0].init,
                    default=orig.data[0].default,
                )
            else:
                if is_attrib(value):
                    # Replace the attrib in the class dict with its type.
                    attr = Attribute(
                        name=name,
                        typ=value.data[0].typ,
                        init=value.data[0].init,
                        default=value.data[0].default,
                    )
                    cls.members[name] = attr.typ
                else:
                    # cls.members[name] has already been set via a typecomment
                    attr = Attribute(
                        name=name,
                        typ=value,
                        init=orig.data[0].init,
                        default=orig.data[0].default,
                    )
            own_attrs.append(attr)
        elif self.args[cls]["auto_attribs"]:
            # TODO(b/72678203): typing.ClassVar is the only way to filter a variable
            # out from auto_attribs, but we don't even support importing it.
            attr = Attribute(name=name, typ=value, init=True, default=orig)
            cls.members[name] = value
            own_attrs.append(attr)

    base_attrs = self.get_base_class_attrs(cls, own_attrs, _ATTRS_METADATA_KEY)
    attrs = base_attrs + own_attrs
    # Stash attributes in class metadata for subclasses.
    cls.metadata[_ATTRS_METADATA_KEY] = attrs

    # Add an __init__ method
    if self.args[cls]["init"]:
        init_method = self.make_init(node, cls, attrs)
        cls.members["__init__"] = init_method