mailbox: document Message vs EmailMessage situation

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

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

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
48/100
issue の種類
ドキュメント
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
documentation

調査の方向性

mailbox モジュールのドキュメントから始め、そこにある email.Message への参照を、EmailMessage と compat32 API に関する email パッケージのドキュメントと比較します。mailbox.Message、email.Message、email.message.EmailMessage の関係を確認し、その後、mailbox のドキュメントでそれぞれの役割と移行状況を明確にします。ドキュメントで、アプリケーションがどのクラスを使用すべきか、またなぜ mailbox が引き続きレガシー階層を公開しているのかが説明されていれば完了です。

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

説明

docs

Documentation

If I read the email documentation, it makes a clear case for staying away from email.Message:

The foregoing represent the modern (unicode friendly) API of the email package. The remaining sections, starting with the Message class, cover the legacy compat32 API that deals much more directly with the details of how email messages are represented. The compat32 API does not hide the details of the RFCs from the application, but for applications that need to operate at that level, they can be useful tools. This documentation is also relevant for applications that are still using the compat32 API for backward compatibility reasons.

Changed in version 3.6: Docs reorganized and rewritten to promote the new EmailMessage/EmailPolicy API.

And indeed, there are common tasks that are hard to do in email.Message and easy with EmailMessage (see get_body() for a very common use case).

However in the documentation of mailbox, email.Message is mentioned like it's the standard.

Since at the moment in the standard library, with regards to email handling, the rule "There should be one-- and preferably only one --obvious way to do it." seems to be violated, and there are several classes with confusingly similar names but very different roles (mailbox.Message, email.Message, email.message.EmailMessage) it would help to have a clarification of the situation in the documentation of mailbox, at least until #77156 happens.

I don't know enough of the background that led to this situation to be able to draft a serious proposal for the documentation, but I guess something along the lines of this could be an initial draft:

There are currently two distinct classes for handling emails: email.Message (deprecated), and email.message.EmailMessage. The latter is more featureful and easier to use, but the mailbox module still has not been updated to transition to it.
mailbox subclasses the deprecated email.Message as mailbox.Message, to act as the base hierarchy for messages read from mailboxes.
It is expected that mailbox.Message will become a subclass of email.message.EmailMessage in a future version of Python [insert API compatibility notes].

主要言語
Python
スター
77.2k
フォーク
36k
平均マージ
1日 9時間
マージ済み PR(30日)
558

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

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

python/cpython のほかの issue

python/cpython の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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