@@ -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
@@ -86,7 +89,6 @@ MYPY_PROTOBUF_VENV=venv_$PY_VER_MYPY_PROTOBUF
86
89
exit 1
87
90
fi
88
91
89
- PROTOC_ARGS=" --proto_path=proto/ --experimental_allow_proto3_optional"
90
92
# Compile protoc -> python
91
93
$PROTOC $PROTOC_ARGS --python_out=test/generated ` find proto -name " *.proto" `
92
94
@@ -102,16 +104,23 @@ MYPY_PROTOBUF_VENV=venv_$PY_VER_MYPY_PROTOBUF
102
104
# Overwrite w/ run with mypy-protobuf without flags
103
105
$PROTOC $PROTOC_ARGS --mypy_out=test/generated ` find proto -name " *.proto" `
104
106
105
- # Compile GRPC
106
- GRPC_PROTOS=$( find proto/testproto/grpc -name " *.proto" )
107
+ # Generate grpc protos
107
108
$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
109
)
110
110
111
111
for PY_VER in $PY_VER_UNIT_TESTS ; do
112
112
UNIT_TESTS_VENV=venv_$PY_VER
113
113
PY_VER_MYPY_TARGET=$( echo $PY_VER | cut -d. -f1-2)
114
114
115
+ # Generate GRPC protos for mypy / tests
116
+ if [[ $PY_VER =~ ^3.* ]]; then
117
+ (
118
+ source $UNIT_TESTS_VENV /bin/activate
119
+ $PROTOC $PROTOC_ARGS --mypy_grpc_out=test/generated $GRPC_PROTOS
120
+ python -m grpc_tools.protoc $PROTOC_ARGS --grpc_python_out=test/generated $GRPC_PROTOS
121
+ )
122
+ fi
123
+
115
124
# Run mypy on unit tests / generated output
116
125
(
117
126
source $MYPY_VENV /bin/activate
0 commit comments