facebook / facebook/pyrefly

Pyrefly infers `Iterator[Any]` instead of `Iterator[int]` for `iter([0])`

Open
#3,265 3 comments 0 reactions 1 assignee Claimed by @asukaminato0721 View on GitHub
typechecking
Dominant language
Rust
Stars
7k
Forks
516
PR merge metrics
No merged PRs in 30d

Description

### Describe the Bug

```
from typing import Iterator, assert_type
assert_type(iter([0]), Iterator[int]) # error: assert_type(Iterator[Any], Iterator[int]) failed
```
This only happens with a list literal - `x: list[int] = [0]; iter(x)` works correctly.

### Sandbox Link

https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeS4ATrgLYAEALqcROgOZ0Q3G6UN0BJBjEqoGvADR1UcOCIYB9JsRgAddDLl8lzGAAoIwynoDaABgC6ASilCRY3idYNrICSDKUYYKKULiaKAoAYjoABVIvH1I6NCw8fDoAY1x0SDYAV1EGCFTCdVCAZRgYOgALBgZiOEQAelrPb19CXjZamHRazFwkuFqUtIhM7NzOujBeaQA3VGhUbFhk1PSssVG6XGIc1Lh89DIGMtSAWimROHWAXjpVEABmQgBGACZb9RAAX3dUJJyzgDFoDAKHEcAQSOQPkA

### (Only applicable for extension issues) IDE Information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.