From b0950e58ccfeeac6a714361f82b8c059dd512828 Mon Sep 17 00:00:00 2001 From: Michael Weimann Date: Tue, 15 Jun 2021 18:08:57 +0200 Subject: [PATCH] add flake8 --- .flake8 | 5 +++++ Pipfile | 15 +++++++------- Pipfile.lock | 36 +++++++++++++++++++++++++++++++-- app.py | 2 +- ki/module.py | 2 +- ki/routes.py | 4 ++-- ki/test/test_skills_endpoint.py | 16 ++++++++------- test.py | 2 -- 8 files changed, 60 insertions(+), 22 deletions(-) create mode 100644 .flake8 delete mode 100644 test.py diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..418b6b5 --- /dev/null +++ b/.flake8 @@ -0,0 +1,5 @@ +[flake8] +max-line-length = 120 +exclude = + .git, + migrations diff --git a/Pipfile b/Pipfile index 703066c..23b1370 100644 --- a/Pipfile +++ b/Pipfile @@ -4,15 +4,16 @@ verify_ssl = true name = "pypi" [packages] -flask = "*" -python-dotenv = "*" -flask-migrate = "*" -flask-sqlalchemy = "*" -sqlalchemy = "*" -waitress = "*" -pyyaml = "*" +flask = "~=2.0.1" +python-dotenv = "~=0.17.1" +flask-migrate = "~=3.0.1" +flask-sqlalchemy = "~=2.5.1" +sqlalchemy = "~=1.4.18" +waitress = "~=2.0.0" +pyyaml = "~=5.4.1" [dev-packages] +flake8 = "~=3.9.2" [requires] python_version = "3.8" diff --git a/Pipfile.lock b/Pipfile.lock index 14d52c3..0b1ef91 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "5cf841925fa45f6b1c8fd6b5bd3829f5b02b81413815d3fa4755acb6c4132e2e" + "sha256": "439b60cb87b0180f0b78c531085f9bbeef7685ef038256f80b0a8123e7d144e6" }, "pipfile-spec": 6, "requires": { @@ -297,5 +297,37 @@ "version": "==2.0.1" } }, - "develop": {} + "develop": { + "flake8": { + "hashes": [ + "sha256:07528381786f2a6237b061f6e96610a4167b226cb926e2aa2b6b1d78057c576b", + "sha256:bf8fd333346d844f616e8d47905ef3a3384edae6b4e9beb0c5101e25e3110907" + ], + "index": "pypi", + "version": "==3.9.2" + }, + "mccabe": { + "hashes": [ + "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42", + "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f" + ], + "version": "==0.6.1" + }, + "pycodestyle": { + "hashes": [ + "sha256:514f76d918fcc0b55c6680472f0a37970994e07bbb80725808c17089be302068", + "sha256:c389c1d06bf7904078ca03399a4816f974a1d590090fecea0c63ec26ebaf1cef" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==2.7.0" + }, + "pyflakes": { + "hashes": [ + "sha256:7893783d01b8a89811dd72d7dfd4d84ff098e5eed95cfa8905b22bbffe52efc3", + "sha256:f5bc8ecabc05bb9d291eb5203d6810b49040f6ff446a756326104746cc00c1db" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==2.3.1" + } + } } diff --git a/app.py b/app.py index 6e5d7c0..db05bb2 100644 --- a/app.py +++ b/app.py @@ -15,4 +15,4 @@ app.config["KI_AUTH"] = os.getenv("KI_AUTH") db = SQLAlchemy(app) migrate = Migrate(app, db) -from ki import module +from ki import module # noqa diff --git a/ki/module.py b/ki/module.py index 7aa8b9a..da8bc46 100644 --- a/ki/module.py +++ b/ki/module.py @@ -1 +1 @@ -from ki import models, commands, routes +from ki import models, commands, routes # noqa diff --git a/ki/routes.py b/ki/routes.py index 3cd76e4..34247af 100644 --- a/ki/routes.py +++ b/ki/routes.py @@ -46,8 +46,8 @@ def handle_completion_request(model, key): query = query.filter(model.name.startswith(request.args.get("search"))) results = query.order_by(model.name) \ - .limit(10) \ - .all() + .limit(10) \ + .all() api_results = models_to_list(results) response_data = {} diff --git a/ki/test/test_skills_endpoint.py b/ki/test/test_skills_endpoint.py index 0bbb0d6..0603102 100644 --- a/ki/test/test_skills_endpoint.py +++ b/ki/test/test_skills_endpoint.py @@ -20,13 +20,15 @@ class TestSkillsEndpoint(unittest.TestCase): def test_get_skills1(self): response = self.client.get("/skills?search=p") self.assertEqual(response.status_code, 200) - self.assertEqual( \ - {"skills": [ \ - {"id": 1, "name": "PHP"}, \ - {"id": 3, "name": "Python"} - ]}, \ - response.json \ - ) + self.assertEqual( + { + "skills": [ + {"id": 1, "name": "PHP"}, + {"id": 3, "name": "Python"} + ] + }, + response.json + ) if __name__ == "main": diff --git a/test.py b/test.py deleted file mode 100644 index 139597f..0000000 --- a/test.py +++ /dev/null @@ -1,2 +0,0 @@ - -