From 05c11a432b137f291bd35fbb4912cc7b0b733196 Mon Sep 17 00:00:00 2001 From: Steve Lacey Date: Mon, 23 Jan 2023 11:27:02 +0800 Subject: [PATCH] Flake8 improvements --- .github/workflows/ci.yml | 1 - Pipfile | 5 +- Pipfile.lock | 287 ++++++++++++++++++++++++++++++++++++++- pyproject.toml | 38 ++++++ script/check | 4 + tests/models.py | 2 +- tests/test_shortcuts.py | 5 - tests/test_validators.py | 6 +- worf/settings.py | 2 +- worf/shortcuts.py | 15 -- worf/validators.py | 2 +- worf/views/__init__.py | 14 +- 12 files changed, 346 insertions(+), 35 deletions(-) delete mode 100644 tests/test_shortcuts.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e0de0c7..0ed36b3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,5 +52,4 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 - run: pip install pipenv - - run: pipenv run install_linters - run: pipenv run check diff --git a/Pipfile b/Pipfile index f955008..2857faa 100644 --- a/Pipfile +++ b/Pipfile @@ -15,6 +15,10 @@ build = "*" coverage = "*" factory-boy = "*" flake8 = "*" +flake8-bandit = "*" +flake8-bugbear = "*" +flake8-docstrings = "*" +flake8-pyproject = "*" flake8-quotes = "*" isort = "*" pytest = "*" @@ -27,6 +31,5 @@ pytest-xdist = {extras = ["psutil"], version = "*"} twine = "*" [scripts] -install_linters = "pipenv install autoflake black flake8 isort --dev --skip-lock" check = "./script/check" lint = "./script/lint" diff --git a/Pipfile.lock b/Pipfile.lock index 6f0e8ad..37e7903 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "88ad00110fbe55708724f02017f3df3e9cce6b155bab738e743bbaa2ed109b04" + "sha256": "c9019efc66b128a95a7313c39d5454c0d66bed7dd32eb3b90718881acce641aa" }, "pipfile-spec": 6, "requires": {}, @@ -128,6 +128,14 @@ "index": "pypi", "version": "==2.0.1" }, + "bandit": { + "hashes": [ + "sha256:2d63a8c573417bae338962d4b9b06fbc6080f74ecd955a092849e1e65c717bd2", + "sha256:412d3f259dab4077d0e7f0c11f50f650cc7d10db905d98f6520a95a18049658a" + ], + "markers": "python_version >= '3.7'", + "version": "==1.7.4" + }, "black": { "hashes": [ "sha256:06f9d8846f2340dfac80ceb20200ea5d1b3f181dd0556b47af4e8e0b24fa0a6b", @@ -181,6 +189,75 @@ "markers": "python_version >= '3.6'", "version": "==2022.12.7" }, + "cffi": { + "hashes": [ + "sha256:00a9ed42e88df81ffae7a8ab6d9356b371399b91dbdf0c3cb1e84c03a13aceb5", + "sha256:03425bdae262c76aad70202debd780501fabeaca237cdfddc008987c0e0f59ef", + "sha256:04ed324bda3cda42b9b695d51bb7d54b680b9719cfab04227cdd1e04e5de3104", + "sha256:0e2642fe3142e4cc4af0799748233ad6da94c62a8bec3a6648bf8ee68b1c7426", + "sha256:173379135477dc8cac4bc58f45db08ab45d228b3363adb7af79436135d028405", + "sha256:198caafb44239b60e252492445da556afafc7d1e3ab7a1fb3f0584ef6d742375", + "sha256:1e74c6b51a9ed6589199c787bf5f9875612ca4a8a0785fb2d4a84429badaf22a", + "sha256:2012c72d854c2d03e45d06ae57f40d78e5770d252f195b93f581acf3ba44496e", + "sha256:21157295583fe8943475029ed5abdcf71eb3911894724e360acff1d61c1d54bc", + "sha256:2470043b93ff09bf8fb1d46d1cb756ce6132c54826661a32d4e4d132e1977adf", + "sha256:285d29981935eb726a4399badae8f0ffdff4f5050eaa6d0cfc3f64b857b77185", + "sha256:30d78fbc8ebf9c92c9b7823ee18eb92f2e6ef79b45ac84db507f52fbe3ec4497", + "sha256:320dab6e7cb2eacdf0e658569d2575c4dad258c0fcc794f46215e1e39f90f2c3", + "sha256:33ab79603146aace82c2427da5ca6e58f2b3f2fb5da893ceac0c42218a40be35", + "sha256:3548db281cd7d2561c9ad9984681c95f7b0e38881201e157833a2342c30d5e8c", + "sha256:3799aecf2e17cf585d977b780ce79ff0dc9b78d799fc694221ce814c2c19db83", + "sha256:39d39875251ca8f612b6f33e6b1195af86d1b3e60086068be9cc053aa4376e21", + "sha256:3b926aa83d1edb5aa5b427b4053dc420ec295a08e40911296b9eb1b6170f6cca", + "sha256:3bcde07039e586f91b45c88f8583ea7cf7a0770df3a1649627bf598332cb6984", + "sha256:3d08afd128ddaa624a48cf2b859afef385b720bb4b43df214f85616922e6a5ac", + "sha256:3eb6971dcff08619f8d91607cfc726518b6fa2a9eba42856be181c6d0d9515fd", + "sha256:40f4774f5a9d4f5e344f31a32b5096977b5d48560c5592e2f3d2c4374bd543ee", + "sha256:4289fc34b2f5316fbb762d75362931e351941fa95fa18789191b33fc4cf9504a", + "sha256:470c103ae716238bbe698d67ad020e1db9d9dba34fa5a899b5e21577e6d52ed2", + "sha256:4f2c9f67e9821cad2e5f480bc8d83b8742896f1242dba247911072d4fa94c192", + "sha256:50a74364d85fd319352182ef59c5c790484a336f6db772c1a9231f1c3ed0cbd7", + "sha256:54a2db7b78338edd780e7ef7f9f6c442500fb0d41a5a4ea24fff1c929d5af585", + "sha256:5635bd9cb9731e6d4a1132a498dd34f764034a8ce60cef4f5319c0541159392f", + "sha256:59c0b02d0a6c384d453fece7566d1c7e6b7bae4fc5874ef2ef46d56776d61c9e", + "sha256:5d598b938678ebf3c67377cdd45e09d431369c3b1a5b331058c338e201f12b27", + "sha256:5df2768244d19ab7f60546d0c7c63ce1581f7af8b5de3eb3004b9b6fc8a9f84b", + "sha256:5ef34d190326c3b1f822a5b7a45f6c4535e2f47ed06fec77d3d799c450b2651e", + "sha256:6975a3fac6bc83c4a65c9f9fcab9e47019a11d3d2cf7f3c0d03431bf145a941e", + "sha256:6c9a799e985904922a4d207a94eae35c78ebae90e128f0c4e521ce339396be9d", + "sha256:70df4e3b545a17496c9b3f41f5115e69a4f2e77e94e1d2a8e1070bc0c38c8a3c", + "sha256:7473e861101c9e72452f9bf8acb984947aa1661a7704553a9f6e4baa5ba64415", + "sha256:8102eaf27e1e448db915d08afa8b41d6c7ca7a04b7d73af6514df10a3e74bd82", + "sha256:87c450779d0914f2861b8526e035c5e6da0a3199d8f1add1a665e1cbc6fc6d02", + "sha256:8b7ee99e510d7b66cdb6c593f21c043c248537a32e0bedf02e01e9553a172314", + "sha256:91fc98adde3d7881af9b59ed0294046f3806221863722ba7d8d120c575314325", + "sha256:94411f22c3985acaec6f83c6df553f2dbe17b698cc7f8ae751ff2237d96b9e3c", + "sha256:98d85c6a2bef81588d9227dde12db8a7f47f639f4a17c9ae08e773aa9c697bf3", + "sha256:9ad5db27f9cabae298d151c85cf2bad1d359a1b9c686a275df03385758e2f914", + "sha256:a0b71b1b8fbf2b96e41c4d990244165e2c9be83d54962a9a1d118fd8657d2045", + "sha256:a0f100c8912c114ff53e1202d0078b425bee3649ae34d7b070e9697f93c5d52d", + "sha256:a591fe9e525846e4d154205572a029f653ada1a78b93697f3b5a8f1f2bc055b9", + "sha256:a5c84c68147988265e60416b57fc83425a78058853509c1b0629c180094904a5", + "sha256:a66d3508133af6e8548451b25058d5812812ec3798c886bf38ed24a98216fab2", + "sha256:a8c4917bd7ad33e8eb21e9a5bbba979b49d9a97acb3a803092cbc1133e20343c", + "sha256:b3bbeb01c2b273cca1e1e0c5df57f12dce9a4dd331b4fa1635b8bec26350bde3", + "sha256:cba9d6b9a7d64d4bd46167096fc9d2f835e25d7e4c121fb2ddfc6528fb0413b2", + "sha256:cc4d65aeeaa04136a12677d3dd0b1c0c94dc43abac5860ab33cceb42b801c1e8", + "sha256:ce4bcc037df4fc5e3d184794f27bdaab018943698f4ca31630bc7f84a7b69c6d", + "sha256:cec7d9412a9102bdc577382c3929b337320c4c4c4849f2c5cdd14d7368c5562d", + "sha256:d400bfb9a37b1351253cb402671cea7e89bdecc294e8016a707f6d1d8ac934f9", + "sha256:d61f4695e6c866a23a21acab0509af1cdfd2c013cf256bbf5b6b5e2695827162", + "sha256:db0fbb9c62743ce59a9ff687eb5f4afbe77e5e8403d6697f7446e5f609976f76", + "sha256:dd86c085fae2efd48ac91dd7ccffcfc0571387fe1193d33b6394db7ef31fe2a4", + "sha256:e00b098126fd45523dd056d2efba6c5a63b71ffe9f2bbe1a4fe1716e1d0c331e", + "sha256:e229a521186c75c8ad9490854fd8bbdd9a0c9aa3a524326b55be83b54d4e0ad9", + "sha256:e263d77ee3dd201c3a142934a086a4450861778baaeeb45db4591ef65550b0a6", + "sha256:ed9cb427ba5504c1dc15ede7d516b84757c3e3d7868ccc85121d9310d27eed0b", + "sha256:fa6693661a4c91757f4412306191b6dc88c1703f780c8234035eac011922bc01", + "sha256:fcd131dd944808b5bdb38e6f5b53013c5aa4f334c5cad0c72742f6eba4b73db0" + ], + "version": "==1.15.1" + }, "charset-normalizer": { "hashes": [ "sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845", @@ -269,6 +346,35 @@ "index": "pypi", "version": "==7.0.3" }, + "cryptography": { + "hashes": [ + "sha256:1a6915075c6d3a5e1215eab5d99bcec0da26036ff2102a1038401d6ef5bef25b", + "sha256:1ee1fd0de9851ff32dbbb9362a4d833b579b4a6cc96883e8e6d2ff2a6bc7104f", + "sha256:407cec680e811b4fc829de966f88a7c62a596faa250fc1a4b520a0355b9bc190", + "sha256:50386acb40fbabbceeb2986332f0287f50f29ccf1497bae31cf5c3e7b4f4b34f", + "sha256:6f97109336df5c178ee7c9c711b264c502b905c2d2a29ace99ed761533a3460f", + "sha256:754978da4d0457e7ca176f58c57b1f9de6556591c19b25b8bcce3c77d314f5eb", + "sha256:76c24dd4fd196a80f9f2f5405a778a8ca132f16b10af113474005635fe7e066c", + "sha256:7dacfdeee048814563eaaec7c4743c8aea529fe3dd53127313a792f0dadc1773", + "sha256:80ee674c08aaef194bc4627b7f2956e5ba7ef29c3cc3ca488cf15854838a8f72", + "sha256:844ad4d7c3850081dffba91cdd91950038ee4ac525c575509a42d3fc806b83c8", + "sha256:875aea1039d78557c7c6b4db2fe0e9d2413439f4676310a5f269dd342ca7a717", + "sha256:887cbc1ea60786e534b00ba8b04d1095f4272d380ebd5f7a7eb4cc274710fad9", + "sha256:ad04f413436b0781f20c52a661660f1e23bcd89a0e9bb1d6d20822d048cf2856", + "sha256:bae6c7f4a36a25291b619ad064a30a07110a805d08dc89984f4f441f6c1f3f96", + "sha256:c52a1a6f81e738d07f43dab57831c29e57d21c81a942f4602fac7ee21b27f288", + "sha256:e0a05aee6a82d944f9b4edd6a001178787d1546ec7c6223ee9a848a7ade92e39", + "sha256:e324de6972b151f99dc078defe8fb1b0a82c6498e37bff335f5bc6b1e3ab5a1e", + "sha256:e5d71c5d5bd5b5c3eebcf7c5c2bb332d62ec68921a8c593bea8c394911a005ce", + "sha256:f3ed2d864a2fa1666e749fe52fb8e23d8e06b8012e8bd8147c73797c506e86f1", + "sha256:f671c1bb0d6088e94d61d80c606d65baacc0d374e67bf895148883461cd848de", + "sha256:f6c0db08d81ead9576c4d94bbb27aed8d7a430fa27890f39084c2d0e2ec6b0df", + "sha256:f964c7dcf7802d133e8dbd1565914fa0194f9d683d82411989889ecd701e8adf", + "sha256:fec8b932f51ae245121c4671b4bbc030880f363354b2f0e0bd1366017d891458" + ], + "markers": "python_version >= '3.6'", + "version": "==39.0.0" + }, "docopt": { "hashes": [ "sha256:49b3a825280bd66b3aa83585ef59c4a8c82f2c8a522dbe754a8bc8d08c85c491" @@ -323,6 +429,37 @@ "index": "pypi", "version": "==6.0.0" }, + "flake8-bandit": { + "hashes": [ + "sha256:068e09287189cbfd7f986e92605adea2067630b75380c6b5733dab7d87f9a84e", + "sha256:4c8a53eb48f23d4ef1e59293657181a3c989d0077c9952717e98a0eace43e06d" + ], + "index": "pypi", + "version": "==4.1.1" + }, + "flake8-bugbear": { + "hashes": [ + "sha256:04a115e5f9c8e87c38bdbbcdf9f58223ffe05469c07c9a7bd8633330bc4d078b", + "sha256:55902ab5a48c5ea53d8689ecd146eda548e72f2724192b9c1d68f6d975d13c06" + ], + "index": "pypi", + "version": "==23.1.20" + }, + "flake8-docstrings": { + "hashes": [ + "sha256:99cac583d6c7e32dd28bbfbef120a7c0d1b6dde4adb5a9fd441c4227a6534bde", + "sha256:9fe7c6a306064af8e62a055c2f61e9eb1da55f84bb39caef2b84ce53708ac34b" + ], + "index": "pypi", + "version": "==1.6.0" + }, + "flake8-pyproject": { + "hashes": [ + "sha256:52d412219e7db6227faa654675b1435947b11d49b453f3eced760f19bdd6f06a" + ], + "index": "pypi", + "version": "==1.2.2" + }, "flake8-quotes": { "hashes": [ "sha256:6e26892b632dacba517bf27219c459a8396dcfac0f5e8204904c5a4ba9b480e1" @@ -330,6 +467,22 @@ "index": "pypi", "version": "==3.3.2" }, + "gitdb": { + "hashes": [ + "sha256:6eb990b69df4e15bad899ea868dc46572c3f75339735663b81de79b06f17eb9a", + "sha256:c286cf298426064079ed96a9e4a9d39e7f3e9bf15ba60701e95f5492f28415c7" + ], + "markers": "python_version >= '3.7'", + "version": "==4.0.10" + }, + "gitpython": { + "hashes": [ + "sha256:769c2d83e13f5d938b7688479da374c4e3d49f71549aaf462b646db9602ea6f8", + "sha256:cd455b0000615c60e286208ba540271af9fe531fa6a87cc590a7298785ab2882" + ], + "markers": "python_version >= '3.7'", + "version": "==3.1.30" + }, "idna": { "hashes": [ "sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4", @@ -377,6 +530,14 @@ "markers": "python_version >= '3.7'", "version": "==3.2.3" }, + "jeepney": { + "hashes": [ + "sha256:5efe48d255973902f6badc3ce55e2aa6c5c3b3bc642059ef3a91247bcfcc5806", + "sha256:c0a454ad016ca575060802ee4d590dd912e35c122fa04e70306de3d076cce755" + ], + "markers": "sys_platform == 'linux'", + "version": "==0.8.0" + }, "keyring": { "hashes": [ "sha256:771ed2a91909389ed6148631de678f82ddc73737d85a927f382a8a1b157898cd", @@ -385,6 +546,14 @@ "markers": "python_version >= '3.7'", "version": "==23.13.1" }, + "markdown-it-py": { + "hashes": [ + "sha256:93de681e5c021a432c63147656fe21790bc01231e0cd2da73626f1aa3ac0fe27", + "sha256:cf7e59fed14b5ae17c0006eff14a2d9a00ed5f3a846148153899a0224e2c07da" + ], + "markers": "python_version >= '3.7'", + "version": "==2.1.0" + }, "mccabe": { "hashes": [ "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325", @@ -393,6 +562,14 @@ "markers": "python_version >= '3.6'", "version": "==0.7.0" }, + "mdurl": { + "hashes": [ + "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8", + "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba" + ], + "markers": "python_version >= '3.7'", + "version": "==0.1.2" + }, "more-itertools": { "hashes": [ "sha256:250e83d7e81d0c87ca6bd942e6aeab8cc9daa6096d12c5308f3f92fa5e5c1f41", @@ -424,6 +601,14 @@ "markers": "python_version >= '3.7'", "version": "==0.10.3" }, + "pbr": { + "hashes": [ + "sha256:567f09558bae2b3ab53cb3c1e2e33e726ff3338e7bae3db5dc954b3a44eef12b", + "sha256:aefc51675b0b533d56bb5fd1c8c6c0522fe31896679882e1c4c63d5e4a0fccb3" + ], + "markers": "python_version >= '2.6'", + "version": "==5.11.1" + }, "pep517": { "hashes": [ "sha256:4ba4446d80aed5b5eac6509ade100bff3e7943a8489de249654a5ae9b33ee35b", @@ -483,6 +668,21 @@ "markers": "python_version >= '3.6'", "version": "==2.10.0" }, + "pycparser": { + "hashes": [ + "sha256:8ee45429555515e1f6b185e78100aea234072576aa43ab53aefcae078162fca9", + "sha256:e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206" + ], + "version": "==2.21" + }, + "pydocstyle": { + "hashes": [ + "sha256:118762d452a49d6b05e194ef344a55822987a462831ade91ec5c06fd2169d019", + "sha256:7ce43f0c0ac87b07494eb9c0b462c0b73e6ff276807f204d6b53edc72b7e44e1" + ], + "markers": "python_version >= '3.6'", + "version": "==6.3.0" + }, "pyflakes": { "hashes": [ "sha256:ec55bf7fe21fff7f1ad2f7da62363d749e2a470500eab1b555334b67aa1ef8cf", @@ -499,6 +699,14 @@ "markers": "python_version >= '3.6'", "version": "==2.14.0" }, + "pyproject-hooks": { + "hashes": [ + "sha256:283c11acd6b928d2f6a7c73fa0d01cb2bdc5f07c57a2eeb6e83d5e56b97976f8", + "sha256:f271b298b97f5955d53fb12b72c1fb1948c22c1a6b70b315c54cedaca0264ef5" + ], + "markers": "python_version >= '3.7'", + "version": "==1.0.0" + }, "pytest": { "hashes": [ "sha256:892f933d339f068883b6fd5a459f03d85bfcb355e4981e146d2c7616c21fef71", @@ -566,6 +774,52 @@ "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==2.8.2" }, + "pyyaml": { + "hashes": [ + "sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf", + "sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293", + "sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b", + "sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57", + "sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b", + "sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4", + "sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07", + "sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba", + "sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9", + "sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287", + "sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513", + "sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0", + "sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782", + "sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0", + "sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92", + "sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f", + "sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2", + "sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc", + "sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1", + "sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c", + "sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86", + "sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4", + "sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c", + "sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34", + "sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b", + "sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d", + "sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c", + "sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb", + "sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7", + "sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737", + "sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3", + "sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d", + "sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358", + "sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53", + "sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78", + "sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803", + "sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a", + "sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f", + "sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174", + "sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5" + ], + "markers": "python_version >= '3.6'", + "version": "==6.0" + }, "readme-renderer": { "hashes": [ "sha256:cd653186dfc73055656f090f227f5cb22a046d7f71a841dfa305f55c9a513273", @@ -606,6 +860,14 @@ "markers": "python_full_version >= '3.7.0'", "version": "==13.0.0" }, + "secretstorage": { + "hashes": [ + "sha256:2403533ef369eca6d2ba81718576c5e0f564d5cca1b58f73a8b23e7d4eeebd77", + "sha256:f356e6628222568e3af06f2eba8df495efa13b3b63081dafd4f7d9a7b7bc9f99" + ], + "markers": "sys_platform == 'linux'", + "version": "==3.3.3" + }, "six": { "hashes": [ "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926", @@ -614,6 +876,29 @@ "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", "version": "==1.16.0" }, + "smmap": { + "hashes": [ + "sha256:2aba19d6a040e78d8b09de5c57e96207b09ed71d8e55ce0959eeee6c8e190d94", + "sha256:c840e62059cd3be204b0c9c9f74be2c09d5648eddd4580d9314c3ecde0b30936" + ], + "markers": "python_version >= '3.6'", + "version": "==5.0.0" + }, + "snowballstemmer": { + "hashes": [ + "sha256:09b16deb8547d3412ad7b590689584cd0fe25ec8db3be37788be3810cbf19cb1", + "sha256:c8e1716e83cc398ae16824e5572ae04e0d9fc2c6b985fb0f900f5f0c96ecba1a" + ], + "version": "==2.2.0" + }, + "stevedore": { + "hashes": [ + "sha256:7f8aeb6e3f90f96832c301bff21a7eb5eefbe894c88c506483d355565d88cc1a", + "sha256:aa6436565c069b2946fe4ebff07f5041e0c8bf18c7376dd29edf80cf7d524e4e" + ], + "markers": "python_version >= '3.8'", + "version": "==4.1.1" + }, "tomli": { "hashes": [ "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc", diff --git a/pyproject.toml b/pyproject.toml index 7d9618b..038187a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,44 @@ [tool.black] line-length = 88 +[tool.flake8] +ignore = [ + "B001", + "B006", + "B028", + "D100", + "D101", + "D102", + "D103", + "D104", + "D105", + "D106", + "D107", + "D203", + "D202", + "D205", + "D212", + "D213", + "D400", + "D401", + "D404", + "E203", + "E501", + "N818", + "S101", + "S105", + "S106", + "S107", + "S110", + "S311", + "W503", +] +inline-quotes = "double" +per-file-ignores = [ + "__init__.py:F403", +] +max-complexity = 12 + [tool.isort] combine_as_imports = true known_django = "django" diff --git a/script/check b/script/check index d307f57..33f6e11 100755 --- a/script/check +++ b/script/check @@ -5,6 +5,10 @@ cd "$(dirname "$0")/.." ARROW="\033[93m==>\033[0m" +if [ ${CI:+x} ]; then + cat Pipfile | grep "^black\|^flake8\|^isort" | sed "s/ = .*//g" | xargs pipenv install --dev --skip-lock +fi + echo -e "$ARROW black worf tests --check" black worf tests --check diff --git a/tests/models.py b/tests/models.py index 93b32b2..12c28e3 100644 --- a/tests/models.py +++ b/tests/models.py @@ -44,7 +44,7 @@ def get_avatar_url(self): return self.avatar.url if self.avatar else self.get_gravatar_url() def get_gravatar_hash(self): - return md5(self.user.email.lower().encode()).hexdigest() + return md5(self.user.email.lower().encode()).hexdigest() # noqa: S324 def get_gravatar_url(self, default="identicon", size=512): return f"https://www.gravatar.com/avatar/{self.get_gravatar_hash()}?d={default}&s={size}" diff --git a/tests/test_shortcuts.py b/tests/test_shortcuts.py deleted file mode 100644 index a7b19d1..0000000 --- a/tests/test_shortcuts.py +++ /dev/null @@ -1,5 +0,0 @@ -from worf.shortcuts import get_version - - -def test_get_version(): - assert get_version().startswith("v") diff --git a/tests/test_validators.py b/tests/test_validators.py index 291ac13..0013e4a 100644 --- a/tests/test_validators.py +++ b/tests/test_validators.py @@ -39,12 +39,14 @@ def profile_view_fixture(db, now, profile_factory, rf): def test_strip_fields(profile_view): profile_view.set_bundle(dict(slug="te\x00st ")) - profile_view.validate_bundle("slug") == "test" + profile_view.validate_bundle("slug") + assert profile_view.bundle["slug"] == "test" profile_view.secure_fields = ["slug"] profile_view.set_bundle(dict(slug="te\x00st ")) - profile_view.validate_bundle("slug") == "te\x00st " + profile_view.validate_bundle("slug") + assert profile_view.bundle["slug"] == "te\x00st " def test_validate_bundle(profile_view): diff --git a/worf/settings.py b/worf/settings.py index 00b421f..2027ca6 100644 --- a/worf/settings.py +++ b/worf/settings.py @@ -1,6 +1,6 @@ from django.conf import settings -DATA_UPLOAD_MAX_MEMORY_SIZE = getattr(settings, "DATA_UPLOAD_MAX_MEMORY_SIZE") +DATA_UPLOAD_MAX_MEMORY_SIZE = settings.DATA_UPLOAD_MAX_MEMORY_SIZE WORF_API_NAME = getattr(settings, "WORF_API_NAME", "Worf API") WORF_API_ROOT = getattr(settings, "WORF_API_ROOT", "/api/") diff --git a/worf/shortcuts.py b/worf/shortcuts.py index f54f95c..d4e81a6 100644 --- a/worf/shortcuts.py +++ b/worf/shortcuts.py @@ -1,6 +1,3 @@ -import subprocess - -from worf import __version__ from worf.casing import camel_to_snake @@ -11,17 +8,5 @@ def field_list(value, delimiter="."): ] -def get_version(): - try: - hash = ( - subprocess.check_output(["git", "rev-parse", "--short", "HEAD"]) - .strip() - .decode() - ) - return f"{__version__}@{hash}" - except: # pragma: no cover # noqa E722 Dont crash for any reason whatsoever - return __version__ - - def string_list(value): return value.split(",") if isinstance(value, str) else value diff --git a/worf/validators.py b/worf/validators.py index 93fdedb..f4e8602 100644 --- a/worf/validators.py +++ b/worf/validators.py @@ -142,7 +142,7 @@ def validate_email(self, value): raise ValidationError(f"{value} is not a valid email address") return email - def validate_bundle(self, key): + def validate_bundle(self, key): # noqa: C901 """ Handle basic type validation and coercion. diff --git a/worf/views/__init__.py b/worf/views/__init__.py index 801a04d..455476d 100644 --- a/worf/views/__init__.py +++ b/worf/views/__init__.py @@ -1,7 +1,7 @@ -from worf.views.action import ActionAPI # noqa -from worf.views.base import AbstractBaseAPI, APIResponse # noqa -from worf.views.create import CreateAPI # noqa -from worf.views.delete import DeleteAPI # noqa -from worf.views.detail import DetailAPI, DetailUpdateAPI # noqa -from worf.views.list import ListAPI, ListCreateAPI # noqa -from worf.views.update import UpdateAPI # noqa +from worf.views.action import ActionAPI # noqa: F401 +from worf.views.base import AbstractBaseAPI, APIResponse # noqa: F401 +from worf.views.create import CreateAPI # noqa: F401 +from worf.views.delete import DeleteAPI # noqa: F401 +from worf.views.detail import DetailAPI, DetailUpdateAPI # noqa: F401 +from worf.views.list import ListAPI, ListCreateAPI # noqa: F401 +from worf.views.update import UpdateAPI # noqa: F401