Reject arguments that are both keyword and positional only
オープン
まだ誰も着手していません。
bug
priority-2-low
topic-calls
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
I tried to use Calalble protocol like this:
from typing import Callable, Protocol
class F(Protocol):
def __call__(self, *__args: str, __arg: int) -> int: ...
def f(*__args: str, __arg: int) -> int: ...
f_: F = f
but it fails with quite confusing message:
error: Incompatible types in assignment (expression has type "Callable[[VarArg(str), NamedArg(int)], int]", variable has type "F")
note: "F.__call__" has type "Callable[[VarArg(str), NamedArg(int)], int]"
Found 1 error in 1 file (checked 1 source file)
If I move varargs, things pass:
class G(Protocol):
def __call__(self, __arg: int, *__args: str) -> int: ...
def g(__arg: int, *__args: str) -> int: ...
g_: G = g
I cannot say if this is a bug, or expected behaviour with confusing message.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、issue にある 2 つの Callable/Protocol の再現コードに対して mypy を実行し、代入に関する診断を比較します。callable の互換性における __args と __arg の処理を追跡し、その後、キーワード引数と位置引数の両方として扱われる引数が、明確な診断とともに拒否されることを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100