Repository: Project-MONAI/MONAI
File: runtests.sh (Shell)

Code before:
    then
        print_style_fail_msg
        exit ${pylint_status}
    else
        echo "${green}passed!${noColor}"
    fi
    set -e # enable exit on failure
fi


if [ $doRuffFormat = true ]
then
    set +e  # disable exit on failure so that diagnostics can be given on failure
    if [ $doRuffFix = true ]
    then
        echo "${separator}${blue}ruff-fix${noColor}"
    else
        echo "${separator}${blue}ruff${noColor}"
    fi

    # ensure that the necessary packages for code format testing are installed
    if ! is_pip_installed ruff
    then
        install_deps
    fi
    ${cmdPrefix}${PY_EXE} -m ruff --version

    if [ $doRuffFix = true ]
    then
        ${cmdPrefix}${PY_EXE} -m ruff check --fix "$(pwd)"
    else
        ${cmdPrefix}${PY_EXE} -m ruff check "$(pwd)"
    fi

    ruff_status=$?
    if [ ${ruff_status} -ne 0 ]
    then
        print_style_fail_msg
        exit ${ruff_status}
    else
        echo "${green}passed!${noColor}"
    fi
    set -e # enable exit on failure
fi


if [ $doPytypeFormat = true ]
then
    set +e  # disable exit on failure so that diagnostics can be given on failure
    echo "${separator}${blue}pytype${noColor}"
    # ensure that the necessary packages for code format testing are installed

Review comment (bug):
getting error messages:
```
[2023-08-04T20:22:14.894Z] ruff
[2023-08-04T20:22:14.894Z] Traceback (most recent call last):
[2023-08-04T20:22:14.894Z]   File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
[2023-08-04T20:22:14.894Z]     return _run_code(code, main_globals, None,
[2023-08-04T20:22:14.894Z]   File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
[2023-08-04T20:22:14.894Z]     exec(code, run_globals)
[2023-08-04T20:22:14.894Z]   File "/usr/local/lib/python3.8/dist-packages/ruff/__main__.py", line 34, in <module>
[2023-08-04T20:22:14.894Z]     ruff = find_ruff_bin()
[2023-08-04T20:22:14.894Z]   File "/usr/local/lib/python3.8/dist-packages/ruff/__main__.py", line 30, in find_ruff_bin
[2023-08-04T20:22:14.894Z]     raise FileNotFoundError(path)
[2023-08-04T20:22:14.894Z] FileNotFoundError: /root/.local/bin/ruff
[2023-08-04T20:22:14.894Z] Traceback (most recent call last):
[2023-08-04T20:22:14.894Z]   File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
[2023-08-04T20:22:14.894Z]     return _run_code(code, main_globals, None,
[2023-08-04T20:22:14.894Z]   File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
[2023-08-04T20:22:14.894Z]     exec(code, run_globals)
[2023-08-04T20:22:14.894Z]   File "/usr/local/lib/python3.8/dist-packages/ruff/__main__.py", line 34, in <module>
[2023-08-04T20:22:14.894Z]     ruff = find_ruff_bin()
[2023-08-04T20:22:14.894Z]   File "/usr/local/lib/python3.8/dist-packages/ruff/__main__.py", line 30, in find_ruff_bin
[2023-08-04T20:22:14.894Z]     raise FileNotFoundError(path)
[2023-08-04T20:22:14.894Z] FileNotFoundError: /root/.local/bin/ruff
[2023-08-04T20:22:14.894Z] Check failed!
```
I'll try to use `ruff` directly as per suggested https://github.com/astral-sh/ruff/issues/2520#issuecomment-1416102075

Code after:
    then
        print_style_fail_msg
        exit ${pylint_status}
    else
        echo "${green}passed!${noColor}"
    fi
    set -e # enable exit on failure
fi


if [ $doRuffFormat = true ]
then
    set +e  # disable exit on failure so that diagnostics can be given on failure
    if [ $doRuffFix = true ]
    then
        echo "${separator}${blue}ruff-fix${noColor}"
    else
        echo "${separator}${blue}ruff${noColor}"
    fi

    # ensure that the necessary packages for code format testing are installed
    if ! is_pip_installed ruff
    then
        install_deps
    fi
    ruff --version

    if [ $doRuffFix = true ]
    then
        ruff check --fix "$(pwd)"
    else
        ruff check "$(pwd)"
    fi

    ruff_status=$?
    if [ ${ruff_status} -ne 0 ]
    then
        print_style_fail_msg
        exit ${ruff_status}
    else
        echo "${green}passed!${noColor}"
    fi
    set -e # enable exit on failure
fi


if [ $doPytypeFormat = true ]
then
    set +e  # disable exit on failure so that diagnostics can be given on failure
    echo "${separator}${blue}pytype${noColor}"
    # ensure that the necessary packages for code format testing are installed