Add stubs for stdlib `_colorize` module
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 5.1k
- フォーク
- 2.1k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 82
説明
Description
_colorize was introduced in 3.13, and has been steadily growing since then.
From (https://github.com/python/cpython/issues/133346), I got the impression that the naming is due to unfortunate timing:
Rename
_colorizetocolorizeThere's frankly very little time for this before Python 3.14 beta 1. I would rather keep the library name underscored for 3.14 and gather feedback from the community on the format and behavior, and introduce a stable API in Python 3.15, keeping
_colorizefor backward compatibility.
Interestingly, _colorize is already fully-typed (https://github.com/python/cpython/blob/main/Lib/_colorize.py).
I'm here because the absence in _typeshed means this example [^1] can produce errors in some type checkers:
[^1]: Adapted from a comment in _colorize
from typing import reveal_type
try:
from _colorize import ANSIColors, Syntax, default_theme, set_theme
except ImportError:
pass
else:
reveal_type(set_theme)
theme_with_dim_operators = default_theme.copy_with(syntax=Syntax(op=ANSIColors.INTENSE_BLACK))
set_theme(theme_with_dim_operators)
del set_theme, default_theme, Syntax, ANSIColors, theme_with_dim_operators
This checks out fine with pyright, but both pyrefly and ty seem to not know about _colorize yet.
Perhaps adding to typeshed would help?
Related
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず CPython の Lib/_colorize.py を読み、そこにある型付き定義を typeshed の標準ライブラリのスタブと比較します。提供されている reveal_type の例を pyright、pyrefly、ty で確認します。_colorize の名前とシグネチャが、エラーなしで一貫して認識されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- tooling
- issue の種類
- 機能追加
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 活発
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 72/100