[spec] clarification or change of "`partial\n` in a `py.typed` file"
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 1.8k
- フォーク
- 302
- 平均マージ
- 23時間
- マージ済み PR(30日)
- 8
説明
Reading through https://typing.python.org/en/latest/spec/distributing.html#partial-stub-packages today for unrelated purposes, it struck me that the occurrences of partial\n are ambiguous because it could be interpreted as requiring literally a backslash and an n. Furthermore, assuming \n is actually not to be taken literally (which is reasonable given that other places in the spec use glob stars anyway, although never in something you actually type into a file) it's ambiguous what happens if you use CRLF or CR as line terminators in your file. This also seems to rule out a file that just contains partial and then ends, without a newline character (you're not "supposed to" do this, but it happens).
To keep exactly the current behavior, I think this verbiage should be tweaked to "partial, followed by a newline". Perhaps the linefeed and carriage return characters could be mentioned explicitly, or a mention can be made of universal newlines.
However, I am not sure if the current behavior is actually important to specify, and I think other possibilities make more sense. Other possibilities include "partial on a line by itself", "partial surrounded by any amount of whitespace", and just "partial". "As the sole content of the file" may be added if desired.
A brief survey suggests that:
- mypy does
fscache.read(stub_typed_file).decode().strip() == "partial", which is not quite the same as the specified check - pyright does
(pyTypedContents.match(/partial\n/) || pyTypedContents.match(/partial\r\n/)), which is certainly a reasonable interpretation of the current spec, especially if you assume that no one ever uses only-CR newlines - ty does
to_ascii_lowercase().contains("partial")to be deliberately permissive, as explained in a comment
There is a reasonably long discussion about this topic over at https://discuss.python.org/t/pep-561-clarification-regarding-n/32875, but I didn't find it very enlightening.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず distributing.html の部分的なスタブパッケージに関するセクションを読み、次にリンクされている mypy、pyright、ty のチェックと、参照されている discuss.python.org のスレッドを比較してください。意図されたマッチング規則について合意し、改行とファイル末尾の動作を含めて、その規則を曖昧さなく記述するよう仕様を更新できたら完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- documentation
- issue の種類
- ドキュメント
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100