f9b7138b22
After #8611 and #8866, it's no longer necessary to apply the formatters to each module separately. So don't! In addition, update the black exclusion list in `pyproject.toml` to only contain files that were _not_ listed in `format_python_code.sh`. This way, formatting will automatically be enforced for all new files. For a few of the files reformatting only creates a small diff, so don't even bother excluding them - reformat them instead. Also, delete a few `pyproject.toml` files that are now redundant.
30 lines
936 B
Bash
Executable File
30 lines
936 B
Bash
Executable File
#! /bin/env bash
|
|
|
|
set -e
|
|
|
|
REPO_ROOT="$(dirname "$0")/.."
|
|
PYTHON="${PYTHON:-python3}"
|
|
BLACK="${PYTHON} -m black"
|
|
ISORT="${PYTHON} -m isort"
|
|
|
|
if ! ${BLACK} --version >/dev/null 2>&1; then
|
|
echo "black is not found, please check it is installed"
|
|
exit 1
|
|
fi
|
|
if ! ${ISORT} --version >/dev/null 2>&1; then
|
|
echo "isort is not found, please check it is installed"
|
|
exit 1
|
|
fi
|
|
|
|
cd -- "${REPO_ROOT}"
|
|
${BLACK} .
|
|
|
|
# isort is slow at skipping large Git-ignored directories when invoked as `isort .`,
|
|
# so pass it an explicit list of files instead.
|
|
|
|
# isort will only skip files listed in the config file corresponding to the first file
|
|
# on the command line, which would normally be cvat-cli/pyproject.toml. Force the first
|
|
# file to be manage.py, so that it uses `pyproject.toml` instead.
|
|
git ls-files -z --exclude-standard --deduplicate --cached --others '*.py' \
|
|
| xargs -0 ${ISORT} --resolve-all-configs --filter-files manage.py
|