@@ -9,6 +9,9 @@ PY_VER_MYPY_PROTOBUF_SHORT=$(echo $PY_VER_MYPY_PROTOBUF | cut -d. -f1-2)
9
9
PY_VER_MYPY=${PY_VER_MYPY:= 3.8.11}
10
10
PY_VER_UNIT_TESTS=" ${PY_VER_UNIT_TESTS_3:= 3.8.11} ${PY_VER_UNIT_TESTS_2:= 2.7.18} "
11
11
12
+ PROTOC_ARGS=" --proto_path=proto/ --experimental_allow_proto3_optional"
13
+ GRPC_PROTOS=$( find proto/testproto/grpc -name " *.proto" )
14
+
12
15
# Clean out generated/ directory - except for .generated / __init__.py
13
16
find test/generated -type f -not \( -name " *.expected" -or -name " __init__.py" \) -delete
14
17
@@ -72,6 +75,8 @@ MYPY_PROTOBUF_VENV=venv_$PY_VER_MYPY_PROTOBUF
72
75
# Confirm version number
73
76
test " $( protoc-gen-mypy -V) " = " mypy-protobuf 2.9"
74
77
test " $( protoc-gen-mypy --version) " = " mypy-protobuf 2.9"
78
+ test " $( protoc-gen-mypy_grpc -V) " = " mypy-protobuf 2.9"
79
+ test " $( protoc-gen-mypy_grpc --version) " = " mypy-protobuf 2.9"
75
80
76
81
# Run mypy on mypy-protobuf internal code for developers to catch issues
77
82
FILES=" mypy_protobuf/main.py"
@@ -86,7 +91,6 @@ MYPY_PROTOBUF_VENV=venv_$PY_VER_MYPY_PROTOBUF
86
91
exit 1
87
92
fi
88
93
89
- PROTOC_ARGS=" --proto_path=proto/ --experimental_allow_proto3_optional"
90
94
# Compile protoc -> python
91
95
$PROTOC $PROTOC_ARGS --python_out=test/generated ` find proto -name " *.proto" `
92
96
@@ -102,16 +106,22 @@ MYPY_PROTOBUF_VENV=venv_$PY_VER_MYPY_PROTOBUF
102
106
# Overwrite w/ run with mypy-protobuf without flags
103
107
$PROTOC $PROTOC_ARGS --mypy_out=test/generated ` find proto -name " *.proto" `
104
108
105
- # Compile GRPC
106
- GRPC_PROTOS=$( find proto/testproto/grpc -name " *.proto" )
109
+ # Generate grpc protos
107
110
$PROTOC $PROTOC_ARGS --mypy_grpc_out=test/generated $GRPC_PROTOS
108
- python -m grpc_tools.protoc $PROTOC_ARGS --grpc_python_out=test/generated $GRPC_PROTOS
109
111
)
110
112
111
113
for PY_VER in $PY_VER_UNIT_TESTS ; do
112
114
UNIT_TESTS_VENV=venv_$PY_VER
113
115
PY_VER_MYPY_TARGET=$( echo $PY_VER | cut -d. -f1-2)
114
116
117
+ # Generate GRPC protos for mypy / tests
118
+ if [[ $PY_VER =~ ^3.* ]]; then
119
+ (
120
+ source $UNIT_TESTS_VENV /bin/activate
121
+ python -m grpc_tools.protoc $PROTOC_ARGS --grpc_python_out=test/generated $GRPC_PROTOS
122
+ )
123
+ fi
124
+
115
125
# Run mypy on unit tests / generated output
116
126
(
117
127
source $MYPY_VENV /bin/activate
0 commit comments