Model inheritance does not convert correctly
まだ誰も着手していません。
評価
調査の方向性
address_model.py と user_model.py を使用して変換を再現し、その後、PydanticObjectType が TUser.address フィールドと報告された ConversionError をどのように処理するかを調査します。異なるモジュールで定義されたモデルと、TAddress を介してネストされたモデルがこのエラーなしで正常に変換されれば、変更は完了です。
索引モデルが issue の本文から書いたものです。
説明
Use Case Scenario
I've two pydantic models. Each in his own module (file). One Model, the TUser depends on the TAddress.
address_model.py
class TAddress(BaseModel):
id: Optional[int]
address: Optional[constr(max_length=100, strip_whitespace=True)]
city: Optional[constr(max_length=80, strip_whitespace=True)]
postal_code: Optional[constr(max_length=15, strip_whitespace=True)]
country: Optional[constr(max_length=3)]
user_model.py
class TUser(BaseModel):
id: UUID = None
email: Optional[EmailStr]
address: Optional[TAddress]
is_active: Optional[bool]
is_email_verified: Optional[bool]
created_at: Optional[datetime.datetime]
If I use the TUser model know for my PydanticObjectType
class UserType(PydanticObjectType):
class Meta:
model = TUser
I get the following error message:
graphene_pydantic.converters.ConversionError: Don't know how to convert the Pydantic field ModelField(name='address', type=Optional[TAddress], required=False, default=None) (<class 'app.address.serializers.TAddress'>)
It seems like that there is a problem when using pydantic models from different modules that depends on each other.
What is the solution for this use case?
Any idea?
- 主要言語
- Python
- スター
- 249
- フォーク
- 47
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
graphql-python/graphene-pydantic のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
graphql-python/graphene-pydantic#116 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
graphql-python/graphene-pydantic#111 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
graphql-python/graphene-pydantic#107 · コメント 2 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
graphql-python/graphene-pydantic の issue をすべて見る
似ている issue
-
Path subtraction removes repeated suffix characters instead of one suffix対応中かも @Gwerdonatus が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
joke2k/django-environ#671 ·
-
good first issue help wanted windows
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
-
test_pgbouncer deploys the server under test from Charmhub instead of the local build (track/1.31)オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
canonical/temporal-k8s-operator#195 · コメント 1 件 ·
メンテナーはふだん 4 日以内に返信
-
`burr` fails to start when the Python path has a space in it対応中かも @enekoreto が今日担当しました。 オープンstatus/needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 5 日以内に返信
-
device support request
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
zigpy/zha-device-handlers#5461 ·
メンテナーはふだん 4 日以内に返信