`UNBOUND_TYPEVAR` error message should be more direct and shorter
オープン
まだ誰も着手していません。
bug
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
*Notes:
- mypy test.py
- mypy 1.19.1
- Python 3.14.0
- Related comment
The last 3 examples get the same indirect and long error messages of UNBOUND_TYPEVAR as shown below:
*Notes:
- A parameter is a variable defined in a function header to receive an argument.
- An argument is a value passed to a function parameter.
A function returning TypeVar should receive at least one argument containing the same TypeVar
With T for x:
def func[T](x: T) -> T:
return x
# No error
Without T for x:
def func[T](x) -> T:
return x
# error: A function returning TypeVar should receive at least one argument containing the same TypeVar
With no parameters:
from typing import cast
def func[T]() -> T:
return cast(T, 'Hello')
# error: A function returning TypeVar should receive at least one argument containing the same TypeVar
With T1 for x and T2 for return type:
def func[T1, T2](x: T1) -> T2:
return x
# error: A function returning TypeVar should receive at least one argument containing the same TypeVar
So, the same indirect and long error messages of UNBOUND_TYPEVAR should be changed:
From:
A function returning TypeVar should receive at least one argument containing the same TypeVar
To more direct and shorter one below:
A function returning TypeVar should have at least one same TypeVar parameter
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
mypy test.py の例から始めて、UNBOUND_TYPEVAR 診断がどこで生成され、テストされているかを特定します。メッセージを要求された短い文言に更新し、その後、3 つの失敗する例が新しい診断を出力し、有効な例は変更されていないことを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100