Better `repr` for `string.templatelib.Template`.
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Feature or enhancement
Proposal:
Currently the repr output for template strings shows how the data is stored internally, but this is not how the template could be reconstructed via an constructor call and the format is unintuitive since the template parts are not output in the order they appear in the template source. The repr result should output the parts in the order as iterating over the template object does, i.e.
x = 1
y = 2
print(repr(t'{x} + {y}'))
should print
Template(Interpolation(1, 'x', None, ''), ' + ', Interpolation(2, 'y', None, ''))
instead of
Template(strings=('', ' + ', ''), interpolations=(Interpolation(1, 'x', None, ''), Interpolation(2, 'y', None, '')))
This has already been discussed at https://discuss.python.org/t/repr-output-of-t-strings/107653
I'm working on a patch/pull request.
Has this already been discussed elsewhere?
I have already discussed this feature proposal on Discourse
Links to previous discussion of this feature:
https://discuss.python.org/t/repr-output-of-t-strings/107653
Linked PRs
- gh-151104
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
issue で説明されている string.templatelib.Template の repr の動作から始め、template オブジェクトの反復処理と比較してください。repr が反復順序で Template の各部分を出力し、提案されているコンストラクター呼び出し形式と一致することを確認してください。gh-151104 が関連付けられているため、開始する前にその作業を確認してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- backend
- issue の種類
- 機能追加
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 25/100