`for` loop over a subclass ignores its overridden `__iter__` and uses the base class's type argument
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
調査の方向性
The reproducer shows that iter(b) infers Iterator[int], while for loops and comprehensions infer object; start by running the Python example in the Pyrefly sandbox and tracing how iteration types are inferred for each construct. Find the relevant Rust implementation and regression tests for for loops and comprehensions. Done means both infer int for this subclass and existing iteration tests still pass.
索引モデルが issue の本文から書いたものです。
説明
Describe the Bug
from collections.abc import Iterable, Iterator
from typing import reveal_type
class B(Iterable[object]):
def __iter__(self) -> Iterator[int]:
yield 1
def f(b: B) -> None:
reveal_type(iter(b)) # Iterator[int]
for y in b:
reveal_type(y) # expected int, got object
y + 1 # false positive
reveal_type([y for y in b]) # expected list[int], got list[object]
Spotted in Requests
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
-
language-server
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
-
Attribute access after `if sys.platform != ...: return` is checked against the current platformオープン
難易度 4/5 3〜5日 初心者へのやさしさ 54/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
facebook/pyrefly の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
aosama/astronomical#1973 ·
メンテナーはふだん 1 日以内に返信
-
bug triage
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 6 日以内に返信
-
complexity: high external-contributors test
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
Meet-hybrid/soroban-forge#584 ·
メンテナーはふだん 1 日以内に返信
-
app bug pets
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
dekobon/big-code-analysis#1859 ·
メンテナーはふだん 1 日以内に返信