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 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 diff --git a/services/requirements.txt b/services/requirements.txt index a17431b..0bf9bef 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 @@ -9,20 +8,20 @@ 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.7.3 +importlib-metadata==3.8.1 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 +pycodestyle==2.7.0 +pyflakes==2.3.1 pyparsing==2.4.6 python-dateutil==2.8.1 pytoml==0.1.21 @@ -31,9 +30,7 @@ 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 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/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 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()