Include mypy for type checking

main
Hammy 3 years ago
parent c2b53c838d
commit 92f4a574f6

@ -20,5 +20,5 @@ venv:
. ${VENV_NAME}/Scripts/activate . ${VENV_NAME}/Scripts/activate
echo "virtualenv prepared, please run 'source ${VENV_NAME}/bin/activate' if you wish to use it in your current shell" echo "virtualenv prepared, please run 'source ${VENV_NAME}/bin/activate' if you wish to use it in your current shell"
pycodestyle: venv pycodestyle:
. ${VENV_NAME}/Scripts/activate && pycodestyle --first src/template.py . ${VENV_NAME}/Scripts/activate && mypy --warn-unused-configs --disallow-any-generics --disallow-subclassing-any --disallow-untyped-calls --disallow-untyped-defs --disallow-incomplete-defs --check-untyped-defs --disallow-untyped-decorators --no-implicit-optional --warn-redundant-casts --warn-unused-ignores --warn-return-any --no-implicit-reexport --strict-equality --ignore-missing-imports --pretty src/*.py && pycodestyle --first src/*.py

@ -1,4 +1,5 @@
troposphere==3.0.2 troposphere==3.0.2
awacs==2.0.0 awacs==2.0.0
ydiff ydiff==1.2
pycodestyle==2.7.0 pycodestyle==2.7.0
mypy==0.910

@ -1,18 +1,18 @@
from troposphere import Template from troposphere import Template
from troposphere.sqs import Queue
from util import Util from util import Util
PROJECT_NAME = "Tweeter" PROJECT_NAME: str = "Tweeter"
S3_QUEUE_NAME = PROJECT_NAME + "S3Queue" S3_QUEUE_NAME: str = "S3Queue"
TWEETER_QUEUE_NAME = PROJECT_NAME + "Queue" TWEETER_QUEUE_NAME: str = "TwitterQueue"
DYNAMO_DB_QUEUE_NAME = PROJECT_NAME + "DynamoDbQueue" DYNAMO_DB_QUEUE_NAME: str = "DynamoDbQueue"
SHARED_CONFIG_BUCKET_NAME = PROJECT_NAME + "SharedConfig"
template = Template(PROJECT_NAME + "Workflow") template: Template = Template(PROJECT_NAME + "Workflow")
templateUtil = Util(template) templateUtil: Util = Util(template)
s3_queue = templateUtil.create_queue(S3_QUEUE_NAME) s3_queue: Queue = templateUtil.create_queue(S3_QUEUE_NAME)
tweeter_queue = templateUtil.create_queue(TWEETER_QUEUE_NAME) tweeter_queue: Queue = templateUtil.create_queue(TWEETER_QUEUE_NAME)
dynamo_db_queue = templateUtil.create_queue(DYNAMO_DB_QUEUE_NAME) dynamo_db_queue: Queue = templateUtil.create_queue(DYNAMO_DB_QUEUE_NAME)
print(template.to_json()) print(template.to_json())

@ -1,11 +1,12 @@
from troposphere import Template
from troposphere.sqs import Queue from troposphere.sqs import Queue
class Util: class Util:
def __init__(self, template): def __init__(self, template: Template) -> None:
self.template = template self.template = template
def create_queue(self, queue_name): def create_queue(self, queue_name: str) -> Queue:
return self.template.add_resource( return self.template.add_resource(
Queue( Queue(
queue_name, queue_name,

Loading…
Cancel
Save