-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply isort to almost all Python sources (#8866)
isort has a `--resolve-all-configs` options that allows you to use different configs for different subdirectories. With this option, we can reformat/check the whole codebase with one command. So let's just do that. It's a little janky, because isort's first party module detection doesn't seem to work properly when you run it from the project root and not the appropriate subdirectory. So I had to patch that up with explicit `known_first_party` settings. I also didn't feel like doing that for all of the serverless functions, so I just added them to the ignore list for now.
- Loading branch information
Showing
173 changed files
with
951 additions
and
637 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,35 +5,11 @@ jobs: | |
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- id: files | ||
uses: tj-actions/[email protected] | ||
with: | ||
files: | | ||
cvat-sdk/**/*.py | ||
cvat-cli/**/*.py | ||
tests/python/**/*.py | ||
cvat/apps/quality_control/**/*.py | ||
cvat/apps/analytics_report/**/*.py | ||
dir_names: true | ||
|
||
- name: Run checks | ||
run: | | ||
# If different modules use different isort configs, | ||
# we need to run isort for each python component group separately. | ||
# Otherwise, they all will use the same config. | ||
pipx install $(grep "^isort" ./dev/requirements.txt) | ||
UPDATED_DIRS="${{steps.files.outputs.all_changed_files}}" | ||
echo "isort version: $(isort --version-number)" | ||
if [[ ! -z $UPDATED_DIRS ]]; then | ||
pipx install $(grep "^isort" ./dev/requirements.txt) | ||
echo "isort version: $(isort --version-number)" | ||
echo "The dirs will be checked: $UPDATED_DIRS" | ||
EXIT_CODE=0 | ||
for DIR in $UPDATED_DIRS; do | ||
isort --check $DIR || EXIT_CODE=$(($? | $EXIT_CODE)) || true | ||
done | ||
exit $EXIT_CODE | ||
else | ||
echo "No files with the \"py\" extension found" | ||
fi | ||
isort --check --diff --resolve-all-configs . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.