Skip to content

Services with same package gets its comment overwritten #221

@qria

Description

@qria

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 6c1c41e .

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions