From 489b3d7b0153c1ff82c193ebfd3863859f885ed8 Mon Sep 17 00:00:00 2001 From: MarkKoz Date: Wed, 4 Mar 2020 18:52:04 -0800 Subject: Update dev dependencies --- .flake8 | 4 +- Pipfile | 18 +++---- Pipfile.lock | 167 +++++++++++++++++++++++++++-------------------------------- 3 files changed, 87 insertions(+), 102 deletions(-) diff --git a/.flake8 b/.flake8 index 1598f17c..bcd26d9e 100644 --- a/.flake8 +++ b/.flake8 @@ -15,6 +15,6 @@ ignore= # Docstring Content D400,D401,D402,D404,D405,D406,D407,D408,D409,D410,D411,D412,D413,D414,D416,D417 # Type Annotations - TYP002,TYP003,TYP101,TYP102,TYP204,TYP206 + ANN002,ANN003,ANN101,ANN102,ANN204,ANN206 per-file-ignores = - **/tests/**:D1,S106,TYP + **/tests/**:D1,S106,ANN diff --git a/Pipfile b/Pipfile index 3327d72e..7d71d58e 100644 --- a/Pipfile +++ b/Pipfile @@ -24,20 +24,20 @@ django-allauth = "~=0.40" sentry-sdk = "~=0.14" [dev-packages] -coverage = "~=4.5.3" +coverage = "~=5.0" flake8 = "~=3.7" -flake8-annotations = "~=1.1" +flake8-annotations = "~=2.0" flake8-bandit = "~=2.1" -flake8-bugbear = "~=19.8" -flake8-docstrings = "~=1.4" +flake8-bugbear = "~=20.1" +flake8-docstrings = "~=1.5" flake8-import-order = "~=0.18" -flake8-string-format = "~=0.2" -flake8-tidy-imports = "~=2.0" +flake8-string-format = "~=0.3" +flake8-tidy-imports = "~=4.0" flake8-todo = "~=0.7" mccabe = "~=0.6.1" -pep8-naming = "~=0.8.2" -pre-commit = "~=1.18" -unittest-xml-reporting = "~=2.5.1" +pep8-naming = "~=0.9" +pre-commit = "~=2.1" +unittest-xml-reporting = "~=3.0" [requires] python_version = "3.7" diff --git a/Pipfile.lock b/Pipfile.lock index e949f3f9..0adb35c7 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "1384fa13d1eb81fe566f2d395da1d8ca986bc52a5ed7b0c133965df08793c366" + "sha256": "28ebc86c71f033b8aceebf18c84a1c70c98c7a0c859b0d2131663b74d5f6cb2c" }, "pipfile-spec": 6, "requires": { @@ -46,11 +46,11 @@ }, "django": { "hashes": [ - "sha256:1226168be1b1c7efd0e66ee79b0e0b58b2caa7ed87717909cd8a57bb13a7079a", - "sha256:9a4635813e2d498a3c01b10c701fe4a515d76dd290aaa792ccb65ca4ccb6b038" + "sha256:65e2387e6bde531d3bb803244a2b74e0253550a9612c64a60c8c5be267b30f50", + "sha256:b51c9c548d5c3b3ccbb133d0bebc992e8ec3f14899bce8936e6fdda6b23a1881" ], "index": "pypi", - "version": "==2.2.10" + "version": "==2.2.11" }, "django-allauth": { "hashes": [ @@ -358,11 +358,11 @@ }, "sentry-sdk": { "hashes": [ - "sha256:b06dd27391fd11fb32f84fe054e6a64736c469514a718a99fb5ce1dff95d6b28", - "sha256:e023da07cfbead3868e1e2ba994160517885a32dfd994fc455b118e37989479b" + "sha256:480eee754e60bcae983787a9a13bc8f155a111aef199afaa4f289d6a76aa622a", + "sha256:a920387dc3ee252a66679d0afecd34479fb6fc52c2bc20763793ed69e5b0dcc0" ], "index": "pypi", - "version": "==0.14.1" + "version": "==0.14.2" }, "six": { "hashes": [ @@ -380,10 +380,10 @@ }, "sqlparse": { "hashes": [ - "sha256:40afe6b8d4b1117e7dff5504d7a8ce07d9a1b15aeeade8a2d10f130a834f8177", - "sha256:7c3dca29c022744e95b547e867cee89f4fce4373f3549ccd8797d8eb52cdb873" + "sha256:022fb9c87b524d1f7862b3037e541f68597a730a8843245c349fc93e1643dc4e", + "sha256:e162203737712307dfe78860cc56c8da8a852ab2ee33750e33aeadf38d12c548" ], - "version": "==0.3.0" + "version": "==0.3.1" }, "urllib3": { "hashes": [ @@ -424,13 +424,6 @@ ], "version": "==1.4.3" }, - "aspy.yaml": { - "hashes": [ - "sha256:463372c043f70160a9ec950c3f1e4c3a82db5fca01d334b6bc89c7164d744bdc", - "sha256:e7c742382eff2caed61f87a39d13f99109088e5e93f04d76eb8d4b28aa143f45" - ], - "version": "==1.3.0" - }, "attrs": { "hashes": [ "sha256:08a96c641c3a74e44eb59afb61a24f2cb9f4d7188748e76ba4bb5edfa3cb7d1c", @@ -447,48 +440,47 @@ }, "cfgv": { "hashes": [ - "sha256:04b093b14ddf9fd4d17c53ebfd55582d27b76ed30050193c14e560770c5360eb", - "sha256:f22b426ed59cd2ab2b54ff96608d846c33dfb8766a67f0b4a6ce130ce244414f" + "sha256:1ccf53320421aeeb915275a196e23b3b8ae87dea8ac6698b1638001d4a486d53", + "sha256:c8e8f552ffcc6194f4e18dd4f68d9aef0c0d58ae7e7be8c82bee3c5e9edfa513" ], - "version": "==3.0.0" + "version": "==3.1.0" }, "coverage": { "hashes": [ - "sha256:08907593569fe59baca0bf152c43f3863201efb6113ecb38ce7e97ce339805a6", - "sha256:0be0f1ed45fc0c185cfd4ecc19a1d6532d72f86a2bac9de7e24541febad72650", - "sha256:141f08ed3c4b1847015e2cd62ec06d35e67a3ac185c26f7635f4406b90afa9c5", - "sha256:19e4df788a0581238e9390c85a7a09af39c7b539b29f25c89209e6c3e371270d", - "sha256:23cc09ed395b03424d1ae30dcc292615c1372bfba7141eb85e11e50efaa6b351", - "sha256:245388cda02af78276b479f299bbf3783ef0a6a6273037d7c60dc73b8d8d7755", - "sha256:331cb5115673a20fb131dadd22f5bcaf7677ef758741312bee4937d71a14b2ef", - "sha256:386e2e4090f0bc5df274e720105c342263423e77ee8826002dcffe0c9533dbca", - "sha256:3a794ce50daee01c74a494919d5ebdc23d58873747fa0e288318728533a3e1ca", - "sha256:60851187677b24c6085248f0a0b9b98d49cba7ecc7ec60ba6b9d2e5574ac1ee9", - "sha256:63a9a5fc43b58735f65ed63d2cf43508f462dc49857da70b8980ad78d41d52fc", - "sha256:6b62544bb68106e3f00b21c8930e83e584fdca005d4fffd29bb39fb3ffa03cb5", - "sha256:6ba744056423ef8d450cf627289166da65903885272055fb4b5e113137cfa14f", - "sha256:7494b0b0274c5072bddbfd5b4a6c6f18fbbe1ab1d22a41e99cd2d00c8f96ecfe", - "sha256:826f32b9547c8091679ff292a82aca9c7b9650f9fda3e2ca6bf2ac905b7ce888", - "sha256:93715dffbcd0678057f947f496484e906bf9509f5c1c38fc9ba3922893cda5f5", - "sha256:9a334d6c83dfeadae576b4d633a71620d40d1c379129d587faa42ee3e2a85cce", - "sha256:af7ed8a8aa6957aac47b4268631fa1df984643f07ef00acd374e456364b373f5", - "sha256:bf0a7aed7f5521c7ca67febd57db473af4762b9622254291fbcbb8cd0ba5e33e", - "sha256:bf1ef9eb901113a9805287e090452c05547578eaab1b62e4ad456fcc049a9b7e", - "sha256:c0afd27bc0e307a1ffc04ca5ec010a290e49e3afbe841c5cafc5c5a80ecd81c9", - "sha256:dd579709a87092c6dbee09d1b7cfa81831040705ffa12a1b248935274aee0437", - "sha256:df6712284b2e44a065097846488f66840445eb987eb81b3cc6e4149e7b6982e1", - "sha256:e07d9f1a23e9e93ab5c62902833bf3e4b1f65502927379148b6622686223125c", - "sha256:e2ede7c1d45e65e209d6093b762e98e8318ddeff95317d07a27a2140b80cfd24", - "sha256:e4ef9c164eb55123c62411f5936b5c2e521b12356037b6e1c2617cef45523d47", - "sha256:eca2b7343524e7ba246cab8ff00cab47a2d6d54ada3b02772e908a45675722e2", - "sha256:eee64c616adeff7db37cc37da4180a3a5b6177f5c46b187894e633f088fb5b28", - "sha256:ef824cad1f980d27f26166f86856efe11eff9912c4fed97d3804820d43fa550c", - "sha256:efc89291bd5a08855829a3c522df16d856455297cf35ae827a37edac45f466a7", - "sha256:fa964bae817babece5aa2e8c1af841bebb6d0b9add8e637548809d040443fee0", - "sha256:ff37757e068ae606659c28c3bd0d923f9d29a85de79bf25b2b34b148473b5025" - ], - "index": "pypi", - "version": "==4.5.4" + "sha256:15cf13a6896048d6d947bf7d222f36e4809ab926894beb748fc9caa14605d9c3", + "sha256:1daa3eceed220f9fdb80d5ff950dd95112cd27f70d004c7918ca6dfc6c47054c", + "sha256:1e44a022500d944d42f94df76727ba3fc0a5c0b672c358b61067abb88caee7a0", + "sha256:25dbf1110d70bab68a74b4b9d74f30e99b177cde3388e07cc7272f2168bd1477", + "sha256:3230d1003eec018ad4a472d254991e34241e0bbd513e97a29727c7c2f637bd2a", + "sha256:3dbb72eaeea5763676a1a1efd9b427a048c97c39ed92e13336e726117d0b72bf", + "sha256:5012d3b8d5a500834783689a5d2292fe06ec75dc86ee1ccdad04b6f5bf231691", + "sha256:51bc7710b13a2ae0c726f69756cf7ffd4362f4ac36546e243136187cfcc8aa73", + "sha256:527b4f316e6bf7755082a783726da20671a0cc388b786a64417780b90565b987", + "sha256:722e4557c8039aad9592c6a4213db75da08c2cd9945320220634f637251c3894", + "sha256:76e2057e8ffba5472fd28a3a010431fd9e928885ff480cb278877c6e9943cc2e", + "sha256:77afca04240c40450c331fa796b3eab6f1e15c5ecf8bf2b8bee9706cd5452fef", + "sha256:7afad9835e7a651d3551eab18cbc0fdb888f0a6136169fbef0662d9cdc9987cf", + "sha256:9bea19ac2f08672636350f203db89382121c9c2ade85d945953ef3c8cf9d2a68", + "sha256:a8b8ac7876bc3598e43e2603f772d2353d9931709345ad6c1149009fd1bc81b8", + "sha256:b0840b45187699affd4c6588286d429cd79a99d509fe3de0f209594669bb0954", + "sha256:b26aaf69713e5674efbde4d728fb7124e429c9466aeaf5f4a7e9e699b12c9fe2", + "sha256:b63dd43f455ba878e5e9f80ba4f748c0a2156dde6e0e6e690310e24d6e8caf40", + "sha256:be18f4ae5a9e46edae3f329de2191747966a34a3d93046dbdf897319923923bc", + "sha256:c312e57847db2526bc92b9bfa78266bfbaabac3fdcd751df4d062cd4c23e46dc", + "sha256:c60097190fe9dc2b329a0eb03393e2e0829156a589bd732e70794c0dd804258e", + "sha256:c62a2143e1313944bf4a5ab34fd3b4be15367a02e9478b0ce800cb510e3bbb9d", + "sha256:cc1109f54a14d940b8512ee9f1c3975c181bbb200306c6d8b87d93376538782f", + "sha256:cd60f507c125ac0ad83f05803063bed27e50fa903b9c2cfee3f8a6867ca600fc", + "sha256:d513cc3db248e566e07a0da99c230aca3556d9b09ed02f420664e2da97eac301", + "sha256:d649dc0bcace6fcdb446ae02b98798a856593b19b637c1b9af8edadf2b150bea", + "sha256:d7008a6796095a79544f4da1ee49418901961c97ca9e9d44904205ff7d6aa8cb", + "sha256:da93027835164b8223e8e5af2cf902a4c80ed93cb0909417234f4a9df3bcd9af", + "sha256:e69215621707119c6baf99bda014a45b999d37602cb7043d943c76a59b05bf52", + "sha256:ea9525e0fef2de9208250d6c5aeeee0138921057cd67fcef90fbed49c4d62d37", + "sha256:fca1669d464f0c9831fd10be2eef6b86f5ebd76c724d1e0706ebdff86bb4adf0" + ], + "index": "pypi", + "version": "==5.0.3" }, "distlib": { "hashes": [ @@ -520,11 +512,11 @@ }, "flake8-annotations": { "hashes": [ - "sha256:47705be09c6e56e9e3ac1656e8f5ed70862a4657116dc472f5a56c1bdc5172b1", - "sha256:564702ace354e1059252755be79d082a70ae1851c86044ae1a96d0f5453280e9" + "sha256:a38b44d01abd480586a92a02a2b0a36231ec42dcc5e114de78fa5db016d8d3f9", + "sha256:d5b0e8704e4e7728b352fa1464e23539ff2341ba11cc153b536fa2cf921ee659" ], "index": "pypi", - "version": "==1.2.0" + "version": "==2.0.1" }, "flake8-bandit": { "hashes": [ @@ -535,11 +527,11 @@ }, "flake8-bugbear": { "hashes": [ - "sha256:d8c466ea79d5020cb20bf9f11cf349026e09517a42264f313d3f6fddb83e0571", - "sha256:ded4d282778969b5ab5530ceba7aa1a9f1b86fa7618fc96a19a1d512331640f8" + "sha256:a3ddc03ec28ba2296fc6f89444d1c946a6b76460f859795b35b77d4920a51b63", + "sha256:bd02e4b009fb153fe6072c31c52aeab5b133d508095befb2ffcf3b41c4823162" ], "index": "pypi", - "version": "==19.8.0" + "version": "==20.1.4" }, "flake8-docstrings": { "hashes": [ @@ -574,11 +566,11 @@ }, "flake8-tidy-imports": { "hashes": [ - "sha256:1c476aabc6e8db26dc75278464a3a392dba0ea80562777c5f13fd5cdf2646154", - "sha256:b3f5b96affd0f57cacb6621ed28286ce67edaca807757b51227043ebf7b136a1" + "sha256:8aa34384b45137d4cf33f5818b8e7897dc903b1d1e10a503fa7dd193a9a710ba", + "sha256:b26461561bcc80e8012e46846630ecf0aaa59314f362a94cb7800dfdb32fa413" ], "index": "pypi", - "version": "==2.0.0" + "version": "==4.0.0" }, "flake8-todo": { "hashes": [ @@ -589,24 +581,17 @@ }, "gitdb": { "hashes": [ - "sha256:24572287933a9e5bf45260cd7a5629e5b3b190ec3c2c6a5d5e4125dd06ff4027", - "sha256:d82c6b76ce8496c5209adf1c0ab969a6e1a8a31510ceb5f57a206fc7c77c0fea" - ], - "version": "==4.0.1" - }, - "gitdb2": { - "hashes": [ - "sha256:0986cb4003de743f2b3aba4c828edd1ab58ce98e1c4a8acf72ef02760d4beb4e", - "sha256:a1c974e5fab8c2c90192c1367c81cbc54baec04244bda1816e9c8ab377d1cba3" + "sha256:284a6a4554f954d6e737cddcff946404393e030b76a282c6640df8efd6b3da5e", + "sha256:598e0096bb3175a0aab3a0b5aedaa18a9a25c6707e0eca0695ba1a0baf1b2150" ], "version": "==4.0.2" }, "gitpython": { "hashes": [ - "sha256:620b3c729bbc143b498cfea77e302999deedc55faec5b1067086c9ef90e101bc", - "sha256:a43a5d88a5bbc3cf32bb5223e4b4e68fd716db5e9996cad6e561bbfee6e5f4af" + "sha256:43da89427bdf18bf07f1164c6d415750693b4d50e28fc9b68de706245147b9dd", + "sha256:e426c3b587bd58c482f0b7fe6145ff4ac7ae6c82673fc656f489719abca6f4cb" ], - "version": "==3.0.8" + "version": "==3.1.0" }, "identify": { "hashes": [ @@ -646,19 +631,19 @@ }, "pep8-naming": { "hashes": [ - "sha256:01cb1dab2f3ce9045133d08449f1b6b93531dceacb9ef04f67087c11c723cea9", - "sha256:0ec891e59eea766efd3059c3d81f1da304d858220678bdc351aab73c533f2fbb" + "sha256:45f330db8fcfb0fba57458c77385e288e7a3be1d01e8ea4268263ef677ceea5f", + "sha256:a33d38177056321a167decd6ba70b890856ba5025f0a8eca6a3eda607da93caf" ], "index": "pypi", - "version": "==0.8.2" + "version": "==0.9.1" }, "pre-commit": { "hashes": [ - "sha256:8f48d8637bdae6fa70cc97db9c1dd5aa7c5c8bf71968932a380628c25978b850", - "sha256:f92a359477f3252452ae2e8d3029de77aec59415c16ae4189bcfba40b757e029" + "sha256:09ebe467f43ce24377f8c2f200fe3cd2570d328eb2ce0568c8e96ce19da45fa6", + "sha256:f8d555e31e2051892c7f7b3ad9f620bd2c09271d87e9eedb2ad831737d6211eb" ], "index": "pypi", - "version": "==1.21.0" + "version": "==2.1.1" }, "pycodestyle": { "hashes": [ @@ -762,25 +747,25 @@ }, "unittest-xml-reporting": { "hashes": [ - "sha256:358bbdaf24a26d904cc1c26ef3078bca7fc81541e0a54c8961693cc96a6f35e0", - "sha256:9d28ddf6524cf0ff9293f61bd12e792de298f8561a5c945acea63fb437789e0e" + "sha256:74eaf7739a7957a74f52b8187c5616f61157372189bef0a32ba5c30bbc00e58a", + "sha256:e09b8ae70cce9904cdd331f53bf929150962869a5324ab7ff3dd6c8b87e01f7d" ], "index": "pypi", - "version": "==2.5.2" + "version": "==3.0.2" }, "virtualenv": { "hashes": [ - "sha256:531b142e300d405bb9faedad4adbeb82b4098b918e35209af2adef3129274aae", - "sha256:5dd42a9f56307542bddc446cfd10ef6576f11910366a07609fe8d0d88fa8fb7e" + "sha256:0c04c7e8e0314470b4c2b43740ff68be1c62bb3fdef8309341ff1daea60d49d1", + "sha256:1f0369d068d9761b5c1ed7b44dad1ec124727eb10bc7f4aaefbba0cdca3bd924" ], - "version": "==20.0.5" + "version": "==20.0.8" }, "zipp": { "hashes": [ - "sha256:12248a63bbdf7548f89cb4c7cda4681e537031eda29c02ea29674bc6854460c2", - "sha256:7c0f8e91abc0dc07a5068f315c52cb30c66bfbc581e5b50704c8a2f6ebae794a" + "sha256:aa36550ff0c0b7ef7fa639055d797116ee891440eac1a56f378e2d3179e0320b", + "sha256:c599e4d75c98f6798c509911d08a22e6c021d074469042177c8c86fb92eefd96" ], - "version": "==3.0.0" + "version": "==3.1.0" } } } -- cgit v1.2.3 From 5ed6e71fed014759ef07399ecb25eb7538b1d5ae Mon Sep 17 00:00:00 2001 From: MarkKoz Date: Wed, 4 Mar 2020 19:27:04 -0800 Subject: Add more pre-commit hooks Hooks added: * check-merge-conflict - checks for files with merge conflict strings * check-toml - attempts to load all toml files to verify syntax * check-yaml - attempts to load all yaml files to verify syntax * end-of-file-fixer - ensures files end in a newline and only a newline * mixed-line-ending - replaces mixed line endings with LF * trailing-whitespace - trims trailing whitespace * python-check-blanket-noqa - enforces that noqa annotations always occur with specific codes Changes made to comply with new hooks: * Remove trailing whitespaces * Remove some useless noqa annotations * Specify errors for noqa annotations * Add missing newlines at end of files See: python-discord/organisation#138 --- .gitattributes | 1 - .pre-commit-config.yaml | 23 ++++++++++++++++++---- CONTRIBUTING.md | 4 ++-- Pipfile | 2 +- pydis_site/apps/api/tests/base.py | 2 +- pydis_site/apps/api/tests/test_deleted_messages.py | 4 ++-- .../apps/api/tests/test_documentation_links.py | 4 ++-- pydis_site/apps/api/tests/test_infractions.py | 6 +++--- pydis_site/apps/api/tests/test_nominations.py | 4 ++-- .../apps/api/tests/test_off_topic_channel_names.py | 4 ++-- .../apps/api/tests/test_offensive_message.py | 6 +++--- pydis_site/apps/api/tests/test_roles.py | 2 +- pydis_site/apps/api/tests/test_users.py | 4 ++-- pydis_site/apps/api/views.py | 4 ++-- .../apps/home/tests/test_repodata_helpers.py | 2 +- pydis_site/static/css/home/index.css | 1 - pydis_site/static/favicons/safari-pinned-tab.svg | 2 +- pydis_site/templates/home/account/settings.html | 1 - pydis_site/templates/home/index.html | 1 - pydis_site/templates/wiki/history.html | 2 -- 20 files changed, 44 insertions(+), 35 deletions(-) diff --git a/.gitattributes b/.gitattributes index e9e08359..fa1530c8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8,4 +8,3 @@ # See e.g. https://stackoverflow.com/a/38588882/4464570 *.png binary *.whl binary - diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 86035786..be57904e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,10 +1,25 @@ repos: -- repo: local + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.5.0 hooks: - - id: flake8 + - id: check-merge-conflict + - id: check-toml + - id: check-yaml + - id: end-of-file-fixer + - id: mixed-line-ending + args: [--fix=lf] + - id: trailing-whitespace + args: [--markdown-linebreak-ext=md] + - repo: https://github.com/pre-commit/pygrep-hooks + rev: v1.5.1 + hooks: + - id: python-check-blanket-noqa + - repo: local + hooks: + - id: flake8 name: Flake8 description: This hook runs flake8 within our project's pipenv environment. - entry: pipenv run lint + entry: pipenv run flake8 language: python types: [python] - require_serial: true \ No newline at end of file + require_serial: true diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c1344cce..39fe9670 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -44,7 +44,7 @@ Instructions for setting up environments for both the site and the bot can be fo When pulling down changes from GitHub, remember to sync your environment using `pipenv sync --dev` to ensure you're using the most up-to-date versions the project's dependencies. ### Type Hinting -[PEP 484](https://www.python.org/dev/peps/pep-0484/) formally specifies type hints for Python functions, added to the Python Standard Library in version 3.5. Type hints are recognized by most modern code editing tools and provide useful insight into both the input and output types of a function, preventing the user from having to go through the codebase to determine these types. +[PEP 484](https://www.python.org/dev/peps/pep-0484/) formally specifies type hints for Python functions, added to the Python Standard Library in version 3.5. Type hints are recognized by most modern code editing tools and provide useful insight into both the input and output types of a function, preventing the user from having to go through the codebase to determine these types. For example: @@ -106,4 +106,4 @@ As stated earlier, **ensure that "Allow edits from maintainers" is checked**. Th ## Footnotes -This document was inspired by the [Glowstone contribution guidelines](https://github.com/GlowstoneMC/Glowstone/blob/dev/docs/CONTRIBUTING.md). \ No newline at end of file +This document was inspired by the [Glowstone contribution guidelines](https://github.com/GlowstoneMC/Glowstone/blob/dev/docs/CONTRIBUTING.md). diff --git a/Pipfile b/Pipfile index 7d71d58e..7b4298c9 100644 --- a/Pipfile +++ b/Pipfile @@ -48,5 +48,5 @@ makemigrations = "python manage.py makemigrations" django_shell = "python manage.py shell" test = "coverage run manage.py test" report = "coverage report -m" -lint = "flake8" +lint = "pre-commit run --all-files" precommit = "pre-commit install" diff --git a/pydis_site/apps/api/tests/base.py b/pydis_site/apps/api/tests/base.py index b779256e..61c23b0f 100644 --- a/pydis_site/apps/api/tests/base.py +++ b/pydis_site/apps/api/tests/base.py @@ -5,7 +5,7 @@ from rest_framework.test import APITestCase test_user, _created = User.objects.get_or_create( username='test', email='test@example.com', - password='testpass', # noqa + password='testpass', is_superuser=True, is_staff=True ) diff --git a/pydis_site/apps/api/tests/test_deleted_messages.py b/pydis_site/apps/api/tests/test_deleted_messages.py index b3a8197b..fb93cae6 100644 --- a/pydis_site/apps/api/tests/test_deleted_messages.py +++ b/pydis_site/apps/api/tests/test_deleted_messages.py @@ -8,7 +8,7 @@ from ..models import MessageDeletionContext, User class DeletedMessagesWithoutActorTests(APISubdomainTestCase): @classmethod - def setUpTestData(cls): # noqa + def setUpTestData(cls): cls.author = User.objects.create( id=55, name='Robbie Rotten', @@ -49,7 +49,7 @@ class DeletedMessagesWithoutActorTests(APISubdomainTestCase): class DeletedMessagesWithActorTests(APISubdomainTestCase): @classmethod - def setUpTestData(cls): # noqa + def setUpTestData(cls): cls.author = cls.actor = User.objects.create( id=12904, name='Joe Armstrong', diff --git a/pydis_site/apps/api/tests/test_documentation_links.py b/pydis_site/apps/api/tests/test_documentation_links.py index f6c78391..e560a2fd 100644 --- a/pydis_site/apps/api/tests/test_documentation_links.py +++ b/pydis_site/apps/api/tests/test_documentation_links.py @@ -57,7 +57,7 @@ class EmptyDatabaseDocumentationLinkAPITests(APISubdomainTestCase): class DetailLookupDocumentationLinkAPITests(APISubdomainTestCase): @classmethod - def setUpTestData(cls): # noqa + def setUpTestData(cls): cls.doc_link = DocumentationLink.objects.create( package='testpackage', base_url='https://example.com', @@ -141,7 +141,7 @@ class DocumentationLinkCreationTests(APISubdomainTestCase): class DocumentationLinkDeletionTests(APISubdomainTestCase): @classmethod - def setUpTestData(cls): # noqa + def setUpTestData(cls): cls.doc_link = DocumentationLink.objects.create( package='example', base_url='https://example.com', diff --git a/pydis_site/apps/api/tests/test_infractions.py b/pydis_site/apps/api/tests/test_infractions.py index ca87026c..bc258b77 100644 --- a/pydis_site/apps/api/tests/test_infractions.py +++ b/pydis_site/apps/api/tests/test_infractions.py @@ -42,7 +42,7 @@ class UnauthenticatedTests(APISubdomainTestCase): class InfractionTests(APISubdomainTestCase): @classmethod - def setUpTestData(cls): # noqa + def setUpTestData(cls): cls.user = User.objects.create( id=5, name='james', @@ -164,7 +164,7 @@ class InfractionTests(APISubdomainTestCase): class CreationTests(APISubdomainTestCase): @classmethod - def setUpTestData(cls): # noqa + def setUpTestData(cls): cls.user = User.objects.create( id=5, name='james', @@ -517,7 +517,7 @@ class CreationTests(APISubdomainTestCase): class ExpandedTests(APISubdomainTestCase): @classmethod - def setUpTestData(cls): # noqa + def setUpTestData(cls): cls.user = User.objects.create( id=5, name='james', diff --git a/pydis_site/apps/api/tests/test_nominations.py b/pydis_site/apps/api/tests/test_nominations.py index add5a7e4..76cb4112 100644 --- a/pydis_site/apps/api/tests/test_nominations.py +++ b/pydis_site/apps/api/tests/test_nominations.py @@ -8,7 +8,7 @@ from ..models import Nomination, User class CreationTests(APISubdomainTestCase): @classmethod - def setUpTestData(cls): # noqa + def setUpTestData(cls): cls.user = User.objects.create( id=1234, name='joe dart', @@ -185,7 +185,7 @@ class CreationTests(APISubdomainTestCase): class NominationTests(APISubdomainTestCase): @classmethod - def setUpTestData(cls): # noqa + def setUpTestData(cls): cls.user = User.objects.create( id=1234, name='joe dart', diff --git a/pydis_site/apps/api/tests/test_off_topic_channel_names.py b/pydis_site/apps/api/tests/test_off_topic_channel_names.py index 9ab71409..bd42cd81 100644 --- a/pydis_site/apps/api/tests/test_off_topic_channel_names.py +++ b/pydis_site/apps/api/tests/test_off_topic_channel_names.py @@ -58,7 +58,7 @@ class EmptyDatabaseTests(APISubdomainTestCase): class ListTests(APISubdomainTestCase): @classmethod - def setUpTestData(cls): # noqa + def setUpTestData(cls): cls.test_name = OffTopicChannelName.objects.create(name='lemons-lemonade-stand') cls.test_name_2 = OffTopicChannelName.objects.create(name='bbq-with-bisk') @@ -129,7 +129,7 @@ class CreationTests(APISubdomainTestCase): class DeletionTests(APISubdomainTestCase): @classmethod - def setUpTestData(cls): # noqa + def setUpTestData(cls): cls.test_name = OffTopicChannelName.objects.create(name='lemons-lemonade-stand') cls.test_name_2 = OffTopicChannelName.objects.create(name='bbq-with-bisk') diff --git a/pydis_site/apps/api/tests/test_offensive_message.py b/pydis_site/apps/api/tests/test_offensive_message.py index d5896714..0f3dbffa 100644 --- a/pydis_site/apps/api/tests/test_offensive_message.py +++ b/pydis_site/apps/api/tests/test_offensive_message.py @@ -71,7 +71,7 @@ class CreationTests(APISubdomainTestCase): class ListTests(APISubdomainTestCase): @classmethod - def setUpTestData(cls): # noqa + def setUpTestData(cls): delete_at = datetime.datetime.now() + datetime.timedelta(days=1) aware_delete_at = delete_at.replace(tzinfo=datetime.timezone.utc) @@ -110,7 +110,7 @@ class ListTests(APISubdomainTestCase): class DeletionTests(APISubdomainTestCase): @classmethod - def setUpTestData(cls): # noqa + def setUpTestData(cls): delete_at = datetime.datetime.now(tz=datetime.timezone.utc) + datetime.timedelta(days=1) cls.valid_offensive_message = OffensiveMessage.objects.create( @@ -134,7 +134,7 @@ class DeletionTests(APISubdomainTestCase): class NotAllowedMethodsTests(APISubdomainTestCase): @classmethod - def setUpTestData(cls): # noqa + def setUpTestData(cls): delete_at = datetime.datetime.now(tz=datetime.timezone.utc) + datetime.timedelta(days=1) cls.valid_offensive_message = OffensiveMessage.objects.create( diff --git a/pydis_site/apps/api/tests/test_roles.py b/pydis_site/apps/api/tests/test_roles.py index 0a6cea9e..4d1a430c 100644 --- a/pydis_site/apps/api/tests/test_roles.py +++ b/pydis_site/apps/api/tests/test_roles.py @@ -6,7 +6,7 @@ from ..models import Role class CreationTests(APISubdomainTestCase): @classmethod - def setUpTestData(cls): # noqa + def setUpTestData(cls): cls.admins_role = Role.objects.create( id=1, name="Admins", diff --git a/pydis_site/apps/api/tests/test_users.py b/pydis_site/apps/api/tests/test_users.py index bbdd3ff4..86799f19 100644 --- a/pydis_site/apps/api/tests/test_users.py +++ b/pydis_site/apps/api/tests/test_users.py @@ -36,7 +36,7 @@ class UnauthedUserAPITests(APISubdomainTestCase): class CreationTests(APISubdomainTestCase): @classmethod - def setUpTestData(cls): # noqa + def setUpTestData(cls): cls.role = Role.objects.create( id=5, name="Test role pls ignore", @@ -124,7 +124,7 @@ class CreationTests(APISubdomainTestCase): class UserModelTests(APISubdomainTestCase): @classmethod - def setUpTestData(cls): # noqa + def setUpTestData(cls): cls.role_top = Role.objects.create( id=777, name="High test role", diff --git a/pydis_site/apps/api/views.py b/pydis_site/apps/api/views.py index fd5a6d4d..a73d4718 100644 --- a/pydis_site/apps/api/views.py +++ b/pydis_site/apps/api/views.py @@ -24,7 +24,7 @@ class HealthcheckView(APIView): authentication_classes = () permission_classes = () - def get(self, request, format=None): # noqa + def get(self, request, format=None): # noqa: D102,ANN001,ANN201 return Response({'status': 'ok'}) @@ -96,7 +96,7 @@ class RulesView(APIView): ) # `format` here is the result format, we have a link format here instead. - def get(self, request, format=None): # noqa + def get(self, request, format=None): # noqa: D102,ANN001,ANN201 link_format = request.query_params.get('link_format', 'md') if link_format not in ('html', 'md'): raise ParseError( diff --git a/pydis_site/apps/home/tests/test_repodata_helpers.py b/pydis_site/apps/home/tests/test_repodata_helpers.py index 71bd4f2d..77b1a68d 100644 --- a/pydis_site/apps/home/tests/test_repodata_helpers.py +++ b/pydis_site/apps/home/tests/test_repodata_helpers.py @@ -10,7 +10,7 @@ from pydis_site.apps.home.models import RepositoryMetadata from pydis_site.apps.home.views import HomeView -def mocked_requests_get(*args, **kwargs) -> "MockResponse": # noqa +def mocked_requests_get(*args, **kwargs) -> "MockResponse": # noqa: F821 """A mock version of requests.get, so we don't need to call the API every time we run a test.""" class MockResponse: def __init__(self, json_data, status_code): diff --git a/pydis_site/static/css/home/index.css b/pydis_site/static/css/home/index.css index 4c36031b..ba856a8e 100644 --- a/pydis_site/static/css/home/index.css +++ b/pydis_site/static/css/home/index.css @@ -85,4 +85,3 @@ span.repo-language-dot.javascript { max-width: none; } } - diff --git a/pydis_site/static/favicons/safari-pinned-tab.svg b/pydis_site/static/favicons/safari-pinned-tab.svg index 3a7ec4a7..32064879 100644 --- a/pydis_site/static/favicons/safari-pinned-tab.svg +++ b/pydis_site/static/favicons/safari-pinned-tab.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/pydis_site/templates/home/account/settings.html b/pydis_site/templates/home/account/settings.html index 9f48d736..ed59b052 100644 --- a/pydis_site/templates/home/account/settings.html +++ b/pydis_site/templates/home/account/settings.html @@ -134,4 +134,3 @@ - diff --git a/pydis_site/templates/home/index.html b/pydis_site/templates/home/index.html index 1ee93b10..d153b293 100644 --- a/pydis_site/templates/home/index.html +++ b/pydis_site/templates/home/index.html @@ -105,4 +105,3 @@ {% endblock %} - diff --git a/pydis_site/templates/wiki/history.html b/pydis_site/templates/wiki/history.html index 3788385f..ee297bdd 100644 --- a/pydis_site/templates/wiki/history.html +++ b/pydis_site/templates/wiki/history.html @@ -124,5 +124,3 @@ {% endblock %} - - -- cgit v1.2.3 From 21dcf7ae8bfc73aa72cedfa5638966284d602452 Mon Sep 17 00:00:00 2001 From: MarkKoz Date: Wed, 4 Mar 2020 19:54:47 -0800 Subject: CI: run pre-commit hooks in CI This also means flake8 will output to stdout in CI now. It didn't before because it output to an XML format for publishing. Pre-commit creates its own environment in which it installs hooks. To speed up runs, the pipeline will cache this for use with future jobs. The cache will update if .pre-commit-config.yaml changes. The flake8 pre-commit hook invokes flake8 via `pipenv run flake8`. It's normally useful to use pipenv here cause it ensures flake8 is invoked within the context of the venv. However, in CI, there is no venv - dependencies are installed directly to the system site-packages. `pipenv run` does not work in such case because it tries to create a new venv if one doesn't exist (it doesn't consider the system interpreter to be a venv). This workaround (okay, it's a hack) creates an executable shell script which replaces the original pipenv binary. The shell script simply ignores the first argument (i.e. ignores `run` in `pipenv run`) and executes the rest of the arguments as a command. It essentially makes `pipenv run flake8` equivalent to just having ran `flake8`. When pre-commit executes pipenv, the aforementioned script is what will run. --- azure-pipelines.yml | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0331e67f..f273dad3 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -8,10 +8,12 @@ jobs: variables: PIP_CACHE_DIR: .cache/pip + PRE_COMMIT_HOME: $(Pipeline.Workspace)/pre-commit-cache steps: - task: UsePythonVersion@0 displayName: 'Set Python Version' + name: PythonVersion inputs: versionSpec: '3.7.x' addToPath: true @@ -31,8 +33,28 @@ jobs: pip install flake8-formatter-junit-xml displayName: 'Install Project Environment' - - script: flake8 --format junit-xml --output-file TEST-lint.xml - displayName: 'Run Linter' + # Create an executable shell script which replaces the original pipenv binary. + # The shell script ignores the first argument and executes the rest of the args as a command. + # It makes the `pipenv run flake8` command in the pre-commit hook work by circumventing + # pipenv entirely, which is too dumb to know it should use the system interpreter rather than + # creating a new venv. + - script: | + printf '%s\n%s' '#!/bin/bash' '"${@:2}"' > $(PythonVersion.pythonLocation)/bin/pipenv \ + && chmod +x $(PythonVersion.pythonLocation)/bin/pipenv + displayName: 'Mock pipenv binary' + + - task: Cache@2 + displayName: 'Restore pre-commit environment' + inputs: + key: pre-commit | "$(PythonVersion.pythonLocation)" | .pre-commit-config.yaml + restoreKeys: | + pre-commit | "$(PythonVersion.pythonLocation)" + path: $(PRE_COMMIT_HOME) + + # flake8 runs so it can generate the XML output. pre-commit will run it again to show stdout. + # flake8 standalone runs first to avoid any fixes pre-commit hooks may make. + - script: flake8 --format junit-xml --output-file TEST-lint.xml; pre-commit run --all-files + displayName: 'Run pre-commit hooks' - script: | python3 manage.py makemigrations --check -- cgit v1.2.3