def main():
    """Remove unused imports Unsafe!

    Only tested on our codebase, which uses simple absolute imports on the form, "import
    a.b.c".

    """
    parser = argparse.ArgumentParser(
        description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
    )
    parser.add_argument("path", nargs="+", help="File or directory path")
    parser.add_argument("--exclude", nargs="+", help="Exclude glob patterns")
    parser.add_argument(
        "--no-recursive",
        dest="recursive",
        action="store_false",
        help="Search directories recursively",
    )
    parser.add_argument(
        "--ignore-invalid", action="store_true", help="Ignore invalid paths"
    )
    parser.add_argument(
        "--pycharm", action="store_true", help="Enable PyCharm integration"
    )
    parser.add_argument(
        "--diff",
        dest="show_diff",
        action="store_true",
        help="Show diff and do not modify any files",
    )
    parser.add_argument(
        "--dry-run", action="store_true", help="Process files but do not write results"
    )
    parser.add_argument("--debug", action="store_true", help="Debug level logging")

    args = parser.parse_args()
    d1_common.util.log_setup(args.debug)

    repo_path = d1_dev.util.find_repo_root_by_path(__file__)
    repo = git.Repo(repo_path)

    specified_file_path_list = get_specified_file_path_list(args)
    # tracked_path_list = list(d1_dev.util.get_tracked_files(repo))
    # format_path_list = sorted(
    #     set(specified_file_path_list).intersection(tracked_path_list)
    # )
    format_path_list = specified_file_path_list
    for format_path in format_path_list:
        comment_unused_imports(args, format_path)
def main ( ) : parser = argparse . ArgumentParser ( description = __doc__ , formatter_class = argparse . RawDescriptionHelpFormatter ) parser . add_argument ( "path" , nargs = "+" , help = "File or directory path" ) parser . add_argument ( "--exclude" , nargs = "+" , help = "Exclude glob patterns" ) parser . add_argument ( "--no-recursive" , dest = "recursive" , action = "store_false" , help = "Search directories recursively" , ) parser . add_argument ( "--ignore-invalid" , action = "store_true" , help = "Ignore invalid paths" ) parser . add_argument ( "--pycharm" , action = "store_true" , help = "Enable PyCharm integration" ) parser . add_argument ( "--diff" , dest = "show_diff" , action = "store_true" , help = "Show diff and do not modify any files" , ) parser . add_argument ( "--dry-run" , action = "store_true" , help = "Process files but do not write results" ) parser . add_argument ( "--debug" , action = "store_true" , help = "Debug level logging" ) args = parser . parse_args ( ) d1_common . util . log_setup ( args . debug ) repo_path = d1_dev . util . find_repo_root_by_path ( __file__ ) repo = git . Repo ( repo_path ) specified_file_path_list = get_specified_file_path_list ( args ) format_path_list = specified_file_path_list for format_path in format_path_list : comment_unused_imports ( args , format_path )
Remove unused imports Unsafe!

    Only tested on our codebase, which uses simple absolute imports on the form, "import
    a.b.c".