{"library":"mypy-protobuf","code":"mkdir -p project/proto project/output\n\ncat <<EOF > project/proto/example.proto\nsyntax = \"proto3\";\n\npackage example;\n\nmessage MyMessage {\n  string name = 1;\n  int32 id = 2;\n  bool is_active = 3;\n}\nEOF\n\n# Ensure protoc and protoc-gen-mypy are in PATH or specify full paths\n# protoc --plugin=protoc-gen-mypy=/path/to/protoc-gen-mypy ...\nprotoc --python_out=project/output --mypy_out=project/output project/proto/example.proto\n\n# Expected output will include example_pb2.py and example_pb2.pyi in project/output\n\ncat <<EOF > project/main.py\nfrom project.output import example_pb2\n\ndef process_message(msg: example_pb2.MyMessage) -> None:\n    print(f\"Processing: {msg.name} (ID: {msg.id}, Active: {msg.is_active})\")\n\n# Correct usage\nmy_msg = example_pb2.MyMessage(name=\"Test\", id=123, is_active=True)\nprocess_message(my_msg)\n\n# Incorrect usage (mypy would catch this)\n# invalid_msg = example_pb2.MyMessage(name=123, id=\"abc\")\n# process_message(invalid_msg)\nEOF\n\n# Run mypy to type-check the project\nmypy project","lang":"bash","description":"This quickstart demonstrates how to generate Python protobuf code and mypy stubs from a `.proto` file, and then use `mypy` to type-check Python code that consumes these generated types. It first creates a sample `.proto` file, then uses `protoc` with the `mypy-protobuf` plugin to generate the `.py` and `.pyi` files. Finally, it provides a Python script that imports and uses the generated message, along with a `mypy` command to verify type correctness.","tag":null,"tag_description":null,"last_tested":"2026-04-24","results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}