Document type inference behavior in case type declaration has (not) initializer
オープン
まだ誰も着手していません。
documentation
priority-1-normal
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
In cases like this mypy doesn't narrow down the type in assignment:
x: Union[int, str] = 0
# type of x is Union[int, str] here!
Any assignment after the initial declaration will narrow the type down:
x: Union[int, str]
x = 0
# type of x is int here!
Document this behavior since it can be surprising. The motivation for this is that this behavior makes it easy to override the inferred type for a variable, which is sometimes useful.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
issue 内の 2 つの例をドキュメントの情報源として使用します。初期化子を伴う宣言と、後続の代入を比較し、narrowing の挙動の違いと、推論された型を上書きすることが有用な理由を説明してください。mypy ドキュメント内の適切なセクションを見つけ、そこに説明を追加し、両方の例と推論された型が正確であることを確認してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- documentation
- issue の種類
- ドキュメント
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100