colorful how to handle dynamic types
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 5.1k
- フォーク
- 2.1k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 82
説明
I played around with the new colorful types and there is a interesting problem.
Colorful takes full advantage of __getattr__ and im a bit out of ideas how to type this.
Common usage is (also seen in the readme):
import colorful as cf
print(cf.bold_white('Hello World'))
Where bold_white is dynamically build with the dynamically loadable color plate and a modifier.
Which makes this valid working python code:
import colorful as cf
print(cf.bold_underlined_struckthrough_italic_bold_red("typeshed"))
where the color from the pallet is red and the modifiers are separated by a _ and need to be out of a list of MODIFIERS but otherwise can be combined in any order and even be repeated.
MODIFIERS = {
'reset': (0, 0),
'bold': (1, 22),
'dimmed': (2, 22),
'italic': (3, 23),
'underlined': (4, 24),
'blinkslow': (5, 25),
'blinkrapid': (6, 25),
'inversed': (7, 27),
'concealed': (8, 28),
'struckthrough': (9, 29)
}
Is there any good solution to type something this dynamic?
Or is the only way to kinda allow everything after colorful.<anything>
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
colorful の README の使用方法と、issue で説明されている動的な getattr の動作から始め、次に MODIFIERS の組み合わせがどのように形成されるかを調べます。動的に構築される属性に対する合意済みの型付けアプローチがあれば完了とします。issue では対象ファイルもテストも指定されていません。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- developer-experience
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100