From 60b1c93b89ba15d4dc54aad0c6acc6c4aeb67265 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Fri, 20 Dec 2024 14:32:03 +0200 Subject: [PATCH] Centralize Python linter/formatter requirements These are currently duplicated all over the codebase, often with mismatched constraints. Put them all in one requirements file instead. Fix a few minor issues while I'm at it: * Constrain black to the current major version to avoid New Year surprises (black can change styles between major versions). Constrain isort too, just in case. * Remove usages of `egrep`, which is deprecated (and unnecessary here). --- .github/workflows/black.yml | 2 +- .github/workflows/isort.yml | 2 +- .github/workflows/pylint.yml | 6 ++-- cvat-cli/requirements/development.txt | 5 --- cvat-sdk/gen/requirements.txt | 1 - cvat/requirements/all.txt | 2 -- cvat/requirements/development.in | 4 --- cvat/requirements/development.txt | 44 ++------------------------- cvat/requirements/testing.txt | 2 -- dev/requirements.txt | 5 +++ site/requirements.txt | 1 - 11 files changed, 12 insertions(+), 62 deletions(-) delete mode 100644 cvat-cli/requirements/development.txt create mode 100644 dev/requirements.txt diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml index a74f70c54379..a86f236f49d7 100644 --- a/.github/workflows/black.yml +++ b/.github/workflows/black.yml @@ -8,7 +8,7 @@ jobs: - name: Run checks run: | - pipx install $(grep "^black" ./cvat-cli/requirements/development.txt) + pipx install $(grep "^black" ./dev/requirements.txt) echo "Black version: $(black --version)" diff --git a/.github/workflows/isort.yml b/.github/workflows/isort.yml index 19332d917030..bf90604cbb2f 100644 --- a/.github/workflows/isort.yml +++ b/.github/workflows/isort.yml @@ -25,7 +25,7 @@ jobs: UPDATED_DIRS="${{steps.files.outputs.all_changed_files}}" if [[ ! -z $UPDATED_DIRS ]]; then - pipx install $(egrep "isort.*" ./cvat-cli/requirements/development.txt) + pipx install $(grep "^isort" ./dev/requirements.txt) echo "isort version: $(isort --version-number)" echo "The dirs will be checked: $UPDATED_DIRS" diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index d808a823771f..05237f441988 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -19,11 +19,11 @@ jobs: CHANGED_FILES="${{steps.files.outputs.all_changed_files}}" if [[ ! -z $CHANGED_FILES ]]; then - pipx install $(egrep "^pylint==" ./cvat/requirements/development.txt) + pipx install $(grep "^pylint==" ./dev/requirements.txt) pipx inject pylint \ - $(egrep "^pylint-.+==" ./cvat/requirements/development.txt) \ - $(egrep "^django==" ./cvat/requirements/base.txt) + $(grep "^pylint-.\+==" ./dev/requirements.txt) \ + $(grep "^django==" ./cvat/requirements/base.txt) echo "Pylint version: "$(pylint --version | head -1) echo "The files will be checked: "$(echo $CHANGED_FILES) diff --git a/cvat-cli/requirements/development.txt b/cvat-cli/requirements/development.txt deleted file mode 100644 index 42a144087213..000000000000 --- a/cvat-cli/requirements/development.txt +++ /dev/null @@ -1,5 +0,0 @@ --r base.txt - -black>=24.1 -isort>=5.10.1 -pylint>=2.7.0 \ No newline at end of file diff --git a/cvat-sdk/gen/requirements.txt b/cvat-sdk/gen/requirements.txt index 18f397e59dc6..54c28f0b0007 100644 --- a/cvat-sdk/gen/requirements.txt +++ b/cvat-sdk/gen/requirements.txt @@ -1,5 +1,4 @@ # can't have a dependency on base.txt, because it depends on the generated file inflection >= 0.5.1 -isort>=5.10.1 ruamel.yaml>=0.17.21 diff --git a/cvat/requirements/all.txt b/cvat/requirements/all.txt index 4e05dcc9e85f..482db32ecf87 100644 --- a/cvat/requirements/all.txt +++ b/cvat/requirements/all.txt @@ -8,5 +8,3 @@ -r development.txt -r production.txt -r testing.txt - -# The following packages are considered to be unsafe in a requirements file: diff --git a/cvat/requirements/development.in b/cvat/requirements/development.in index ad5a5b6557ec..9c5e0662b52d 100644 --- a/cvat/requirements/development.in +++ b/cvat/requirements/development.in @@ -1,10 +1,6 @@ -r base.in -black>=24.1 django-extensions==3.0.8 django-silk==5.* -pylint-django==2.5.3 -pylint-plugin-utils==0.7 -pylint==2.14.5 rope==0.17.0 snakeviz==2.1.0 diff --git a/cvat/requirements/development.txt b/cvat/requirements/development.txt index b0c563374067..cc730b7916eb 100644 --- a/cvat/requirements/development.txt +++ b/cvat/requirements/development.txt @@ -1,4 +1,4 @@ -# SHA1:b71f4fe955f645187b7ccdf82b05f6a8d61eb3ab +# SHA1:cd8d0825dc4cfe37b22a489422105acba5483fe4 # # This file is autogenerated by pip-compile-multi # To update, run: @@ -6,61 +6,21 @@ # pip-compile-multi # -r base.txt -astroid==2.11.7 - # via pylint autopep8==2.3.1 # via django-silk -black==24.10.0 - # via -r cvat/requirements/development.in -dill==0.3.9 - # via pylint django-extensions==3.0.8 # via -r cvat/requirements/development.in django-silk==5.3.2 # via -r cvat/requirements/development.in gprof2dot==2024.6.6 # via django-silk -isort==5.13.2 - # via pylint -lazy-object-proxy==1.10.0 - # via astroid -mccabe==0.7.0 - # via pylint -mypy-extensions==1.0.0 - # via black -pathspec==0.12.1 - # via black -platformdirs==4.3.6 - # via - # black - # pylint pycodestyle==2.12.1 # via autopep8 -pylint==2.14.5 - # via - # -r cvat/requirements/development.in - # pylint-django - # pylint-plugin-utils -pylint-django==2.5.3 - # via -r cvat/requirements/development.in -pylint-plugin-utils==0.7 - # via - # -r cvat/requirements/development.in - # pylint-django rope==0.17.0 # via -r cvat/requirements/development.in snakeviz==2.1.0 # via -r cvat/requirements/development.in tomli==2.2.1 - # via - # autopep8 - # black - # pylint -tomlkit==0.13.2 - # via pylint + # via autopep8 tornado==6.4.2 # via snakeviz - -# The following packages are considered to be unsafe in a requirements file: -setuptools==75.6.0 - # via astroid diff --git a/cvat/requirements/testing.txt b/cvat/requirements/testing.txt index 90c8a13254c0..86ab66664526 100644 --- a/cvat/requirements/testing.txt +++ b/cvat/requirements/testing.txt @@ -14,5 +14,3 @@ lupa==1.14.1 # via fakeredis sortedcontainers==2.4.0 # via fakeredis - -# The following packages are considered to be unsafe in a requirements file: diff --git a/dev/requirements.txt b/dev/requirements.txt new file mode 100644 index 000000000000..4603689ae469 --- /dev/null +++ b/dev/requirements.txt @@ -0,0 +1,5 @@ +black==24.* +isort==5.* +pylint-django==2.5.3 +pylint-plugin-utils==0.7 +pylint==2.14.5 diff --git a/site/requirements.txt b/site/requirements.txt index e240c7a0f90e..10db0c33a9b0 100644 --- a/site/requirements.txt +++ b/site/requirements.txt @@ -1,5 +1,4 @@ gitpython inflection >= 0.5.1 -isort>=5.10.1 packaging toml