[ty] Use range instead of custom IntIterable (#21138)

## Summary

We previously didn't understand `range` and wrote these custom
`IntIterable`/`IntIterator` classes for tests. We can now remove them
and make the tests shorter in some places.
This commit is contained in:
David Peter
2025-10-30 15:21:55 +01:00
committed by GitHub
parent 1ebedf6df5
commit 1b0ee4677e
3 changed files with 35 additions and 115 deletions

View File

@@ -1,14 +1,6 @@
# Comprehensions with invalid syntax
```py
class IntIterator:
def __next__(self) -> int:
return 42
class IntIterable:
def __iter__(self) -> IntIterator:
return IntIterator()
# Missing 'in' keyword.
# It's reasonably clear here what they *meant* to write,
@@ -16,7 +8,7 @@ class IntIterable:
# error: [invalid-syntax] "Expected 'in', found name"
# revealed: int
[reveal_type(a) for a IntIterable()]
[reveal_type(a) for a range(3)]
# Missing iteration variable
@@ -25,7 +17,7 @@ class IntIterable:
# error: [invalid-syntax] "Expected 'in', found name"
# error: [unresolved-reference]
# revealed: Unknown
[reveal_type(b) for in IntIterable()]
[reveal_type(b) for in range(3)]
# Missing iterable