Skip to content

Commit cbc7952

Browse files
authored
chore: pip update + add mypy (#511)
1 parent 4cf682f commit cbc7952

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+334
-193
lines changed

.github/workflows/serverless-service.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
- name: pre commit
4444
run: |
4545
make pre-commit
46-
- name: Lint with flake8
46+
- name: Lint with flake8 and mypy
4747
run: |
4848
make lint
4949
- name: file format

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ dev:
99
lint:
1010
@echo "Running flake8"
1111
flake8 service/* cdk/* tests/* docs/examples/* --exclude patterns='build,cdk.json,cdk.context.json,.yaml'
12+
@echo "Running mypy"
13+
make mypy-lint
1214

1315
complex:
1416
@echo "Running Radon"
@@ -22,6 +24,9 @@ sort:
2224
pre-commit:
2325
pre-commit run -a --show-diff-on-failure
2426

27+
mypy-lint:
28+
mypy --pretty service docs/examples cdk tests
29+
2530
deps:
2631
pipenv requirements --dev > dev_requirements.txt
2732
pipenv requirements > lambda_requirements.txt
@@ -47,10 +52,10 @@ deploy:
4752
make deps
4853
mkdir -p .build/lambdas ; cp -r service .build/lambdas
4954
mkdir -p .build/common_layer ; pipenv requirements > .build/common_layer/requirements.txt
50-
cdk deploy --app="python3 ${PWD}/cdk/my_service/app.py" --require-approval=never
55+
cdk deploy --app="python3 ${PWD}/app.py" --require-approval=never
5156

5257
destroy:
53-
cdk destroy --app="python3 ${PWD}/cdk/my_service/app.py" --force
58+
cdk destroy --app="python3 ${PWD}/app.py" --force
5459

5560
docs:
5661
mkdocs serve

Pipfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ boto3 = "*"
2323
mkdocs-material = "*"
2424
mkdocs-git-revision-date-plugin = "*"
2525
setuptools = ">=65.5.1"
26+
types-cachetools = "*"
27+
mypy = "*"
28+
types-requests = "*"
2629

2730
[packages]
2831
aws-lambda-powertools= {extras = ["all"],version = "*"}

Pipfile.lock

Lines changed: 139 additions & 77 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ This project aims to reduce cognitive load and answer these questions for you by
4343

4444
- Python Serverless service with a recommended file structure.
4545
- CDK infrastructure with infrastructure tests and security tests.
46-
- CI/CD pipelines based on Github actions that deploys to AWS with python linters, complexity checks and style formatters.
46+
- CI/CD pipelines based on Github actions that deploys to AWS with python linters, static code analysis, complexity checks and style formatters.
4747
- The AWS Lambda handler embodies Serverless best practices and has all the bells and whistles for a proper production ready handler.
4848
- AWS Lambda handler uses [AWS Lambda Powertools](https://awslabs.github.io/aws-lambda-powertools-python/).
4949
- Unit, integration and E2E tests.

app.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env python3
2+
import os
3+
4+
from aws_cdk import App, Environment
5+
from boto3 import client, session
6+
7+
from cdk.my_service.service_stack import ServiceStack, get_stack_name
8+
9+
account = client('sts').get_caller_identity()['Account']
10+
region = session.Session().region_name
11+
app = App()
12+
my_stack = ServiceStack(
13+
app,
14+
get_stack_name(),
15+
env=Environment(account=os.environ.get('AWS_DEFAULT_ACCOUNT', account), region=os.environ.get('AWS_DEFAULT_REGION', region)),
16+
)
17+
18+
app.synth()

cdk.context.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
File renamed without changes.

cdk/my_service/app.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

cdk/my_service/cdk.context.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)