From 0d695d0f9eada88f80fb4e52fc45d1345c10c19d Mon Sep 17 00:00:00 2001 From: Steve Lacey Date: Tue, 26 Oct 2021 17:15:02 +0700 Subject: [PATCH] Lint script --- .github/workflows/ci.yml | 3 +- Pipfile | 8 ++- Pipfile.lock | 111 +++++++++++++++++++++------------------ script/lint | 15 ++++++ worf/views/__init__.py | 17 ++---- 5 files changed, 86 insertions(+), 68 deletions(-) create mode 100755 script/lint diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6e6421b..aa9a59b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,5 +27,6 @@ jobs: - uses: actions/setup-python@v2 with: python-version: 3.8.8 - - run: pip install black + - run: pip install black flake8 - run: black worf --check + - run: flake8 worf diff --git a/Pipfile b/Pipfile index f783d10..d1300cb 100644 --- a/Pipfile +++ b/Pipfile @@ -8,8 +8,10 @@ name = "pypi" worf = {editable = true, path = "."} [dev-packages] +autoflake = "*" autopep8 = "*" black = "==20.8b1" +build = "*" coverage = "*" factory-boy = "*" flake8 = "*" @@ -18,10 +20,12 @@ pytest = "*" pytest-cov = "*" pytest-django = "*" pytest-factoryboy = "*" -pytest-xdist = {extras = ["psutil"], version = "*"} pytest-watch = "*" -build = "*" +pytest-xdist = {extras = ["psutil"], version = "*"} twine = "*" [requires] python_version = "3.8" + +[scripts] +lint = "./script/lint" diff --git a/Pipfile.lock b/Pipfile.lock index d903312..f1370b5 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "fa720675bb1329780623ed8e3a00639db26d651e452bcf330ae16680e7e4ebc4" + "sha256": "851f6f398ccf8ef0e0669e130f1afe296cee29a77af6ccfdb11b2b341319f43a" }, "pipfile-spec": 6, "requires": { @@ -97,13 +97,20 @@ "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", "version": "==21.2.0" }, + "autoflake": { + "hashes": [ + "sha256:61a353012cff6ab94ca062823d1fb2f692c4acda51c76ff83a8d77915fba51ea" + ], + "index": "pypi", + "version": "==1.4" + }, "autopep8": { "hashes": [ - "sha256:276ced7e9e3cb22e5d7c14748384a5cf5d9002257c0ed50c0e075b68011bb6d0", - "sha256:aa213493c30dcdac99537249ee65b24af0b2c29f2e83cd8b3f68760441ed0db9" + "sha256:44f0932855039d2c15c4510d6df665e4730f2b8582704fa48f9c55bd3e17d979", + "sha256:ed77137193bbac52d029a52c59bec1b0629b5a186c495f1eb21b126ac466083f" ], "index": "pypi", - "version": "==1.5.7" + "version": "==1.6.0" }, "black": { "hashes": [ @@ -314,11 +321,11 @@ }, "faker": { "hashes": [ - "sha256:262d51b4e536adf58f09fdccc510b69a5a7348d9ca698402c0fccfaed93c60a7", - "sha256:449ab92ab9bd663095df251444b9e974862f81f0dfa479ba9c5ae7277ec85827" + "sha256:072b61422be9da464b0bb40cdb44267dd584582056b77a2982d7c66c767f044c", + "sha256:8ffd1ca479364a2ea78fe23a5710d5f940c50576f45c3f62edf9f7f9242cec0b" ], "markers": "python_version >= '3.6'", - "version": "==9.5.2" + "version": "==9.6.0" }, "flake8": { "hashes": [ @@ -508,11 +515,11 @@ }, "pyparsing": { "hashes": [ - "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1", - "sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b" + "sha256:84196357aa3566d64ad123d7a3c67b0e597a115c4934b097580e5ce220b91531", + "sha256:fd93fc45c47893c300bd98f5dd1b41c0e783eaeb727e7cea210dcc09d64ce7c3" ], - "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==2.4.7" + "markers": "python_version >= '3.6'", + "version": "==3.0.1" }, "pytest": { "hashes": [ @@ -589,44 +596,44 @@ }, "regex": { "hashes": [ - "sha256:0f82de529d7595011a40573cc0f27422e59cafa94943b64a4d17d966d75f2c01", - "sha256:130a002fa386c976615a2f6d6dff0fcc25da24858994a36b14d2e3129dce7de2", - "sha256:164e51ace4d00f07c519f85ec2209e8faaeab18bc77be6b35685c18d4ac1c22a", - "sha256:19c4fd59747236423016ccd89b9a6485d958bf1aa7a8a902a6ba28029107a87f", - "sha256:201890fdc8a65396cfb6aa4493201353b2a6378e27d2de65234446f8329233cb", - "sha256:2044174af237bb9c56ecc07294cf38623ee379e8dca14b01e970f8b015c71917", - "sha256:2ff91696888755e96230138355cbe8ce2965d930d967d6cff7c636082d038c78", - "sha256:3b5a0660a63b0703380758a7141b96cc1c1a13dee2b8e9c280a2522962fd12af", - "sha256:468de52dd3f20187ab5ca4fd265c1bea61a5346baef01ad0333a5e89fa9fad29", - "sha256:4832736b3f24617e63dc919ce8c4215680ba94250a5d9e710fcc0c5f457b5028", - "sha256:5b75a3db3aab0bfa51b6af3f820760779d360eb79f59e32c88c7fba648990b4f", - "sha256:678d9a4ce79e1eaa4ebe88bc9769df52919eb30c597576a0deba1f3cf2360e65", - "sha256:72a0b98d41c4508ed23a96eef41090f78630b44ba746e28cd621ecbe961e0a16", - "sha256:740a28580520b099b804776db1e919360fcbf30a734a14c5985d5e39a39e7237", - "sha256:74d03c256cf0aed81997e87be8e24297b5792c9718f3a735f5055ddfad392f06", - "sha256:8bd83d9b8ee125350cd666b55294f4bc9993c4f0d9b1be9344a318d0762e94cc", - "sha256:98743a2d827a135bf3390452be18d95839b947a099734d53c17e09a64fc09480", - "sha256:98fe0e1b07a314f0a86dc58af4e717c379d48a403eddd8d966ab9b8bf91ce164", - "sha256:9c613d797a3790f6b12e78a61e1cd29df7fc88135218467cf8b0891353292b9c", - "sha256:9cd14f22425beecf727f6dbdf5c893e46ecbc5ff16197c16a6f38a9066f2d4d5", - "sha256:ad1fedca001fefc3030d1e9022b038af429e58dc06a7e9c55e40bd1f834582ec", - "sha256:b9dfba513eae785e3d868803f5a7e21a032cb2b038fa4a1ea7ec691037426ad3", - "sha256:bc4637390235f1e3e2fcdd3e904ca0b42aa655ae28a78072248b2992b4ad4c08", - "sha256:c0f49f1f03be3e4a5faaadc35db7afa2b83a871943b889f9f7bba56e0e2e8bd5", - "sha256:c5a2ac760f2fc13a1c58131ec217779911890899ce1a0a63c9409bd23fecde6f", - "sha256:d6432daf42f2c487b357e1aa0bdc43193f050ff53a3188bfab20b88202b53027", - "sha256:dc1a9bedf389bf3d3627a4d2b21cbdc5fe5e0f029d1f465972f4437833dcc946", - "sha256:de7dbf72ae80f06e79444ff9614fb5e3a7956645d513b0e12d1bbe6f3ccebd11", - "sha256:ded4748c7be6f31fb207387ee83a3a0f625e700defe32f268cb1d350ed6e4a66", - "sha256:e39eafa854e469d7225066c806c76b9a0acba5ff5ce36c82c0224b75e24888f2", - "sha256:edff4e31d159672a7b9d70164b21289e4b53b239ce1dc945bf9643d266537573", - "sha256:f1b23304855303bd97b5954edab63b8ddd56c91c41c6d4eba408228c0bae95f3", - "sha256:f3da121de36a9ead0f32b44ea720ee8c87edbb59dca6bb980d18377d84ad58a3", - "sha256:f68c71aabb10b1352a06515e25a425a703ba85660ae04cf074da5eb91c0af5e5", - "sha256:f82d3adde46ac9188db3aa7e6e1690865ebb6448d245df5a3ea22284f70d9e46", - "sha256:fd1bfc6b7347de9f0ae1fb6f9080426bed6a9ca55b5766fa4fdf7b3a29ccae9c" - ], - "version": "==2021.10.21" + "sha256:0c186691a7995ef1db61205e00545bf161fb7b59cdb8c1201c89b333141c438a", + "sha256:0dcc0e71118be8c69252c207630faf13ca5e1b8583d57012aae191e7d6d28b84", + "sha256:0f7552429dd39f70057ac5d0e897e5bfe211629652399a21671e53f2a9693a4e", + "sha256:129472cd06062fb13e7b4670a102951a3e655e9b91634432cfbdb7810af9d710", + "sha256:13ec99df95003f56edcd307db44f06fbeb708c4ccdcf940478067dd62353181e", + "sha256:1f2b59c28afc53973d22e7bc18428721ee8ca6079becf1b36571c42627321c65", + "sha256:2b20f544cbbeffe171911f6ce90388ad36fe3fad26b7c7a35d4762817e9ea69c", + "sha256:2fb698037c35109d3c2e30f2beb499e5ebae6e4bb8ff2e60c50b9a805a716f79", + "sha256:34d870f9f27f2161709054d73646fc9aca49480617a65533fc2b4611c518e455", + "sha256:391703a2abf8013d95bae39145d26b4e21531ab82e22f26cd3a181ee2644c234", + "sha256:450dc27483548214314640c89a0f275dbc557968ed088da40bde7ef8fb52829e", + "sha256:45b65d6a275a478ac2cbd7fdbf7cc93c1982d613de4574b56fd6972ceadb8395", + "sha256:5095a411c8479e715784a0c9236568ae72509450ee2226b649083730f3fadfc6", + "sha256:530fc2bbb3dc1ebb17f70f7b234f90a1dd43b1b489ea38cea7be95fb21cdb5c7", + "sha256:56f0c81c44638dfd0e2367df1a331b4ddf2e771366c4b9c5d9a473de75e3e1c7", + "sha256:5e9c9e0ce92f27cef79e28e877c6b6988c48b16942258f3bc55d39b5f911df4f", + "sha256:6d7722136c6ed75caf84e1788df36397efdc5dbadab95e59c2bba82d4d808a4c", + "sha256:74d071dbe4b53c602edd87a7476ab23015a991374ddb228d941929ad7c8c922e", + "sha256:7b568809dca44cb75c8ebb260844ea98252c8c88396f9d203f5094e50a70355f", + "sha256:80bb5d2e92b2258188e7dcae5b188c7bf868eafdf800ea6edd0fbfc029984a88", + "sha256:8d1cdcda6bd16268316d5db1038965acf948f2a6f43acc2e0b1641ceab443623", + "sha256:9f665677e46c5a4d288ece12fdedf4f4204a422bb28ff05f0e6b08b7447796d1", + "sha256:a30513828180264294953cecd942202dfda64e85195ae36c265daf4052af0464", + "sha256:a7a986c45d1099a5de766a15de7bee3840b1e0e1a344430926af08e5297cf666", + "sha256:a940ca7e7189d23da2bfbb38973832813eab6bd83f3bf89a977668c2f813deae", + "sha256:ab7c5684ff3538b67df3f93d66bd3369b749087871ae3786e70ef39e601345b0", + "sha256:be04739a27be55631069b348dda0c81d8ea9822b5da10b8019b789e42d1fe452", + "sha256:c0938ddd60cc04e8f1faf7a14a166ac939aac703745bfcd8e8f20322a7373019", + "sha256:cb46b542133999580ffb691baf67410306833ee1e4f58ed06b6a7aaf4e046952", + "sha256:d134757a37d8640f3c0abb41f5e68b7cf66c644f54ef1cb0573b7ea1c63e1509", + "sha256:de557502c3bec8e634246588a94e82f1ee1b9dfcfdc453267c4fb652ff531570", + "sha256:ded0c4a3eee56b57fcb2315e40812b173cafe79d2f992d50015f4387445737fa", + "sha256:e1dae12321b31059a1a72aaa0e6ba30156fe7e633355e445451e4021b8e122b6", + "sha256:eb672217f7bd640411cfc69756ce721d00ae600814708d35c930930f18e8029f", + "sha256:ee684f139c91e69fe09b8e83d18b4d63bf87d9440c1eb2eeb52ee851883b1b29", + "sha256:f3f9a91d3cc5e5b0ddf1043c0ae5fa4852f18a1c0050318baf5fc7930ecc1f9c" + ], + "version": "==2021.10.23" }, "requests": { "hashes": [ @@ -683,11 +690,11 @@ }, "tomli": { "hashes": [ - "sha256:8dd0e9524d6f386271a36b41dbf6c57d8e32fd96fd22b6584679dc569d20899f", - "sha256:a5b75cb6f3968abb47af1b40c1819dc519ea82bcc065776a866e8d74c5ca9442" + "sha256:c6ce0015eb38820eaf32b5db832dbc26deb3dd427bd5f6556cf0acac2c214fee", + "sha256:f04066f68f5554911363063a30b108d2b5a5b1a010aa8b6132af78489fe3aade" ], "markers": "python_version >= '3.6'", - "version": "==1.2.1" + "version": "==1.2.2" }, "tqdm": { "hashes": [ diff --git a/script/lint b/script/lint new file mode 100755 index 0000000..56bc388 --- /dev/null +++ b/script/lint @@ -0,0 +1,15 @@ +#!/bin/bash + +set -eou pipefail +cd "$(dirname "$0")/.." + +Y=$(tput setaf 3) X=$(tput sgr0) + +echo -e "${Y}==>${X} Autoflake" +autoflake --in-place --recursive --remove-all-unused-imports worf + +echo -e "${Y}==>${X} Black" +black worf + +echo -e "${Y}==>${X} Flake8" +flake8 worf diff --git a/worf/views/__init__.py b/worf/views/__init__.py index e93525e..fc48c44 100644 --- a/worf/views/__init__.py +++ b/worf/views/__init__.py @@ -1,13 +1,4 @@ -from worf.views.detail import ( - DetailAPI, - DetailUpdateAPI, -) -from worf.views.list import ( - ListAPI, - ListCreateAPI, -) -from worf.views.base import ( - APIResponse, - AbstractBaseAPI, -) -from worf.views.create import CreateAPI +from worf.views.base import APIResponse, AbstractBaseAPI # noqa +from worf.views.create import CreateAPI # noqa +from worf.views.detail import DetailAPI, DetailUpdateAPI # noqa +from worf.views.list import ListAPI, ListCreateAPI # noqa