# Buggy code
def visit_conditional_expr(self, e: ConditionalExpr) -> Type:
    cond_type = self.accept(e.cond)
    self.check_usable_type(cond_type, e)
    ctx = self.chk.type_context[-1]

    # Gain type information from isinstance if it is there
    # but only for the current expression
    if_map, else_map = mypy.checker.find_isinstance_check(e.cond, self.chk.type_map)

    if_type = self.analyze_cond_branch(if_map, e.if_expr, context=ctx)

    if not mypy.checker.is_valid_inferred_type(if_type):
        # Analyze the right branch disregarding the left branch.
        else_type = self.analyze_cond_branch(else_map, e.else_expr, context=ctx)

        # If it would make a difference, re-analyze the left
        # branch using the right branch's type as context.
        if ctx is None or not is_equivalent(else_type, ctx):
            # TODO: If it's possible that the previous analysis of
            # the left branch produced errors that are avoided
            # using this context, suppress those errors.
            if_type = self.analyze_cond_branch(if_map, e.if_expr, context=else_type)

    else:
        # Analyze the right branch in the context of the left
        # branch's type.
        else_type = self.analyze_cond_branch(else_map, e.else_expr, context=if_type)

    res = join.join_types(if_type, else_type)

    return res


# Traceback (AttributeError)
Traceback (most recent call last):
File "./scripts/mypy", line 6, in <module>
main(__file__)
File "mypy/mypy/main.py", line 50, in main
type_check_only(sources, bin_dir, options)
File "mypy/mypy/main.py", line 94, in type_check_only
python_path=options.python_path)
File "mypy/mypy/build.py", line 210, in build
result = manager.process(initial_states)
File "mypy/mypy/build.py", line 425, in process
next.process()
File "mypy/mypy/build.py", line 930, in process
self.type_checker().visit_file(self.tree, self.tree.path)
File "mypy/mypy/checker.py", line 409, in visit_file
self.accept(d)
File "mypy/mypy/checker.py", line 450, in accept
typ = node.accept(self)
File "mypy/mypy/nodes.py", line 707, in accept
return visitor.visit_try_stmt(self)
File "mypy/mypy/checker.py", line 1732, in visit_try_stmt
self.accept(s.else_body)
File "mypy/mypy/checker.py", line 450, in accept
typ = node.accept(self)
File "mypy/mypy/nodes.py", line 526, in accept
return visitor.visit_block(self)
File "mypy/mypy/checker.py", line 1113, in visit_block
self.accept(s)
File "mypy/mypy/checker.py", line 450, in accept
typ = node.accept(self)
File "mypy/mypy/nodes.py", line 382, in accept
return visitor.visit_func_def(self)
File "mypy/mypy/checker.py", line 594, in visit_func_def
'redefinition with type')
File "mypy/mypy/checker.py", line 2117, in check_subtype
if not is_subtype(subtype, supertype):
File "mypy/mypy/subtypes.py", line 49, in is_subtype
return left.accept(SubtypeVisitor(right, type_parameter_checker))
AttributeError: 'NoneType' object has no attribute 'accept'

# Fixed code
def visit_conditional_expr(self, e: ConditionalExpr) -> Type:
    cond_type = self.accept(e.cond)
    self.check_usable_type(cond_type, e)
    ctx = self.chk.type_context[-1]

    # Gain type information from isinstance if it is there
    # but only for the current expression
    if_map, else_map = self.chk.find_isinstance_check(e.cond)

    if_type = self.analyze_cond_branch(if_map, e.if_expr, context=ctx)

    if not mypy.checker.is_valid_inferred_type(if_type):
        # Analyze the right branch disregarding the left branch.
        else_type = self.analyze_cond_branch(else_map, e.else_expr, context=ctx)

        # If it would make a difference, re-analyze the left
        # branch using the right branch's type as context.
        if ctx is None or not is_equivalent(else_type, ctx):
            # TODO: If it's possible that the previous analysis of
            # the left branch produced errors that are avoided
            # using this context, suppress those errors.
            if_type = self.analyze_cond_branch(if_map, e.if_expr, context=else_type)

    else:
        # Analyze the right branch in the context of the left
        # branch's type.
        else_type = self.analyze_cond_branch(else_map, e.else_expr, context=if_type)

    res = join.join_types(if_type, else_type)

    return res