Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Use pre-commit from `.pyz` executable (#1045)

Dhruv Bhanushalid93237ce8509
diff --git a/.gitignore b/.gitignore
index 34f3ae3d9..874ec62f6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -109,6 +109,9 @@ venv.bak/
# mkdocs documentation
/site
+# Lint
+pre-commit.pyz
+
# mypy
.mypy_cache/
diff --git a/api/Pipfile b/api/Pipfile
index 24c5aa17e..6d524bcd2 100644
--- a/api/Pipfile
+++ b/api/Pipfile
@@ -10,7 +10,6 @@ furo = "~=2022.9"
ipython = "~=8.7"
myst-parser = "~=0.18"
openapi-spec-validator = "~=0.5"
-pre-commit = "~=2.20"
pycodestyle = "~=2.10"
pytest = "~=7.1"
pytest-django = "~=4.5"
diff --git a/api/Pipfile.lock b/api/Pipfile.lock
index 9eb73c0f0..83312c7b6 100644
--- a/api/Pipfile.lock
+++ b/api/Pipfile.lock
@@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
- "sha256": "9cf1b1dd4f7b74b6c711f7508836782b3259903eea10669c5ab8144ab36eee4e"
+ "sha256": "9777026074f3fe739971d6d1fd6f21932f03657e5aaa4db5ffb574004d196acc"
},
"pipfile-spec": 6,
"requires": {
@@ -151,19 +151,19 @@
},
"boto3": {
"hashes": [
- "sha256:2e5e80daae3873185b046d1fabc13676aea519e891faf4f27ca71d287bc26039",
- "sha256:4fb4a0ce2679e5dc1719441192b45687654201d5de76224f2c376b689c9ed4aa"
+ "sha256:4cef9ebc9c15fd0abd5097d6fa2676a8785c7b80d3e9242a783480b6192df2ea",
+ "sha256:5a37503ad456a6beae2740d2367c0a514b07ef0e134cdcc2b77cc8481832751b"
],
"index": "pypi",
- "version": "==1.26.29"
+ "version": "==1.26.31"
},
"botocore": {
"hashes": [
- "sha256:97a6d059e688ff9caa7c0a4e30cc58fa27be8bf3347578ce7c62fb808380fb55",
- "sha256:dca2daf108aae6c847d8ec99b7e918b46ae81713bf70b2199ab94627faf935a1"
+ "sha256:2e3cacf13d0997fd931e3a3f7d819bf200df8dcc74609a027ebc9dff2c0980d7",
+ "sha256:2ef360b7323f94128943a40297e457832384141577ded0b807e6d6a794fba636"
],
"markers": "python_version >= '3.7'",
- "version": "==1.29.29"
+ "version": "==1.29.31"
},
"certifi": {
"hashes": [
@@ -247,7 +247,7 @@
"sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845",
"sha256:83e9a75d1911279afd89352c68b45348559d1fc0506b054b346651b5e7fee29f"
],
- "markers": "python_version >= '3.6'",
+ "markers": "python_full_version >= '3.6.0'",
"version": "==2.1.1"
},
"coreapi": {
@@ -1004,7 +1004,7 @@
"sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86",
"sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"
],
- "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'",
+ "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==2.8.2"
},
"python-decouple": {
@@ -1121,7 +1121,7 @@
"sha256:f01da5790e95815eb5a8a138508c01c758e5f5bc0ce4286c4f7028b8dd7ac3d0",
"sha256:f34019dced51047d6f70cb9383b2ae2853b7fc4dce65129a5acd49f4f9256646"
],
- "markers": "platform_python_implementation == 'CPython' and python_version < '3.11'",
+ "markers": "python_version < '3.11' and platform_python_implementation == 'CPython'",
"version": "==0.2.7"
},
"s3transfer": {
@@ -1134,11 +1134,11 @@
},
"sentry-sdk": {
"hashes": [
- "sha256:675f6279b6bb1fea09fd61751061f9a90dca3b5929ef631dd50dc8b3aeb245e9",
- "sha256:8b4ff696c0bdcceb3f70bbb87a57ba84fd3168b1332d493fcd16c137f709578c"
+ "sha256:3c9bc64025976842c1103cd75d45cff94a7c0cc48fa07770d07a09d2ab8dac30",
+ "sha256:dc0fe6ef2f77a3853b399c75c97d87be7666098817c1c314f8fcdf68a6865914"
],
"index": "pypi",
- "version": "==1.11.1"
+ "version": "==1.12.0"
},
"setuptools": {
"hashes": [
@@ -1153,7 +1153,7 @@
"sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926",
"sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"
],
- "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'",
+ "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==1.16.0"
},
"sqlparse": {
@@ -1200,7 +1200,7 @@
"sha256:73aae30359291c14fa3b956f8b5ca31960e420c28c1bec002547fb04928cf89b",
"sha256:b64ef5141be559cfade448f044fa45c2260351edcb6a8ef6b7e00c7dcef0c323"
],
- "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'",
+ "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==1.8.7"
},
"wrapt": {
@@ -1363,10 +1363,10 @@
},
"zope.event": {
"hashes": [
- "sha256:2666401939cdaa5f4e0c08cf7f20c9b21423b95e88f4675b1443973bdb080c42",
- "sha256:5e76517f5b9b119acf37ca8819781db6c16ea433f7e2062c4afc2b6fbedb1330"
+ "sha256:73d9e3ef750cca14816a9c322c7250b0d7c9dbc337df5d1b807ff8d3d0b9e97c",
+ "sha256:81d98813046fc86cc4136e3698fee628a3282f9c320db18658c21749235fce80"
],
- "version": "==4.5.0"
+ "version": "==4.6"
},
"zope.interface": {
"hashes": [
@@ -1419,6 +1419,14 @@
],
"version": "==0.7.12"
},
+ "appnope": {
+ "hashes": [
+ "sha256:02bd91c4de869fbb1e1c50aafc4098827a7a54ab2f39d9dcba6c9547ed920e24",
+ "sha256:265a455292d0bd8a72453494fa24df5a11eb18373a60c7c0430889f22548605e"
+ ],
+ "markers": "sys_platform == 'darwin'",
+ "version": "==0.1.3"
+ },
"asttokens": {
"hashes": [
"sha256:4622110b2a6f30b77e1473affaa97e711bc2f07d3f10848420ff1898edbe94f3",
@@ -1462,7 +1470,7 @@
"sha256:58d5c3d29f5a36ffeb94f02f0d786cd53014cf9b3b3951d42e0080d8a9498d30",
"sha256:ad9aa55b65ef2808eb405f46cf74df7fcb7044d5cbc26487f96eb2ef2e436693"
],
- "markers": "python_version >= '3.6'",
+ "markers": "python_full_version >= '3.6.0'",
"version": "==4.11.1"
},
"certifi": {
@@ -1473,20 +1481,12 @@
"markers": "python_version >= '3.6'",
"version": "==2022.12.7"
},
- "cfgv": {
- "hashes": [
- "sha256:c6a0883f3917a037485059700b9e75da2464e6c27051014ad85ba6aaa5884426",
- "sha256:f5a830efb9ce7a445376bb66ec94c638a9787422f96264c98edc6bdeed8ab736"
- ],
- "markers": "python_full_version >= '3.6.1'",
- "version": "==3.3.1"
- },
"charset-normalizer": {
"hashes": [
"sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845",
"sha256:83e9a75d1911279afd89352c68b45348559d1fc0506b054b346651b5e7fee29f"
],
- "markers": "python_version >= '3.6'",
+ "markers": "python_full_version >= '3.6.0'",
"version": "==2.1.1"
},
"colorama": {
@@ -1505,13 +1505,6 @@
"markers": "python_version >= '3.5'",
"version": "==5.1.1"
},
- "distlib": {
- "hashes": [
- "sha256:14bad2d9b04d3a36127ac97f30b12a19268f211063d8f8ee4f47108896e11b46",
- "sha256:f35c4b692542ca110de7ef0bea44d73981caeb34ca0b9b6b2e6d7790dda8f80e"
- ],
- "version": "==0.3.6"
- },
"docutils": {
"hashes": [
"sha256:33995a6753c30b7f577febfc2c50411fec6aac7f7ffeb7c4cfe5991072dcf9e6",
@@ -1559,14 +1552,6 @@
"index": "pypi",
"version": "==1.10.1"
},
- "filelock": {
- "hashes": [
- "sha256:7565f628ea56bfcd8e54e42bdc55da899c85c1abfe1b5bcfd147e9188cebb3b2",
- "sha256:8df285554452285f79c035efb0c861eb33a4bcfa5b7a137016e32e6a90f9792c"
- ],
- "markers": "python_version >= '3.7'",
- "version": "==3.8.2"
- },
"furl": {
"hashes": [
"sha256:5a6188fe2666c484a12159c18be97a1977a71d632ef5bb867ef15f54af39cc4e",
@@ -1582,14 +1567,6 @@
"index": "pypi",
"version": "==2022.12.7"
},
- "identify": {
- "hashes": [
- "sha256:906036344ca769539610436e40a684e170c3648b552194980bb7b617a8daeb9f",
- "sha256:a390fb696e164dbddb047a0db26e57972ae52fbd037ae68797e5ae2f4492485d"
- ],
- "markers": "python_version >= '3.7'",
- "version": "==2.5.9"
- },
"idna": {
"hashes": [
"sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4",
@@ -1658,7 +1635,7 @@
"sha256:1e525177574c23ae0f55cd62382632a083a0339928f0ca846a975a4da9851cec",
"sha256:780a22d517cdc857d9714a80d8349c546945063f20853ea32ba7f85bc643ec7d"
],
- "markers": "python_version >= '3.7' and python_version < '4'",
+ "markers": "python_full_version >= '3.7.0' and python_full_version < '4.0.0'",
"version": "==0.1.2"
},
"lazy-object-proxy": {
@@ -1778,20 +1755,12 @@
"index": "pypi",
"version": "==0.18.1"
},
- "nodeenv": {
- "hashes": [
- "sha256:27083a7b96a25f2f5e1d8cb4b6317ee8aeda3bdd121394e5ac54e498028a042e",
- "sha256:e0e7f7dfb85fc5394c6fe1e8fa98131a2473e04311a45afb6508f7cf1836fa2b"
- ],
- "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6'",
- "version": "==1.7.0"
- },
"openapi-schema-validator": {
"hashes": [
"sha256:34fbd14b7501abe25e64d7b4624a9db02cde1a578d285b3da6f34b290cdf0b3a",
"sha256:7cf27585dd7970b7257cefe48e1a3a10d4e34421831bdb472d96967433bc27bd"
],
- "markers": "python_version >= '3.7' and python_version < '4'",
+ "markers": "python_full_version >= '3.7.0' and python_full_version < '4.0.0'",
"version": "==0.3.4"
},
"openapi-spec-validator": {
@@ -1830,7 +1799,7 @@
"sha256:5c869d315be50776cc8a993f3af43e0c60dc01506b399643f919034ebf4cdcab",
"sha256:cdd7b1f9d7d5c8b8d3315dbf5a86b2596053ae845f056f57d97c0eefff84da14"
],
- "markers": "python_version >= '3.7' and python_version < '4'",
+ "markers": "python_full_version >= '3.7.0' and python_full_version < '4.0.0'",
"version": "==0.4.3"
},
"pexpect": {
@@ -1848,14 +1817,6 @@
],
"version": "==0.7.5"
},
- "platformdirs": {
- "hashes": [
- "sha256:1a89a12377800c81983db6be069ec068eee989748799b946cce2a6e80dcc54ca",
- "sha256:b46ffafa316e6b83b47489d240ce17173f123a9b9c83282141c3daf26ad9ac2e"
- ],
- "markers": "python_version >= '3.7'",
- "version": "==2.6.0"
- },
"pluggy": {
"hashes": [
"sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159",
@@ -1873,14 +1834,6 @@
"index": "pypi",
"version": "==1.0.2"
},
- "pre-commit": {
- "hashes": [
- "sha256:51a5ba7c480ae8072ecdb6933df22d2f812dc897d5fe848778116129a681aac7",
- "sha256:a978dac7bc9ec0bcee55c18a277d553b0f419d259dadb4b9418ff2d00eb43959"
- ],
- "index": "pypi",
- "version": "==2.20.0"
- },
"prompt-toolkit": {
"hashes": [
"sha256:3e163f254bef5a03b146397d7c1963bd3e2812f0964bb9a24e6ec761fd28db63",
@@ -1976,7 +1929,7 @@
"sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86",
"sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"
],
- "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'",
+ "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==2.8.2"
},
"pytz": {
@@ -2056,20 +2009,12 @@
"markers": "python_version >= '3.7' and python_version < '4'",
"version": "==2.28.1"
},
- "setuptools": {
- "hashes": [
- "sha256:57f6f22bde4e042978bcd50176fdb381d7c21a9efa4041202288d3737a0c6a54",
- "sha256:a7620757bf984b58deaf32fc8a4577a9bbc0850cf92c20e1ce41c38c19e5fb75"
- ],
- "markers": "python_version >= '3.7'",
- "version": "==65.6.3"
- },
"six": {
"hashes": [
"sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926",
"sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"
],
- "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'",
+ "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==1.16.0"
},
"snowballstemmer": {
@@ -2173,14 +2118,6 @@
],
"version": "==0.6.2"
},
- "toml": {
- "hashes": [
- "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b",
- "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"
- ],
- "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2'",
- "version": "==0.10.2"
- },
"tomli": {
"hashes": [
"sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc",
@@ -2230,14 +2167,6 @@
"markers": "python_version >= '3.6'",
"version": "==1.26.13"
},
- "virtualenv": {
- "hashes": [
- "sha256:ce3b1684d6e1a20a3e5ed36795a97dfc6af29bc3970ca8dab93e11ac6094b3c4",
- "sha256:f8b927684efc6f1cc206c9db297a570ab9ad0e51c16fa9e45487d36d1905c058"
- ],
- "markers": "python_version >= '3.6'",
- "version": "==20.17.1"
- },
"wcwidth": {
"hashes": [
"sha256:beb4802a9cebb9144e99086eff703a642a13d6a0052920003a230f3294bbe784",
diff --git a/justfile b/justfile
index da5f17644..747a9aa61 100644
--- a/justfile
+++ b/justfile
@@ -102,11 +102,24 @@ init: _api-up
# Setup pre-commit as a Git hook
precommit:
- cd api && pipenv run pre-commit install
+ #!/usr/bin/env bash
+ set -eo pipefail
+ if [ -z "$SKIP_PRE_COMMIT" ] && [ ! -f ./pre-commit.pyz ]; then
+ echo "Downloading pre-commit";
+ curl \
+ https://api.github.com/repos/pre-commit/pre-commit/releases/latest \
+ | grep -o 'https://.*\.pyz' -m 1 \
+ | xargs \
+ | xargs curl -fsJo pre-commit.pyz -L;
+ echo "Installing pre-commit";
+ python3 pre-commit.pyz install -t pre-push -t pre-commit;
+ else
+ echo "Skipping pre-commit installation";
+ fi
# Run pre-commit to lint and reformat all files
lint:
- cd api && pipenv run pre-commit run --all-files
+ python3 pre-commit.pyz run --all-files
# Make locally trusted certificates
cert: