From d89d7342816eb165223b8ff3e70b40bb53581446 Mon Sep 17 00:00:00 2001 From: Mawoka Date: Thu, 9 Jun 2022 17:12:39 +0200 Subject: [PATCH] :sparkles: Added pre-commit --- .flake8 | 2 +- .github/FUNDING.yml | 2 +- .github/ISSUE_TEMPLATE/Bug_report.md | 2 +- .github/ISSUE_TEMPLATE/Feature_request.md | 1 - .../Repo_architecture_changes.md | 1 - .github/workflows/frontend_lint.yml | 2 +- .github/workflows/pytest.yml | 2 +- .gitignore | 2 +- .pre-commit-config.yaml | 24 ++++ CONTRIBUTING.md | 2 +- Dockerfile | 2 +- Pipfile | 1 + Pipfile.lock | 124 ++++++++++++++++-- SocketIo.md | 2 +- classquiz/emails/templates/footer.jinja2 | 2 +- .../templates/forgotten_password.jinja2 | 2 +- classquiz/emails/templates/register.jinja2 | 2 +- classquiz/kahoot_importer/README.md | 2 +- docker-compose.yml | 2 +- frontend/Dockerfile | 2 +- frontend/src/routes/docs/self-host.svelte | 52 ++++---- frontend/static/safari-pinned-tab.svg | 2 +- pytest.ini | 2 +- start.sh | 2 +- 24 files changed, 186 insertions(+), 53 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.flake8 b/.flake8 index 51d5a5c..8332de3 100644 --- a/.flake8 +++ b/.flake8 @@ -1,3 +1,3 @@ [flake8] max-line-length = 120 -extend-ignore = E203 \ No newline at end of file +extend-ignore = E203 diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 6632409..18e0402 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,2 +1,2 @@ ko_fi: mawoka -liberapay: Mawoka \ No newline at end of file +liberapay: Mawoka diff --git a/.github/ISSUE_TEMPLATE/Bug_report.md b/.github/ISSUE_TEMPLATE/Bug_report.md index f641ebf..acbfb51 100644 --- a/.github/ISSUE_TEMPLATE/Bug_report.md +++ b/.github/ISSUE_TEMPLATE/Bug_report.md @@ -30,7 +30,7 @@ If applicable, add the error stacktrace to help explain your problem. - Browser [e.g. Chrome, Firefox, Safari]: - ~~Classquiz Version [e.g. 0.10]:~~ :warning:** No versioning for now** :warning: - Classquiz installation [e.g. classquiz.de]: - - Commit SHA [e.g : ed35c5c69019e7cd6331ea438519f53b8bce70cf]: + - Commit SHA [e.g : ed35c5c69019e7cd6331ea438519f53b8bce70cf]: **Additional context** Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/Feature_request.md b/.github/ISSUE_TEMPLATE/Feature_request.md index 1b29d0d..5fab04e 100644 --- a/.github/ISSUE_TEMPLATE/Feature_request.md +++ b/.github/ISSUE_TEMPLATE/Feature_request.md @@ -15,4 +15,3 @@ If applicable, add screenshots to help explain your feature. Add any other context about the problem here. Thanks for contributing to ClassQuiz! - diff --git a/.github/ISSUE_TEMPLATE/Repo_architecture_changes.md b/.github/ISSUE_TEMPLATE/Repo_architecture_changes.md index a1e80e6..6510be9 100644 --- a/.github/ISSUE_TEMPLATE/Repo_architecture_changes.md +++ b/.github/ISSUE_TEMPLATE/Repo_architecture_changes.md @@ -12,4 +12,3 @@ A clear and concise description of the improvement you're asking for. Add any other context about the problem here. Thanks for contributing to ClassQuiz! - diff --git a/.github/workflows/frontend_lint.yml b/.github/workflows/frontend_lint.yml index f92073e..ec61842 100644 --- a/.github/workflows/frontend_lint.yml +++ b/.github/workflows/frontend_lint.yml @@ -32,4 +32,4 @@ jobs: - name: Lint working-directory: ./frontend run: | - pnpm run lint \ No newline at end of file + pnpm run lint diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 19ab8b2..1f54b12 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -37,7 +37,7 @@ jobs: run: | # Install deepsource CLI curl https://deepsource.io/cli | sh - + # From the root directory, run the report coverage command ./bin/deepsource report --analyzer test-coverage --key python --value-file ./coverage.xml diff --git a/.gitignore b/.gitignore index d70ef3c..6431888 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,4 @@ node_modules/ *.db *.rdb survey.json -.coverage \ No newline at end of file +.coverage diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..fda8b78 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,24 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.3.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + + - repo: https://github.com/psf/black + rev: 22.3.0 + hooks: + - id: black + - repo: https://github.com/pre-commit/mirrors-prettier + rev: 'v2.6.2' # Use the sha / tag you want to point at + hooks: + - id: prettier + files: "^frontend/" + exclude: "^frontend/src/lib/i18n/locales/" + additional_dependencies: + - "prettier-plugin-svelte@latest" + - "prettier@latest" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b3faea0..1fa1177 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -22,4 +22,4 @@ an issue here on GitHub. Go to [Weblate](https://translate.mawoka.eu/projects/classquiz/frontend/). If the language isn't available, please open -an issue here, so I'll be able to add it. \ No newline at end of file +an issue here, so I'll be able to add it. diff --git a/Dockerfile b/Dockerfile index a7d1f95..43128bb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,4 +12,4 @@ EXPOSE 80 ENV PYTHONPATH=/app RUN chmod +x start.sh ENV APP_MODULE=classquiz:app -CMD ["./start.sh"] \ No newline at end of file +CMD ["./start.sh"] diff --git a/Pipfile b/Pipfile index 83817ef..a3a960a 100644 --- a/Pipfile +++ b/Pipfile @@ -36,6 +36,7 @@ flake8 = "*" black = "*" pytest-dependency = "*" pytest-order = "*" +pre-commit = "*" [requires] python_version = "3.10" diff --git a/Pipfile.lock b/Pipfile.lock index 38a8109..2bbf747 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "546fc11840f6375e7138824e7251b452fcb56e9bd736591360b6a831c2319634" + "sha256": "7d4797eb27534a4d9abc7ae6cb3033255b792e22a0d67204153ab7cb0b2f5715" }, "pipfile-spec": 6, "requires": { @@ -308,7 +308,7 @@ "sha256:2857e29ff0d34db842cd7ca3230549d1a697f96ee6d3fb071cfa6c7393832597", "sha256:6881edbebdb17b39b4eaaa821b438bf6eddffb4468cf344f09f89def34a8b1df" ], - "markers": "python_version >= '3.5'", + "markers": "python_full_version >= '3.5.0'", "version": "==2.0.12" }, "click": { @@ -340,7 +340,7 @@ "sha256:0f7569a4a6ff151958b64304071d370daa3243d15941a7beedf0c9fe5105603e", "sha256:a851e51367fb93e9e1361732c1d60dab63eff98712e503ea7d92e6eccb109b4f" ], - "markers": "python_version >= '3.6' and python_version < '4'", + "markers": "python_version >= '3.6' and python_full_version < '4.0.0'", "version": "==2.2.1" }, "ecdsa": { @@ -553,7 +553,7 @@ "sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff", "sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d" ], - "markers": "python_version >= '3.5'", + "markers": "python_full_version >= '3.5.0'", "version": "==3.3" }, "jinja2": { @@ -994,7 +994,7 @@ "sha256:bc7861137fbce630f17b03d3ad02ad0bf978c844f3536d0edda6499dafce2b6f", "sha256:d568723a7ebd25875d8d1eaf5dfa068cd2fc8194b2e483d7b1f7c81918dbec6b" ], - "markers": "python_version >= '3.7' and python_version < '4'", + "markers": "python_version >= '3.7' and python_full_version < '4.0.0'", "version": "==2.28.0" }, "rsa": { @@ -1002,7 +1002,7 @@ "sha256:5c6bd9dc7a543b7fe4304a631f8a8a3b674e2bbfc49c2ae96200cdbe55df6b17", "sha256:95c5d300c4e879ee69708c428ba566c59478fd653cc3a22243eeb8ed846950bb" ], - "markers": "python_version >= '3.6' and python_version < '4'", + "markers": "python_version >= '3.6' and python_full_version < '4.0.0'", "version": "==4.8" }, "sentry-sdk": { @@ -1034,7 +1034,7 @@ "sha256:471b71698eac1c2112a40ce2752bb2f4a4814c22a54a3eed3676bc0f5ca9f663", "sha256:c4666eecec1d3f50960c6bdf61ab7bc350648da6c126e3cf6898d8cd4ddcd3de" ], - "markers": "python_version >= '3.5'", + "markers": "python_full_version >= '3.5.0'", "version": "==1.2.0" }, "sqlalchemy": { @@ -1100,7 +1100,7 @@ "sha256:44ece4d53fb1706f667c9bd1c648f5469a2ec925fcf3a776667042d645472c14", "sha256:aabaf16477806a5e1dd19aa41f8c2b7950dd3c746362d7e3223dbe6de6ac448e" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'", + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_full_version < '4.0.0'", "version": "==1.26.9" }, "uvicorn": { @@ -1397,6 +1397,14 @@ "index": "pypi", "version": "==22.3.0" }, + "cfgv": { + "hashes": [ + "sha256:c6a0883f3917a037485059700b9e75da2464e6c27051014ad85ba6aaa5884426", + "sha256:f5a830efb9ce7a445376bb66ec94c638a9787422f96264c98edc6bdeed8ab736" + ], + "markers": "python_full_version >= '3.6.1'", + "version": "==3.3.1" + }, "click": { "hashes": [ "sha256:7682dc8afb30297001674575ea00d1814d808d6a36af415a82bd481d37ba7b8e", @@ -1452,6 +1460,21 @@ "index": "pypi", "version": "==6.4.1" }, + "distlib": { + "hashes": [ + "sha256:6564fe0a8f51e734df6333d08b8b94d4ea8ee6b99b5ed50613f731fd4089f34b", + "sha256:e4b58818180336dc9c529bfb9a0b58728ffc09ad92027a3f30b7cd91e3458579" + ], + "version": "==0.3.4" + }, + "filelock": { + "hashes": [ + "sha256:37def7b658813cda163b56fc564cdc75e86d338246458c4c28ae84cabefa2404", + "sha256:3a0fd85166ad9dbab54c9aec96737b744106dc5f15c0b09a6744a445299fcf04" + ], + "markers": "python_version >= '3.7'", + "version": "==3.7.1" + }, "flake8": { "hashes": [ "sha256:479b1304f72536a55948cb40a32dce8bb0ffe3501e26eaf292c7e60eb5e0428d", @@ -1460,6 +1483,14 @@ "index": "pypi", "version": "==4.0.1" }, + "identify": { + "hashes": [ + "sha256:0dca2ea3e4381c435ef9c33ba100a78a9b40c0bab11189c7cf121f75815efeaa", + "sha256:3d11b16f3fe19f52039fb7e39c9c884b21cb1b586988114fbe42671f03de3e82" + ], + "markers": "python_version >= '3.7'", + "version": "==2.5.1" + }, "iniconfig": { "hashes": [ "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3", @@ -1481,6 +1512,13 @@ ], "version": "==0.4.3" }, + "nodeenv": { + "hashes": [ + "sha256:3ef13ff90291ba2a4a7a4ff9a979b63ffdd00a464dbe04acf0ea6471517a4c2b", + "sha256:621e6b7076565ddcacd2db0294c0381e01fd28945ab36bcf00f41c5daf63bef7" + ], + "version": "==1.6.0" + }, "packaging": { "hashes": [ "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb", @@ -1512,6 +1550,14 @@ "markers": "python_version >= '3.6'", "version": "==1.0.0" }, + "pre-commit": { + "hashes": [ + "sha256:10c62741aa5704faea2ad69cb550ca78082efe5697d6f04e5710c3c229afdd10", + "sha256:4233a1e38621c87d9dda9808c6606d7e7ba0e087cd56d3fe03202a01d2919615" + ], + "index": "pypi", + "version": "==2.19.0" + }, "py": { "hashes": [ "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719", @@ -1576,6 +1622,60 @@ "index": "pypi", "version": "==1.0.1" }, + "pyyaml": { + "hashes": [ + "sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293", + "sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b", + "sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57", + "sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b", + "sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4", + "sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07", + "sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba", + "sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9", + "sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287", + "sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513", + "sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0", + "sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0", + "sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92", + "sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f", + "sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2", + "sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc", + "sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c", + "sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86", + "sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4", + "sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c", + "sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34", + "sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b", + "sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c", + "sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb", + "sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737", + "sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3", + "sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d", + "sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53", + "sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78", + "sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803", + "sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a", + "sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174", + "sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5" + ], + "version": "==6.0" + }, + "six": { + "hashes": [ + "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926", + "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==1.16.0" + }, + "toml": { + "hashes": [ + "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b", + "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f" + ], + "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==0.10.2" + }, "tomli": { "hashes": [ "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc", @@ -1583,6 +1683,14 @@ ], "markers": "python_version >= '3.7'", "version": "==2.0.1" + }, + "virtualenv": { + "hashes": [ + "sha256:e617f16e25b42eb4f6e74096b9c9e37713cf10bf30168fb4a739f3fa8f898a3a", + "sha256:ef589a79795589aada0c1c5b319486797c03b67ac3984c48c669c0e4f50df3a5" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", + "version": "==20.14.1" } } } diff --git a/SocketIo.md b/SocketIo.md index 87909da..c25c3bb 100644 --- a/SocketIo.md +++ b/SocketIo.md @@ -76,4 +76,4 @@ return (example): "game_pin": "45823169", "started": false } -``` \ No newline at end of file +``` diff --git a/classquiz/emails/templates/footer.jinja2 b/classquiz/emails/templates/footer.jinja2 index 732e987..7a8e3c3 100644 --- a/classquiz/emails/templates/footer.jinja2 +++ b/classquiz/emails/templates/footer.jinja2 @@ -21,4 +21,4 @@ - \ No newline at end of file + diff --git a/classquiz/emails/templates/forgotten_password.jinja2 b/classquiz/emails/templates/forgotten_password.jinja2 index 569ca73..2b94556 100644 --- a/classquiz/emails/templates/forgotten_password.jinja2 +++ b/classquiz/emails/templates/forgotten_password.jinja2 @@ -70,4 +70,4 @@ {% include 'footer.jinja2' %} - \ No newline at end of file + diff --git a/classquiz/emails/templates/register.jinja2 b/classquiz/emails/templates/register.jinja2 index cda74a1..da81ab2 100644 --- a/classquiz/emails/templates/register.jinja2 +++ b/classquiz/emails/templates/register.jinja2 @@ -70,4 +70,4 @@ {% include 'footer.jinja2' %} - \ No newline at end of file + diff --git a/classquiz/kahoot_importer/README.md b/classquiz/kahoot_importer/README.md index 0e5f956..d6e5cc4 100644 --- a/classquiz/kahoot_importer/README.md +++ b/classquiz/kahoot_importer/README.md @@ -37,4 +37,4 @@ run(main()) ## Import-Quiz This script is meant just to be used with classquiz, not alone. --- -*Kahoot! and the K! logo are trademarks of Kahoot! AS* \ No newline at end of file +*Kahoot! and the K! logo are trademarks of Kahoot! AS* diff --git a/docker-compose.yml b/docker-compose.yml index 556d112..7564722 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -69,4 +69,4 @@ services: - meilisearch-data:/data.ms volumes: data: - meilisearch-data: \ No newline at end of file + meilisearch-data: diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 5b3684e..6ab30e8 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -41,4 +41,4 @@ COPY --from=builder /usr/src/app/node_modules ./node_modules EXPOSE 3000 # the command that starts our app -CMD ["pnpm", "run", "run:prod"] \ No newline at end of file +CMD ["pnpm", "run", "run:prod"] diff --git a/frontend/src/routes/docs/self-host.svelte b/frontend/src/routes/docs/self-host.svelte index be7a96c..02516f6 100644 --- a/frontend/src/routes/docs/self-host.svelte +++ b/frontend/src/routes/docs/self-host.svelte @@ -1,4 +1,4 @@ -