def lint(filename, options=()):
<EOL>full_path = osp.abspath(filename)<EOL>parent_path = osp.dirname(full_path)<EOL>child_path = osp.basename(full_path)<EOL>while parent_path != "<STR_LIT:/>" and osp.exists(osp.join(parent_path, "<STR_LIT>")):<EOL><INDENT>child_path = osp.join(osp.basename(parent_path), child_path)<EOL>parent_path = osp.dirname(parent_path)<EOL><DEDENT>run_cmd = "<STR_LIT>"<EOL>cmd = (<EOL>[sys.executable, "<STR_LIT:-c>", run_cmd]<EOL>+ [<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT:n>",<EOL>child_path,<EOL>]<EOL>+ list(options)<EOL>)<EOL>process = Popen(<EOL>cmd, stdout=PIPE, cwd=parent_path, env=_get_env(), universal_newlines=True<EOL>)<EOL>for line in process.stdout:<EOL><INDENT>if line.startswith("<STR_LIT>"):<EOL><INDENT>continue<EOL><DEDENT>parts = line.split("<STR_LIT::>")<EOL>if parts and parts[<NUM_LIT:0>] == child_path:<EOL><INDENT>line = "<STR_LIT::>".join([filename] + parts[<NUM_LIT:1>:])<EOL><DEDENT>print(line, end="<STR_LIT:U+0020>")<EOL><DEDENT>process.wait()<EOL>return process.returncode<EOL>
Pylint the given file.

    When run from emacs we will be in the directory of a file, and passed its
    filename.  If this file is part of a package and is trying to import other
    modules from within its own package or another package rooted in a directory
    below it, pylint will classify it as a failed import.

    To get around this, we traverse down the directory tree to find the root of
    the package this module is in.  We then invoke pylint from this directory.

    Finally, we must correct the filenames in the output generated by pylint so
    Emacs doesn't become confused (it will expect just the original filename,
    while pylint may extend it with extra directories if we've traversed down
    the tree)