Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Use pydantic instead of dicts

Đang mở
#24 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
python

Hướng nghiên cứu

Bắt đầu bằng cách xem xét các dict nội dung sự kiện hiện có và phần triển khai sự kiện ArtC trong commit 59136e4, sau đó xem lại cách các sự kiện được tạo và giải tuần tự. Xác định cách các model Pydantic được sinh ra và tính tương thích giữa các phiên bản sự kiện cần hoạt động trước khi thử thực hiện thay đổi; hoàn tất có nghĩa là thiết kế đã giải quyết việc giải tuần tự các phiên bản cũ và duy trì hoặc cố ý thay đổi cách sử dụng dựa trên dict.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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?

Ngôn ngữ chính
Python
Star
8
Fork
12
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của eiffel-community/eiffel-pythonlib

Tất cả issue của eiffel-community/eiffel-pythonlib

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.