Better message for "Function ... could always be true"
オープン
まだ誰も着手していません。
feature
topic-usability
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Consider this example:
def f(x: int) -> str: pass
if f:
pass
It generates this error:
t.py:3: error: Function "Callable[[int], str]" could always be true in boolean context [truthy-function]
Instead, if we have a direct reference to a function definition, we could generate a message like this which would be clearer, especially if the signature is complex:
t.py:3: error: Function "f" could always be true in boolean context [truthy-function]
There are at least these different cases to consider:
- Direct reference to a function using a short name of a function (similar to the above example).
- Direct reference to a function using a module prefix (e.g.
if mod.func:). - Reference to a method (e.g.
if obj.method:). - Reference to a variable/attribute (
Varnode) with typeCallable[...](in this case we could show the name of the variable/attribute or the callable type -- both would be okay). - Any other expression that produces a callable value, such as
if func():wherefuncreturns a callable. Here the best option is to show the callable type as we do now.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず例を再現し、[truthy-function] 診断が呼び出し可能な式をどのようにフォーマットするかを調べます。関数への直接参照、モジュール修飾された関数、メソッド、呼び出し可能な変数または属性、呼び出し可能なオブジェクトを返す式を比較します。直接参照では適切な場合に、より分かりやすい関数名が使われ、それ以外の場合では有用な呼び出し可能オブジェクトの型または式の説明が維持されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- 機能追加
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 42/100