# Buggy code
def visit_file(self, file_node: MypyFile, path: str, options: Options) -> None:
    """Type check a mypy file with the given path."""
    self.options = options
    self.pass_num = 0
    self.is_stub = file_node.is_stub
    self.errors.set_file(path)
    self.globals = file_node.names
    self.enter_partial_types()
    self.is_typeshed_stub = self.errors.is_typeshed_file(path)
    self.module_type_map = {}
    self.module_refs = set()
    if self.options.strict_optional_whitelist is None:
        self.suppress_none_errors = not self.options.show_none_errors
    else:
        self.suppress_none_errors = not any(
            fnmatch.fnmatch(path, pattern)
            for pattern in self.options.strict_optional_whitelist
        )

    for d in file_node.defs:
        self.accept(d)

    self.leave_partial_types()

    if self.deferred_nodes:
        self.check_second_pass()

    self.current_node_deferred = False

    all_ = self.globals.get("__all__")
    if all_ is not None and all_.type is not None:
        seq_str = self.named_generic_type(
            "typing.Sequence", [self.named_type("builtins.str")]
        )
        if not is_subtype(all_.type, seq_str):
            str_seq_s, all_s = self.msg.format_distinctly(seq_str, all_.type)
            self.fail(messages.ALL_MUST_BE_SEQ_STR.format(str_seq_s, all_s), all_.node)

    del self.options


# 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_file(self, file_node: MypyFile, path: str, options: Options) -> None:
    """Type check a mypy file with the given path."""
    self.options = options
    self.pass_num = 0
    self.is_stub = file_node.is_stub
    self.errors.set_file(path)
    self.globals = file_node.names
    self.enter_partial_types()
    self.is_typeshed_stub = self.errors.is_typeshed_file(path)
    self.module_type_map = {}
    self.module_refs = set()
    if self.options.strict_optional_whitelist is None:
        self.suppress_none_errors = not self.options.show_none_errors
    else:
        self.suppress_none_errors = not any(
            fnmatch.fnmatch(path, pattern)
            for pattern in self.options.strict_optional_whitelist
        )

    with self.binder.top_frame_context():
        for d in file_node.defs:
            self.accept(d)

    self.leave_partial_types()

    if self.deferred_nodes:
        self.check_second_pass()

    self.current_node_deferred = False

    all_ = self.globals.get("__all__")
    if all_ is not None and all_.type is not None:
        seq_str = self.named_generic_type(
            "typing.Sequence", [self.named_type("builtins.str")]
        )
        if not is_subtype(all_.type, seq_str):
            str_seq_s, all_s = self.msg.format_distinctly(seq_str, all_.type)
            self.fail(messages.ALL_MUST_BE_SEQ_STR.format(str_seq_s, all_s), all_.node)

    del self.options