Description
Relative imports are broken when a Buf module has a dependency on another one and you try to import a protobuf type.
Steps to Reproduce
- Create two Buf modules
- Add a dependency from one to the other
- Install the package that has the dependency
- Try to import a protobuf type
(You can also depend on a pre-existing module, e.g. protovalidate)
Expected Behavior
Package is installable and types are importable.
Actual Behavior
The Buf registry packages use relative imports that are incorrect and try to recurse too many levels upwards.
Screenshots/Logs
from ...buf.validate import validate_pb
ImportError: attempted relative import beyond top-level package
Environment
- protobuf-py Version: 0.2.0 / 0.3.0
- protobuf-py Plugin (
protoc-gen-py) Version: Unsure - whatever Buf registry is using
- Python Version: 3.12
- Protobuf Compiler & Version: Unsure - whatever Buf registry is using
- Operating System and Version: macOS 26.6.1 (aarch64)
Possible Solution
Additional Context
See #15
Description
Relative imports are broken when a Buf module has a dependency on another one and you try to import a protobuf type.
Steps to Reproduce
(You can also depend on a pre-existing module, e.g.
protovalidate)Expected Behavior
Package is installable and types are importable.
Actual Behavior
The Buf registry packages use relative imports that are incorrect and try to recurse too many levels upwards.
Screenshots/Logs
Environment
protoc-gen-py) Version: Unsure - whatever Buf registry is usingPossible Solution
Additional Context
See #15