False positive in `dict.update` with variadic tuple keys
まだ誰も着手していません。
評価
調査の方向性
Start by running the four-line snippet in the issue (the d.update({(*prefix, 0, n): 1 ...}) case) against a local build to reproduce the no-matching-overload error. The payload does not name the source files, so locate the contextual inference for dict comprehensions and the handling of variadic tuple keys. Done means the snippet type-checks cleanly with no new errors in the existing test suite.
索引モデルが issue の本文から書いたものです。
説明
Describe the Bug
Actual: no-matching-overload
The comprehension is inferred as dict[tuple[*tuple[int, ...], int, str], int], and dict[tuple[*tuple[int, ...], int, str], int] cannot be assigned to SupportsKeysAndGetItem[tuple[*tuple[int, ...], str], int] (this protocol is invariant in the key type).
Expected: Contextual inference should allow the comprehension to be typed as dict[Key, int]. ty 0.0.107 accepts this example.
type Key = tuple[*tuple[int, ...], str]
prefix: tuple[int, ...] = (1, 2, 3)
d: dict[Key, int] = {}
d.update({(*prefix, 0, n): 1 for n in ("train", "test")})
ERROR sandbox.py:4:9-58: No matching overload found for function `typing.MutableMapping.update` called with arguments: (dict[tuple[*tuple[int, ...], int, str], int]) [no-matching-overload]
Possible overloads:
(m: SupportsKeysAndGetItem[tuple[*tuple[int, ...], str], int], /) -> None [closest match]
(m: Iterable[tuple[tuple[*tuple[int, ...], str], int]], /) -> None
Argument `dict[tuple[*tuple[int, ...], int, str], int]` is not assignable to parameter `m` with type `SupportsKeysAndGetItem[tuple[*tuple[int, ...], str], int]` in function `typing.MutableMapping.update`
Sandbox Link
(Only applicable for extension issues) IDE Information
No response
- 主要言語
- Rust
- スター
- 7.2k
- フォーク
- 578
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
facebook/pyrefly のほかの issue
-
pytorch tensor-shapes typechecking
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
good first issue typechecking
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
cargo b warning: unused dependency `zstd`対応中かも @Narendersingh007 が 4 日前に担当しました。 オープンgood first issue
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
-
pydantic
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
facebook/pyrefly の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
eventflux-io/eventflux#203 ·
メンテナーはふだん 1 日以内に返信
-
bug ui
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
userFRM/egui-charts#4068 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
trezor/trezor-firmware#8357 ·
メンテナーはふだん 2 日以内に返信
-
fuzz-crash review-followup
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信