False-positive with multiple *args splats in a function call
オープン
まだ誰も着手していません。
bug
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Bug Report
mypy falsely(?) reports a type error when the *args syntax is used more than once in a function call.
To Reproduce
mypy --no-incremental --config /dev/null -c '
def foobar(a: int, b: str, c: int) -> None:
...
foo = (1,)
bar = ("b", 3)
foobar(*foo, *bar)
'
Expected Behavior
Success: no issues found in 1 source file
Actual Behavior
<string>:9: error: Argument 2 to "foobar" has incompatible type "*Tuple[str, int]"; expected "str"
<string>:9: error: Argument 2 to "foobar" has incompatible type "*Tuple[str, int]"; expected "int"
This error goes away if I:
- make
fooanintinstead ofTuple[int], and remove the splat whenfoobar()is called. - make
bartwo ints and makefoobar()take three int arguments. - make
fooaTuple[str, int]and makefoobar()takestr, int, str, intarguments. - make
barjust aTuple[str]and makefoobar()takeint, strarguments.
Your Environment
This occurs with the standard version of mypy in Debian Testing:
$ /usr/bin/mypy --version
mypy 0.812
...as well as with the latest git revision:
$ ~/.local/pipx/venvs/mypy/bin/mypy --version
mypy 0.820+dev.8642b351cff94c471333256f9cd6867807384f01
In both cases, I'm using the Debian-provided Python 3.9.2,
on up-to-date Debian Testing.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供されている mypy コマンドを実行し、複数の tuple splat を含む呼び出しについて 2 つの診断を確認します。次に、呼び出し引数のチェックと tuple-splat の処理を追跡し、この再現例のカバレッジを追加します。完了条件は、一覧にあるバリエーションをリグレッションさせずに、コマンドが問題を報告しないことです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100