python-betterproto icon indicating copy to clipboard operation
python-betterproto copied to clipboard

Services with same package gets its comment overwritten

Open qria opened this issue 4 years ago • 0 comments

Say you have two files service1.proto and service2.proto with same package assigned:

service1.proto:

syntax = "proto3";

package service;

/* Service1 */
service Service1 {}

service2.proto:

syntax = "proto3";

package service;

/* Service2 */
service Service2 {}

Compiling these together with the command python3 -m grpc_tools.protoc -I . --python_betterproto_out=./ service1.proto service2.proto results in this:

service/init.py:

# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: service1.proto, service2.proto
# plugin: python-betterproto
from dataclasses import dataclass
from typing import Dict

import betterproto
from betterproto.grpc.grpclib_server import ServiceBase
import grpclib


class Service1Stub(betterproto.ServiceStub):
    """Service1"""


class Service2Stub(betterproto.ServiceStub):
    """Service1"""


class Service1Base(ServiceBase):
    """Service1"""

    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        return {}


class Service2Base(ServiceBase):
    """Service1"""

    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        return {}

As you can see the comment for Service2 got overwritten.

I have reproduced this with current master branch, which I believe is version 2.0.0b2 with commit hash 6c1c41e9ccf7d020641e87f82e6419c3393a3841 .

qria avatar Mar 07 '21 05:03 qria