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

Use pydantic instead of dicts

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

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

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
python

調査の方向性

まず、既存の event-content dicts と commit 59136e4 の ArtC イベント実装を調べ、次にイベントの作成方法とデシリアライズ方法を確認する。変更に取りかかる前に、生成される Pydantic モデルとイベントバージョンの互換性がどのように機能すべきかを定義する。完了とは、設計によって旧バージョンのデシリアライズが解決され、dict ベースの使用方法が維持されるか、意図的に変更されることを意味する。

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

説明

Description

Instead of just storing the event contents as three anonymous dicts we should use pydantic to allow proper typed instance attributes. I tried it out with the ArtC event in https://github.com/magnusbaeck/eiffel-pythonlib/commit/59136e4188914ec8530ba658cef1b2e64f1ba185. Writing these classes by hand is rather boring so we should explore using github.com/koxudaxi/datamodel-code-generator to generate the code.

Motivation

Typed classes would enable linters and IDEs to help out when writing code that accesses events.

Exemplification

I'd expect any piece of code that creates events would be easier to write. Reasonable people may disagree, but pydantic-based classes can be initialized from a dict so you could continue working with dicts if you prefer (but the syntax would be slightly different so it would break backwards compatibility).

Benefits

See Motivation, above.

Possible Drawbacks

It's not clear how we should deal with different versions of the events. When producing events we can probably just use the latest known version, but what do we do when deserializing events of old versions? They might not be acceptable to the current version of the schema (which is what the pydantic model would contain). Should we version the event classes too, when necessary?

主要言語
Python
スター
8
フォーク
12
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

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

eiffel-community/eiffel-pythonlib のほかの issue

eiffel-community/eiffel-pythonlib の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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