(ctx, check, fix)
Validate spelling in the source code.

    If `check` is specified, only the directory is validated.
    Use codespell command line tool to detect spelling errors.
Validate spelling in the source code.
Validate spelling in the source code .
def typos(ctx, check, fix):
    """Validate spelling in the source code.

    If `check` is specified, only the directory is validated.
    Use codespell command line tool to detect spelling errors.
    """
    root = get_root()

    if check:
        path = os.path.join(root, check)
    else:
        path = root

    cmd = f"codespell {path} --config={root}/.codespell/setup.cfg"

    if fix:
        cmd += " -w"

    try:
        output, err, code = run_command(cmd, capture=True)
        if code == 0:
            echo_success("All files are valid!")
            abort()
        annotate_typos(output)
    except Exception as e:
        echo_info(f"Encountered error validating spell check: {e}")
def typos ( ctx , check , fix ) : root = get_root ( ) if check : path = os . path . join ( root , check ) else : path = root cmd = f"codespell {path} --config={root}/.codespell/setup.cfg" if fix : cmd += " -w" try : output , err , code = run_command ( cmd , capture = True ) if code == 0 : echo_success ( "All files are valid!" ) abort ( ) annotate_typos ( output ) except Exception as e : echo_info ( f"Encountered error validating spell check: {e}" )