pip install mypy-protobuf==3.2.0
Add --mypy_out="${PROJECT_DIR}"/genproto
to proto.sh file
python -m grpc_tools.protoc -I "${PROJECT_DIR}" -I "${PWD}" --mypy_out="${PROJECT_DIR}"/genproto --python_out="${PROJECT_DIR}"/genproto broker/*.proto
python -m grpc_tools.protoc -I "${PROJECT_DIR}" -I "${PWD}" --mypy_out="${PROJECT_DIR}"/genproto --python_out="${PROJECT_DIR}"/genproto broker/purchase_order/*.proto
....
if you have custom type hint like this
class CompanyData(typing.NamedTuple):
pass
async def company_create_or_update(data):
company_pb: CompanyData = pb.Company().FromString(data)
company = await models.Company.raw_objects().get(models.Company.id == company_pb.id)
change to
async def company_create_or_update(data):
company_pb = pb.Company().FromString(data)
company = await models.Company.raw_objects().get(models.Company.id == company_pb.id)