@@ -9,6 +9,9 @@ PY_VER_MYPY_PROTOBUF_SHORT=$(echo $PY_VER_MYPY_PROTOBUF | cut -d. -f1-2)
99PY_VER_MYPY=${PY_VER_MYPY:= 3.8.11}
1010PY_VER_UNIT_TESTS=" ${PY_VER_UNIT_TESTS_3:= 3.8.11} ${PY_VER_UNIT_TESTS_2:= 2.7.18} "
1111
12+ PROTOC_ARGS=" --proto_path=proto/ --experimental_allow_proto3_optional"
13+ GRPC_PROTOS=$( find proto/testproto/grpc -name " *.proto" )
14+
1215# Clean out generated/ directory - except for .generated / __init__.py
1316find test/generated -type f -not \( -name " *.expected" -or -name " __init__.py" \) -delete
1417
@@ -72,6 +75,8 @@ MYPY_PROTOBUF_VENV=venv_$PY_VER_MYPY_PROTOBUF
7275 # Confirm version number
7376 test " $( protoc-gen-mypy -V) " = " mypy-protobuf 2.9"
7477 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"
7580
7681 # Run mypy on mypy-protobuf internal code for developers to catch issues
7782 FILES=" mypy_protobuf/main.py"
@@ -86,7 +91,6 @@ MYPY_PROTOBUF_VENV=venv_$PY_VER_MYPY_PROTOBUF
8691 exit 1
8792 fi
8893
89- PROTOC_ARGS=" --proto_path=proto/ --experimental_allow_proto3_optional"
9094 # Compile protoc -> python
9195 $PROTOC $PROTOC_ARGS --python_out=test/generated ` find proto -name " *.proto" `
9296
@@ -102,16 +106,22 @@ MYPY_PROTOBUF_VENV=venv_$PY_VER_MYPY_PROTOBUF
102106 # Overwrite w/ run with mypy-protobuf without flags
103107 $PROTOC $PROTOC_ARGS --mypy_out=test/generated ` find proto -name " *.proto" `
104108
105- # Compile GRPC
106- GRPC_PROTOS=$( find proto/testproto/grpc -name " *.proto" )
109+ # Generate grpc protos
107110 $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
109111)
110112
111113for PY_VER in $PY_VER_UNIT_TESTS ; do
112114 UNIT_TESTS_VENV=venv_$PY_VER
113115 PY_VER_MYPY_TARGET=$( echo $PY_VER | cut -d. -f1-2)
114116
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+
115125 # Run mypy on unit tests / generated output
116126 (
117127 source $MYPY_VENV /bin/activate
0 commit comments