python-betterproto
python-betterproto copied to clipboard
Issue importing structures between files in subpackages
Given a file like...
import "badger/mushroom";
package badger.snake;
message Snake {
badger.mushroom.Mushroom mushroom = ...;
}
This results in compiling a badger/snake.py which includes the line from .badger import mushroom instead of from . import mushroom.
I am seeing this as well in v1.2.5. Given:
- proj/pkg1/pkg1.proto
import "proj/pkg2/pkg2.proto"; package proj.pkg1; message Test1 { proj.pkg2.Test2 test = 1; } - proj/pkg2/pkg2.proto
package proj.pkg2; message Test2 { string test = 1; }
The generated proj/pkg1/pkg1.py has:
# Generated by the protocol buffer compiler. DO NOT EDIT!
# sources: proj/pkg1/mapping.proto
# plugin: python-betterproto
from dataclasses import dataclass
from typing import Dict, List
import betterproto
from .proj import pkg2
When it should either be from .. import pkg2 or from proj import pkg2
Is this still an issue on V2.0.0b2?
Is this still an issue on V2.0.0b2?
v2.0.0b2 packs everything for each package in to the __init__.py file and seems to have solved the parent/cousin import issues.