# Buggy code
def visit_Attribute(self, n: ast35.Attribute) -> Type:
    before_dot = self.visit(n.value)

    assert isinstance(before_dot, UnboundType)
    assert not before_dot.args

    return UnboundType("{}.{}".format(before_dot.name, n.attr), line=self.line)


# Traceback (AssertionError)
Traceback (most recent call last):
File "/usr/local/bin/mypy", line 6, in <module>
main(__file__)
File "/usr/local/lib/python3.4/dist-packages/mypy/main.py", line 42, in main
res = type_check_only(sources, bin_dir, options)
File "/usr/local/lib/python3.4/dist-packages/mypy/main.py", line 86, in type_check_only
options=options)
File "/usr/local/lib/python3.4/dist-packages/mypy/build.py", line 183, in build
dispatch(sources, manager)
File "/usr/local/lib/python3.4/dist-packages/mypy/build.py", line 1523, in dispatch
graph = load_graph(sources, manager)
File "/usr/local/lib/python3.4/dist-packages/mypy/build.py", line 1605, in load_graph
root_source=True)
File "/usr/local/lib/python3.4/dist-packages/mypy/build.py", line 1212, in __init__
self.parse_file()
File "/usr/local/lib/python3.4/dist-packages/mypy/build.py", line 1376, in parse_file
self.ignore_all or self.options.ignore_errors)
File "/usr/lib/python3.4/contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/local/lib/python3.4/dist-packages/mypy/build.py", line 1293, in wrap_context
yield
File "/usr/local/lib/python3.4/dist-packages/mypy/build.py", line 1376, in parse_file
self.ignore_all or self.options.ignore_errors)
File "/usr/local/lib/python3.4/dist-packages/mypy/build.py", line 462, in parse_file
tree = parse(source, path, self.errors, options=self.options)
File "/usr/local/lib/python3.4/dist-packages/mypy/parse.py", line 96, in parse
custom_typing_module=options.custom_typing_module)
File "/usr/local/lib/python3.4/dist-packages/mypy/fastparse.py", line 74, in parse
).visit(ast)
File "/usr/local/lib/python3.4/dist-packages/typed_ast-0.6.3-py3.4-linux-x86_64.egg/typed_ast/ast35.py", line 256, in visit
return visitor(node)
File "/usr/local/lib/python3.4/dist-packages/mypy/fastparse.py", line 257, in visit_Module
body = self.fix_function_overloads(self.translate_stmt_list(mod.body))
File "/usr/local/lib/python3.4/dist-packages/mypy/fastparse.py", line 157, in translate_stmt_list
stmt = self.visit(e)
File "/usr/local/lib/python3.4/dist-packages/typed_ast-0.6.3-py3.4-linux-x86_64.egg/typed_ast/ast35.py", line 256, in visit
return visitor(node)
File "/usr/local/lib/python3.4/dist-packages/mypy/fastparse.py", line 101, in wrapper
node = f(self, ast)
File "/usr/local/lib/python3.4/dist-packages/mypy/fastparse.py", line 502, in visit_Assign
typ = TypeConverter(self.errors, line=n.lineno).visit(n.annotation)  # type: ignore
File "/usr/local/lib/python3.4/dist-packages/typed_ast-0.6.3-py3.4-linux-x86_64.egg/typed_ast/ast35.py", line 256, in visit
return visitor(node)
File "/usr/local/lib/python3.4/dist-packages/mypy/fastparse.py", line 968, in visit_Subscript
params = [self.visit(n.slice.value)]
File "/usr/local/lib/python3.4/dist-packages/typed_ast-0.6.3-py3.4-linux-x86_64.egg/typed_ast/ast35.py", line 256, in visit
return visitor(node)
File "/usr/local/lib/python3.4/dist-packages/mypy/fastparse.py", line 979, in visit_Attribute
assert isinstance(before_dot, UnboundType)
AssertionError:

# Fixed code
def visit_Attribute(self, n: ast35.Attribute) -> Type:
    before_dot = self.visit(n.value)

    if isinstance(before_dot, UnboundType) and not before_dot.args:
        return UnboundType("{}.{}".format(before_dot.name, n.attr), line=self.line)
    else:
        self.fail(TYPE_COMMENT_AST_ERROR, self.line, getattr(n, "col_offset", -1))
        return AnyType()