Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Invalid Enum member names which contain the Enum name

オープン
#603 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
compilers

調査の方向性

test.proto の定義と、ドキュメントに記載されている protoc -I . --python_betterproto_out=lib test.proto コマンドを使って issue を再現します。生成された lib/hello/__init__.py を 2.0.0b6 で期待される出力と比較し、Risk enum のメンバーに重点を置きます。LOW_RISK や HIGH_RISK などの enum 名が _ に変わらず保持されていれば完了です。

索引モデルが issue の本文から書いたものです。

説明

compiler-bug
Summary

2.0.0b7 breaks enums with underscores in field names

Reproduction Steps

Test proto definition, in test.proto:

syntax = "proto3";

package hello;

// Greeting represents a message you can tell a user.
message Greeting {
  Risk risk = 1;
}

enum Risk {
    LOW_RISK = 0;
    HIGH_RISK = 1;
}

Protoc compiler invocation:

$ protoc -I . --python_betterproto_out=lib test.proto
Expected Results

2.0.0b6 output (lib/hello/__init__.py):

# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: test.proto
# plugin: python-betterproto
# This file has been @generated

from dataclasses import dataclass

import betterproto


class Risk(betterproto.Enum):
    LOW_RISK = 0
    HIGH_RISK = 1


@dataclass(eq=False, repr=False)
class Greeting(betterproto.Message):
    """Greeting represents a message you can tell a user."""

    risk: "Risk" = betterproto.enum_field(1)
Actual Results

2.0.0b7 output (lib/hello/__init__.py):

# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: test.proto
# plugin: python-betterproto
# This file has been @generated

from dataclasses import dataclass

import betterproto


class Risk(betterproto.Enum):
    _ = 0
    _ = 1


@dataclass(eq=False, repr=False)
class Greeting(betterproto.Message):
    """Greeting represents a message you can tell a user."""

    risk: "Risk" = betterproto.enum_field(1)

System Information
  • Protoc version: libprotoc 27.3
  • Python version: Python 3.11.7
  • Betterproto version:
Name: betterproto
Version: 2.0.0b7
Summary: A better Protobuf / gRPC generator & library
Home-page: https://github.com/danielgtaylor/python-betterproto
Author: Daniel G. Taylor
Author-email: [email protected]
License: MIT
Location: /Users/connor/Code/tests/test070/.venv/lib/python3.11/site-packages
Requires: grpclib, python-dateutil, typing-extensions
Required-by:
Checklist
  • I have searched the issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have verified this issue occurs on the latest prelease of betterproto which can be installed using pip install -U --pre betterproto, if possible.
主要言語
Python
スター
1.8k
フォーク
235
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

danielgtaylor/python-betterproto のほかの issue

danielgtaylor/python-betterproto の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。