Skip to content

Commit 3267a7d

Browse files
committed
Type checking
1 parent cab7d09 commit 3267a7d

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

Makefile

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ ci: typecheck test lint
1919

2020
typecheck:
2121
@echo check types
22-
mypy ./ \
23-
--disallow-untyped-defs \
24-
--disallow-any-expr \
25-
--no-implicit-optional \
26-
--no-site-packages \
22+
mypy ./python_api_template
2723

2824
lint:
2925
@echo check style
@@ -37,9 +33,6 @@ test:
3733
##### application
3834
GUNICORN_CONFIG_PATH := config/gunicorn.py
3935

40-
install:
41-
poetry install
42-
4336
launch:
4437
gunicorn app:app -c ${GUNICORN_CONFIG_PATH}
4538

mypy.ini

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Global options:
2+
3+
[mypy]
4+
python_version = 3.7
5+
disallow_untyped_defs = True
6+
no_implicit_optional = True
7+
8+
# Per-module options:
9+
[tests/*]
10+
ignore_errors = True

python_api_template/controller.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
11

22
from flask import Blueprint, Flask, jsonify
3+
from flask.wrappers import Response
34

45

56
dummy = Blueprint('dummy', __name__)
67
api = Blueprint('api', __name__)
78

89

910
@dummy.route('/', methods=["GET"])
10-
def dummy_home():
11+
def dummy_home() -> Response:
1112
return jsonify({
1213
"msg": "hello {}".format(dummy.name)
1314
})
1415

1516

1617
@api.route('/', methods=["GET"])
17-
def api_home():
18+
def api_home() -> Response:
1819
return jsonify({
1920
"msg": "hey {}".format(api.name)
2021
})
2122

2223

23-
def create_app(env=None):
24+
def create_app() -> Flask:
2425
app = Flask(__name__)
2526
app.url_map.strict_slashes = False
2627
app.register_blueprint(dummy, url_prefix='/dummy')
2728
app.register_blueprint(api, url_prefix='/api')
2829

2930
@app.route("/health")
30-
def health():
31+
def health() -> Response:
3132
return jsonify({
3233
"msg": "I'm healthy"
3334
})

0 commit comments

Comments
 (0)