-
Notifications
You must be signed in to change notification settings - Fork 229
builtins.NameError: name 'betterproto_lib_google_protobuf' is not defined #377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
# Generated by the protocol buffer compiler. DO NOT EDIT!
# sources: example.proto
# plugin: python-betterproto
from dataclasses import dataclass
from typing import Dict
import betterproto
from betterproto.grpc.grpclib_server import ServiceBase
import grpclib
@dataclass(eq=False, repr=False)
class Reply(betterproto.Message):
success: bool = betterproto.bool_field(1)
error: str = betterproto.string_field(2)
class UftpLinkStub(betterproto.ServiceStub):
async def start_link(self) -> "Reply":
request = betterproto_lib_google_protobuf.Empty()
return await self._unary_unary("/uftplink.UftpLink/startLink", request, Reply)
async def stop_link(self) -> "Reply":
request = betterproto_lib_google_protobuf.Empty()
return await self._unary_unary("/uftplink.UftpLink/stopLink", request, Reply)
class UftpLinkBase(ServiceBase):
async def start_link(self) -> "Reply":
raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
async def stop_link(self) -> "Reply":
raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
async def __rpc_start_link(self, stream: grpclib.server.Stream) -> None:
request = await stream.recv_message()
request_kwargs = {}
response = await self.start_link(**request_kwargs)
await stream.send_message(response)
async def __rpc_stop_link(self, stream: grpclib.server.Stream) -> None:
request = await stream.recv_message()
request_kwargs = {}
response = await self.stop_link(**request_kwargs)
await stream.send_message(response)
def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
return {
"/uftplink.UftpLink/startLink": grpclib.const.Handler(
self.__rpc_start_link,
grpclib.const.Cardinality.UNARY_UNARY,
betterproto_lib_google_protobuf.Empty,
Reply,
),
"/uftplink.UftpLink/stopLink": grpclib.const.Handler(
self.__rpc_stop_link,
grpclib.const.Cardinality.UNARY_UNARY,
betterproto_lib_google_protobuf.Empty,
Reply,
),
}
import betterproto.lib.google.protobuf as betterproto_lib_google_protobuf This is the file that I get generated, everything here looks fine to me. This however isn't the full 300+ line file that you are using so maybe you need the whole thing? |
I shorten the proto file, check |
|
For the master verion of betterproto, the line is missed in the produced python: # Generated by the protocol buffer compiler. DO NOT EDIT!
# sources: test.proto
# plugin: python-betterproto
from dataclasses import dataclass
from typing import (
TYPE_CHECKING,
Dict,
Optional,
)
import betterproto
import grpclib
from betterproto.grpc.grpclib_server import ServiceBase
if TYPE_CHECKING:
from betterproto.grpc.grpclib_client import MetadataLike
from grpclib.metadata import Deadline
@dataclass(eq=False, repr=False)
class Reply(betterproto.Message):
success: bool = betterproto.bool_field(1)
error: str = betterproto.string_field(2)
class UftpLinkStub(betterproto.ServiceStub):
async def start_link(
self,
timeout: Optional[float] = None,
deadline: Optional["Deadline"] = None,
metadata: Optional["_MetadataLike"] = None,
) -> "Reply":
return await self._unary_unary(
"/uftplink.UftpLink/startLink",
betterproto_lib_google_protobuf_empty,
Reply,
timeout=timeout,
deadline=deadline,
metadata=metadata,
)
async def stop_link(
self,
timeout: Optional[float] = None,
deadline: Optional["Deadline"] = None,
metadata: Optional["_MetadataLike"] = None,
) -> "Reply":
return await self._unary_unary(
"/uftplink.UftpLink/stopLink",
betterproto_lib_google_protobuf_empty,
Reply,
timeout=timeout,
deadline=deadline,
metadata=metadata,
)
class UftpLinkBase(ServiceBase):
async def start_link(self) -> "Reply":
raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
async def stop_link(self) -> "Reply":
raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
async def __rpc_start_link(self, stream: grpclib.server.Stream) -> None:
request = await stream.recv_message()
response = await self.start_link(request)
await stream.send_message(response)
async def __rpc_stop_link(self, stream: grpclib.server.Stream) -> None:
request = await stream.recv_message()
response = await self.stop_link(request)
await stream.send_message(response)
def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
return {
"/uftplink.UftpLink/startLink": grpclib.const.Handler(
self.__rpc_start_link,
grpclib.const.Cardinality.UNARY_UNARY,
betterproto_lib_google_protobuf.Empty,
Reply,
),
"/uftplink.UftpLink/stopLink": grpclib.const.Handler(
self.__rpc_stop_link,
grpclib.const.Cardinality.UNARY_UNARY,
betterproto_lib_google_protobuf.Empty,
Reply,
),
} I uninstall and then reinstall betterproto for the latest version:
|
Ok yes I've been able to reproduce this on master fix incoming soon |
I've managed to fix this locally. The fix should be ready for testing tomorrow |
manually add line |
also |
Would you mind testing generation with #381? |
@Gobot1234 I'll test it tomorrow, become it only occured in another pc which is not at my handside rightnow. |
@Gobot1234 test passed! |
Env: win10/python3.10.4/python-betterproto 2.0.0b4+
proto file:
The text was updated successfully, but these errors were encountered: