Enum.from_enum() fails with Django IntegerChoices
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 45/100
調査の方向性
graphene.Enum.from_enum() と生成された GrapheneEnumType の動作から始め、提供されている Django IntegerChoices の例を使って失敗を再現します。TextChoices と IntegerChoices の処理を比較します。1、2、9 などの値を、報告されたエラーなしに生成された Graphene enum で表現できれば、作業は完了です。
索引モデルが issue の本文から書いたものです。
説明
Current Behavior
I am working in a Django Python codebase that has a GraphQL schema. A lot of TextChoices are used in our GraphQL schema and, to properly represent these we use the provided graphene.Enum.from_enum() function.
This same approach doesn't seem to work with Django's IntegerChoices. It seems when graphene generates a GrapheneEnumType, the values are created with the IntegerChoices member names. This makes it so the IntegerChoices value cannot be represented with the generated GrapheneEnumType.
This results in an error like the following:
"Enum 'Status' cannot represent value: 2"
Expected Behavior
A value from a Django IntegerChoices object is usable to get the appropriate GrapheneEnumType value name.
motivation
To allow for graphene.Enum.from_enum() to be usable by Django's IntegerChoices class.
Environment
- Graphene Version: 3.3
- Graphene Django Version: 3.2.0
- Graphene Version: 3.3
- Django Version: 4.1.12
- Python Version: 3.10
Code Example
class Status(models.IntegerChoices):
COMPLETED = 1, "Completed"
IN_PROGRESS = 2, "In progress"
ERRORED = 9, "Errored"
StatusChoices = graphene.Enum.from_enum(Status)
class Process(graphene.ObjectType):
reference = graphene.String(description="The process reference.")
status = graphene.Field(
StatusChoices,
description="Current process status.",
)
This results in an error like the following:
"Enum 'Status' cannot represent value: 2"
- 主要言語
- Python
- スター
- 8.2k
- フォーク
- 822
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
graphql-python/graphene のほかの issue
-
Tutorial mistakesオープン🐛 bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
graphql-python/graphene#1389 · コメント 5 件 · リアクション 2 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 68/100
graphql-python/graphene#1606 ·
-
Python 3.14 supportオープン✨ enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 38/100
graphql-python/graphene#1601 · コメント 2 件 ·
-
✨ enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
graphql-python/graphene#1600 ·
-
Inaccurate Float-to-Decimal Conversion in `parse_value` of `Decimal` `Scalar`対応中かも @mak626 が 606 日前に担当しました。 オープン🐛 bug
難易度 2/5 1〜3時間 初心者へのやさしさ 55/100
graphql-python/graphene#1593 ·
graphql-python/graphene の issue をすべて見る
似ている issue
-
request-theme
難易度 2/5 1時間未満 初心者へのやさしさ 70/100
LizardByte/ThemerrDB#8877 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area/install-update comp/gateway P0 sweeper:risk-compatibility type/bug
難易度 2/5 1時間未満 初心者へのやさしさ 72/100
NousResearch/hermes-agent#135997 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
deepset-ai/haystack#13199 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] JSONLoader rejects valid UTF-8 BOM files対応中かも @zouyonghe が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
anthropics/knowledge-work-plugins#1298 ·
メンテナーはふだん 1 日以内に返信