File tree 7 files changed +32
-6
lines changed 7 files changed +32
-6
lines changed Original file line number Diff line number Diff line change 15
15
- name : Install Library
16
16
run : |
17
17
python3 -m pip install --upgrade pip
18
- pip install requests flask
18
+ pip install requests flask mypy
19
+ - name : Run mypy
20
+ run : |
21
+ mypy python_test_example --config-file python_test_example/mypy.ini
19
22
- name : Run unittest
20
23
run : |
21
24
cd python_test_example
Original file line number Diff line number Diff line change 1
1
FROM python:3.7-slim
2
2
3
3
RUN pip install --no-cache-dir --upgrade pip setuptools wheel \
4
- && pip install --no-cache-dir requests flask
4
+ && pip install --no-cache-dir requests flask mypy
Original file line number Diff line number Diff line change @@ -10,6 +10,10 @@ dbuild:
10
10
drun :
11
11
docker run --rm -it -v $(curdir ) :/opt -w /opt $(image ) :$(tag ) bash
12
12
13
+ .PHONY : drmi
14
+ drmi :
15
+ docker rmi -f $(image ) :$(tag )
16
+
13
17
.PHONY : all_test
14
18
all_test :
15
19
python3 -m unittest discover --verbose --pattern " *_test.py"
Original file line number Diff line number Diff line change 1
1
import json
2
2
3
3
from flask import Flask , jsonify , make_response
4
+ from flask .wrappers import Response
4
5
5
6
from .service import Service
6
7
10
11
service = Service ()
11
12
12
13
@app .route ('/' , methods = ['GET' ])
13
- def index ():
14
+ def index () -> Response :
14
15
message = {'message' : 'OK' }
15
16
return make_response (jsonify (message ), 200 )
16
17
17
18
@app .route ('/predict' , methods = ['POST' ])
18
- def predict ():
19
+ def predict () -> Response :
19
20
print ('Call predict in app' )
20
21
target = 'A'
21
22
if not service .check_model ():
Original file line number Diff line number Diff line change 1
- def load_model ():
1
+ def load_model () -> str :
2
2
print ('Call load_model in model' )
3
3
return 'model'
Original file line number Diff line number Diff line change 5
5
print ('In service' )
6
6
7
7
class Service :
8
- def __init__ (self ):
8
+ def __init__ (self ) -> None :
9
9
print ('Init Service' )
10
10
self .model = load_model ()
11
11
print (f'self.model: { self .model } ' )
Original file line number Diff line number Diff line change
1
+ [mypy]
2
+ python_version = 3.7
3
+ disallow_untyped_defs = True
4
+ ignore_missing_imports = True
5
+ warn_redundant_casts = True
6
+ no_implicit_optional = True
7
+
8
+ [mypy-flask_app.app_test.*]
9
+ disallow_untyped_defs = False
10
+
11
+ [mypy-i76_testcase_subclass.utils_test.*]
12
+ disallow_untyped_defs = False
13
+
14
+ [mypy-i77_setup_and_teardown.*]
15
+ disallow_untyped_defs = False
16
+
17
+ [mypy-mock.my_class_test.*]
18
+ disallow_untyped_defs = False
You can’t perform that action at this time.
0 commit comments