This directory contains examples demonstrating all Python code generation configurations supported by Bufrnix.
Basic Python protobuf generation without additional features.
- Generates:
*_pb2.pyfiles - Use case: Simple message serialization/deserialization
Python with gRPC service support.
- Generates:
*_pb2.pyand*_pb2_grpc.pyfiles - Use case: Building gRPC servers and clients
Python with type stubs for IDE support and static type checking.
- Generates:
*_pb2.py,*.pyi, andpy.typedmarker - Use case: Projects using mypy or requiring strong IDE support
Modern Python approach using dataclasses.
- Generates: Python files with
@dataclassdecorators - Use case: Projects wanting more Pythonic API
Comprehensive example with all features enabled.
- Generates: All of the above
- Use case: Exploring all capabilities
Each example has a test.sh script:
cd examples/python-basic
nix develop
./test.sh| Feature | basic | grpc | typed | betterproto | full |
|---|---|---|---|---|---|
| Base protobuf | ✓ | ✓ | ✓ | ✗ | ✓ |
| gRPC services | ✗ | ✓ | ✓ | ✓* | ✓ |
| Type stubs | ✗ | ✗ | ✓ | ✗ | ✓ |
| Mypy support | ✗ | ✗ | ✓ | ✗ | ✓ |
| Dataclasses | ✗ | ✗ | ✗ | ✓ | ✓ |
*Betterproto uses grpclib instead of grpcio
- Basic: When you only need message serialization
- gRPC: When building gRPC services with standard tooling
- Typed: When using type checkers or wanting better IDE support
- Betterproto: When you prefer modern Python patterns (async, dataclasses)
- Full: When experimenting or needing maximum flexibility