From 202be1b29cab2ac16bd0331c966aafac9e96b288 Mon Sep 17 00:00:00 2001 From: Carl Schroedl Date: Sat, 27 Mar 2021 14:00:11 -0500 Subject: [PATCH 1/9] Remove pylint --- services/requirements.txt | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/services/requirements.txt b/services/requirements.txt index a17431b..5a8f7e2 100644 --- a/services/requirements.txt +++ b/services/requirements.txt @@ -1,5 +1,4 @@ appdirs==1.4.3 -astroid==2.5.1 boto3==1.17.26 botocore==1.20.26 CacheControl==0.12.6 @@ -11,18 +10,13 @@ distlib==0.3.0 distro==1.4.0 html5lib==1.0.1 idna==2.8 -importlib-metadata==3.7.3 ipaddr==2.2.0 -isort==5.8.0 jmespath==0.10.0 -lazy-object-proxy==1.6.0 lockfile==0.12.2 -mccabe==0.6.1 msgpack==0.6.2 packaging==20.3 pep517==0.8.2 progress==1.5 -pylint==2.7.2 pyparsing==2.4.6 python-dateutil==2.8.1 pytoml==0.1.21 @@ -30,10 +24,5 @@ requests==2.22.0 retrying==1.3.3 s3transfer==0.3.4 six==1.14.0 -toml==0.10.2 -typed-ast==1.4.2 -typing-extensions==3.7.4.3 urllib3==1.25.8 webencodings==0.5.1 -wrapt==1.12.1 -zipp==3.4.1 From 4be84c93acb2c76e6e9f3c10ffef54db281bd078 Mon Sep 17 00:00:00 2001 From: Carl Schroedl Date: Sat, 27 Mar 2021 14:16:41 -0500 Subject: [PATCH 2/9] Added flake8 --- services/requirements.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/services/requirements.txt b/services/requirements.txt index 5a8f7e2..8ff0daa 100644 --- a/services/requirements.txt +++ b/services/requirements.txt @@ -8,15 +8,21 @@ colorama==0.4.3 contextlib2==0.6.0 distlib==0.3.0 distro==1.4.0 +flake8==3.9.0 html5lib==1.0.1 idna==2.8 +importlib-metadata==3.8.1 ipaddr==2.2.0 jmespath==0.10.0 lockfile==0.12.2 +mccabe==0.6.1 msgpack==0.6.2 packaging==20.3 pep517==0.8.2 +pkg-resources==0.0.0 progress==1.5 +pycodestyle==2.7.0 +pyflakes==2.3.1 pyparsing==2.4.6 python-dateutil==2.8.1 pytoml==0.1.21 @@ -24,5 +30,8 @@ requests==2.22.0 retrying==1.3.3 s3transfer==0.3.4 six==1.14.0 +toml==0.10.2 +typing-extensions==3.7.4.3 urllib3==1.25.8 webencodings==0.5.1 +zipp==3.4.1 From 41f99bdc017073dd084f570917e189d25e131648 Mon Sep 17 00:00:00 2001 From: Carl Schroedl Date: Sat, 27 Mar 2021 14:16:58 -0500 Subject: [PATCH 3/9] Added flake8 config --- services/setup.cfg | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/setup.cfg b/services/setup.cfg index 6fe85ee..09dac95 100644 --- a/services/setup.cfg +++ b/services/setup.cfg @@ -22,3 +22,7 @@ python_requires = >=3.6 [options.packages.find] where = services + +[flake8] +exclude = .git,__pycache__,build,dist,venv +show_source = True \ No newline at end of file From a65e057d4d7abdb10884f184ccf42454b1b63c15 Mon Sep 17 00:00:00 2001 From: Carl Schroedl Date: Sat, 27 Mar 2021 14:21:56 -0500 Subject: [PATCH 4/9] Fixed flake8 linting errors --- services/services/common/http_support.py | 1 + services/services/election/handlers/create.py | 3 +-- services/services/election/handlers/delete.py | 1 + services/services/election/handlers/read.py | 1 + services/services/election/handlers/update.py | 1 + services/tests/election/handlers/test_create.py | 2 ++ 6 files changed, 7 insertions(+), 2 deletions(-) diff --git a/services/services/common/http_support.py b/services/services/common/http_support.py index 4fbca33..fb86955 100644 --- a/services/services/common/http_support.py +++ b/services/services/common/http_support.py @@ -2,6 +2,7 @@ Common HTTP Functionality """ + def cors_headers(): """ Return Cross-Origin Resource Sharing (CORS) HTTP Headers. diff --git a/services/services/election/handlers/create.py b/services/services/election/handlers/create.py index a61e87b..a5f9f5c 100644 --- a/services/services/election/handlers/create.py +++ b/services/services/election/handlers/create.py @@ -1,13 +1,12 @@ import json from services.common.http_support import cors_headers -import boto3 + def handler(event, context): body = { "message": "POST executed successfully!", "input": event } - response = { "statusCode": 200, "body": json.dumps(body), diff --git a/services/services/election/handlers/delete.py b/services/services/election/handlers/delete.py index 27ca32d..9b0f883 100644 --- a/services/services/election/handlers/delete.py +++ b/services/services/election/handlers/delete.py @@ -1,5 +1,6 @@ import json + def handler(event, context): body = { "message": "DELETE executed successfully!", diff --git a/services/services/election/handlers/read.py b/services/services/election/handlers/read.py index 2b6aee4..c64da95 100644 --- a/services/services/election/handlers/read.py +++ b/services/services/election/handlers/read.py @@ -1,5 +1,6 @@ import json + def handler(event, context): body = { "message": "GET executed successfully!", diff --git a/services/services/election/handlers/update.py b/services/services/election/handlers/update.py index 2cea3fd..f11047f 100644 --- a/services/services/election/handlers/update.py +++ b/services/services/election/handlers/update.py @@ -1,5 +1,6 @@ import json + def handler(event, context): body = { "message": "PUT executed successfully!", diff --git a/services/tests/election/handlers/test_create.py b/services/tests/election/handlers/test_create.py index 187d1df..f8ca838 100644 --- a/services/tests/election/handlers/test_create.py +++ b/services/tests/election/handlers/test_create.py @@ -5,6 +5,7 @@ import unittest from services.election.handlers.create import handler + class CreateTest(unittest.TestCase): """ Election Creation Test Suite @@ -26,5 +27,6 @@ def test(self): } self.assertEqual(handler({}, {}), expected) + if __name__ == '__main__': unittest.main() From 73c9e0866bdd21afa8ff3477a5d14d4f5dd49fea Mon Sep 17 00:00:00 2001 From: Carl Schroedl Date: Sat, 27 Mar 2021 14:22:46 -0500 Subject: [PATCH 5/9] Added flake8 to CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 45c684e..8060614 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,5 +44,5 @@ jobs: - run: | cd services pip3 install -r requirements.txt - pylint services tests + flake8 services tests python3 -m unittest From 6d63f9f09b362d813fd33dfbce27973f07e14fa2 Mon Sep 17 00:00:00 2001 From: Carl Schroedl Date: Sat, 27 Mar 2021 14:25:20 -0500 Subject: [PATCH 6/9] Added flake8 to docs --- services/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/services/README.md b/services/README.md index 8984dc0..a3a1b53 100644 --- a/services/README.md +++ b/services/README.md @@ -16,4 +16,5 @@ Make code changes, then deploy them to AWS using the [infrastructure deployment ## Useful Commands + * `flake8` lint code * `python3 -m unittest` run unit tests From 8dc9017556820d7c298f57366604f4988607e060 Mon Sep 17 00:00:00 2001 From: Carl Schroedl Date: Sat, 27 Mar 2021 14:26:26 -0500 Subject: [PATCH 7/9] remove false package --- services/requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/services/requirements.txt b/services/requirements.txt index 8ff0daa..0bf9bef 100644 --- a/services/requirements.txt +++ b/services/requirements.txt @@ -19,7 +19,6 @@ mccabe==0.6.1 msgpack==0.6.2 packaging==20.3 pep517==0.8.2 -pkg-resources==0.0.0 progress==1.5 pycodestyle==2.7.0 pyflakes==2.3.1 From 3a4a732c17d38807a556e2ffd518b4381edd25d5 Mon Sep 17 00:00:00 2001 From: Carl Schroedl Date: Sat, 27 Mar 2021 14:29:19 -0500 Subject: [PATCH 8/9] verify bad code causes linter to fail in CI --- services/services/election/handlers/delete.py | 1 + 1 file changed, 1 insertion(+) diff --git a/services/services/election/handlers/delete.py b/services/services/election/handlers/delete.py index 9b0f883..8484e14 100644 --- a/services/services/election/handlers/delete.py +++ b/services/services/election/handlers/delete.py @@ -1,5 +1,6 @@ import json +print "borked" def handler(event, context): body = { From a378d5d2ba975a89f08ae6a645021e94ad581798 Mon Sep 17 00:00:00 2001 From: Carl Schroedl Date: Sat, 27 Mar 2021 14:31:31 -0500 Subject: [PATCH 9/9] Revert "verify bad code causes linter to fail in CI" This reverts commit 3a4a732c17d38807a556e2ffd518b4381edd25d5. --- services/services/election/handlers/delete.py | 1 - 1 file changed, 1 deletion(-) diff --git a/services/services/election/handlers/delete.py b/services/services/election/handlers/delete.py index 8484e14..9b0f883 100644 --- a/services/services/election/handlers/delete.py +++ b/services/services/election/handlers/delete.py @@ -1,6 +1,5 @@ import json -print "borked" def handler(event, context): body = {